summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-01-22 14:00:33 +0000
committerjilles <jilles@FreeBSD.org>2012-01-22 14:00:33 +0000
commitae59680813890a93e9eaebbf69c2d63b852e512f (patch)
tree2e29d787749cfc02654715cbca4bcb06b3c510ec /tools/regression
parentf317ff0f6559bac3c7a0ee926ba002b29cdf2d53 (diff)
downloadFreeBSD-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.09
-rw-r--r--tools/regression/bin/sh/builtins/for3.08
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 ]
OpenPOWER on IntegriCloud