From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: [bug] shwordsplit not working on $@ when $# > 1
Date: Thu, 11 Aug 2016 11:05:45 +0100 [thread overview]
Message-ID: <20160811110545.1b066d2f@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <160810102836.ZM15324@torch.brasslantern.com>
On Wed, 10 Aug 2016 10:28:36 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> torch% x=(a:b "c d" ef)
> torch% print -l ${(s.:.)x}
> a
> b c d ef
That's correct, that's forced joining, which is documented. As I said
in my previous email, it's not clear it's actually a lot of use.
> torch% print -l ${(@s.:.)x}
> a:b
> c d
> ef
>
> The second one used to work exactly like the first one,
> and is the one that worries me the most.
I think it should only cause a visible effect in double quotes as that's
its real point --- though I wouldn't be surprised if there were already
exceptions. It's hard to see how it could be interpreted to mean ignore
the (s.:.), even if there are double quotes.
You might also hope that logically this would have the same effect as
${(s.:.)@} when the contents of $@ were the same as the contents of $x,
regardless of context (i.e. whether or not in double quotes). Possibly
that conflicts with the principle that it has no effect outside double
quotes, but I can't think of a case. To be clear: it is not a conflict
that SHWORDSPLIT behaviour and (s...) behaviour differ from one another,
e.g. with respect to forced joinging, only if expressions
involving the same modifications to ${(@)x} and $@ differ when the
contents of the arrays and the contexts are the same.
Note the documented oddity of the behaviour of (s...) in double quotes
when (@) does *not* also appear. But as far as I know the combination
of the two has always behaved rationally by zsh standards.
> Then there's this weird edge case, where an empty $IFS acts like you
> have specified the (@) flag when shwordsplit is set:
>
> torch% IFS=
> torch% setopt shwordsplit
> torch% print -l ${(s.:.)x}
> a:b
> c d
> ef
Hmm... I would guess that what's happened is without an IFS forced
joining with a default separator fails, and because it didn't get joined
we refuse to split it (I think there was a sort of vague assumption at
one time that it only made sense to split a scalar into an array, rather
than an array into multiple arrays, though there are obviously
exceptions so this isn't much use as a rule). That's probably a bug ---
I would think the most logical answer here is it should have been joined
with no separator and then split, but I doubt this has ever been thought
about before.
I wouldn't expect SHWORDSPLIT to make a difference if forced splitting
is in use, but that's another cavalier statement.
pws
next prev parent reply other threads:[~2016-08-11 10:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-08 11:16 Stephane Chazelas
2016-08-08 17:28 ` Bart Schaefer
2016-08-08 18:02 ` Jérémie Roquet
2016-08-08 18:27 ` Peter Stephenson
2016-08-09 1:21 ` Bart Schaefer
2016-08-09 8:40 ` Peter Stephenson
2016-08-10 17:28 ` Bart Schaefer
2016-08-11 10:05 ` Peter Stephenson [this message]
2016-08-11 17:28 ` Bart Schaefer
2016-08-12 7:50 ` Bart Schaefer
2016-08-10 12:56 ` Peter Stephenson
2016-08-11 0:39 ` 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=20160811110545.1b066d2f@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--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).