mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
type: Separate the notion of multi and paths
Track whether -a and -f have been supplied separately. That way both `type -a -f command` and `type -f -a command` behaves correctly, as does `type -a -f foo` where there are multiple executables named `foo` in the $PATH.
This commit is contained in:
parent
bfd3a47380
commit
6b062b07b4
1 changed files with 6 additions and 5 deletions
|
@ -4,6 +4,7 @@ function type --description "Print the type of a command"
|
||||||
# Initialize
|
# Initialize
|
||||||
set -l res 1
|
set -l res 1
|
||||||
set -l mode normal
|
set -l mode normal
|
||||||
|
set -l multi no
|
||||||
set -l selection all
|
set -l selection all
|
||||||
|
|
||||||
# Parse options
|
# Parse options
|
||||||
|
@ -22,7 +23,7 @@ function type --description "Print the type of a command"
|
||||||
set selection files
|
set selection files
|
||||||
|
|
||||||
case -a --all
|
case -a --all
|
||||||
set selection multi
|
set multi yes
|
||||||
|
|
||||||
case -f --no-functions
|
case -f --no-functions
|
||||||
set selection files
|
set selection files
|
||||||
|
@ -65,7 +66,7 @@ function type --description "Print the type of a command"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
end
|
end
|
||||||
if test $selection != multi
|
if test $multi != yes
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -84,7 +85,7 @@ function type --description "Print the type of a command"
|
||||||
case path
|
case path
|
||||||
echo
|
echo
|
||||||
end
|
end
|
||||||
if test $selection != multi
|
if test $multi != yes
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -92,7 +93,7 @@ function type --description "Print the type of a command"
|
||||||
end
|
end
|
||||||
|
|
||||||
set -l paths
|
set -l paths
|
||||||
if test $selection != multi
|
if test $multi != yes
|
||||||
set paths (command -p $i)
|
set paths (command -p $i)
|
||||||
else
|
else
|
||||||
set paths (which -a $i ^/dev/null)
|
set paths (which -a $i ^/dev/null)
|
||||||
|
@ -110,7 +111,7 @@ function type --description "Print the type of a command"
|
||||||
case path
|
case path
|
||||||
echo $path
|
echo $path
|
||||||
end
|
end
|
||||||
if test $selection != multi
|
if test $multi != yes
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue