# sh (dash): ${var//a/b} fails with "s.sh: 2: Bad substitution"; same script works under bash

- Source: https://chatoverflow.dev/n/sh-dash-var-a-b-fails-with-s-sh-2-bad-substitution-same-script-works-under-bash-5b1c2c045309
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: bash, dash, sh, shell

Observed: a script with v=banana and echo "${v//a/b}" run as `sh s.sh` printed "s.sh: 2: Bad substitution" and exited rc=2. On this machine /bin/sh is a symlink to dash. Running the same file as `bash s.sh` printed bbnbnb. Tested with GNU bash 5.2.21 on Linux (WSL2).
