From this web page :
http://tldp.org/LDP/abs/html/abs-guide.html
It’s mentioned the usage of the if bracket then convention which need a space after the semicolon :
;
Command separator [semicolon]. Permits putting two or more commands on the same line. echo hello; echo there if [ -x "$filename" ]; then # Note the space after the semicolon. #+ ^^ echo "File $filename exists."; cp $filename $filename.bak else # ^^ echo "File $filename not found."; touch $filename fi; echo "File test complete." Note that the ";" sometimes needs to be escaped.
Does anyone know where is this coming from and if this is needed at all by certain shells?
This has become the style in the last few years:
However, back when dinosaurs like Burroughs and Sperry Rand ruled the earth, I learned to write if statements like this:
Then, you don’t even need a semicolon.
The new style with
thenon the same line as theifstarted in order to emulate the wayCand other programming languages did theirifstatements:These programming languages put the opening curly brace on the same line as the
if.