mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:17:12 +08:00
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
This commit is contained in:
parent
99a93b5add
commit
d58b9de63b
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user