This command requires extglob
support to be enabled. Presumably you're turning it on (with shopt -s extglob
) in your dotfiles, but it's off-by-default in scripts.
See the bash-hackers' wiki on extended pattern language, describing the specific items that require the extglob
flag to be enabled; @(...)
is among them.
Thus, to fix your script without changing the pattern you're replacing:
#!/usr/bin/env bash
shopt -s extglob
CHROMEDRIVER="75.0.3770.8/"
echo "$CHROMEDRIVER"
echo "${CHROMEDRIVER//@([\/])/}"
...though insofar as your goal is just to strip a trailing slash, use "${CHROMEDRIVER%/}"
instead, as described in the bash-hackers' wiki page on parameter expansion.