Exploring how different shell brands handles this
- bash version 5.1-6
- dash version 0.5.11
- ksh93 version 1.0.0~beta.2
- zsh version 5.8.1
Ksh93 seems to show the most distinctive behavior.
What it teaches is:
Within an arithmetic context, shells interpret a single quote as the single quote character itself, but not as the quoted literal value.
#!/usr/bin/env sh
for shell in bash dash ksh93 zsh; do
printf 'Testing with %s:\n' "$shell"
"$shell" <<'EOF'
LC_ALL=C
echo "$((''))"
EOF
echo
done
Output:
Testing with bash:
bash: line 2: '': syntax error: operand expected (error token is "''")
Testing with dash:
ash: 2: arithmetic expression: expecting primary: "''"
Testing with ksh93:
39
Testing with zsh:
zsh: bad math expression: illegal character: '