Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't persist redirs when failing to exec a program (re: 53937b9)
As of the referenced commit, the interactive shell no longer forces an exit upon 'exec program' when 'program' cannot be executed. This is good. However, any redirections to 'program' then persist in the current interactive shell environment, which is wrong and harmful. Further discussion: https://austingroupbugs.net/view.php?id=1896 src/cmd/ksh93/sh/xec.c: sh_exec(): case TCOM: - Upon processing redirections for 'exec', when the shell is interactive (which excludes subshells of interactive shells) and at least one non-redirection operand was passed to 'exec', pass a type/flag argument of 0 to sh_redirect (in io.c) instead of 1; this makes sh_redirect save the FD state for later restoraton in case exec fails. - Mildly refactor this whole code block for legibility. Get rid of opaque arithmetic with boolean 0/1 results. - For normal command redirections, simplify the exec optimisation for redirections: remove checks for virtual subshell and EXIT trap after checking for nonzero execflg. These became redundant since execflg is set to 0 if check_exec_optimization returns false on lines 1108 and 1109. (re: b0a6c1b, 88aa369)
- Loading branch information