From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23652 invoked from network); 22 Mar 2001 12:11:12 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Mar 2001 12:11:12 -0000 Received: (qmail 6838 invoked by alias); 22 Mar 2001 12:11:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13706 Received: (qmail 6811 invoked from network); 22 Mar 2001 12:10:59 -0000 Date: Thu, 22 Mar 2001 13:10:59 +0100 (MET) Message-Id: <200103221210.NAA05985@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.dk In-reply-to: "Bart Schaefer"'s message of Thu, 22 Mar 2001 06:35:12 +0000 Subject: PATCH: piped loops (was: Re: `make' completion in zsh-3.1.9) 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