* PATCH: piped loops (was: Re: `make' completion in zsh-3.1.9)
@ 2001-03-22 12:10 Sven Wischnowsky
0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 2001-03-22 12:10 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-03-22 12:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-22 12:10 PATCH: piped loops (was: Re: `make' completion in zsh-3.1.9) Sven Wischnowsky
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).