Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix another comsub regression (rhbz#1116508) (re: 970069a)
Another Red Hat patch of a patch. With the new comsub mechanism, functions could sometimes return the wrong exit status when invoked from a command substitution. Original patch: https://src.fedoraproject.org/rpms/ksh/blob/642af4d6/f/ksh-20120801-fununset.patch I have determined that the extra setexit() in the Red Hat patch, which copies the current exit status to $?, is not needed, as the code for running functions already sets $? on termination. I've added extra regression tests to prove this. By the way, the setexit() macro is defined like this in defs.h: #define exitset() (sh.savexit=sh.exitval) That's more evidence (see also 3654ee7) that it does not matter whether you address the shell's status struct via a pointer. That macro is used in places that use shp pointers. But, that aside... src/cmd/ksh93/sh/subshell.c: sh_subshell(): - When waiting within a command substitution for a forked process to end, save & restore sh.exitval (the exit status of the command currently being run) so that job_wait() cannot override it. src/cmd/ksh93/tests/functions.sh: - Add tests based in part on the reproducer from rhbz#1116508.
- Loading branch information