mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix shell exit on function call redirection error (re: 23f2e23)
This regression also exists on ksh 93v- and ksh2020, from which it
was backported.
Reproducer:
$ (fn() { true; }; fn >/dev/null/ne; true) 2>/dev/null; echo $?
1
Expected output: 0 (as on ksh 93u+).
FreeBSD sh and NetBSD sh are the only other known shells that share
this behaviour. POSIX currently allows both behaviours, but may
require the ksh 93u+ behaviour in future. In any case, this causes
an incompatibility with established ksh behaviour that could easily
break existing ksh scripts.
src/cmd/ksh93/sh/xec.c: sh_exec():
- Commit 23f2e23 introduced a check for jmpval > SH_JMPIO (5).
When a function call pushes context for a redirection, this is
done with the jmpval exit value of SH_JMPCMD (6). Change that to
SH_JMPIO to avoid triggering that check.
src/cmd/ksh93/tests/exit.sh:
- Add regression tests for exit behaviour on various kinds of
shell errors as listed in the POSIX standard, including an error
in a redirection of a function call.
Fixes: https://github.com/ksh93/ksh/issues/310
This commit is contained in:
parent
07eb2040e8
commit
0dd115e4b4
3 changed files with 56 additions and 1 deletions
|
|
@ -1550,7 +1550,7 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
if(io)
|
||||
{
|
||||
indx = shp->topfd;
|
||||
sh_pushcontext(shp,buffp,SH_JMPCMD);
|
||||
sh_pushcontext(shp,buffp,SH_JMPIO);
|
||||
jmpval = sigsetjmp(buffp->buff,0);
|
||||
}
|
||||
if(jmpval == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue