8

I used to think that the built-ins . and source are equivalent. This question agrees with me when it comes to bash. However I encountered the following using 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 did what I expected, but what's . trying to do?

11

man zshall has the answer:

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

Example:

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 `)'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.