Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix corner case bug involving 'eval' and return < 0 (re: b90b8cd)
Reproducer: $ foo() { return -1; } $ eval foo -ksh: eval: not found ksh tries to run 'eval' as an external command. No such external command generally exists on $PATH, hence the error message. Analysis: Built-ins may have the BLT_EXIT attribute (see data/builtins.c) which has two functions: 1) To avoid trimming a built-in's exit status to the least significant eight bits (xec.c, lines 1278-1279). 2) To fall back to an external command by the same name if the built-in returns an exit status < 0 (xec.c, lines 1338-1345). This of course depends on the exit status not being trimmed. As of the referenced commit which made 'return' accept a negative exit status, feature 2 triggers this bug. 'eval' has the BLT_EXIT attribute, and it needs it beecause of feature 1, but feature 2 is not desired here. Feature 2 also unused, and (as far as I can tell) always has been. No regular built-in falls back to an external command. Some libcmd built-ins (date, getconf, uname) can fall back to their external counterparts, but they use the sh_run() interface to do so. Since feature 2 is unused except for triggering this bug, the simplest fix is to remove it. This commit does that.
- Loading branch information