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

zsh in sh compatibility mode splits IFS slightly differently from other shells



Hi all,

I think this may be a known bug, as you can see it documented here:
https://www.in-ulm.de/~mascheck/various/ifs/

However, it bit users of one of my scripts lately
(https://github.com/apenwarr/redo/blob/master/minimal/do) because it
was accidentally depending on the non-sh behaviour.

Simple test:

emulate sh
x="/a/b/c/"
IFS=/
f() {
    echo "$2" "$#"
}
f $x

On zsh, this prints:
   a 5

on bash, dash, mksh, ksh93, and posh (at least), this prints:
   a 4

I've already worked around the problem in my script, but it would be
nice if nobody ever has to experience this again. Would it be possible
to change zsh to match other shells' behaviour, at least when in sh
compatibility mode?

Thanks,

Avery



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