anordal / shellharden

The corrective bash syntax highlighter
Mozilla Public License 2.0
4.63k stars 130 forks source link

shellarden conflicts with shellcheck:SC2145 #23

Closed Maryse47 closed 6 years ago

Maryse47 commented 6 years ago

Shellcheck requires changing printf "Error: %s\n" "Bad parameters: $@" to printf "Error: %s\n" "Bad parameters: $*". Shellharden requires the opposite.

Is there fundamental disagreement or is it a false positive?

https://github.com/koalaman/shellcheck/wiki/SC2145

anordal commented 6 years ago

Thanks for the report!

No disagreement here. There is the opposite rule, which Shellharden arguably applies too broadly (i.e. always). This feature was added in commit 7f47706.

The reason why Shellharden simply always transforms $ → $@ is to forbid the very bad unquoted $ variant (which is a big coding smell, always wrong and never useful), whereas the quoted "$@" variant, safe as it is, I've honestly never seen or imagined a legitimate use for.

I could trivially allow the quoted "$*" variant. Oh boy, that's a change of mindset – I want to think a bit about that.

anordal commented 6 years ago

Commit 1fcc97 allows "$*".