libmakepkg/srcinfo.sh: fix missing extglob in srcinfo_write_attr
We use an extended glob here, but were relying on having it globally set in makepkg. This causes it to fail when used in scripts. Since scripts using libmakepkg may not want extglob to be set, save and restore the environment while explicitly setting extglob only where we need it. Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
parent
f343db5b8e
commit
016fd2633e
1 changed files with 6 additions and 0 deletions
|
@ -40,11 +40,17 @@ srcinfo_write_attr() {
|
||||||
|
|
||||||
local attrname=$1 attrvalues=("${@:2}")
|
local attrname=$1 attrvalues=("${@:2}")
|
||||||
|
|
||||||
|
# this function requires extglob - save current status to restore later
|
||||||
|
local shellopts=$(shopt -p extglob)
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
# normalize whitespace, strip leading and trailing
|
# normalize whitespace, strip leading and trailing
|
||||||
attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
|
attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
|
||||||
attrvalues=("${attrvalues[@]#[[:space:]]}")
|
attrvalues=("${attrvalues[@]#[[:space:]]}")
|
||||||
attrvalues=("${attrvalues[@]%[[:space:]]}")
|
attrvalues=("${attrvalues[@]%[[:space:]]}")
|
||||||
|
|
||||||
|
eval "$shellopts"
|
||||||
|
|
||||||
printf "\t$attrname = %s\n" "${attrvalues[@]}"
|
printf "\t$attrname = %s\n" "${attrvalues[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue