question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

file() verification should be able to expand a leading tilde (~)

See original GitHub issue

file() currently fails for a path like ~/my-file.txt as ~ is not expanded. It would be great if ~ would be expanded when running on shells that support it similar to like we do here, maybe by introducing an expandTilde parameter to file() which defaults to true.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ajaltcommented, Feb 19, 2020

That’s correct. I implemented the tilde expansion for file checks in #132, so you can use it with snapshot 2.5.0-beta1.387-SNAPSHOT or newer if you need the functionality now. Otherwise I’m planning a release within the next week.

1reaction
ajaltcommented, Feb 18, 2020

Sorry about that, I misread your code. The reason it doesn’t work is because convert (which file and all conversions call) replaces the existing conversion. So in your case the block passed to convert wouldn’t get called, since file overwrites it.

The type system normally prevents you from calling convert more than once, since it convert usually changes the type of the option. But if convert returns a String, the types stays the same and this mistake is possible to make. Maybe a future version of Clikt will be more strict with they types, but that’s a serious breaking change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expand tilde in Rust Path idiomatically - Stack Overflow
The most idiomatic way would be to just use an existing crate, in this case shellexpand (github, crates.io) seems to do what you...
Read more >
path.expand: Expand File Paths - Rdrr.io
Expand File Paths. Description. Expand a path name, for example by replacing a leading tilde by the user's home directory (if defined on...
Read more >
Tilde expansion if named file exists #3239 - GitHub
I had a mis-configured program that was creating directories named ~ in its working directory. After I fixed the configuration, ...
Read more >
bash - How Can I Expand A Tilde ~ As Part Of A Variable?
The shell attempts a tilde expansion on echo $x , there is no tilde to ... This structure explicitly check the presence of...
Read more >
Naming Files, Paths, and Namespaces - Win32 apps
This is true even if a long file name contains extended characters, regardless of the code page that is active during a disk...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found