From 016fd2633e2285341eae383130627512f540f4e9 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Wed, 28 Feb 2024 21:18:42 +0100 Subject: [PATCH] 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 --- scripts/libmakepkg/srcinfo.sh.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/libmakepkg/srcinfo.sh.in b/scripts/libmakepkg/srcinfo.sh.in index 2705ad7d..c43d4cee 100644 --- a/scripts/libmakepkg/srcinfo.sh.in +++ b/scripts/libmakepkg/srcinfo.sh.in @@ -40,11 +40,17 @@ srcinfo_write_attr() { 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 attrvalues=("${attrvalues[@]//+([[:space:]])/ }") attrvalues=("${attrvalues[@]#[[:space:]]}") attrvalues=("${attrvalues[@]%[[:space:]]}") + eval "$shellopts" + printf "\t$attrname = %s\n" "${attrvalues[@]}" }