ZSH:“.”和“source”有什么区别?

ZSH:“.”和“source”有什么区别?

我曾经认为内置函数.source是等价的。这个问题同意我的观点bash。但是我遇到了以下使用zsh

desktop➜  ~/pst  . env
/usr/bin/env:1: no such file or directory:  ^@^A^@^@^@X^Z@^@^@^@^@^@@^@^@^@^@^@^@^@\M-8q^@^@^@^@^@^@^@^@^@^@@^@8^@
/usr/bin/env:2: parse error near `)'
desktop➜  ~/pst  source env
desktop➜  ~/pst  file env
env: ASCII text

source做了我所期望的,但是.想做什么?

答案1

man zshall有答案:

   source file [ arg ... ]
          Same as `.', except that the current directory is always searched and is always searched first, before directories in $path.

例子:

desktop➜  ~/pst  source /bin/env
/bin/env:1: no such file or directory: ^@^A^@^@^@X^Z@^@^@^@^@^@@^@^@^@^@^@^@^@\M-8q^@^@^@^@^@^@^@^@^@^@@^@8^@
/bin/env:2: parse error near `)'
desktop➜  ~/pst  . env
/usr/bin/env:1: no such file or directory: ^@^A^@^@^@X^Z@^@^@^@^@^@@^@^@^@^@^@^@^@\M-8q^@^@^@^@^@^@^@^@^@^@@^@8^@
/usr/bin/env:2: parse error near `)'

相关内容