When must a script be POSIX `sh` rather than Bash?
BeginnerConceptShellCheck, debugging, testing, portability and security
Answer
When Bash may not exist: Alpine and BusyBox-based images (only ash), distroless images with a shell, initramfs, embedded devices, Docker HEALTHCHECK or entrypoints in minimal images, and /bin/sh -c contexts you do not control (Makefiles by default, some CI runners, system() calls). Everywhere else, we use Bash explicitly and get arrays and [[ ]].
More on ShellCheck, debugging, testing, portability and security
What is ShellCheck and how do you use it in a team?BeginnerHow do you disable a ShellCheck warning, and when is that acceptable?IntermediateName the ShellCheck warnings you see most and what each means.IntermediateHow do you debug a Bash script?BeginnerHow do you make `set -x` output more useful with `PS4`?IntermediateWhat is bats, and how do you test a script that calls external commands?Intermediate