I want to check function arguments, and check whether $2
and $3
are numeric
Is the following line the way to use the AND
statement? Am I using =
the correct way to check for numeric digits?
if [[ "$2" = +([[:digit:]]) ]] && [[ "$3" = +([[:digit:]]) ]]; then
https://shellcheck.net
, a syntax checker, or installshellcheck
locally. Make usingshellcheck
part of your development process. – waltinator Nov 17 '21 at 05:32"a1a", "1a", "129"
"a1a"
returns false, whilst"123"
returns true. – Vera Nov 17 '21 at 14:54=
or==
. Is there any general rule? – Vera Nov 17 '21 at 15:18