Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Redirection bug



There is a feature which appeared after Zefram's redirection fixes:

% (echo bug >&2) >& /dev/tty >& /dev/null ; sleep 1
bug
bug

sleep 1 is not necessary above, but without sleep 1 the prompt comes back
while the tee process is still running which makes the output less
readable (that's really an other much older bug).

The problem above is the duplicated `bug'.  Considering that >& foo is the
> same as foo 2>&1, this produce the same output:

% (echo bug >&2) > /dev/tty 2>&1 > /dev/null 2>&1 ; sleep 1
bug
bug

Or swapping stderr and stdout:

% echo bug 2> /dev/tty >&2 > /dev/null >&2 ; sleep 1
bug
bug

And if we omit > /dev/null:

% echo bug 2> /dev/tty >&2 >&2 ; sleep 1
bug
bug

At this point this behavour seems to be correct.  bug is duplicated since
stdout is redirected twice.  Here bug was printed only once before
zsh-2.6-beta18.  That was probably a bug.  But now it is quite
counter-intuitive that >& /dev/tty >& /dev/null duplicates stderr on
/dev/tty.  I do not understand redirection staff in exec.c very much but I
do hope that Zefram knows some elegant solution to this problem.

Zoltan




Messages sorted by: Reverse Date, Date, Thread, Author