From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from math.gatech.edu (euclid.skiles.gatech.edu [130.207.146.50]) by werple.net.au (8.7/8.7.1) with SMTP id FAA09955 for ; Tue, 14 Nov 1995 05:04:10 +1100 (EST) Received: by math.gatech.edu (5.x/SMI-SVR4) id AA03105; Mon, 13 Nov 1995 12:42:13 -0500 Resent-Date: Mon, 13 Nov 1995 18:42:05 +0100 Old-Return-Path: Message-Id: <9511131742.AA02362@sgi.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Yet another fake subshell fix Date: Mon, 13 Nov 1995 18:42:05 +0100 From: Peter William Stephenson Resent-Message-Id: <"oGgnS2.0.Om.pDufm"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/604 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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 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.