another exit code in substitution questionable thing

split this one by set ±o sh
This commit is contained in:
tg
2009-10-15 14:58:51 +00:00
parent 84f8d3191a
commit 25516ac756
2 changed files with 35 additions and 18 deletions

44
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.325 2009/10/15 14:12:46 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.326 2009/10/15 14:58:50 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -3056,19 +3056,6 @@ stdin:
expected-stdout: expected-stdout:
bye bye
--- ---
name: regression-10
description:
The following:
set -- `false`
echo $?
shoud not print 0. (according to /bin/sh, AT&T ksh88, and the
getopt(1) man page - not according to POSIX)
stdin:
set -- `false`
echo $?
expected-stdout:
1
---
name: regression-11 name: regression-11
description: description:
The following: The following:
@ -4365,6 +4352,35 @@ expected-stdout:
E 0 E 0
F 0 F 0
--- ---
name: exit-subst-1
description:
Used to be regression-10 but was split into two tests.
The following:
set -- `false`
echo $?
should print 0 according to POSIX, but not 0 according to /bin/sh
(XXX on which system?), AT&T ksh88, and the getopt(1) manual page
stdin:
set -- `false`
echo $?
expected-stdout:
1
---
name: exit-subst-2
description:
Used to be regression-10 but was split into two tests.
The following:
set -- `false`
echo $?
should print 0 according to POSIX, but not 0 according to /bin/sh
(XXX on which system?), AT&T ksh88, and the getopt(1) manual page
stdin:
test -n "$POSH_VERSION" || set -o sh
set -- `false`
echo $?
expected-stdout:
0
---
name: test-stlt-1 name: test-stlt-1
description: description:
Check that test also can handle string1 < string2 etc. Check that test also can handle string1 < string2 etc.

View File

@ -25,7 +25,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.137 2009/10/10 21:17:29 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.138 2009/10/15 14:58:51 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -2336,13 +2336,14 @@ c_set(const char **wp)
for (wp = l->argv; (*wp++ = *owp++) != NULL; ) for (wp = l->argv; (*wp++ = *owp++) != NULL; )
; ;
} }
/* POSIX says set exit status is 0, but old scripts that use /*
* getopt(1), use the construct: set -- $(getopt ab:c "$@") * POSIX says set exit status is 0, but old scripts that use
* getopt(1) use the construct: set -- $(getopt ab:c "$@")
* which assumes the exit value set will be that of the $() * which assumes the exit value set will be that of the $()
* (subst_exstat is cleared in execute() so that it will be 0 * (subst_exstat is cleared in execute() so that it will be 0
* if there are no command substitutions). * if there are no command substitutions).
*/ */
return (subst_exstat); return (Flag(FSH) ? 0 : subst_exstat);
} }
int int