Next line:
str=$(echo "${str// /-}")
results in Syntax error: Bad substitutionbecause you are not running your script with bash. You execute your script with shor dash, which causes an error.
EDIT: in order to fix your script so that it works with shand dashin addition to bash, you could replace the following lines:
str=$(printf "%${leng}s" "-")
str=$(echo "${str// /-}")
from
str=$(printf '=%.0s' $(seq $leng) | tr '=' '-')
source
share