From 01af87a1f7d8ae5dcd68213bdc8b46047611583a Mon Sep 17 00:00:00 2001 From: Bo Lopker Date: Thu, 25 Apr 2013 15:19:46 -0700 Subject: [PATCH] Changed which to command for more accurate results. --- plugins/debian/debian.plugin.zsh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 55b90e379..b60f9f6e2 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -4,16 +4,26 @@ # # Debian-related zsh aliases and functions for zsh +# Function to check if a command exists +exists() { + if command -v $1 >/dev/null 2>&1 + then + return 0 + else + return 1 + fi +} + # Use aptitude if installed, or apt-get if not. # You can just set apt_pref='apt-get' to override it. -if [[ -e $( which aptitude 2>&1 ) ]]; then +if exists aptitude; then apt_pref='aptitude' else apt_pref='apt-get' fi # Use sudo by default if it's installed -if [[ -e $( which sudo 2>&1 ) ]]; then +if exists sudo; then use_sudo=1 fi