Nagel Nagel - 3 months ago 8
Bash Question

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

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's using double semicolons?

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

Answer

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.

Comments