ZSH: Qual a diferença entre `.` e` source`?


10

Eu costumava pensar que os embutidos .e sourcesão equivalentes. Esta pergunta concorda comigo quando se trata bash. No entanto, encontrei o seguinte usando 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

sourcefiz o que eu esperava, mas o que está .tentando fazer?

Respostas:


13

man zshall tem a resposta:

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

Exemplo:

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 `)'
Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.