Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sh vs zsh behavior
- X-seq: zsh-workers 898
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: luomat@xxxxxxxxxxxxxxxxxxxxxxxxxxx
- Subject: Re: sh vs zsh behavior
- Date: Tue, 9 Apr 1996 18:55:42 +0200 (MET DST)
- Cc: zsh-workers@xxxxxxxxxxxxxxx (zsh-workers)
- In-reply-to: <Pine.NXT.3.92.960409105914.11311H-100000@xxxxxxxxxxxxxxxxxxxxxxxx> from "Timothy J. Luoma" at "Apr 9, 96 11:01:35 am"
- Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary
- Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368
> 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