zsh-users
 help / color / mirror / code / Atom feed
From: Avery Pennarun <apenwarr@gmail.com>
To: zsh-users@zsh.org
Subject: zsh in sh compatibility mode splits IFS slightly differently from other shells
Date: Wed, 24 Jul 2019 04:02:38 -0400	[thread overview]
Message-ID: <CAHqTa-08MY4FxwwKGFFODwsP6pZMZ1wHqM4mb-POtT7cekoBhQ@mail.gmail.com> (raw)

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

             reply	other threads:[~2019-07-24  8:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24  8:02 Avery Pennarun [this message]
2019-07-24 16:30 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHqTa-08MY4FxwwKGFFODwsP6pZMZ1wHqM4mb-POtT7cekoBhQ@mail.gmail.com \
    --to=apenwarr@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).