Skip to contentSkip to conversation

t0005 failing with ksh93 on linux

PATCH Superseded Jonathan Nieder 6 participants 9 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I can’t seem to get test-sigchain to run with ksh93 on linux:

 $ ksh

ksh>$ ../bin-wrappers/test-sigchain
three
two
one
Terminated
ksh>$ echo $?
271
ksh>$ exit

 $ ../bin-wrappers/test-sigchain 
 three
 two
 one
 Terminated
 $ echo $?
 143

As a result, t0005-signals.sh fails when run through that shell. Ideas?

$ ksh t0005-signals.sh  -v
Initialized empty Git repository in /dev/shm/alt-git/t/trash directory.t0005-signals/.git/
expecting success: 
[...]
        test_cmp expect actual

not ok - 1 sigchain works
[...]

$ git describe
v1.7.2-rc2
$ ksh --version
  version         sh (AT&T Research) 93s+ 2008-01-31
$ uname -s -r -m
Linux 2.6.26-2-686-bigmem i686
#1 lore raw

PATCH 1/1 t0005: work around strange $? in ksh when program terminated by a signal

From: Johannes Sixt <[email protected]>

ksh is known to report $? of programs that terminated by a signal as 256 + signal number instead of 128 + signal number like other POSIX compliant shells. (ksh's behavior is still POSIX compliant in this regard.)

---
Am 7/9/2010 5:08, schrieb Jonathan Nieder:

Quoted 11 lines

I can’t seem to get test-sigchain to run with ksh93 on linux:

 $ ksh

ksh>$ ../bin-wrappers/test-sigchain
three
two
one
Terminated
ksh>$ echo $?
271

ksh is not wrong, just strange. See http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_02 (last sentence).

-- Hannes

 t/t0005-signals.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
t/t0005-signals.sh +1 -0
index 09f855a..93e58c0 100755
@@ -13,6 +13,7 @@ test_expect_success 'sigchain works' '
 	test-sigchain >actual
 	case "$?" in
 	143) true ;; # POSIX w/ SIGTERM=15
+	271) true ;; # ksh w/ SIGTERM=15
 	  3) true ;; # Windows
 	  *) false ;;
 	esac &&
Signature · 1 line
1.7.1.585.gf3448
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH] t0005: work around strange $? in ksh when program terminated by a signal

Quoted 5 lines · Johannes Sixt

From: Johannes Sixt <[email protected]>

ksh is known to report $? of programs that terminated by a signal as 256 + signal number instead of 128 + signal number like other POSIX compliant shells. (ksh's behavior is still POSIX compliant in this regard.)

Thanks, that fix looks good to me.

-Peff

#3 lore raw

Re: [PATCH] t0005: work around strange $? in ksh when program terminated by a signal

In reply to Johannes Sixt
Quoted 3 lines · Johannes Sixt

ksh is known to report $? of programs that terminated by a signal as 256 + signal number instead of 128 + signal number like other POSIX compliant shells. (ksh's behavior is still POSIX compliant in this regard.)

This patch works for me.

 $ ksh t0005-signals.sh
 *   ok 1: sigchain works
 * passed all 1 test(s)

Thanks for the explanation.

#4 lore raw

Re: [PATCH] t0005: work around strange $? in ksh when program terminated by a signal

In reply to Johannes Sixt
Quoted 5 lines · Johannes Sixt

From: Johannes Sixt <[email protected]>

ksh is known to report $? of programs that terminated by a signal as 256 + signal number instead of 128 + signal number like other POSIX compliant shells. (ksh's behavior is still POSIX compliant in this regard.)

This may only be true for Ksh93. The Ksh88 man page says that the exit status is 128+signum. The Public domain Korn shell, and ksh on IRIX 6.5, Solaris 7, 9, and 10 all exit with the standard behavior of 128+signum. So, it may be appropriate to change the commit message and comment in t0005 to reflect this fact.

-Brandon

Quoted 15 lines
 t/t0005-signals.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
t/t0005-signals.sh +1 -0
index 09f855a..93e58c0 100755
@@ -13,6 +13,7 @@ test_expect_success 'sigchain works' '
 	test-sigchain >actual
 	case "$?" in
 	143) true ;; # POSIX w/ SIGTERM=15
+	271) true ;; # ksh w/ SIGTERM=15
 	  3) true ;; # Windows
 	  *) false ;;
 	esac &&
#5 lore raw

Re: [PATCH] t0005: work around strange $? in ksh when program terminated by a signal

Quoted 4 lines · Brandon Casey

the exit status is 128+signum.  The Public domain Korn shell, and ksh on IRIX 6.5, Solaris 7, 9, and 10 all exit with the standard behavior of 128+signum.  So, it may be appropriate to change the commit message and comment in t0005 to reflect this fact.

s/standard/conventional/, no?

#6 lore raw

Re: [PATCH] t0005: work around strange $? in ksh when program terminated by a signal

Quoted 8 lines · Ævar Arnfjörð Bjarmason
Quoted 4 lines · Brandon Casey

the exit status is 128+signum. The Public domain Korn shell, and ksh on IRIX 6.5, Solaris 7, 9, and 10 all exit with the standard behavior of 128+signum. So, it may be appropriate to change the commit message and comment in t0005 to reflect this fact.

s/standard/conventional/, no?

sure.

#7 lore raw

PATCH v2 1/1 t0005: work around strange $? in ksh93 when program terminated by a signal

In reply to Brandon Casey

From: Johannes Sixt <[email protected]>

ksh93 is known to report $? of programs that terminated by a signal as 256 + signal number instead of 128 + signal number like other POSIX compliant shells. (ksh's behavior is still POSIX compliant in this regard.)

---
Am 7/9/2010 17:45, schrieb Brandon Casey:

Quoted 4 lines

This may only be true for Ksh93. The Ksh88 man page says that the exit status is 128+signum. The Public domain Korn shell, and ksh on IRIX 6.5, Solaris 7, 9, and 10 all exit with the standard behavior of 128+signum.

Thanks for you input!

Hannes

 t/t0005-signals.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
t/t0005-signals.sh +1 -0
index 09f855a..e17c96a 100755
@@ -13,6 +13,7 @@ test_expect_success 'sigchain works' '
 	test-sigchain >actual
 	case "$?" in
 	143) true ;; # POSIX w/ SIGTERM=15
+	271) true ;; # ksh93 w/ SIGTERM=15
 	  3) true ;; # Windows
 	  *) false ;;
 	esac &&
Signature · 1 line
1.7.1.585.gf3448
#8 lore raw

Re: [PATCH v2] t0005: work around strange $? in ksh93 when program terminated by a signal

Thanks; I've queued this last week already but have been busy this weekend and haven't managed to push anything out.