From fa6723a5eef1811d68d6a43194ee23d573449757 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Mon, 9 Dec 2013 15:29:14 +0100 Subject: [PATCH] Don't use sudo if implicitly called by Pacman frontend Don't rely on alias expansion to handle Pacman because aliases are not expanded in sudo. Signed-off-by: Sorin Ionescu --- modules/pacman/init.zsh | 32 +++++++++++++++++--------------- modules/pacman/yaourt.zsh | 4 ++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/modules/pacman/init.zsh b/modules/pacman/init.zsh index bbbdcfb5..8b9a4330 100644 --- a/modules/pacman/init.zsh +++ b/modules/pacman/init.zsh @@ -27,6 +27,8 @@ if (( $+commands[$_pacman_frontend] )); then if [[ -s "${0:h}/${_pacman_frontend}.zsh" ]]; then source "${0:h}/${_pacman_frontend}.zsh" fi +else + _pacman_sudo='sudo ' fi # @@ -34,49 +36,49 @@ fi # # Pacman. -alias pac='pacman' +alias pac= "${_pacman_frontend}" # Installs packages from repositories. -alias paci='sudo pacman --sync' +alias paci="${_pacman_sudo}${_pacman_frontend} --sync" # Installs packages from files. -alias pacI='sudo pacman --upgrade' +alias pacI="${_pacman_sudo}${_pacman_frontend} --upgrade" # Removes packages and unneeded dependencies. -alias pacx='sudo pacman --remove' +alias pacx="${_pacman_sudo}${_pacman_frontend} --remove" # Removes packages, their configuration, and unneeded dependencies. -alias pacX='sudo pacman --remove --nosave --recursive' +alias pacX="${_pacman_sudo}${_pacman_frontend} --remove --nosave --recursive" # Displays information about a package from the repositories. -alias pacq='pacman --sync --info' +alias pacq="${_pacman_frontend} --sync --info" # Displays information about a package from the local database. -alias pacQ='pacman --query --info' +alias pacQ="${_pacman_frontend} --query --info" # Searches for packages in the repositories. -alias pacs='pacman --sync --search' +alias pacs="${_pacman_frontend} --sync --search" # Searches for packages in the local database. -alias pacS='pacman --query --search' +alias pacS="${_pacman_frontend} --query --search" # Lists orphan packages. -alias pacman-list-orphans='sudo pacman --query --deps --unrequired' +alias pacman-list-orphans="${_pacman_sudo}${_pacman_frontend} --query --deps --unrequired" # Removes orphan packages. -alias pacman-remove-orphans='sudo pacman --remove --recursive $(pacman --quiet --query --deps --unrequired)' +alias pacman-remove-orphans="${_pacman_sudo}${_pacman_frontend} --remove --recursive \$(${_pacman_frontend} --quiet --query --deps --unrequired)" # Synchronizes the local package and Arch Build System databases against the # repositories. if (( $+commands[abs] )); then - alias pacu='sudo pacman --sync --refresh && sudo abs' + alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh && ${_pacman_sudo}abs" else - alias pacu='sudo pacman --sync --refresh' + alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh" fi # Synchronizes the local package database against the repositories then # upgrades outdated packages. -alias pacU='sudo pacman --sync --refresh --sysupgrade' +alias pacU="${_pacman_sudo}${_pacman_frontend} --sync --refresh --sysupgrade" -unset _pacman_frontend +unset _pacman_{frontend,sudo} diff --git a/modules/pacman/yaourt.zsh b/modules/pacman/yaourt.zsh index fb2a8dc2..f4709e08 100644 --- a/modules/pacman/yaourt.zsh +++ b/modules/pacman/yaourt.zsh @@ -11,9 +11,9 @@ # Disable color. if ! zstyle -t ':prezto:module:pacman:yaourt' color; then - alias pacman='pacman --nocolor' + alias pacman='yaourt --nocolor' fi # Manages .pac* files. -alias pacc='pacman -C' +alias pacc='yaourt -C'