[pacman-contrib] [PATCH] pacscripts: Use pacman-conf rather than evaling pacman.conf fragments
Signed-off-by: Johannes Löthberg <johannes@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:-@localstatedir@/lib/pacman}/local" -pac_cache="${CacheDir:-@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:-@localstatedir@/lib/pacman}/local" +pac_cache="${CacheDir:-@localstatedir@/cache/pacman/pkg}" + version() { printf "%s %s\n" "$myname" "$myver" echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>' -- 2.16.1
On 02/14/2018 02:42 PM, Johannes Löthberg wrote:
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- src/pacscripts.sh.in | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
Looks okay, I just didn't notice when grepping that this was still there. :D -- Eli Schwartz Bug Wrangler and Trusted User
Quoting Eli Schwartz (2018-02-14 21:01:05)
On 02/14/2018 02:42 PM, Johannes Löthberg wrote:
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> --- src/pacscripts.sh.in | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
Looks okay, I just didn't notice when grepping that this was still there. :D
Yeah, I wouldn't have at first either, but then when I saw that one script eval-ed a pacman.conf fragment I figured it'd be likely that at least one other did as well, haha. -- Sincerely, Johannes Löthberg PGP Key ID: 0x50FB9B273A9D0BB5 PGP Key FP: 5134 EF9E AF65 F95B 6BB1 608E 50FB 9B27 3A9D 0BB5 https://theos.kyriasis.com/~kyrias/
participants (2)
-
Eli Schwartz
-
Johannes Löthberg