zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Martijn Dekker <martijn@inlv.org>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: shwordsplit: final non-whitespace IFS character problem
Date: Fri, 4 Aug 2017 11:56:01 +0100	[thread overview]
Message-ID: <20170804105601.GA10499@chaz.gmail.com> (raw)
In-Reply-To: <0f71b764-cc3d-5274-a16a-498b792bff6e@inlv.org>

2017-08-04 04:03:19 +0200, Martijn Dekker:
> In field/word splitting, a final non-whitespace IFS delimiter character
> is counted as an empty field. This is unlike every other current shell
> (including current versions of pdksh, i.e. mksh and OpenBSD ksh).
> 
> Test script:
> 
> setopt shwordsplit
> IFS=:
> x=a:b:
> set -- $x
> echo $#
[...]

IIRC, it was discussed before, and the concensus at the time was
that it would be silly as the S in IFS stands for *S*eparator, not
terminator nor delimiter. At the time though, a number of shells
(pdksh and ash based ones) still behaved like zsh and not ksh88
and POSIX was even less clear about it.

Note that, it also affects "read", where "IFS=: read var" on an
output that contains "word:" should (as per POSIX) store "word"
into "var" (while it "should" store "word1:word2:" on a line
with "word1:word2:").

I can't imagine changing the behaviour in the sh/ksh emulations
would be a problem (though I still think it's silly).

Note that with that semantic, you can no longer do things like:

IFS=:
set -o noglob
for dir in $PATH; do
  ...
done

You need to use some kludge like the "which" POSIX script does
on Debian to account for PATHs like "/bin:/usr/bin:".

-- 
Stephane


  reply	other threads:[~2017-08-04 10:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04  2:03 Martijn Dekker
2017-08-04 10:56 ` Stephane Chazelas [this message]
2017-08-04 11:13   ` Peter Stephenson
2017-08-06 18:08 ` Peter Stephenson
2017-08-06 20:01   ` Peter Stephenson
2017-08-08 10:56     ` Kamil Dudka
2017-08-08 12:17       ` Peter Stephenson

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=20170804105601.GA10499@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --cc=martijn@inlv.org \
    --cc=zsh-workers@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).