libmakepkg: fix compatibility with bash-5.2 patsub_replacement

Bash-5.2 introduced the patsub_replacement shell option, which is enabled
by default.  Apparently is it supposed to handle a sed-like idiom, but
what it does achieve is making any substitution involving a "&" requiring
special care.

For makepkg's DLAGENTS, we replace "%o" and "%u" if present.  Any "&" in
the replacement fields triggers patsub_replacement unless quoted.  This is
particularly important for the URL field.

Add relevant quotes to avoid issues.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2022-12-12 18:37:59 +10:00
parent 1327ce7bd8
commit 0e938f1886

View file

@ -60,11 +60,11 @@ download_file() {
# replace %o by the temporary dlfile if it exists # replace %o by the temporary dlfile if it exists
if [[ ${cmdline[*]} = *%o* ]]; then if [[ ${cmdline[*]} = *%o* ]]; then
dlfile=$filename.part dlfile=$filename.part
cmdline=("${cmdline[@]//%o/$dlfile}") cmdline=("${cmdline[@]//%o/"$dlfile"}")
fi fi
# add the URL, either in place of %u or at the end # add the URL, either in place of %u or at the end
if [[ ${cmdline[*]} = *%u* ]]; then if [[ ${cmdline[*]} = *%u* ]]; then
cmdline=("${cmdline[@]//%u/$url}") cmdline=("${cmdline[@]//%u/"$url"}")
else else
cmdline+=("$url") cmdline+=("$url")
fi fi