>>>>> On Tue, 13 Jun 2023, Michał Górny wrote:
> _pypi_normalize_name() {
> local name=${1}
> - local shopt_save=$(shopt -p extglob)
> - shopt -s extglob
> + local prev_extglob=-s
> + if ! shopt -p extglob >/dev/null; then
> + prev_extglob=-u
> + shopt -s extglob
> + fi
> name=${name//+([._-])/_}
> - ${shopt_save}
> + shopt "${prev_extglob}" extglob
> _PYPI_NORMALIZED_NAME="${name,,}"
> }
In principle you could also do something like this:
if shopt -pq extglob; then
name=${name//+([._-])/_}
else
shopt -s extglob
name=${name//+([._-])/_}
shopt -u extglob
fi
It duplicates one line of code, but saves a variable and IMHO the code
would be easier to understand.
Also, with the -q option no output redirection is needed.
Ulrich
signature.asc
Description: PGP signature
