-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2050
koalaman edited this page Jul 13, 2017
·
1 revision
if [ myvar = "test" ]
then
echo "Test mode"
fi
if [ "$myvar" = "test" ]
then
echo "Test mode"
fi
ShellCheck has found a [ .. ]
or [[ .. ]]
comparison that only involves literal strings. The intention was probably to check a variable or command output instead.
This is usually due to missing $
or bad quoting:
if [[ "myvar" = "test" ]] # always false because myvar is a literal string
if [[ "$myvar" = "test" ]] # correctly compares a variable
if [ 'grep -c foo bar' -ge 10 ] # always false because grep doesn't run
if [ "$(grep -c foo bar)" -ge 10 ] # correctly checks grep output
None