|
# TODO Yash does not yet support this |
|
test_oE -e 0 -f 'default exit status in trap in function' |
|
trap '(exit 1); return; echo X $?' INT |
|
f() { |
|
(kill -INT $$; exit 2) |
|
echo Y $? |
|
} |
|
f |
|
echo Z $? |
|
__IN__ |
|
Z 2 |
|
__OUT__ |
Fixing this issue would be trickier than it looks. The return built-in needs to determine the exit status of the function it is in, and if it is in the handle_traps function, it would need to tell whether the function is being called from the trap handle or the trap handler is being called from the function. This is not straightforward since we don't have a stack trace or a way to determine the context of the call.
yash/tests/return-p.tst
Lines 158 to 169 in b302c8d
Fixing this issue would be trickier than it looks. The
returnbuilt-in needs to determine the exit status of the function it is in, and if it is in thehandle_trapsfunction, it would need to tell whether the function is being called from the trap handle or the trap handler is being called from the function. This is not straightforward since we don't have a stack trace or a way to determine the context of the call.