diff options
author | jilles <jilles@FreeBSD.org> | 2016-01-10 16:31:28 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2016-01-10 16:31:28 +0000 |
commit | d42a26ab2089d53213cf28c22508023ea16e7efb (patch) | |
tree | 0b136c34e36d2b2c085d1618158aaa9df9b91c19 /bin/sh/tests | |
parent | 21632a9bd96fd68b505602bfdd4850ab1e18574a (diff) | |
download | FreeBSD-src-d42a26ab2089d53213cf28c22508023ea16e7efb.zip FreeBSD-src-d42a26ab2089d53213cf28c22508023ea16e7efb.tar.gz |
sh: Update associated state when restoring locals while leaving a function.
Some variables like PATH call a function when modified. Make sure to call
this also when leaving a function where such a variable was made local.
Make sure to restore local variables before shellparam, so getopts state is
not clobbered.
Diffstat (limited to 'bin/sh/tests')
-rw-r--r-- | bin/sh/tests/builtins/Makefile | 1 | ||||
-rw-r--r-- | bin/sh/tests/builtins/local5.0 | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile index 11240ca..1511f70 100644 --- a/bin/sh/tests/builtins/Makefile +++ b/bin/sh/tests/builtins/Makefile @@ -111,6 +111,7 @@ FILES+= local1.0 FILES+= local2.0 FILES+= local3.0 FILES+= local4.0 +FILES+= local5.0 .if ${MK_NLS} != "no" FILES+= locale1.0 .endif diff --git a/bin/sh/tests/builtins/local5.0 b/bin/sh/tests/builtins/local5.0 new file mode 100644 index 0000000..2f2a14e --- /dev/null +++ b/bin/sh/tests/builtins/local5.0 @@ -0,0 +1,15 @@ +# $FreeBSD$ + +f() { + local PATH IFS elem + IFS=: + for elem in ''$PATH''; do + PATH=/var/empty/$elem:$PATH + done + ls -d / >/dev/null +} + +p1=$(command -v ls) +f +p2=$(command -v ls) +[ "$p1" = "$p2" ] |