summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/subst.c8
-rw-r--r--Test/E01options.ztst27
3 files changed, 36 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 19c2674c6..3d867afe2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2010-10-22  Peter Stephenson  <pws@csr.com>
 
+	* 28360: Src/subst.c, Test/E01options.ztst: NO_UNSET option
+	should test parameters with following operators, too.
+
 	* not quite posted: Completion/Unix/Command/_screen: better to
 	allow sessions to be completed after -S.
 
@@ -13778,5 +13781,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5112 $
+* $Revision: 1.5113 $
 *****************************************************
diff --git a/Src/subst.c b/Src/subst.c
index cace51e8c..5f65945a5 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2649,8 +2649,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		}
 		getmatcharr(&aval, s, flags, flnum, replstr);
 	    } else {
-		if (vunset)
+		if (vunset) {
+		    if (unset(UNSET)) {
+			*idend = '\0';
+			zerr("%s: parameter not set", idbeg);
+			return NULL;
+		    }
 		    val = dupstring("");
+		}
 		if (!copied) {
 		    val = dupstring(val);
 		    copied = 1;
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 410944643..be83ceccd 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -998,7 +998,7 @@
 >two
 >words
 
-  fn() { unset foo; print $foo; }
+  fn() { unset foo; print value is $foo; }
   setopt nounset
   print option unset unset by setting nounset
   eval fn
@@ -1008,9 +1008,32 @@
 0:UNSET option
 >option unset unset by setting nounset
 >option unset reset
->
+>value is
 ?fn: foo: parameter not set
 
+  fn1() { unset foo; print value 1 is ${foo#bar}; }
+  fn2() { unset foo; print value 2 is ${foo%bar}; }
+  fn3() { unset foo; print value 3 is ${foo/bar}; }
+  setopt nounset
+  print option unset unset by setting nounset
+  eval fn1
+  eval fn2
+  eval fn3
+  print option unset reset
+  setopt unset
+  fn1
+  fn2
+  fn3
+0:UNSET option with operators
+>option unset unset by setting nounset
+>option unset reset
+>value 1 is
+>value 2 is
+>value 3 is
+?fn1: foo: parameter not set
+?fn2: foo: parameter not set
+?fn3: foo: parameter not set
+
   fn() {
     emulate -L zsh
     setopt warncreateglobal