Git*_*Gud 3 bash fish shell-builtin
这是巴什。这种行为在鱼类中是相似的。
$ which python
/usr/bin/python
$ alias py=python
$ type py
py is aliased to `python'
Run Code Online (Sandbox Code Playgroud)
?然后,运行type -P py
什么也不打印,正如我所期望的那样以/usr/bin/pyton
与下面看到的类似的方式打印。?
$ type ls
ls is aliased to `ls --color=auto'
$ type -P ls
/bin/ls
Run Code Online (Sandbox Code Playgroud)
该-P
选项的文档读取
-P force a PATH search for each NAME, even if it is an alias,
builtin, or function, and returns the name of the disk file
that would be executed
Run Code Online (Sandbox Code Playgroud)
我已经确认/usr/bin
(所在的目录python
)在PATH
.
这里发生了什么?
这个:
强制对每个 NAME 进行 PATH 搜索,即使它是别名,
并不意味着 bash 会展开别名然后搜索展开的命令。这意味着,如果有一个命令foo
,也是一个别名foo
时,type -P foo
仍然会寻找命名的命令foo
,即使有一个别名掩盖它。所以庆典并没有扩张py
的type -P py
是python
,它不会显示/usr/bin/python
。