From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: [bug] shwordsplit not working on $@ when $# > 1
Date: Fri, 12 Aug 2016 00:50:44 -0700 [thread overview]
Message-ID: <160812005044.ZM17236@torch.brasslantern.com> (raw)
In-Reply-To: <160811102803.ZM2533@torch.brasslantern.com>
On Aug 11, 10:28am, Bart Schaefer wrote:
}
} This is still broken after 39019 (sigh) because IFS= plus shwordsplit
} implies that joining should not happen in other circumstances, and we
} only split after joining, so that unintentionally bleeds into this. I
} thought I'd got it worked out and that the tests I added covered it,
} but trying this specific example again still fails. Back to prodding
} at it, I guess.
OK, this finally seems to both test and solve all the weird combos.
Note the only difference from nojoin == 0 to nojoin == 1 in the case
of force_split is that ms_flags is not cleared. I really don't follow
what that's doing.
diff --git a/Src/subst.c b/Src/subst.c
index ae3e4c4..99e1650 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3461,11 +3461,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
val = sepjoin(aval, sep, 1);
isarr = 0;
ms_flags = 0;
- } else if (force_split && nojoin == 2) {
+ } else if (force_split && (spsep || nojoin == 2)) {
/* Hack to simulate splitting individual elements:
- * first join on what we later use to split
+ * forced joining as previously determined, or
+ * join on what we later use to forcibly split
*/
- val = sepjoin(aval, spsep, 1);
+ val = sepjoin(aval, (nojoin == 1 ? sep : spsep), 1);
isarr = 0;
}
}
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 35630c5..460a841 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1970,8 +1970,14 @@
set -- one:two bucklemy:shoe
IFS=
setopt shwordsplit
- print -l ${@}
+ print -l ${@} ${(s.:.)*} ${(s.:.j.-.)*}
)
-0:Joining of $@ does not happen when IFS is empty
+0:Joining of $@ does not happen when IFS is empty, but splitting $* does
>one:two
>bucklemy:shoe
+>one
+>twobucklemy
+>shoe
+>one
+>two-bucklemy
+>shoe
next prev parent reply other threads:[~2016-08-12 7:50 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
2016-08-11 17:28 ` Bart Schaefer
2016-08-12 7:50 ` Bart Schaefer [this message]
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=160812005044.ZM17236@torch.brasslantern.com \
--to=schaefer@brasslantern.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).