From d58b9de63b7ac368ae67ab879c9a62df9ad46675 Mon Sep 17 00:00:00 2001 From: axel Date: Tue, 14 Mar 2006 10:21:27 +1000 Subject: [PATCH] Use 'type -f' instead of 'which' to test for presense of command, since the latter does not set the exit status correctly on all platforms darcs-hash:20060314002127-ac50b-6ed726bdcc9e3a7a9608a904c382973799dc73ef.gz --- share/functions/_.fish | 2 +- share/functions/__fish_print_packages.fish | 6 +++--- share/functions/help.fish | 6 +++--- share/functions/type.fish | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/share/functions/_.fish b/share/functions/_.fish index a1404761e..accfdcbc3 100644 --- a/share/functions/_.fish +++ b/share/functions/_.fish @@ -3,7 +3,7 @@ # Alias for gettext (or a fallback if gettext isn't installed) # -if test -x (which gettext) ^/dev/null >/dev/null +if type -f gettext >/dev/null function _ -d "Alias for the gettext command" gettext fish $argv end diff --git a/share/functions/__fish_print_packages.fish b/share/functions/__fish_print_packages.fish index 5c56a223f..77a7da253 100644 --- a/share/functions/__fish_print_packages.fish +++ b/share/functions/__fish_print_packages.fish @@ -12,7 +12,7 @@ function __fish_print_packages #Get the word 'Package' in the current language set -l package (_ Package) - if which apt-cache >/dev/null ^/dev/null + if type -f apt-cache >/dev/null # Apply the following filters to output of apt-cache: # 1) Remove package names with parentesis in them, since these seem to not correspond to actual packages as reported by rpm # 2) Remove package names that are .so files, since these seem to not correspond to actual packages as reported by rpm @@ -25,7 +25,7 @@ function __fish_print_packages # Rpm is too slow for this job, so we set it up to do completions # as a background job and cache the results. - if which rpm >/dev/null ^/dev/null + if type -f rpm >/dev/null # If the cache is less than five minutes old, we do not recalculate it @@ -46,7 +46,7 @@ function __fish_print_packages # This completes the package name from the portage tree. # True for installing new packages. Function for printing # installed on the system packages is in completions/emerge.fish - if which emerge >/dev/null ^/dev/null + if type -f emerge >/dev/null emerge -s \^(commandline -tc) |grep "^*" |cut -d\ -f3 |cut -d/ -f2 return end diff --git a/share/functions/help.fish b/share/functions/help.fish index ae5aa0a4f..5707f4f20 100644 --- a/share/functions/help.fish +++ b/share/functions/help.fish @@ -36,7 +36,7 @@ function help -d (N_ "Show help for the fish shell") else # Check for a text-based browser. for i in $text_browsers - if which $i 2>/dev/null >/dev/null + if type -f $i >/dev/null set fish_browser $i break end @@ -46,7 +46,7 @@ function help -d (N_ "Show help for the fish shell") # browser to use instead. if test "$DISPLAY" -a \( "$XAUTHORITY" = "$HOME/.Xauthority" -o "$XAUTHORITY" = "" \) for i in $graphical_browsers - if which $i 2>/dev/null >/dev/null + if type -f $i >/dev/null set fish_browser $i set fish_browser_bg 1 break @@ -79,7 +79,7 @@ function help -d (N_ "Show help for the fish shell") case $help_topics set fish_help_page "index.html\#$fish_help_item" case "*" - if which $fish_help_item >/dev/null ^/dev/null + if type -f $fish_help_item >/dev/null man $fish_help_item return end diff --git a/share/functions/type.fish b/share/functions/type.fish index 4b48c1223..f84548475 100644 --- a/share/functions/type.fish +++ b/share/functions/type.fish @@ -119,7 +119,7 @@ function type -d (N_ "Print the type of a command") printf (_ 'file\n') case path - which $i + echo $path end if test $selection != multi continue