GNU Bash has made some significant changes across versions. Sometimes we want to write scripts that work on a wide range of versions, e.g. MacOS 12.4 still ships with Bash 3.x.
There are several feature matrices out there for Bash, but they require manual verification and inspection, which is exactly what Shellcheck is good for!
It would be very useful if Shellcheck allowed us to specify a specific Bash version, e.g. shell=bash:3.x, and could then check for feature compatibility.
For example, if I declare shell=bash:3., the mapfile and readarray builtins should be prohibited unless I define my own shell functions of the same name. If the user happens to have an executable program on their system of the same name, they could opt to disable this particular incompatibility warning (or they could use env mapfile to work around the ambiguity).
Of course this could be extended to other shells in principle, but my immediate use case is Bash, and I assume that probably applies to most other Shellcheck users out there.
Finally, thank you for the excellent tool! Shellcheck has been a productivity booster and reliable safeguard in my work, and I am grateful for its existence.
GNU Bash has made some significant changes across versions. Sometimes we want to write scripts that work on a wide range of versions, e.g. MacOS 12.4 still ships with Bash 3.x.
There are several feature matrices out there for Bash, but they require manual verification and inspection, which is exactly what Shellcheck is good for!
Documentation resources include:
It would be very useful if Shellcheck allowed us to specify a specific Bash version, e.g.
shell=bash:3.x
, and could then check for feature compatibility.For example, if I declare
shell=bash:3.
, themapfile
andreadarray
builtins should be prohibited unless I define my own shell functions of the same name. If the user happens to have an executable program on their system of the same name, they could opt to disable this particular incompatibility warning (or they could useenv mapfile
to work around the ambiguity).Of course this could be extended to other shells in principle, but my immediate use case is Bash, and I assume that probably applies to most other Shellcheck users out there.
Finally, thank you for the excellent tool! Shellcheck has been a productivity booster and reliable safeguard in my work, and I am grateful for its existence.