Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/bin/sh add a test for "set -e". related to PR/17514.



details:   https://anonhg.NetBSD.org/src/rev/d3bd3dd3470d
branches:  trunk
changeset: 579904:d3bd3dd3470d
user:      yamt <yamt%NetBSD.org@localhost>
date:      Thu Mar 31 08:52:49 2005 +0000

description:
add a test for "set -e".  related to PR/17514.

commented out in Makefile because i'm not sure
what's a correct behaviour.

diffstat:

 regress/bin/sh/Makefile |   3 ++-
 regress/bin/sh/set_e.sh |  48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletions(-)

diffs (68 lines):

diff -r aee4bb5a4d0c -r d3bd3dd3470d regress/bin/sh/Makefile
--- a/regress/bin/sh/Makefile   Thu Mar 31 04:17:05 2005 +0000
+++ b/regress/bin/sh/Makefile   Thu Mar 31 08:52:49 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.7 2004/06/27 10:31:06 dsl Exp $
+#      $NetBSD: Makefile,v 1.8 2005/03/31 08:52:49 yamt Exp $
 
 NOMAN=         # defined
 
@@ -9,5 +9,6 @@
        sh ${.CURDIR}/varquote.sh
        sh ${.CURDIR}/fsplit.sh
        sh ${.CURDIR}/here.sh
+#      sh ${.CURDIR}/set_e.sh
 
 .include <bsd.prog.mk>
diff -r aee4bb5a4d0c -r d3bd3dd3470d regress/bin/sh/set_e.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/bin/sh/set_e.sh   Thu Mar 31 08:52:49 2005 +0000
@@ -0,0 +1,48 @@
+#!/bin/sh
+# $NetBSD: set_e.sh,v 1.1 2005/03/31 08:52:49 yamt Exp $
+
+rval=0
+exec >&2
+
+nl='
+'
+OIFS="$IFS"
+
+check1()
+{
+       result="`eval $1`"
+       # Remove newlines
+       IFS="$nl"
+       result="`echo $result`"
+       IFS="$OIFS"
+       if [ "$2" != "$result" ]
+       then
+               echo "command: $1"
+               echo "    expected [$2], found [$result]"
+               rval=1
+       fi
+}
+
+p()
+{
+
+       if [ $? = 0 ]
+       then
+               echo ${1}0
+       else
+               echo ${1}1
+       fi
+}
+
+check()
+{
+       check1 "((set -e; $1; p X); p Y)" "$2"
+}
+
+check 'exit 1' 'Y1'
+check 'false' 'Y1'
+check '(false)' 'Y1'
+check 'false || false' 'Y1'
+check '/nonexistent' 'Y1'
+
+exit $rval



Home | Main Index | Thread Index | Old Index