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

Re: sh vs zsh behavior



> On Tue, 9 Apr 1996, Clinton Bunch wrote:
> 
> > Timothy J. Luoma wrote:
> > >
> > > #!/usr/local/bin/zsh -f
> > >
> > > test="one two three"
> > >
> > > for i in $test
> 
> > try replacing the above line with this:
> >   for i in $(echo $test)

No, do not try this.  It works, but it is unnecessarily complicated and zsh
forks just to split $test.  Instead you should read the FAQ and the manual.

You can use setopt shwordsplit to get sh compatible word splitting (see man
zshoptions).  You can also call sh as sh, or you can use $=test (as
described in man zshexpn).

To test if a word is in {one, two, three, four} you can use:

if [[ somethin == (one|two|three) ]] then
	...
else
	...
fi

For more details, see man zshexpn, section FILENAME GENERATION (GLOBBING).

Use all of the above with 2.6-beta13 (2.5.03 is far more buggy than recent
betas I think).

Bye,

Zoltan




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