Skip to content

how do i check for name clashes #9208

Closed Answered by faho
whysthatso asked this question in Q&A
Sep 14, 2022 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

If you want to know if a command (i.e. an executable file somewhere in $PATH) by a name exists, use command -q to just tell you yes/no via the return status, or command -s to give you the path, e.g.

> command -q foobar
> echo $status
# either 0 if it exists or 127 if it doesn't

> command -s foobar
/usr/bin/foobar

To check for all of your functions:

command -s (functions)

For the most part, this isn't really a problem. If you have a function of a name and a command, using just the name will run the function, but you can use command name to run the command. E.g.:

function foobar
   echo Hello I am the function
end

foobar # prints "Hello I am the function

command foobar # runs /usr/bin/fo…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by faho
Comment options

You must be logged in to vote
2 replies
@faho
Comment options

@whysthatso
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants