this method fails if the shell is ksh"
Thanks!
--
-- Rob la Lau
--
-- Sysadmin en webdeveloper in ruste
--
-- web : https://ohreally.nl/
-- eml : r...@ohreally.nl
--
ow 1 regex won't considerably slow down my script, but it's
become a habit to always try and program as light as possible.
--
-- Rob la Lau
--
-- Sysadmin en webdeveloper in ruste
--
-- web : https://ohreally.nl/
-- eml : r...@ohreally.nl
--
x" ] && echo "yes" || echo "no"
[: invalid integer 'x'
no
I hope this won't be fixed, as I rely quite heavily on this behaviour,
lacking some other short 'is integer' test.
Cheers,
Rob
--
-- Rob la Lau
--
-- Sysadmin en webdeveloper in ruste
--
-- web : https://ohreally.nl/
-- eml : r...@ohreally.nl
--
st whether a variable is an integer.
$ [ "${x}" -eq "${x}" ] 2> /dev/null && echo "yes" || echo "no"
...
Looking a bit further: it doesn't do any comparison on the given strings:
$ [[ "x" -eq "y" ]] && echo "yes" || echo "no"
yes
$ [[ "x" -eq "yz" ]] && echo "yes" || echo "no"
yes
but it does on integers:
$ [[ 1 -eq 2 ]] && echo "yes" || echo "no"
no
Kind regards,
Rob
--
-- Rob la Lau
--
-- Sysadmin en webdeveloper in ruste
--
-- web : https://ohreally.nl/
-- eml : r...@ohreally.nl
--