summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-01-15 20:04:05 +0000
committerjilles <jilles@FreeBSD.org>2012-01-15 20:04:05 +0000
commit6253417a7002be7641015b22d63bbe274869ed0b (patch)
treef70a5342132acdff57c298b57df7abd30ebb8dfb /tools
parent67dd0ca2547a8ce8b86b7f88b4ccee6e14abeb4c (diff)
downloadFreeBSD-src-6253417a7002be7641015b22d63bbe274869ed0b.zip
FreeBSD-src-6253417a7002be7641015b22d63bbe274869ed0b.tar.gz
sh: Fix two bugs with case and exit status:
* If no pattern is matched, POSIX says the exit status shall be 0 (even if there are command substitutions). * If a pattern is matched and there are no command substitutions, the first command should see the $? from before the case command, not always 0.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/builtins/case14.05
-rw-r--r--tools/regression/bin/sh/builtins/case15.05
-rw-r--r--tools/regression/bin/sh/builtins/case16.07
3 files changed, 17 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/case14.0 b/tools/regression/bin/sh/builtins/case14.0
new file mode 100644
index 0000000..0338e8a
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/case14.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+case `false` in
+no) exit 3 ;;
+esac
diff --git a/tools/regression/bin/sh/builtins/case15.0 b/tools/regression/bin/sh/builtins/case15.0
new file mode 100644
index 0000000..09b0e11
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/case15.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+case x in
+`false`) exit 3 ;;
+esac
diff --git a/tools/regression/bin/sh/builtins/case16.0 b/tools/regression/bin/sh/builtins/case16.0
new file mode 100644
index 0000000..2430302
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/case16.0
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+f() { return 42; }
+f
+case x in
+x) [ $? = 42 ] ;;
+esac
OpenPOWER on IntegriCloud