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: Fri, 20 Mar 2015 10:57:03 +0000	[thread overview]
Message-ID: <20150320105703.2754b6af@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20150319125351.1e270c2d@pwslap01u.europe.root.pri>

On Thu, 19 Mar 2015 12:53:51 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Thu, 19 Mar 2015 08:27:56 -0400
> Vin Shelton <acs@alumni.princeton.edu> wrote:
> > The !! command now appears inside the $(),
> > but the output is not captured:
>
> This will be an effect of the history substitution turning up in the
> wrong place (hence you're seeing it on stdout which you shouldn't) owing
> to the interaction with the nested parsing.

Not quite --- it's another similar problem to the last, that history and
alias expansions are pushed onto the input stack in a similar way but
need different processing.  The new code is actually slightly more
efficient; inungetc() did too much work for the case in question.
The comment I've added is a distinct oversimplification, but I don't
want to write an essay.

I think what I'm seeing here is another symptom of the general
entanglement between input levels (that's been there since the start)
that's also been giving Bart headaches.

You *should* see the expansion on stdout, that's completely standard.
Because I always use HIST_VERIFY I'd forgotten.

It shouldn't be rocket science to simplify the zpty-based stuff to the
point where we have a framework for testing history.  However, the
baseline for what counts as rocket science is a little bit different in
these parts.

pws

diff --git a/Src/input.c b/Src/input.c
index 92b1ad1..30970a0 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -571,8 +571,20 @@ inpoptop(void)
 {
     if (!lexstop) {
 	inbufflags &= ~INP_ALCONT;
-	while (inbufptr > inbuf)
-	    inungetc(inbufptr[-1]);
+	while (inbufptr > inbuf) {
+	    inbufptr--;
+	    inbufct++;
+	    inbufleft++;
+	    /*
+	     * As elsewhere in input and history mechanisms:
+	     * unwinding aliases and unwinding history have different
+	     * implications as aliases are after the lexer while
+	     * history is before, but they're both pushed onto
+	     * the input stack.
+	     */
+	    if ((inbufflags & (INP_ALIAS|INP_HIST)) == INP_ALIAS)
+		zshlex_raw_back();
+	}
     }
 
     if (inbuf && (inbufflags & INP_FREE))


  reply	other threads:[~2015-03-20 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
2015-03-19 12:27   ` Vin Shelton
2015-03-19 12:53     ` Peter Stephenson
2015-03-20 10:57       ` Peter Stephenson [this message]
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=20150320105703.2754b6af@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).