I've been using emulate sh -c ". $HOME/myscript.sh"
and it's working so far.
However, if I'm at ~
and try to do emulate sh -c ". myscript.sh"
, I get .: no such file or directory: myscript.sh.
. Why?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityThe .
builtin looks for the script passed argument in the command search path ($PATH
) if it doesn't contain a /
. This is true both in POSIX shells and in native zsh, so unsurprisingly it's true in zsh's sh emulation mode as well.
The source
builtin in bash and zsh is identical to .
except that no PATH lookup happens, a script name not containing a /
is looked for in the current directory.
emulate sh -c 'source myscript.sh'
or
emulate sh -c '. ./myscript.sh'