3 ms·
> I am not aware that ShellCheck actually checks POSIX compliance; I am pretty sure it just checks for common errors in your bash/sh scripts Bashisms are erro
by hiq 6y ago
> I am not aware that ShellCheck actually checks POSIX compliance; I am pretty sure it just checks for common errors in your bash/sh scripts
Bashisms are errors if you specify #!/bin/sh. If you want to try it out, you can load random examples on https://www.shellcheck.net/ https://www.shellcheck.net/ until you get a #!/bin/sh. Then you'll get warnings such as "SC3010: In POSIX sh, [[ ]] is undefined."
To go back to the discussion: if you want to use Bash features, you're better off switching to Python.
- chubot 6y agoOK interesting, yeah with #!/bin/sh it points out that 'local' is not POSIX. But every shell I know of supports 'local'. It's not a "bash-ism' because it's universally supported. I consider it essential; otherwise you might as well not use functions in shell. This is a long argument (and is addressed in the same FAQ), but as someone who's written hundreds of thousands of lines of Python, I think shell is still better for a large set of tasks. A typical small project I write might have 300 lines of shell and 1000 lines of Python, rather than 5000 lines of Python. But of course there are problems with using shell; if there weren't then Oil wouldn't exist :)
- justaj 6y agoAFAIK unsetting the variables first works too.