Semicolons superfluous at the end of a line in shell scripts? [duplicate]

I have a shell script which contains the following:

case $1 in
    0 )
    echo $1 = 0;
    OUTPUT=3;;
    1 )
    echo $1 = 1;
    OUTPUT=4;;
    2 )
    echo $1 = 2;
    OUTPUT=4;;
esac

HID=$2;
BUNCH=16;
LR=.008;

Are semicolons completely superfluous in the snippet above? And is there any reason for some people using double semicolons?

It appears semicolons are only a separator, something you would use instead of a new line.


Single semicolons at the end of a line are superfluous, since the newline is also a command separator. case specifically needs double semicolons at the end of the last command in each pattern block; see help case for details.


According to man bash:

  metacharacter
         A character that, when unquoted, separates words.  One of the following:
         |  & ; ( ) < > space tab
  control operator
         A token that performs a control function.  It is one of the following symbols:
         || & && ; ;; ( ) | |& <newline>

So, the ; can be metacharacter or control operator, while the ;; is always a control operator (in case command).

In your particular code, all ; at the end of line are not needed. The ;; is needed however.