koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.39k stars 1.78k forks source link

SC2009 recommends away from a POSIX way to a non-POSIX way #2606

Open ghost opened 2 years ago

ghost commented 2 years ago

For bugs

Shellcheck currently recommends to use pgrep instead of ps | grep. That's fine... if one's on a system with pgrep, but pgrep is not POSIX and not everyone has pgrep (for example AIX).

See also #2449 in which SC2012 does the same.

I'm not sure what the project's stance is recommending the user away from POSIX. I'm inclined to think it should not, particularly if one is targeting /bin/sh or /bin/ksh, but at the very least the wiki should make a note that the error should be ignored if POSIX compliance is important or if the target system lacks the command/option.

bmarwell commented 1 year ago

Hi, I see the same issue and need to deactivate it every single time. Thanks to @tim78245 for opening up. I agree that moving away from posix to a non-standard-tool is not a good recommendation, especially when all other suggestions try to push you to moving to POSIX standards. ;-)

SuperSandro2000 commented 1 year ago

You can globally disable certain checks.

bmarwell commented 1 year ago

I know. But I have to do it in every ci script I write. So I still have to do it multiple times, once for each source code repository.

bmarwell commented 1 year ago

Any update on this?