p16r.nl

Shopware 6 - Bad substitution in shell scripts when using zsh

September 02, 2020 - 1 min read

Update: Fabian showed me an easier way to avoid this warning. Just run it with bash instead of sh.

Instead of Bash shell, I use the zsh shell. The shell scripts that come with the Shopware 6 production template unfortunately only work with Bash. When trying to run it in zsh, it gives this notice;

$ sh watch-storefront.sh 
watch-storefront.sh: 3: Bad substitution

This is because the ${BASH_SOURCE} variable is not known to zsh. The nearest equivalent variable in zsh for this is $0.

Run this command in the bin directory to replace the Bash variable with the zsh equivalent;

sed -i 's/\${BASH_SOURCE\[0\]}/\$0/g' *.sh


Kyle Mathews

Written by Peter Jaap Blaakmeer @PeterJaap