What does the meaning of ;;
in this code from ~/bashrc
file?
case $- in
*i*) ;;
*) return;;
esac
Can I use ;;
in other ways? and where?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityWhat does the meaning of ;;
in this code from ~/bashrc
file?
case $- in
*i*) ;;
*) return;;
esac
Can I use ;;
in other ways? and where?
From man bash
:
If the ;; operator is used, no subsequent matches are
attempted after the first pattern match. Using ;& in place of
;; causes execution to continue with the list associated with
the next set of patterns. Using ;;& in place of ;; causes the
shell to test the next pattern list in the statement, if any,
and execute any associated list on a successful match.
So no, you can't use ";;" elsewhere, it's case-specific syntax in bash scripts. As for the meaning, if you finish each case item with ;;, it will stop after executing the code for the first match. If you use ;& instead, it will execute the first match, then continue looking for other matches, so you could perform multiple match actions.
For additional information see
and
That is the end of a single item in your case-switch,
see e.g.:
bash-case-statement
The double semicolon indicates the end of the case branch. See help case
command for details.