[arch-projects] [devtools] [PATCH 2/7] makechrootpkg: Fix anti-pattern when checking for enabled features
Luke Shumaker
lukeshu at lukeshu.com
Mon Jan 15 16:57:54 UTC 2018
From: Eli Schwartz <eschwartz at archlinux.org>
Don't use error-prone logic e.g.
foo=true; if $foo ...
This completely fails to act as expected when the variable is unset
because of unrelated bugs.
While this merely causes the default behavior to be "false" rather than
"true" in such cases, it is better to fail to enable explicitly
requested behavior (which will be noticed by the user) than to simply
upgrade to this behavior for free (which may not seem to have any
obvious cause).
Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
Reviewed-by: Luke Shumaker <lukeshu at parabola.nu>
---
makechrootpkg.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/makechrootpkg.in b/makechrootpkg.in
index 02c91bc..c7fe076 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -165,7 +165,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}"
@@ -208,7 +208,7 @@ EOF
declare -p SOURCE_DATE_EPOCH 2>/dev/null
printf '_chrootbuild "$@" || exit\n'
- if $run_namcap; then
+ if [[ $run_namcap = true ]]; then
declare -f _chrootnamcap
printf '_chrootnamcap || exit\n'
fi
--
2.15.1
More information about the arch-projects
mailing list