From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1122 invoked by alias); 20 Feb 2012 13:03:12 -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: 30237 Received: (qmail 26934 invoked from network); 20 Feb 2012 13:03:06 -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 14:02:59 +0100 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: suspend (^Z) behavior while a function is running is unclear Message-ID: <20120220130259.GB7797@xvii.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6201-vl-r48020 (2011-12-20) I've reported the following problem on http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660630 The suspend (^Z) behavior while a function is running is unclear. The documentation (man pages) should describe the behavior. There may be a bug in zsh, as some other shells don't behave in the same way. Consider: foo() { emacs "$@"; d=`date`; echo "$d"; } and the following test under X (so that Emacs uses its own window, or you can try with another X application): 1. Run foo. 2. Type ^Z in the terminal. 3. Type: fg [Return]. 4. Quit Emacs. 5. Type: echo "$d" [Return]. With zsh, the whole function is suspended. The effect is that zsh is forked (this is not documented, though can be guessed), thus $d will not be set in the main shell (Step 5: nothing is displayed). With bash, dash, mksh and pdksh, only the emacs process is suspended. With ksh93, the ^Z is ignored until Emacs is quit, then the function is suspended, with the same effects as in zsh. With posh, the whole shell is suspended. Versions of the packages: bash 4.2-1 dash 0.5.7-2 ksh 93u-1 mksh 40.4-3 pdksh 5.2.14-26 posh 0.10.1 zsh 4.3.15-1 zsh-beta 4.3.15-dev-0+20120108-1 BTW, concerning zsh, if the behavior is regarded as correct, a fork is still done even when the suspended command is the last one in the function, e.g. foo() { emacs "$@"; } Is the fork really necessary? -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)