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

Re: Portable zsh scripts

* Peter Stephenson (Wed, 27 Feb 2008 12:52:06 +0000)
> Thorsten Kampe wrote:
> > I'm starting all my zsh scripts with...
> > 
> > #! /bin/zsh -f
> > emulate -R zsh
> > 
> > ...in order to minimize any problems that might occur because other 
> > systems have other zsh options set.
> > 
> > My question is: does it make sense to do it that way?
> > 
> > I'm especially uncertain about the "emulate -R zsh" and the -R 
> > parameter because I don't fully understand what it does. Would 
> > "emulate zsh" or "emulate -L zsh" or "emulate -RL zsh" be even better?
> The -L flag is only useful in functions; in a script you're starting
> a fresh shell so making the changes local to it isn't meaningful.
> The -R flag forces it to set options that affect interactive usage but
> not usually the syntax.  Typically you don't need to set these in
> functions, though there are special cases where you do.  Since, again,
> you're starting from scratch, adding -R will simply ensure that all the
> options are in their default state for zsh.

Okay, but is there a gain in specifying "emulate -R zsh" instead of 
"emulate zsh".
> If /etc/zshenv isn't doing anything nasty, however, it shouldn't be
> needed together with the -f flag.

Sorry, but as far as I understood "-f" makes the shell skip everything 
/except/ /etc/zshenv. Many people set options in the other startup 
files so my script should benefit from "-f"... Or would it do more or 
less the same as "emulate zsh" or "emulate -R zsh".


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