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

Re: zsh silently abandons compound command on trying to write to a closed file descriptor



On Oct 27,  6:21pm, Martijn Dekker wrote:
}
} zsh misbehaves if a redirection produces an error due to writing to a
} closed file descriptor. For instance,
} 
}     echo hi >&- || echo oops
} 
} doesn't output "oops" as expected.

This is exactly the same thing we discussed back in Feburary on the
thread you started with workers/38044, and which was also discussed
in January in workers/37505 and 37506, and which originally came
from workers/16556 with justification in workers/16559.

Somewhere in the middle of that it was noted that Bash no longer has
the behavior referenced in 16559, but there was never an assertion
that we ought to change zsh as well.  The February thread just stops.

It's not "abandoning" the compound command, nor is it an issue with
the file descriptor; it's specific to the print builtin and its
synonyms, which includes echo.

torch% echo hi >&- && echo not abandoned
not abandoned
torch% /bin/echo hi >&-
/bin/echo: write error: Bad file descriptor
torch% echo $?
1
torch% /bin/echo hi >&- || echo oops
/bin/echo: write error: Bad file descriptor
oops



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