diff options
author | jilles <jilles@FreeBSD.org> | 2012-01-22 14:00:33 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2012-01-22 14:00:33 +0000 |
commit | ae59680813890a93e9eaebbf69c2d63b852e512f (patch) | |
tree | 2e29d787749cfc02654715cbca4bcb06b3c510ec /tools/regression | |
parent | f317ff0f6559bac3c7a0ee926ba002b29cdf2d53 (diff) | |
download | FreeBSD-src-ae59680813890a93e9eaebbf69c2d63b852e512f.zip FreeBSD-src-ae59680813890a93e9eaebbf69c2d63b852e512f.tar.gz |
sh: Fix $? in the first command of a 'for'.
In the first command of a 'for', $? should be the exit status of the last
pipeline (command substitution in the word list or command before 'for'),
not always 0.
Diffstat (limited to 'tools/regression')
-rw-r--r-- | tools/regression/bin/sh/builtins/for2.0 | 9 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/for3.0 | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/for2.0 b/tools/regression/bin/sh/builtins/for2.0 new file mode 100644 index 0000000..48c22ce --- /dev/null +++ b/tools/regression/bin/sh/builtins/for2.0 @@ -0,0 +1,9 @@ +# $FreeBSD$ + +r=x +f() { return 42; } +f +for i in x; do + r=$? +done +[ "$r" = 42 ] diff --git a/tools/regression/bin/sh/builtins/for3.0 b/tools/regression/bin/sh/builtins/for3.0 new file mode 100644 index 0000000..cc37238 --- /dev/null +++ b/tools/regression/bin/sh/builtins/for3.0 @@ -0,0 +1,8 @@ +# $FreeBSD$ + +r=x +f() { return 42; } +for i in x`f`; do + r=$? +done +[ "$r" = 42 ] |