[arch-projects] [devtools] [PATCH 2/2] makechrootpkg: Fix anti-pattern when checking for enabled features

Eli Schwartz eschwartz at archlinux.org
Fri Sep 1 22:53:13 UTC 2017


Don't use error-prone logic e.g.
foo=true; if $foo ...

This invokes an extra process as opposed to a simple value comparison,
in the process of completely failing to act as expected when the
variable is unset because of unrelated bugs.

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---
 makechrootpkg.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/makechrootpkg.in b/makechrootpkg.in
index b1c9545..90bd9cf 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -188,7 +188,7 @@ prepare_chroot() {
 	local keepbuilddir=$3
 	local run_namcap=$4
 
-	$keepbuilddir || rm -rf "$copydir/build"
+	[[ $keepbuilddir = true ]] || rm -rf "$copydir/build"
 
 	local builduser_uid builduser_gid
 	builduser_uid="${SUDO_UID:-$UID}"
@@ -225,7 +225,7 @@ EOF
 		declare -f _chrootbuild
 		printf '_chrootbuild "$@" || exit\n'
 
-		if $run_namcap; then
+		if [[ $run_namcap = true ]]; then
 			declare -f _chrootnamcap
 			printf '_chrootnamcap || exit\n'
 		fi
-- 
2.14.1


More information about the arch-projects mailing list