From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: suspend (^Z) behavior while a function is running is unclear
Date: Mon, 20 Feb 2012 20:21:55 +0100 [thread overview]
Message-ID: <20120220192155.GF7797@xvii.vinc17.org> (raw)
In-Reply-To: <120220105301.ZM436@torch.brasslantern.com>
On 2012-02-20 10:53:01 -0800, Bart Schaefer wrote:
> As a hack, one could do:
>
> alias -g NOSUSP='|while { read -rE } { : }'
>
> foreach foo (a b c) { print $foo; sleep 5 } NOSUSP
OK, I could do:
alias Z='while { read -rE } { : }'
and use '|Z', which is shorter and should be safe.
But there are several problems:
1. The left-hand side is run in a subshell, so that side effects
(e.g. setting a variable) are not taken into account. Wanting
to disable TSTP was the main reason to avoid this problem!
2. One still has two processes (I wanted to avoid any additional
process).
3. Buffering, e.g.: { echo -n a; sleep 2; echo b } |Z
The 'a' isn't visible immediately.
4. The "while" terminates with a nonzero exit status (I could locally
unsetopt PRINT_EXIT_VALUE, though).
5. I sometimes get a spurious additional newline.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
next prev parent reply other threads:[~2012-02-20 19:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 13:02 Vincent Lefevre
2012-02-20 15:13 ` Peter Stephenson
2012-02-20 16:09 ` Vincent Lefevre
2012-02-20 16:35 ` Peter Stephenson
2012-02-20 17:41 ` Bart Schaefer
2012-02-20 18:33 ` Vincent Lefevre
2012-02-20 18:53 ` Bart Schaefer
2012-02-20 19:21 ` Vincent Lefevre [this message]
2012-02-20 19:48 ` Mikael Magnusson
2012-02-21 3:27 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120220192155.GF7797@xvii.vinc17.org \
--to=vincent@vinc17.net \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).