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

Re: Portable zsh scripts



On 2008-02-27 12:52:06 +0000, Peter Stephenson wrote:
> 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.

/bin/zsh is definetely not portable. I use:

#!/usr/bin/env zsh

(with the drawback that zsh options can't be used).

> 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.

As some scripts can also be used as functions, it may be a good idea
to use "emulate -LR zsh" every time. This is what I do. And instead
of "exit <value>", I use "return <value>".

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)



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