From 25516ac75608b95c799abf8d70212be245bcbda8 Mon Sep 17 00:00:00 2001 From: tg Date: Thu, 15 Oct 2009 14:58:51 +0000 Subject: [PATCH] =?UTF-8?q?another=20exit=20code=20in=20substitution=20que?= =?UTF-8?q?stionable=20thing=20split=20this=20one=20by=20set=20=C2=B1o=20s?= =?UTF-8?q?h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check.t | 44 ++++++++++++++++++++++++++++++-------------- funcs.c | 9 +++++---- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/check.t b/check.t index cf08f9f..df16ae3 100644 --- a/check.t +++ b/check.t @@ -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: 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 $ @@ -3056,19 +3056,6 @@ stdin: expected-stdout: 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 description: The following: @@ -4365,6 +4352,35 @@ expected-stdout: E 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 description: Check that test also can handle string1 < string2 etc. diff --git a/funcs.c b/funcs.c index c2abfa8..f2ae9ba 100644 --- a/funcs.c +++ b/funcs.c @@ -25,7 +25,7 @@ #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 /* @@ -2336,13 +2336,14 @@ c_set(const char **wp) 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 $() * (subst_exstat is cleared in execute() so that it will be 0 * if there are no command substitutions). */ - return (subst_exstat); + return (Flag(FSH) ? 0 : subst_exstat); } int