diff options
author | stefanf <stefanf@FreeBSD.org> | 2007-10-04 16:14:48 +0000 |
---|---|---|
committer | stefanf <stefanf@FreeBSD.org> | 2007-10-04 16:14:48 +0000 |
commit | 7dc3b250aaa5e54527c6bb8f1feb116eca8f7fb2 (patch) | |
tree | bb55e154819f0464678c1f725aef74d0bc98283b /bin/sh | |
parent | f1ca7ff2d4a6fadab27fdfe822c3fbd87bffeb12 (diff) | |
download | FreeBSD-src-7dc3b250aaa5e54527c6bb8f1feb116eca8f7fb2.zip FreeBSD-src-7dc3b250aaa5e54527c6bb8f1feb116eca8f7fb2.tar.gz |
The exit status of a case statement where none of the patterns is matched
is supposed to be 0, not the status of the previous command.
Reported by: Eygene Ryabinkin
PR: 116559
Approved by: re (gnn)
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/eval.c | 1 | ||||
-rw-r--r-- | bin/sh/sh.1 | 4 |
2 files changed, 5 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 |