about summary refs log tree commit diff
diff options
context:
space:
mode:
-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 != '%') {