Ken Failbus wrote: > When I specify on command-line "bash -n <myscript name>". Bash doesn't > check for valid syntax errors. E.g. if variable is missing a "$" infront > of it while assigning a value. This is not catched by bash.
Unfortunately what you are describing is not a syntax error. It is perfectly valid syntax and in other contexts will be exactly what is desired. > Is there a more specific option that should be specified to bash to > check for syntax errors. Since that case is not an error it can't be caught in this way. You will simply need to test more thoroughly. > ### example code > p=hello > e=world > If [ p != $e ];then You should quote the arguments to avoid the error that would be produced from test if they were not set. if [ "$p" != "$e" ];then > echo "not equal" > else > echo "equals" > fi Consider of this case: if [ "${a+set}" = set ]; then echo a is set else echo a is not set fi There is no way for bash to differentiate "set" from "$set". It will do exactly what it is told to do and has no way to know what you _want_ it to do. Bob