Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] shwordsplit not working on $@ when $# > 1
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author