Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: command substitution: zsh waits until command exits
- X-seq: zsh-users 12270
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: command substitution: zsh waits until command exits
- Date: Sun, 2 Dec 2007 03:16:53 +0100
- In-reply-to: <071130185827.ZM18402@xxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20071130133943.GG5855@xxxxxxxxxxxxxxxxxxx> <071130073719.ZM18090@xxxxxxxxxxxxxxxxxxxxxx> <20071130163155.GL5855@xxxxxxxxxxxxxxxxxxx> <071130185827.ZM18402@xxxxxxxxxxxxxxxxxxxxxx>
On 2007-11-30 18:58:27 -0800, Bart Schaefer wrote:
> On Nov 30, 5:31pm, Vincent Lefevre wrote:
> } By "when zsh does the substitution", this includes the question
> } whether zsh does the substitution before or after the command exits.
> } For instance, zsh could start commands in the left-to-right fashion
> } (I assumed asynchronously), but could replace the $(...) in some
> } arbitrary order, once it knows the result, i.e. once the standard
> } output is closed.
>
> No, that would be non-deterministic with respect to left-to-right order.
> Consider:
>
> echo $(echo first; exec >&- ; echo last > /tmp/first) $(</tmp/first)
>
> If the commands were only started left-to-right and not also finished
> left-to-right, $(</tmp/first) could fail with "no such file".
But there can be the same kind of problem with process substitution.
So, why allowing non-deterministic behavior for process substitution
but not for command substitution?
> The default is to do everything synchronously. That's why cases that
> are asynchronous are explicitly called out, like process substitution.
How can the user know that? The zsh man pages don't seem to say that
the default is to do everything synchronously.
> } > echo $(coproc xterm -e 'tty >&3; sleep 999999' 3>&1 ; read -E <&p)
> }
> } OK, thanks. But is there any reason why Ctrl-C doesn't work in the
> } xterm?
>
> Could be any of a variety of reasons, the most likely of which is that no
> interactive shell is being run.
But Ctrl-C works with things like: xterm -e 'sleep 9999'
and there isn't an interactive shell either. It also works with:
xterm -e 'tty >&3; sleep 999999' 3>&1
but no longer with the full coproc line. Note that with the coproc line,
Ctrl-\ works (only Ctrl-C is affected).
> Explicitly set the tty up the way you want it by using X resources:
>
> XTerm*ttyModes: erase ^? intr ^C
>
> Or
>
> xterm -xrm "*ttyModes: erase ^? intr ^C" -e 'tty >&3; sleep 999999' 3>&1
I've tried the second solution:
echo $(coproc xterm -xrm "*ttyModes: erase ^? intr ^C" -e 'tty >&3; sleep 999999' 3>&1 ; read -E <&p)
and this doesn't change anything.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author