forked from koalaman/shellcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
SC2081
koalaman edited this page Jul 11, 2016
·
1 revision
if [ $var == *[^0-9]* ]
then
echo "$var is not numeric"
fi
if [[ $var == *[^0-9]* ]]
then
echo "$var is not numeric"
fi
[ .. ]
aka test
can not match against globs.
In bash/ksh, you can instead use [[ .. ]]
which supports this behavior.
In sh, you can rewrite to use grep
.
None. If you are not trying to match a glob, quote the argument (e.g. [ $var == '*' ]
to match literal asterisk.