summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-01-16 20:12:40 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-01-16 20:12:40 +0000
commitf2a2f28f7bde196cd1fa205ac0c20336046cf2cf (patch)
treefec9daea2f53a208cc9702aa1343169fdb38fdb6
parentdb05cc51fa2298cf128e480d3ac8e5373029f6b9 (diff)
downloadzsh-f2a2f28f7bde196cd1fa205ac0c20336046cf2cf.tar.gz
zsh-f2a2f28f7bde196cd1fa205ac0c20336046cf2cf.tar.xz
zsh-f2a2f28f7bde196cd1fa205ac0c20336046cf2cf.zip
32413: turn off history word marking in cmd subst
-rw-r--r--ChangeLog5
-rw-r--r--Src/hist.c22
-rw-r--r--Src/lex.c2
3 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f71c53711..3a7e3cdf4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-16  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 34313: Src/hist.c, Src/lex.c: need to turn off history
+	word markers when parsing command substitution.
+
 2015-01-16  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 34304: Src/lex.c: improve use of new command substitution
diff --git a/Src/hist.c b/Src/hist.c
index 1c5d045e7..c77b5dd9d 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -134,6 +134,8 @@ mod_export int hist_skip_flags;
 /* Bits of histactive variable */
 #define HA_ACTIVE	(1<<0)	/* History mechanism is active */
 #define HA_NOINC	(1<<1)	/* Don't store, curhist not incremented */
+#define HA_INWORD       (1<<2)  /* We're inside a word, don't add
+				   start and end markers */
 
 /* Array of word beginnings and endings in current history line. */
 
@@ -299,6 +301,22 @@ hist_context_restore(const struct hist_stack *hs, int toplevel)
     cmdsp = hs->csp;
 }
 
+/*
+ * Mark that the current level of history is or is not
+ * within a word, whatever turns up.  This is used for nested
+ * parsing of substitutions.
+ */
+
+/**/
+void
+hist_in_word(int yesno)
+{
+    if (yesno)
+	histactive |= HA_INWORD;
+    else
+	histactive &= ~HA_INWORD;
+}
+
 /* restore history context */
 
 /* add a character to the current history word */
@@ -1496,7 +1514,7 @@ int hwgetword = -1;
 void
 ihwbegin(int offset)
 {
-    if (stophist == 2)
+    if (stophist == 2 || (histactive & HA_INWORD))
 	return;
     if (chwordpos%2)
 	chwordpos--;	/* make sure we're on a word start, not end */
@@ -1516,7 +1534,7 @@ ihwbegin(int offset)
 void
 ihwend(void)
 {
-    if (stophist == 2)
+    if (stophist == 2 || (histactive & HA_INWORD))
 	return;
     if (chwordpos%2 && chline) {
 	/* end of word reached and we've already begun a word */
diff --git a/Src/lex.c b/Src/lex.c
index 96da1cbeb..6d45c70c7 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1922,6 +1922,7 @@ skipcomm(void)
 	new_lexbuf = lexbuf;
 
 	zcontext_save_partial(ZCONTEXT_LEX|ZCONTEXT_PARSE);
+	hist_in_word(1);
     } else {
 	/*
 	 * Set up for nested command subsitution, however
@@ -1992,6 +1993,7 @@ skipcomm(void)
 	tokstr = new_tokstr;
 	lexbuf = new_lexbuf;
 	lexstop = new_lexstop;
+	hist_in_word(0);
     }
 
     if (!lexstop)