Na página bash(1)
man:
-n Read commands but do not execute them. This may be used to check a
shell script for syntax errors. This is ignored by interactive shells.
Existe alguma opção que posso dar para apenas verificar a sintaxe de um shell script [bash] para verificar a sintaxe dele, mas na verdade não executar nada nem causar algum dano potencial?
Experimente o link
$ shellcheck myscript.sh
In myscript.sh line 590:
for f in $*; do
^-- SC1009: The mentioned parser error was in this for loop.
In myscript.sh line 617:
if [ ! -e "$somefile".vcf ]; then
^-- SC1046: Couldn't find 'fi' for this 'if'.
^-- SC1073: Couldn't parse this if expression.
In myscript.sh line 1026:
done
^-- SC1047: Expected 'fi' matching previously mentioned 'if'.
^-- SC1072: Unexpected keyword/token. Fix any mentioned problems and try again.
Bem, isso não me disse que o 'se' estava faltando na linha 634, mas foi muito útil.
Tags bash testing shell-script