Skip to main content
edited tags; edited title
Link
Gilles 'SO- stop being evil'
  • 837.9k
  • 198
  • 1.7k
  • 2.2k

Change the order Order of executables started in bash

Tweeted twitter.com/#!/StackUnix/status/472236561497481216

change Change the order of executables started in bash

If I execute the test command in bash, test(evaluates conditional expression) built-in utility is started:

$ type test
test is a shell builtin
$ type -a test
test is a shell builtin
test is /usr/local/bin/test
test is /usr/bin/test
$ 

However, as seen in output of type -a test above, there is another test in /usr/local/bin directory and jetyet another one in /usr/bin directory. How are executables ordered, i.e. are the built-in commands always preferred and then the rest of the commands depend on the directory order in $PATH variable? In addition, is it possible to change the order of the executables started, e.g. if I type in test, then /usr/bin/test is started instaedinstead of bash-builtin test?

change the order of executables started in bash

If I execute the test command in bash, test(evaluates conditional expression) built-in utility is started:

$ type test
test is a shell builtin
$ type -a test
test is a shell builtin
test is /usr/local/bin/test
test is /usr/bin/test
$ 

However, as seen in output of type -a test above, there is another test in /usr/local/bin directory and jet another one in /usr/bin directory. How are executables ordered, i.e. are the built-in commands always preferred and then the rest of the commands depend on directory order in $PATH variable? In addition, is it possible to change the order of executables started, e.g. if I type in test, then /usr/bin/test is started instaed of bash-builtin test?

Change the order of executables started in bash

If I execute the test command in bash, test(evaluates conditional expression) built-in utility is started:

$ type test
test is a shell builtin
$ type -a test
test is a shell builtin
test is /usr/local/bin/test
test is /usr/bin/test
$ 

However, as seen in output of type -a test above, there is another test in /usr/local/bin directory and yet another one in /usr/bin directory. How are executables ordered, i.e. are the built-in commands always preferred and then the rest of the commands depend on the directory order in $PATH variable? In addition, is it possible to change the order of the executables started, e.g. if I type in test, then /usr/bin/test is started instead of bash-builtin test?

edited tags
Link
Gilles 'SO- stop being evil'
  • 837.9k
  • 198
  • 1.7k
  • 2.2k
Source Link
Martin
  • 7.6k
  • 43
  • 132
  • 219
Loading