zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: capturing output of !! not working
Date: Thu, 19 Mar 2015 10:57:16 +0000	[thread overview]
Message-ID: <20150319105716.620cd931@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CACeGjnXH=Dk6eAv0OEfyT99RC9J=AMiyxL4wT4p_SVS1pLo0+g@mail.gmail.com>

On Wed, 18 Mar 2015 21:49:37 -0400
Vin Shelton <acs@alumni.princeton.edu> wrote:
> $ ls -l $(!!)
> ls -l $()

This is due to special code for handling aliases inside command
substitutions that got applied too widely because the flag that
indicates aliases also indicates history expansion; however, there's a
discriminator in another bit.  I suspect restricting application of
INP_ALIAS is a better fix overall, but it needs a lot more code tracking
down plus safety checks.

Another case where we need a framework for testing interactive shells.

pws

diff --git a/Src/hist.c b/Src/hist.c
index aa07ce8..b7ef522 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -338,7 +338,8 @@ ihwaddc(int c)
 	 * fashion as we never need the expansion in the history
 	 * line, only in the lexer and above.
 	 */
-	!((histactive & HA_INWORD) && (inbufflags & INP_ALIAS))) {
+	!((histactive & HA_INWORD) &&
+	  (inbufflags & (INP_ALIAS|INP_HIST)) == 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 *
@@ -901,7 +902,8 @@ ihungetc(int c)
 	    zlemetall--;
 	    exlast++;
 	}
-	if (!(histactive & HA_INWORD) || !(inbufflags & INP_ALIAS)) {
+	if (!(histactive & HA_INWORD) ||
+	    (inbufflags & (INP_ALIAS|INP_HIST)) != INP_ALIAS) {
 	    DPUTS(hptr <= chline, "BUG: hungetc attempted at buffer start");
 	    hptr--;
 	    DPUTS(*hptr != (char) c, "BUG: wrong character in hungetc() ");


  parent reply	other threads:[~2015-03-19 10:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19  1:49 Vin Shelton
2015-03-19  2:28 ` Bart Schaefer
2015-03-19 10:57 ` Peter Stephenson [this message]
2015-03-19 12:27   ` Vin Shelton
2015-03-19 12:53     ` Peter Stephenson
2015-03-20 10:57       ` Peter Stephenson
2015-03-20 16:04         ` Bart Schaefer
2015-03-22 18:35           ` Peter Stephenson
2015-03-22 19:18             ` Peter Stephenson
2015-03-22 23:22             ` Bart Schaefer
2015-03-23 21:34               ` Peter Stephenson
2015-03-24  0:54                 ` Testing interactive features (Re: capturing output of !! not working) Bart Schaefer
2015-03-24  4:12                   ` Bart Schaefer
2015-03-24  4:45                     ` Bart Schaefer
2015-03-24 16:09                       ` Bart Schaefer
2016-05-23 14:53                         ` Mikael Magnusson
2015-03-25 15:48                 ` PATCH: Removing aliases from history, 2015 style (was " Peter Stephenson
2015-03-25 17:57                   ` PATCH: Removing aliases from history, 2015 style Peter Stephenson
2015-03-25 18:42                     ` Mikael Magnusson
2015-03-27 10:06                       ` Peter Stephenson
2015-03-27 15:25                         ` Bart Schaefer
2015-03-27 15:41                           ` Peter Stephenson
2015-03-27 17:17                             ` Bart Schaefer
2015-03-27 17:47                               ` Peter Stephenson
2015-03-29 18:38                         ` Peter Stephenson
2015-03-25 18:58                     ` Bart Schaefer
2015-03-25 19:40                   ` PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working) Bart Schaefer
2015-03-26  3:43                     ` Word breaks around aliased tokens (was Re: PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working)) Bart Schaefer
2015-03-30 18:04                       ` Daniel Shahaf
2015-03-30 20:05                         ` Mikael Magnusson
2015-03-30 18:08                       ` Daniel Shahaf
2015-03-26  9:41                     ` PATCH: Removing aliases from history, 2015 style (was capturing output of !! not working) Peter Stephenson
2015-03-26 15:22                       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150319105716.620cd931@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).