zsh-workers
 help / color / mirror / code / Atom feed
* suspend (^Z) behavior while a function is running is unclear
@ 2012-02-20 13:02 Vincent Lefevre
  2012-02-20 15:13 ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Vincent Lefevre @ 2012-02-20 13:02 UTC (permalink / raw)
  To: zsh-workers

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)


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-02-21  3:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-20 13:02 suspend (^Z) behavior while a function is running is unclear 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
2012-02-20 19:48             ` Mikael Magnusson
2012-02-21  3:27               ` Bart Schaefer

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