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

Re: IFS problem



>	var="a%b%c"
>	OIFS=$IFS
>	IFS='%'; set - $var; IFS=$OIFS
>	echo $#
>
>returns 3 under sh, ksh, bash 1.14.3
>but 1 under zsh 2.6.beta15
>
>Is it a known bug ?

No, it's a known feature.  It's discussed in the FAQ.

By default, zsh does not perform field splitting (which IFS is used
for).  To get standard Bourne/Korn/POSIX shell behaviour, use `setopt
sh_word_split`.  (That option, by the way, is misnamed -- word
splitting is something else entirely.)  To get field splitting on a
case-by-case basis, use "$=var" instead of "$var".  "$==var" can also
be used to *dis*able field splitting for one substitution only.

For example:

	var="a%b%c"
	OIFS=$IFS
	IFS='%'; set - $=var; IFS=$OIFS
	echo $#

-zefram




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