Skip to content
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

WIP: make which(str) return the path to the command #13197

Closed
wants to merge 3 commits into from

Conversation

bicycle1885
Copy link
Member

This will make which(cmd::AbstractString) return the path to the command string:

julia> which("ls")
Nullable("/bin/ls")

This method is useful to find the location of a command and to check if a command exists or not.
The same function is available in the shutil module on Python3 (https://docs.python.org/dev/library/shutil.html#shutil.which).

Before going into the details, I'd like to know whether you like it or not.

  • Is this method approved?
  • Is returning a Nullable good?
  • Support Windows.
  • Write document.

@bicycle1885
Copy link
Member Author

No comments? 😢

# which (TODO: tests for Windows)
@unix_only @test !isnull(which("ls"))
@unix_only @test isfile(get(which("ls")))
@unix_only @test isnull(which("abracadabra"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be OK for tests to fail if ls isn't on the path, but failing if abracadabra is on the path seems kind of wrong. You should find a more random non-existant path. Might I suggest something like vyqMEOu1xfKCePhtZro7NUKbDmOEtx5ZmVGfUH?

@nalimilan nalimilan added the missing data Base.missing and related functionality label Sep 6, 2016
@stevengj
Copy link
Member

Note that Sys.which(x) was added in #26559.

@vtjnash vtjnash closed this Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing data Base.missing and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants