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?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
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 community
. 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.
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'
emulate sh -c '. ./myscript.sh'