From 15b6128a45ac42a14ac3d9b080f3c60fdfb39acf Mon Sep 17 00:00:00 2001 From: Kevin Daudt Date: Sat, 15 Oct 2022 11:06:53 +0000 Subject: [PATCH] abump: source APKBUILD in subshell As demonstrated in b7813c3 (abump: demonstrate abump environment polution, 2022-10-15), sourcing APKBUILDs in abump polutes it's environment. Address that by sourcing the APKBUILD in a subshell as well as some of the checks following it that need the information from the APKBUILD. That information is not used any later, it's not an issue that it's discarded outside of the subshell. --- abump.in | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/abump.in b/abump.in index 6cb6c87..ab92179 100644 --- a/abump.in +++ b/abump.in @@ -44,16 +44,21 @@ do_bump() { a=$(aports_buildscript "$name" ) \ || die "can't find APKBUILD for $name" - # verify APKBUILD - . "$a" || exit 1 - name=${name#*/} - [ "$pkgname" = "$name" ] \ - || die "APKBUILD has different \$pkgname for $name" - type package | grep -q function \ - || die "missing package() for $name" - if [ "$pkgver" = "$ver" ] && git diff-index --quiet HEAD -- "$a"; then - die "version is already $ver" - fi + # sourcing APKBUILDs should not affect the environment of abump + # so do that in a subshell, along with any checks that need the + # information from the APKBUILD. + ( + # verify APKBUILD + . "$a" || exit 1 + name=${name#*/} + [ "$pkgname" = "$name" ] \ + || die "APKBUILD has different \$pkgname for $name" + type package | grep -q function \ + || die "missing package() for $name" + if [ "$pkgver" = "$ver" ] && git diff-index --quiet HEAD -- "$a"; then + die "version is already $ver" + fi + ) cd "${a%/*}" section=${PWD%/*}