Skip to content
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

Add warnings for sh for non-POSIX extensions #2125

Open
2 tasks done
shanebishop opened this issue Jan 11, 2021 · 1 comment · May be fixed by #3175
Open
2 tasks done

Add warnings for sh for non-POSIX extensions #2125

shanebishop opened this issue Jan 11, 2021 · 1 comment · May be fixed by #3175

Comments

@shanebishop
Copy link

shanebishop commented Jan 11, 2021

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

This is just a small example, please read More details section below.

#!/bin/sh 
[ -k foo ]

Here's what shellcheck currently says:

No issues detected!

Here's what I wanted or expected to see:

In POSIX sh, -k is undefined.

(Or something similar.)

More details

Shellcheck does not emit warnings for the non-POSIX operators -nt, -ef, -k, -o, <, and > when using a #!/bin/sh shebang or --shell sh.

Shellcheck already emits warnings for non-POSIX syntax (example 1, example 2). It would be useful if shellcheck could also warn for these non-POSIX operators, when the sh shell is specified.

@e-kwsm
Copy link

e-kwsm commented Mar 24, 2025

Non-POSIX unary operators:

  • -a (not supported by dash) SC3017
  • -k
  • -G
  • -N (not supported by dash)
  • -o (not supported by dash)
  • -O
  • -R (not supported by dash)
  • -v (not supported by dash) SC3016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants