Which keyword closes a `case` construct in a bash script?

LPIC-1 Exam 102-500, objective 105. Shells and shell scripting easy

Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.

It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.

The options

Not correct done

Wrong. `done` closes a loop body opened by `do`, that is for, while and until.

Correct esac

Correct. `case WORD in ... esac`, with the opening keyword spelled backwards, the same joke as if/fi.

Not correct fi

Wrong. `fi` closes an `if` construct, after any elif and else branches.

Not correct ;;

Wrong as the closer of the whole construct, though it is real syntax: `;;` ends one individual pattern branch inside case, before the next pattern begins.

Why

A case block looks like: `case "$1" in start) do_start ;; stop) do_stop ;; *) echo usage ;; esac`. Patterns are glob patterns, not regular expressions, so `*` is the catch-all and `start|restart)` matches either word. Each branch ends with `;;` and the whole construct ends with `esac`.

Where this comes from

Cited
LPI exam objective 105.2
What it says
Use standard shell syntax such as loops and conditional branches in scripts.

Practise this

Reading one question is not practice. The trainer will draw a set from objective 105 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500