Skip to main content
deleted 2 characters in body
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type should work in all POSIXy shells. In at least Bash and some others, type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would processesprocess aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type should work in all POSIXy shells. In at least Bash and some others, type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would processes aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type should work in all POSIXy shells. In at least Bash and some others, type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would process aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

added 75 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type should work in all POSIXy shells. In at least Bash and some others, type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would processes aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would processes aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type should work in all POSIXy shells. In at least Bash and some others, type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would processes aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

added 470 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would processes aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter.

type python would recognize the alias, and type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

which is usually/often an external command, it doesn't know about shell aliases, or shell functions for that matter. It only looks for the matching command name in PATH.

type python would recognize the alias, and type -a can be used to show all matches of the given name. It doesn't track where the alias points to, though, just shows the pathname that would be used if there was no alias:

$ alias python=/usr/bin/python3
$ type -a python
python is aliased to '/usr/bin/python3'
python is /usr/bin/python

See: Why not use "which"? What to use then?

Bash itself would processes aliases first, early in the command line processing, then it would check if the first word after all expansions is (1) a function (2) a builtin, or (3) an external command.

(Unless that first word was an unquoted literal keyword like if, in which case it would parsed using the appropriate syntax. You'd need e.g. "if" or /path/to/if to run an external command called if.)

Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441
Loading