zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: suspend (^Z) behavior while a function is running is unclear
Date: Mon, 20 Feb 2012 14:02:59 +0100	[thread overview]
Message-ID: <20120220130259.GB7797@xvii.vinc17.org> (raw)

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 <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)


             reply	other threads:[~2012-02-20 13:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20 13:02 Vincent Lefevre [this message]
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
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=20120220130259.GB7797@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).