This is what I'm trying to do:
#!/bin/bash
check_for_int()
{
if [ "$1" -eq "$1" ] 2>/dev/null
then
return 0
else
return 1
fi
}
if [[check_for_int($1) == 1]]
echo "FATAL: argument must be an integer!"
exit 1
fi
# do stuff
However, no matter how I put it, shellcheck
is complaining:
if [[ check_for_int($1) == 1 ]]; then
^-- SC1009: The mentioned parser error was in this if expression.
^-- SC1073: Couldn't parse this test expression.
^-- SC1036: '(' is invalid here. Did you forget to escape it?
^-- SC1072: Expected "]". Fix any mentioned problems and try again.
I have no idea why this isn't working...