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

sh vs zsh behavior



Compare these two simple scripts (one in sh, one in zsh)

########################################################################
#!/bin/sh

test="one two three"

for i in $test
do
	echo this is $i
	echo loop
done

exit 0

########################################################################
#!/usr/local/bin/zsh -f

test="one two three"

for i in $test
do
	echo this is $i
	echo loop
done

exit 0
########################################################################
########################################################################

THE /bin/sh SCRIPT PRODUCES THE OUTPUT:
this is one
loop
this is two
loop
this is three
loop

THE zsh SCRIPT PRODUCES THE OUTPUT:
this is one two three
loop



I want to have 'zsh' behave like 'sh' in this matter.  Is there a way to
do this?

What I am specifically trying to do is check to see if some variable is
equal to any type part of a list of possibilities.

I can do this easily in CSH (*shudder*) via:

if ( "$variable" == "one" || "$variable" == "two" || "$variable" == "three
) then
# that should all be one line above

	echo "Match"

else

	echo "No Match"

endif


How can I do multiple comparisons in ZSH?

Thanks

TjL

ps -- I'm using 2.6-beta13 under NeXTStep/m68k






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