From fcaf3ecec0f835cc480fdeb653d33754b0de7624 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Wed, 31 Aug 2022 23:49:01 +0200 Subject: fix: do not set extglob globally to avoid side-effects Instead only enable it for whatever operation requires them. Example sides effects: commitpkg can accidently execute PKGBUILD functions when sourcing the PKGBUILD that has function names like package_libsigc++() Fixes #87 --- lib/common.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/common.sh b/lib/common.sh index 0996247..56e49e6 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -19,8 +19,6 @@ export LANG=C export BUILDTOOL=devtools export BUILDTOOLVER=m4_devtools_version -shopt -s extglob - # check if messages are to be printed using color if [[ -t 2 && "$TERM" != dumb ]]; then colorize @@ -142,12 +140,16 @@ pkgver_equal() { find_cached_package() { local searchdirs=("$PWD" "$PKGDEST") results=() local targetname=$1 targetver=$2 targetarch=$3 - local dir pkg pkgbasename name ver rel arch r results + local dir pkg packages pkgbasename name ver rel arch r results for dir in "${searchdirs[@]}"; do [[ -d $dir ]] || continue - for pkg in "$dir"/*.pkg.tar?(.!(sig|*.*)); do + shopt -s extglob nullglob + mapfile -t packages < <(printf "%s\n" "$dir"/*.pkg.tar?(.!(sig|*.*))) + shopt -u extglob nullglob + + for pkg in "${packages[@]}"; do [[ -f $pkg ]] || continue # avoid adding duplicates of the same inode -- cgit v1.2.3-70-g09d2