zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: PATCH: piped loops (was: Re: `make' completion in zsh-3.1.9)
Date: Thu, 22 Mar 2001 13:10:59 +0100 (MET)	[thread overview]
Message-ID: <200103221210.NAA05985@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Thu, 22 Mar 2001 06:35:12 +0000


Bart Schaefer wrote:

> ...
> 
> Why does it work when the while-construct is wrapped with { } ?
> 
> Why can't we "pretend" -- in the wordcode compiler, if necessary -- that
> every complex command is wrapped with { } ?

I thought something similar yesterday but then didn't have the time to 
look.

Now I had.

The first thing I noticed was that while

  % { while read -e; do :; done < foo } | less

worked, this:

  % { while read -e; do :; done } < foo | less

didn't.

>From there it was simple.  execpline2() looks at the code for the
command for exactly the case that there is a current-shell-thing in a
pipeline.  It then fork()s directly (so that it doesn't have to be
done in execcmd()).

BUT.  With

  % { while read -e; do :; done } < foo | less

or

  % while read -e; do :; done < foo | less

the command (the `while') is preceded by the codes for the
redirections and execpline2() didn't skip them when looking for the
command code.

So we only have to make it do that.


I feel much better now.


Bye
 Sven

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.24
diff -u -r1.24 exec.c
--- Src/exec.c	2001/01/16 13:44:20	1.24
+++ Src/exec.c	2001/03/22 12:10:41
@@ -1189,11 +1189,11 @@
 	execcmd(state, input, output, how, last1 ? 1 : 2);
     else {
 	int old_list_pipe = list_pipe;
-	Wordcode next = state->pc + (*state->pc);
+	Wordcode next = state->pc + (*state->pc), pc;
 	wordcode code;
 
 	state->pc++;
-	code = *state->pc;
+	for (pc = state->pc; wc_code(code = *pc) == WC_REDIR; pc += 3);
 
 	mpipe(pipes);
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


                 reply	other threads:[~2001-03-22 12:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200103221210.NAA05985@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.dk \
    /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).