pacman.conf cannot be properly parsed in bash, e.g. it fails to handle `Include = ` directives, hence why pacman introduced a configuration parsing tool in the first place. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- src/checkupdates.sh.in | 2 +- src/paccache.sh.in | 3 +-- src/pacdiff.sh.in | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index 9f34dc1..1d01fda 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -46,7 +46,7 @@ fi trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT -DBPath="$(awk -F' *= *' '/^DBPath/ { print $2 }' @sysconfdir@/pacman.conf)" +DBPath="$(pacman-conf DBPath)" if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then DBPath="@localstatedir@/lib/pacman/" fi diff --git a/src/paccache.sh.in b/src/paccache.sh.in index 143c6e3..25432d4 100644 --- a/src/paccache.sh.in +++ b/src/paccache.sh.in @@ -287,8 +287,7 @@ m4_include(../lib/term_colors.sh) # setting default cachedirs if [[ -z $cachedirs ]]; then - cachedir="$(get_cachedirs_from_config "@sysconfdir@/pacman.conf")" - cachedirs=("${cachedirs[@]:-@localstatedir@/cache/pacman/pkg}") + cachedirs=($(pacman-conf CacheDirs)) fi # remaining args are a whitelist diff --git a/src/pacdiff.sh.in b/src/pacdiff.sh.in index ef385c2..866932d 100644 --- a/src/pacdiff.sh.in +++ b/src/pacdiff.sh.in @@ -130,12 +130,10 @@ case $(( USE_FIND + USE_LOCATE + USE_PACDB )) in esac if (( USE_PACDB )); then - if [[ ! -r @sysconfdir@/pacman.conf ]]; then + if ! DBPath="$(pacman-conf DBPath)"; then error "unable to read @sysconfdir@/pacman.conf" usage; exit 1 fi - - eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf) pac_db="${DBPath:-@localstatedir@/lib/pacman/}local" if [[ ! -d "${pac_db}" ]]; then error "unable to read pacman database %s". "${pac_db}" -- 2.16.1