What is the difference between bash and POSIX sh scripting?

Answer

POSIX sh is a standard defining a minimal, portable shell feature set — scripts with #!/bin/sh should use only POSIX features to run on any compliant system. Bash is a superset — it adds arrays, [[ ]], (( )), process substitution, brace expansion, local (POSIX-optional), FUNCNAME, BASH_SOURCE, regex with =~, mapfile/readarray, and more. Common portability pitfalls: == in [ ] (use = in POSIX), $( ) is POSIX (backticks portable too), {a,b} brace expansion is not POSIX. Use #!/bin/bash and bash features freely for scripts that only run on Linux systems. Use #!/bin/sh only when cross-platform portability (BSD, macOS, Alpine) matters.