shell/aliases: only call pacman one time

This commit is contained in:
Felix Buehler 2017-04-12 22:09:16 +02:00
parent 62d1932eda
commit 78bbb4c3e7

View file

@ -57,11 +57,12 @@ if [ ! -z "$(type sudo 2>/dev/null)" -a "$USER" != 'root' ]; then
unset sudo
pacman(){
# Check if pacman has -R, -S or -U option
local sudo_needed
# Check if pacman has -S, -R or -U option
# which should indicate in most times if we need sudo
echo "$*" | grep -- "-[SRU]" >/dev/null 2>&1 \
&& sudo /usr/bin/pacman $* \
|| /usr/bin/pacman $*
&& sudo_needed="sudo"
${sudo_needed} /usr/bin/pacman $*
}
fi