diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-01-18 16:43:26 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-01-18 16:43:26 +0000 |
commit | e34ce85151dcd5ac698e116a6742d481ff64ae2c (patch) | |
tree | 2067381ddd27bf739a4369ec5761af90717c42f5 /Src | |
parent | 870d880befaede1f55f232717a93ed07b9edb4c6 (diff) | |
download | zsh-e34ce85151dcd5ac698e116a6742d481ff64ae2c.tar.gz zsh-e34ce85151dcd5ac698e116a6742d481ff64ae2c.tar.xz zsh-e34ce85151dcd5ac698e116a6742d481ff64ae2c.zip |
34319: fix alias expansion in history for command substitution
Diffstat (limited to 'Src')
-rw-r--r-- | Src/hist.c | 26 | ||||
-rw-r--r-- | Src/lex.c | 2 |
2 files changed, 21 insertions, 7 deletions
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); |