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

Re: Portable zsh scripts



Thorsten Kampe wrote:
> Hi,
> 
> 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.

So "emulate -R zsh" should work fine.  If /etc/zshenv isn't doing
anything nasty, however, it shouldn't be needed together with the -f
flag.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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