about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/parse.c14
-rw-r--r--Test/C02cond.ztst21
3 files changed, 38 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 7b93632f6..6c3771271 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-09-04  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 31696: Src/parse.c, Test/C02cond.ztst: in "test", no one
+	can hear if you shriek.  Treat exclamation marks as strings in
+	"! -a ..." and "! -o ...".
+
 2013-08-29  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* users/17955: Doc/Zsh/contrib.yo,
diff --git a/Src/parse.c b/Src/parse.c
index 0c2a45833..f0d0855d3 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2088,9 +2088,17 @@ par_cond_2(void)
 	}
     }
     if (tok == BANG) {
-	condlex();
-	ecadd(WCB_COND(COND_NOT, 0));
-	return par_cond_2();
+	/*
+	 * In "test" compatibility mode, "! -a ..." and "! -o ..."
+	 * are treated as "[string] [and] ..." and "[string] [or] ...".
+	 */
+	if (!(condlex == testlex && *testargs && 
+	      (!strcmp(*testargs, "-a") || !strcmp(*testargs, "-o"))))
+	{
+	    condlex();
+	    ecadd(WCB_COND(COND_NOT, 0));
+	    return par_cond_2();
+	}
     }
     if (tok == INPAR) {
 	int r;
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 494261ee3..856251923 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -324,6 +324,27 @@ F:Failures in these cases do not indicate a problem in the shell.
 >	fi
 >}
 
+  weirdies=(
+    '! -a !'
+    '! -o !'
+    '! -a'
+    '! -o'
+    '! -a ! -a !'
+    '! = !'
+    '! !')
+  for w in $weirdies; do
+     eval test $w
+     print $?
+  done
+0:test compatability weirdness: treat ! as a string sometimes
+>0
+>0
+>1
+>0
+>0
+>0
+>1
+
 %clean
   # This works around a bug in rm -f in some versions of Cygwin
   chmod 644 unmodish