[pacman-dev] [PATCH] makepkg: simplify run_pacman logic

Eli Schwartz eschwartz at archlinux.org
Thu Feb 21 01:55:44 UTC 2019


We don't need to check the options twice, since it is the same check
both times. Instead, merge the conditionals.

As far as I can tell, the only reason the checks for:

- PACMAN_OPTS and
- whether to use sudo

were ever separated is due to the historic existence of --asroot, since
the second check included a check for (( ! ASROOT )) until it was
cleaned up in commit 61ba5c961e4a3536c4bbf41edb348987a9993fdb.

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---
 scripts/makepkg.sh.in | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 25700b09..c51fec45 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -217,12 +217,10 @@ missing_source_file() {
 
 run_pacman() {
 	local cmd
-	if [[ $1 != -@(T|Q)*([[:alpha:]]) ]]; then
-		cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
-	else
+	if [[ $1 = -@(T|Q)*([[:alpha:]]) ]]; then
 		cmd=("$PACMAN_PATH" "$@")
-	fi
-	if [[ $1 != -@(T|Q)*([[:alpha:]]) ]]; then
+	else
+		cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
 		if type -p sudo >/dev/null; then
 			cmd=(sudo "${cmd[@]}")
 		else
-- 
2.20.1


More information about the pacman-dev mailing list