Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
zsh in sh compatibility mode splits IFS slightly differently from other shells
- X-seq: zsh-users 24094
- From: Avery Pennarun <apenwarr@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: zsh in sh compatibility mode splits IFS slightly differently from other shells
- Date: Wed, 24 Jul 2019 04:02:38 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=UGybyUunMEH1RkBDuQx29HJ/oFKMaQtGSKm9NZZjT9s=; b=lzOPlc1OqHkcdVmL+us3HBJfTQT5cikQmhdEp3ly9kWuPsyxOGf+omb67zNmhxnAA1 aSDgsJt6ff2FTF8IN1Jeq2G15MuFDC2QhT2ztJDvug8AalND70GHc0U+G7Vqegi8Y10c K2Hnru3VIU9a4AQbcjPL7p5n4fnayXR3y4yycynm+kElbFEuSwKRAN+OCU6kRyLEJAZA Jey8l2we1kck8iI5ynGB8ReGkagYuXWRjKLhPwgiG9RmOwlHcFJEAbrZ6TUTixADSYxq Fw1XCUhCxm+NrjxHYnsHWwX+KeZR11t9En/Tt0xUGn+DK7VcMafyZizBhM3zNedj/P7H 88nQ==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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