From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7951 invoked by alias); 20 Feb 2012 19:22:05 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30245 Received: (qmail 29630 invoked from network); 20 Feb 2012 19:22:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at vinc17.net does not designate permitted sender hosts) Date: Mon, 20 Feb 2012 20:21:55 +0100 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: suspend (^Z) behavior while a function is running is unclear Message-ID: <20120220192155.GF7797@xvii.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <20120220130259.GB7797@xvii.vinc17.org> <20120220151309.4cc1a83d@pwslap01u.europe.root.pri> <20120220160944.GC7797@xvii.vinc17.org> <20120220163557.672588e2@pwslap01u.europe.root.pri> <120220094100.ZM359@torch.brasslantern.com> <20120220183335.GE7797@xvii.vinc17.org> <120220105301.ZM436@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <120220105301.ZM436@torch.brasslantern.com> X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6201-vl-r48020 (2011-12-20) 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 - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)