[PATCH] lex: fix <-> in parameter flags

dana <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
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)...}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.