diff options
author | Levente Polyak <anthraxx@archlinux.org> | 2022-08-31 23:49:01 +0200 |
---|---|---|
committer | Levente Polyak <anthraxx@archlinux.org> | 2022-09-01 23:40:21 +0200 |
commit | fcaf3ecec0f835cc480fdeb653d33754b0de7624 (patch) | |
tree | bfa2e2bf75385cc041fc36233205ea6a9be35087 | |
parent | 280ef10d37e88a9a60d1a4406fc511d09acc3fad (diff) | |
download | devtools-fcaf3ecec0f835cc480fdeb653d33754b0de7624.tar.xz |
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
-rw-r--r-- | lib/common.sh | 10 | ||||
-rw-r--r-- | src/checkpkg.in | 2 | ||||
-rw-r--r-- | src/diffpkg.in | 2 | ||||
-rw-r--r-- | src/find-libdeps.in | 3 |
4 files changed, 8 insertions, 9 deletions
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 diff --git a/src/checkpkg.in b/src/checkpkg.in index 1a7983c..fe5b71a 100644 --- a/src/checkpkg.in +++ b/src/checkpkg.in @@ -2,8 +2,6 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -shopt -s extglob - m4_include(lib/common.sh) usage() { diff --git a/src/diffpkg.in b/src/diffpkg.in index 43af217..10b0904 100644 --- a/src/diffpkg.in +++ b/src/diffpkg.in @@ -2,8 +2,6 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -shopt -s extglob - m4_include(lib/common.sh) usage() { diff --git a/src/find-libdeps.in b/src/find-libdeps.in index e1423b8..5a11580 100644 --- a/src/find-libdeps.in +++ b/src/find-libdeps.in @@ -5,7 +5,6 @@ m4_include(lib/common.sh) set -e -shopt -s extglob IGNORE_INTERNAL=0 @@ -43,7 +42,9 @@ fi process_sofile() { # extract the library name: libfoo.so + shopt -s extglob nullglob soname="${sofile%.so?(+(.+([0-9])))}".so + shopt -u extglob nullglob # extract the major version: 1 soversion="${sofile##*\.so\.}" if [[ "$soversion" = "$sofile" ]] && ((IGNORE_INTERNAL)); then |