-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the error behavior of Sys.which #27284
Comments
Definitely agree about returning |
If |
Interpolation run(`$(Sys.which("tar")) xzf thingo.tar.gz`)
True, though in this case the path is a path to an executable, which is likely mostly useful in |
Oops, nothing does not throw an error when spliced into a command: julia> `$nothing`
`nothing` That should certainly be fixed since it is unlikely that running a command called |
The fact that it's a path to an executable is irrelevant. The key fact is that it's not a collection of words like a |
Currently `Sys.which("prog")` will throw an error if `prog` is not found or is found but is not executable. This changes the function to instead return `nothing` in those cases, thereby simplifying logic for situations such as hierarchically choosing an executable based on which in a list is present. Fixes #27284.
Currently `Sys.which("prog")` will throw an error if `prog` is not found or is found but is not executable. This changes the function to instead return `nothing` in those cases, thereby simplifying logic for situations such as hierarchically choosing an executable based on which in a list is present. Fixes #27284.
There seems to be broad agreement on what to do, so de-triaging. Whether this can make it into master before the release can be discussed in #27298. |
Currently `Sys.which("prog")` will throw an error if `prog` is not found or is found but is not executable. This changes the function to instead return `nothing` in those cases, thereby simplifying logic for situations such as hierarchically choosing an executable based on which in a list is present. Fixes #27284.
I have two suggestions for
Sys.which
, which was added in #26559:Make it both accept and returnCmd
s rather thanString
s.Return
nothing
when the given command is not found rather than throwing an error. (This was actually suggested by someone else in that PR.)As a motivation for this change, consider the case of selecting an executable from a list of candidates. With the above suggestions, one could write this
and use the value of the resulting variable directly in commands,
pipeline
, etc. Currently this must be written aswhich is significantly less ergonomic.
The text was updated successfully, but these errors were encountered: