1

Unix searches first among the declared functions before the PATH:

$ order() { echo "hello from function"; }
$ order
hello from function

$ which order
/usr/bin/which: no order in (all:the:paths)

$ vim order
#!/bin/bash
echo "hello from somewhere"
:wq

$ chmod +x order
$ export PATH=~/:$PATH

$ hash -r

$ which order
~/order

$ order
hello from function

Is there a way to tell unix to search in the PATH before the declared functions?

2

"unix" doesn't interpret commands – shell programs do. So this depends on which shell you use.

In sh/bash/zsh, you can use use the command built-in:

$ order
hello from function

$ command order
hello from somewhere

$

There is no global setting for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.