Skip to content

The exit status of command terminated with a signal in the pipeline seems be wrong #742

Description

@ko1nksm

The seq command seems to terminate with 256+signum (unlike 128+signum in other shells) as expected, but the shell does not seem to get the values right. Perhaps it has something to do with the exit status value obtained from the subshell, but I don't know what is right.

ksh93u+m/1.1.0-alpha+8f84f4b2

$ ksh -c 'set -o pipefail; (seq 1000000; xs=$?; echo $xs >&2; exit $xs) | head > /dev/null; echo $?'
269
13

$ ksh -c '(exit 255); echo $?; (exit 256); echo $?; (exit 257); echo $?'
255
0
1

$ ksh -c 'set -o pipefail; (exit 255)|:; echo $?; (exit 256)|:; echo $?; (exit 257)|:; echo $?'
255
0
1

ksh93u+

$ ksh -c 'set -o pipefail; (seq 1000000; xs=$?; echo $xs >&2; exit $xs) | head > /dev/null; echo $?'
269
141

$ ksh -c '(exit 255); echo $?; (exit 256); echo $?; (exit 257); echo $?'
255
0
257

$ ksh -c 'set -o pipefail; (exit 255)|:; echo $?; (exit 256)|:; echo $?; (exit 257)|:; echo $?'
255
0
129

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis does not seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions