summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/hist.c26
-rw-r--r--Src/lex.c2
3 files changed, 26 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 7971cbf9e..3dd3f8c70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-18 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * 34319: Src/hist.c, Src/lex.c: alias expansion in history of
+ command substitution.
+
2015-01-17 Axel Beckert <abe@deuxchevaux.org>
* 34314: Wieland Hoffmann: Completion/Unix/Command/_git: Change
diff --git a/Src/hist.c b/Src/hist.c
index e5c48dbc1..11d9722d5 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -329,7 +329,16 @@ static void
ihwaddc(int c)
{
/* Only if history line exists and lexing has not finished. */
- if (chline && !(errflag || lexstop)) {
+ if (chline && !(errflag || lexstop) &&
+ /*
+ * If we're reading inside a word for command substitution
+ * we allow the lexer to expand aliases but don't deal
+ * with them here. Note matching code in ihungetc().
+ * TBD: it might be neater to deal with all aliases in this
+ * fashion as we never need the expansion in the history
+ * line, only in the lexer and above.
+ */
+ !((histactive & HA_INWORD) && (inbufflags & INP_ALIAS))) {
/* Quote un-expanded bangs in the history line. */
if (c == bangchar && stophist < 2 && qbang)
/* If qbang is not set, we do not escape this bangchar as it's *
@@ -892,11 +901,16 @@ ihungetc(int c)
zlemetall--;
exlast++;
}
- DPUTS(hptr <= chline, "BUG: hungetc attempted at buffer start");
- hptr--;
- DPUTS(*hptr != (char) c, "BUG: wrong character in hungetc() ");
- qbang = (c == bangchar && stophist < 2 &&
- hptr > chline && hptr[-1] == '\\');
+ if (!(histactive & HA_INWORD) || !(inbufflags & INP_ALIAS)) {
+ DPUTS(hptr <= chline, "BUG: hungetc attempted at buffer start");
+ hptr--;
+ DPUTS(*hptr != (char) c, "BUG: wrong character in hungetc() ");
+ qbang = (c == bangchar && stophist < 2 &&
+ hptr > chline && hptr[-1] == '\\');
+ } else {
+ /* No active bangs in aliases */
+ qbang = 0;
+ }
if (doit)
inungetc(c);
if (!qbang)
diff --git a/Src/lex.c b/Src/lex.c
index 6d45c70c7..e4dfdfaca 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1674,7 +1674,7 @@ parse_subst_string(char *s)
/* Called below to report word positions. */
/**/
-mod_export void
+static void
gotword(void)
{
we = zlemetall + 1 - inbufct + (addedx == 2 ? 1 : 0);