diff options
author | jilles <jilles@FreeBSD.org> | 2011-06-17 13:03:49 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-06-17 13:03:49 +0000 |
commit | c7a72567a8474dcecd93215073976b04171d1144 (patch) | |
tree | d74a77976194c0d5d68bbf18c002a166b97300a5 /bin/sh/eval.c | |
parent | f405f6d6f8e62f9714eb668d35001c794646022b (diff) | |
download | FreeBSD-src-c7a72567a8474dcecd93215073976b04171d1144.zip FreeBSD-src-c7a72567a8474dcecd93215073976b04171d1144.tar.gz |
sh: Add case statement fallthrough (with ';&' instead of ';;').
Replacing ;; with the new control operator ;& will cause the next list to be
executed as well without checking its pattern, continuing until a list ends
with ;; or until the end of the case statement. This is like omitting
"break" in a C "switch" statement.
The sequence ;& was formerly invalid.
This feature is proposed for the next POSIX issue in Austin Group issue
#449.
Diffstat (limited to 'bin/sh/eval.c')
-rw-r--r-- | bin/sh/eval.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 25793c1..a22d4b1 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -386,6 +386,14 @@ evalcase(union node *n, int flags) for (cp = n->ncase.cases ; cp && evalskip == 0 ; cp = cp->nclist.next) { for (patp = cp->nclist.pattern ; patp ; patp = patp->narg.next) { if (casematch(patp, arglist.list->text)) { + while (cp->nclist.next && + cp->type == NCLISTFALLTHRU) { + if (evalskip != 0) + break; + evaltree(cp->nclist.body, + flags & ~EV_EXIT); + cp = cp->nclist.next; + } if (evalskip == 0) { evaltree(cp->nclist.body, flags); } |