Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: loading user startup files for zsh scripts



On Feb 7,  3:34pm, Greg Klanderman wrote:
} 
} As far as I can tell other shells inhibit loading user startup files
} when invoked as a shell script (i.e. #!/bin/zsh).  Should '-f' be the
} default for this use case?

In a word, no.

Zsh already "inhibits" /etc/zprofile and ~/.zprofile when the shell is
not a login shell, and further skips /etc/zshrc and ~/.zshrc when the
shell is not interactive.  The only file for which -f matters during
script startup is ~/.zshenv.

The whole reason that ~/.zshenv exists is to contain commands that are
intended to be sourced by *every* zsh including scripts.  This was a
deliberate design decision; if you don't want any such initialization
done, you can remove that file.

Incidentally, documentation oddness [this has probably been mentioned
before]:  If zsh is configured with --disable-zshenv, then references
to /etc/zshenv in the documentation are replaced with the word "no",
which leads to phrases like "Commands are first read from no; this
cannot be overridden" and "As no is run for all instances of zsh, it
is important that it be kept as small as possible."



Messages sorted by: Reverse Date, Date, Thread, Author