about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2013-10-08 07:21:29 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2013-10-08 07:21:29 -0700
commit8ffdf161c781b374dcaa461c1a5333f70cffdf6f (patch)
tree8576344010ae9a60f225954676724fc8dde6fe90
parent6f195241f3ee98c11bc93ab089417012767d9cec (diff)
downloadzsh-8ffdf161c781b374dcaa461c1a5333f70cffdf6f.tar.gz
zsh-8ffdf161c781b374dcaa461c1a5333f70cffdf6f.tar.xz
zsh-8ffdf161c781b374dcaa461c1a5333f70cffdf6f.zip
31797: to match documentation, avoid expanding history when there is neither a
word nor an event designator

There are still a few cases where expansion is attempted even though the
documentation indicates it will not be, but in most of those cases the
expansion will fail.  The now-fixed case would fall back to default
expansion of the previous command.
-rw-r--r--ChangeLog9
-rw-r--r--Src/hist.c6
2 files changed, 15 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a8dc3b9e0..c06c401e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-10-08  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 31797: partly fix long-standing history expansion bug in which
+	in some circumstances a default history expansion would occur even
+	when there is neither an event nor a word designator, which is
+	contradictory to the documentation.  There are still some cases in
+	which expansion is attempted when it should not be, but in most of
+	those cases the expansion simply fails.
+
 2013-10-07  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 31794: Src/hist.c: further refinement that SHAREHISTORY should
diff --git a/Src/hist.c b/Src/hist.c
index d1af30a29..bd650e81e 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -521,6 +521,12 @@ histsubchar(int c)
 		}
 		c = ingetc();
 	    }
+	    if (ptr == buf &&
+		(c == '}' ||  c == ';' || c == '\'' || c == '"' || c == '`')) {
+	      /* Neither event nor word designator, no expansion */
+	      safeinungetc(c);
+	      return bangchar;
+	    }
 	    *ptr = 0;
 	    if (!*buf) {
 		if (c != '%') {