Earlier quoted context omitted.
Shellcheck is amazingly impressive at catching issues with shell scripts. It makes it very hard to write a shell script that does the wrong thing. Also, look at oilshell[1]; it is bash compatible out-of-the-box, but has several options to make it incompatible, but safer (e.g. no field splitting of parameter expansion by default, making quotes much less needed). 1: https://www.oilshell.org/
FWIW I think ShellCheck is great and the state of the art, but Oil is partly (negatively) inspired by ShellCheck :) Somebody integrated ShellCheck into Google's code review system about four years ago, right before I left. So the result was that every code review I sent with a shell script was filled with red squigglies -- "add double quotes here". Most code reviewers don't really know shell, but if they see red squi…
The only way you know this is being a person who routinely writes shell scripts.
There is no substitute for knowing what you're doing.
Try running shellcheck on configure scripts.
Or try this
curl -4O https://ftp.netbsd.org/pub/NetBSD/NetBSD-release-8/src/build.sh
shellcheck build.sh
Or try shellcheck on the build.sh from buildroot.org.These scripts are "safe" enough for hundreds or thousands of competent users to be running them every day.