From f350b6f16c668cd49dc24be3b6dd44c059fe2e0c Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Tue, 1 Aug 2023 18:49:26 +0200 Subject: properly forward errors on exec, return 123 on any exit status 1-254 Use the CLOEXEC pipe trick to detect if exec happened; read the errno from the pipe if it wasn't closed due to exec. --- t/errors.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/errors.t b/t/errors.t index c2ecd5e..eb05dc0 100755 --- a/t/errors.t +++ b/t/errors.t @@ -1,7 +1,7 @@ #!/bin/sh export "PATH=.:$PATH" -printf '1..13\n' +printf '1..16\n' printf '# error handling\n' tap3 'exit code on success' <<'EOF' @@ -21,6 +21,27 @@ a >>>= 123 EOF +tap3 'exit code on when command fails with 126' <<'EOF' +xe -s 'exit 126' +<<< +a +>>>= 123 +EOF + +tap3 'exit code on when command fails with 127' <<'EOF' +xe -s 'exit 127' +<<< +a +>>>= 123 +EOF + +tap3 'exit code on when command fails with 250' <<'EOF' +xe -s 'exit 250' +<<< +a +>>>= 123 +EOF + tap3 'exit code on when command fails with 255' <<'EOF' xe -s 'exit 255' <<< -- cgit 1.4.1