-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expr is sometimes the only option #15
Comments
On Bash, Ksh and Zsh, you can use [[ ]], but you're right in that there's no POSIX sh way of doing that. Shellcheck should probably not suggest this if you're using : and have specified #!/bin/sh As for floats, POSIX specifically states that string comparison should be used when the arguments are not integers, unlike $(( .. )) where support for floats is allowed. Which shell/environment are you running this on? |
I try to write POSIX /bin/sh scripts, for which some of the messages given by shellcheck are very helpful. You are correct that I could use string comparisons. And anyway there are lots of version numbers for which float (and string) comparison fails. I should probably use dpkg --compare-versions, but that's only available on Debian-derived systems ;) |
From 8d265aa, Shellcheck doesn't warn about expr when using : |
In this case the regular expression cannot be handled by the suggested mechanisms.
expr can compare floats
The text was updated successfully, but these errors were encountered: