summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/subst.c11
-rw-r--r--Test/D04parameter.ztst10
3 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 3377ae3ba..5a727fd4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@
 
 2011-06-03  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 29451: Src/subst.c, Test/D04parameter.ztst: ${##stuff}
+	removes stuff from the head of $#.
+
 	* 29413: Doc/Zsh/builtins.yo, Src/builtin.c, Src/hist.c: print
 	-S takes a single argument, applies lexical history word
 	splitting, and puts it on the history.
@@ -14942,5 +14945,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5359 $
+* $Revision: 1.5360 $
 *****************************************************
diff --git a/Src/subst.c b/Src/subst.c
index f9c48404b..314489e49 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2080,7 +2080,16 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		    || (cc = s[1]) == '*' || cc == Star || cc == '@'
 		    || cc == '?' || cc == Quest
 		    || cc == '$' || cc == String || cc == Qstring
-		    || cc == '#' || cc == Pound
+		    /*
+		     * Me And My Squiggle:
+		     * ${##} is the length of $#, but ${##foo}
+		     * is $# with a "foo" removed from the start.
+		     * If someone had defined the *@!@! language
+		     * properly in the first place we wouldn't
+		     * have this nonsense.
+		     */
+		    || ((cc == '#' || cc == Pound) &&
+			s[2] == Outbrace)
 		    || cc == '-' || (cc == ':' && s[2] == '-')
 		    || (isstring(cc) && (s[2] == Inbrace || s[2] == Inpar)))) {
 	    getlen = 1 + whichlen, s++;
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 378505e12..8f95420dd 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -179,9 +179,17 @@
   print ${##}
   set 1 2 3 4 5 6 7 8 9 10
   print ${##}
-0:${##} is length of $#
+  print ${##""}
+  print ${##1}
+  print ${##2}
+  print ${###<->} # oh, for pete's sake...
+0:${##} is length of $#, and other tales of hash horror
 >1
 >2
+>10
+>0
+>10
+>
 
   array=(once bitten twice shy)
   print IF${array}THEN