Open bittorf opened 8 years ago
amen. I want to use 'local' because it's portable enough, and I don't want to disable all the other checks.
@dankegel - for now we workaround that with e.g.
shellcheck --shell=dash "$FILE"
dash has special handling, e.g. 'local' is allowed
Thanks! Or as it turns out, you can use the undocumented shell directive:
# shellcheck shell=dash
I submitted https://github.com/koalaman/shellcheck/pull/878 to document this.
@dankegel Why not set the shebang to #!/bin/dash
if you're using dash features that do not exist in POSIX sh?
Just ran into this. I'm trying to write a script that is only portable between bash and zsh, and it'd be nice to disable checks for local
, without disabling other bashism checks.
Because then the shell script would not run on the mac.
Yes, but this script is meant to stay on a Linux box.
Each of these checks should be separate indeed. There are reasonable concessions to make here because almost every relevant sh
shell supports local
and it is reasonable to use #!/bin/sh
for them if the requirements are properly documented. (Fortunately local
is being considered via two different means for the next edition of POSIX standard.)
It's difficult to use shellcheck
in an automated fasion when a single warning indication is overloaded with many others.
I don't know about euclio's scripts, but mine are most definitely meant to run on multiple operating systems. Requiring bash or dash is not an option.
I was actually caught out by this recently due to annotating the script that I make use of local
but I didn't realise it was actually disabling the check on my use of ${@:3}
. It was only after reformatting things that a check went through without the omission did I see it.
Just to ensure this issue is not forgotten a friendly bump. We too run into the issue where we want all of the SC2039 to be triggered, except for maybe 1 or 2 cases, we want to globally ignore. This is, sadly, not possible yet.
SC2039 is used for different issues which all are "not POSIX" e.g.
SC2039: In POSIX sh, echo flags are not supported. SC2039: In POSIX sh, HOSTNAME is not supported. SC2039: In POSIX sh, string replacement is not supported. SC2039: In POSIX sh, 'let' is not supported. SC2039: in POSIX sh - 'local' is not supported (and maybe more)
can we use different codes for different issues, so that selective muting works better?