Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] lex: fix <-> in parameter flags
- X-seq: zsh-workers 54437
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] lex: fix <-> in parameter flags
- Date: Thu, 30 Apr 2026 22:55:48 -0500
- Archived-at: <https://zsh.org/workers/54437>
- Feedback-id: i9be146f9:Fastmail
- List-id: <zsh-workers.zsh.org>
fix for this issue:
% print -r - ${(l<3><->):-}
zsh: error in flags near position 8 in '${(l<3><->):-}'
this also short-circuits the isnumglob() test for other cases, like <->
inside an array subscript, but it seems like that's fine?
dana
diff --git a/Src/lex.c b/Src/lex.c
index efbb62b66..70e67b7ea 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1198,7 +1198,7 @@ gettokstr(int c, int sub)
break;
}
hungetc(e);
- if(isnumglob()) {
+ if(!in_brace_param && isnumglob()) {
add(Inang);
while ((c = hgetc()) != '>')
add(c);
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index ed25fd7a9..e6ce3a106 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -788,6 +788,23 @@
0:${(r...)...}
>why?! in?!! goodn name? am?!! I?!!! doing this?
+ print -r - ${(l<3><->):-}
+ print -r - ${(l<3><1->):-}
+ # these cases weren't affected by the fix for this, but just in case
+ str=abc123xyz
+ print -r - ${str//<->/.}
+ print -r - ${str//<1->/.}
+ arr=( abc 123 xyz )
+ print -r - ${arr[(r)<->]}
+ print -r - ${arr[(r)<1->]}
+0:regression test for <-> in flags
+>---
+>-1-
+>abc.xyz
+>abc.xyz
+>123
+>123
+
array=(I\'m simply putting a brave face on)
print ${(j:--:)array}
0:${(j)...}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author