diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-12-15 05:28:41 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-12-15 05:28:41 +0000 |
commit | b04b984568d2522cbf84fa5dbdcc324888cf57ec (patch) | |
tree | 419d44f2968ec4bdfc42b8759cca0fc2d30a971a /regress | |
parent | e7f2116d7cd5e75f1df5bf99d6617a92309a5466 (diff) |
Regression test for PR 2450.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/bin/ksh/Makefile | 7 | ||||
-rw-r--r-- | regress/bin/ksh/varfunction.sh | 76 |
2 files changed, 81 insertions, 2 deletions
diff --git a/regress/bin/ksh/Makefile b/regress/bin/ksh/Makefile index f493d21acca..25e141b061a 100644 --- a/regress/bin/ksh/Makefile +++ b/regress/bin/ksh/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.3 2003/02/09 18:52:49 espie Exp $ +# $OpenBSD: Makefile,v 1.4 2003/12/15 05:28:40 otto Exp $ -REGRESS_TARGETS=shcrash.sh seterror.sh +REGRESS_TARGETS=shcrash.sh seterror.sh varfunction.sh shcrash.sh: ulimit -c 0 && sh ${.CURDIR}/shcrash.sh @@ -8,6 +8,9 @@ shcrash.sh: seterror.sh: sh ${.CURDIR}/seterror.sh +varfunction.sh: + sh ${.CURDIR}/varfunction.sh + .PHONY: ${REGRESS_TARGETS} .include <bsd.regress.mk> diff --git a/regress/bin/ksh/varfunction.sh b/regress/bin/ksh/varfunction.sh new file mode 100644 index 00000000000..c530dfa2c27 --- /dev/null +++ b/regress/bin/ksh/varfunction.sh @@ -0,0 +1,76 @@ +# $OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $ +# +# Calling +# +# FOO=bar f +# +# where f is a ksh style function, should not set FOO in the current env. +# If f is a bourne style function, FOO should be set. Furthermore, +# the function should receive a correct value of FOO. Additionally, +# setting FOO in the function itself should not change the value in +# global environment. +# +# Inspired by PR 2450. +# +function k { + if [ x$FOO != xbar ]; then + echo 1 + return 1 + fi + x=$(env | grep FOO) + if [ "x$x" != "xFOO=bar" ]; then + echo 2 + return 1; + fi + FOO=foo + return 0 +} + +b () { + if [ x$FOO != xbar ]; then + echo 3 + return 1 + fi + x=$(env | grep FOO) + if [ "x$x" != "xFOO=bar" ]; then + echo 4 + return 1; + fi + FOO=foo + return 0 +} + +FOO=bar k +if [ $? != 0 ]; then + exit 1 +fi +if [ x$FOO != x ]; then + exit 1 +fi + +FOO=bar b +if [ $? != 0 ]; then + exit 1 +fi +if [ x$FOO != xbar ]; then + exit 1 +fi + +FOO=barbar + +FOO=bar k +if [ $? != 0 ]; then + exit 1 +fi +if [ x$FOO != xbarbar ]; then + exit 1 +fi + +FOO=bar b +if [ $? != 0 ]; then + exit 1 +fi +if [ x$FOO != xbar ]; then + exit 1 +fi + |