Comments (3)
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?
from shellcheck.
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 shellcheck.
From 8d265aa, Shellcheck doesn't warn about expr when using :
from shellcheck.
Related Issues (20)
- [Feature] Generate Warning for Multiple Traps on the Same Signal
- Add an option to treat `/bin/sh` interpreter as `busybox` HOT 13
- SC3045: incomplete wiki page when printing a literal '-' HOT 1
- SC2198 false positive
- Warn about transposed characters in variable length expansion HOT 1
- SC2119 / SC2120 false positives?
- SC2034 - consider a "test -v" as usage/reference
- [Wiki] Updated SC1074 need double check
- SC2034 local let v=0 - let appears unused HOT 1
- server1 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).", "unreachable": true }
- SC1010 thrown for ``words=(do da di)``
- Shadowing `local` should throw a warning
- SC2050 "expression is constant" when checking against a file
- [Bug]: Shell check ignore is not working
- not detecting malformed brace matching
- Fixing typo "Parentesis"
- SC2319 - changed with Shellcheck 0.10.0 HOT 3
- Cache / save the check results and reuse them
- SC2027 doesn't account for escaped quotes HOT 1
- ksh ~(N) null glob pattern prefix causes error SC1036
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shellcheck.