File need to end with \n
Blank line
Bash need space to evaluate. Thing that look usual in other language can be syntax error in bash.
The for
loop is separated by space too.
For number, Bash does not have <,>,<=,>=
but rather -lt, -gt, -le, -ge
For string, Bash use =, !=
for comparing. For exist and not exist use -n, -z
The ending of here document need to be first thing the line. In the example below, FOO
need to be at the beginning of the line without space or tab.
The alternative operator to support indent <<-
needs tab NOT space.
Something like this will fail. Bash take the argument through $1
, $2
,…
So we need to assign it like this.
To remind me of this fact, I prefer syntax of function ... { }
than the one with ()
. One good part is Bash at least have local
function scope.
Although Bash has return
keyword, it doesn’t work as usual. It can only return 0-255
exit status where 0
mean success.
You need to assign value to Global Variable OMG ! yes it is !