Interview Prep/Shell Scripting/ShellCheck, debugging, testing, portability and security

What are common "bashisms" that break under `/bin/sh`?

IntermediateConceptShellCheck, debugging, testing, portability and security
Answer
Bash POSIX sh alternative
[[ $a == b* ]] case $a in b*) ... ;; esac
arr=(a b) positional params set -- a b or newline-separated strings
function f { } f() { }
$'\n' "$(printf '\n_')" then strip the _
<(cmd) temp file or named pipe
${var//a/b}, ${var^^} sed, tr
source f . f
&>file >file 2>&1
echo -e printf
(( i++ )) i=$((i + 1))

Check with shellcheck -s sh or checkbashisms. Typical error under dash: [[: not found or Syntax error: "(" unexpected.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on ShellCheck, debugging, testing, portability and security