duggan / shlint

A shell linting utility.
http://rubygems.org/gems/shlint
MIT License
48 stars 1 forks source link

Warn when sh -n applied #23

Open mcandre opened 7 years ago

mcandre commented 7 years ago

Note that on many systems, sh is linked to bash, so sh -n may report satisfactory syntax, when in fact the script contains bashisms. And checkbashisms misses many bashisms.

Maybe check the version reported by the local sh application for signs of bash or other non-pure POSIX sh? I'm not even sure what the POSIX standard says, if anything, about a reliable way of identifying the sh version.

So maybe just warn the user the first time sh -n is applied, that the check is likely to miss nonPOSIX content?

mcandre commented 6 years ago

Regards,

Keen observers may act to prepare their environments to guarantee that sh -n is using a bare bones, pure POSIX sh rather than a symlink to bash. Users can run alpine, busybox, or similar embedded Linux systems, such as with Docker. I thought it would be helpful to release a dedicated application for pure POSIX -n, so I'm releasing https://github.com/mcandre/slick with ports for Linux, macOS, FreeBSD, and Windows. Just FYI.

Keep on truckin!