libmakepkg/util/pkgbuild.sh: fix missing extglob

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: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Eli Schwartz 2018-03-19 23:05:21 -04:00 committed by Allan McRae
parent 27f64e3789
commit bcaf1b84ff

View file

@ -80,6 +80,10 @@ extract_function_variable() {
printf -v attr_regex '^[[:space:]]* %s\+?=[^(]' "$2" printf -v attr_regex '^[[:space:]]* %s\+?=[^(]' "$2"
fi fi
# save our shell options and turn on extglob
local shellopts=$(shopt -p)
shopt -s extglob
while read -r; do while read -r; do
# strip leading whitespace and any usage of declare # strip leading whitespace and any usage of declare
decl=${REPLY##*([[:space:]])} decl=${REPLY##*([[:space:]])}
@ -89,6 +93,8 @@ extract_function_variable() {
r=0 r=0
done < <(grep_function "$funcname" "$attr_regex") done < <(grep_function "$funcname" "$attr_regex")
eval "$shellopts"
return $r return $r
} }