ZSH:`.`和`source`有什么区别?


10

我以前认为内置.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达到了我的预期,但是.正在尝试做什么?

Answers:


13

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 `)'
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.