how do i check for name clashes #9208
-
how do i avoid or check if any of my existing aliases clash with binary names in $PATH? i.e. i would like to alias long commands with single letters or short alternative names. if i will install a package that provides a binary with an exact name match, how would i discover that? trial and error, or is there some sort of mechanism? or should i namespace all my fishshell functions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
If you want to know if a command (i.e. an executable file somewhere in $PATH) by a name exists, use > 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 function foobar
echo Hello I am the function
end
foobar # prints "Hello I am the function
command foobar # runs /usr/bin/foobar For instance, that
Because functions take precedence, you can keep on using your existing function. If you then find out you need to use the command, you can use Just try not to trample on anything too well-known ( |
Beta Was this translation helpful? Give feedback.
-
thank you for you comment. just for the sake of argument: so i would have to sort of run a hook after an arbitrary package installation which would loop through all my fish functions, run them as would that be about right? |
Beta Was this translation helpful? Give feedback.
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, orcommand -s
to give you the path, e.g.To check for all of your 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.: