zsh-workers
 help / color / mirror / code / Atom feed
* Yet another fake subshell fix
@ 1995-11-13 17:42 Peter William Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter William Stephenson @ 1995-11-13 17:42 UTC (permalink / raw)
  To: Zsh hackers list

More ramifications to do with exec'ing the last command in a shell
that's about to exit:  going into a subshell messes up the shell
terminal file descriptor (plus other things), so that builtins are
unhappy.  You can see it with things like

% zsh -fc 'vared DISPLAY'

(useless example, obviously) which I scrupulously made sure worked
when I wrote the patch to delay setting up the terminal in
non-interactive shells.

The answer is simple, correct, and I should have done it when I first
thought about exec'ing the final command: there's no point in trying
to do the fake-exec thing for a builtin or shell command anyway; it
simply removes a bit of post processing by the shell (which you might
be glad of someday).

If there are any problems with this, they must have been there for a
long time, since this is what zsh always used to do with builtins (as
well as every other command).

This would actually fix the previous problems with exit instead of
_exit in 99.99% of cases (we return to, say, getoutput, which handles
$(...), and _exit from there), but the second patch I sent for that
does get everything right so we still need it.  The remaining .01% of
cases are where a nervous user asks for a real `exec read' or what
have you inside a subshell.

*** Src/exec.c~	Wed Nov  8 10:05:22 1995
--- Src/exec.c	Mon Nov 13 17:58:16 1995
***************
*** 1266,1274 ****
       * in a subshell pipeline, or if the shell is no longer needed    *
       * (e.g. the last command after a `-c').  However, if the command *
       * is going into the background, or if we need to trap EXIT or    *
!      * ZERR, then we can't do this.                                   */
  
!     if (last1 && (how & Z_SYNC)
  	&& !sigtrapped[SIGZERR] && !sigtrapped[SIGEXIT]
  	&& execok()) {
  	cmd->flags |= CFLAG_FAKE_EXEC;
--- 1266,1276 ----
       * in a subshell pipeline, or if the shell is no longer needed    *
       * (e.g. the last command after a `-c').  However, if the command *
       * is going into the background, or if we need to trap EXIT or    *
!      * ZERR, then we can't do this.  Also, if it's getting run in the *
!      * current shell, there's no point (and we unnecessarily mess up  *
!      * terminal settings etc.)                                        */
  
!     if (last1 && (how & Z_SYNC) && !is_cursh
  	&& !sigtrapped[SIGZERR] && !sigtrapped[SIGEXIT]
  	&& execok()) {
  	cmd->flags |= CFLAG_FAKE_EXEC;

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-11-13 18:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-11-13 17:42 Yet another fake subshell fix Peter William Stephenson

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