diff options
-rw-r--r-- | bin/sh/eval.c | 1 | ||||
-rw-r--r-- | bin/sh/sh.1 | 4 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/case1.0 | 13 |
3 files changed, 18 insertions, 0 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index a26f36d..7ceaa94 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -367,6 +367,7 @@ evalcase(union node *n, int flags) setstackmark(&smark); arglist.lastp = &arglist.list; oexitstatus = exitstatus; + exitstatus = 0; expandarg(n->ncase.expr, &arglist, EXP_TILDE); for (cp = n->ncase.cases ; cp && evalskip == 0 ; cp = cp->nclist.next) { for (patp = cp->nclist.pattern ; patp ; patp = patp->narg.next) { diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 75d243c..10cd607 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -861,6 +861,10 @@ described later), separated by .Dq Li \&| characters. +The exit code of the +.Ic case +command is the exit code of the last command executed in the list or +zero if no patterns were matched. .Ss Grouping Commands Together Commands may be grouped by writing either .Bd -literal -offset indent diff --git a/tools/regression/bin/sh/builtins/case1.0 b/tools/regression/bin/sh/builtins/case1.0 new file mode 100644 index 0000000..860fc67 --- /dev/null +++ b/tools/regression/bin/sh/builtins/case1.0 @@ -0,0 +1,13 @@ +#$FreeBSD$ +f() +{ + false + case $1 in + foo) true ;; + bar) false ;; + esac +} + +f foo || exit 1 +f bar && exit 1 +f quux || exit 1 |