[pacman-contrib] [PATCH] pacscripts: Use pacman-conf rather than evaling pacman.conf fragments

Johannes Löthberg johannes at kyriasis.com
Wed Feb 14 19:42:51 UTC 2018


Signed-off-by: Johannes Löthberg <johannes at kyriasis.com>
---
 src/pacscripts.sh.in | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/pacscripts.sh.in b/src/pacscripts.sh.in
index 68c9441..17e2625 100644
--- a/src/pacscripts.sh.in
+++ b/src/pacscripts.sh.in
@@ -27,18 +27,6 @@ set -o errexit
 declare -r myname='pacscripts'
 declare -r myver='@PACKAGE_VERSION@'
 
-conf="@sysconfdir@/pacman.conf"
-
-if [ ! -r "$conf" ]; then
-	echo "ERROR: unable to read $conf"
-	exit 1
-fi
-
-eval $(awk '/DBPath/ {print $1$2$3}' "$conf")
-eval $(awk '/CacheDir/ {print $1$2$3}' "$conf")
-pac_db="${DBPath:- at localstatedir@/lib/pacman}/local"
-pac_cache="${CacheDir:- at localstatedir@/cache/pacman/pkg}"
-
 error() {
 	local mesg=$1; shift
 	printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
@@ -59,6 +47,15 @@ usage() {
 	echo "Example: ${myname} gconf-editor-3.0.1-3-x86_64.pkg.tar.xz"
 }
 
+
+if ! DBPath="$(pacman-conf DBPath)"; then
+	error "unable to read @sysconfdir@/pacman.conf"
+	exit 1
+fi
+CacheDir="$(pacman-conf CacheDir)"
+pac_db="${DBPath:- at localstatedir@/lib/pacman}/local"
+pac_cache="${CacheDir:- at localstatedir@/cache/pacman/pkg}"
+
 version() {
 	printf "%s %s\n" "$myname" "$myver"
 	echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante at gmail.com>'
-- 
2.16.1


More information about the pacman-contrib mailing list