mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
type: Restore combined flags behavior
Fix the parsing of `type` flags to handle combined short flags as appropriate, e.g. `type -qf ls`.
This commit is contained in:
parent
cce4265cef
commit
16e50c258a
1 changed files with 53 additions and 32 deletions
|
@ -11,44 +11,65 @@ function type --description "Print the type of a command"
|
||||||
set -l names
|
set -l names
|
||||||
if test (count $argv) -gt 0
|
if test (count $argv) -gt 0
|
||||||
for i in (seq (count $argv))
|
for i in (seq (count $argv))
|
||||||
switch $argv[$i]
|
set -l arg $argv[$i]
|
||||||
case -t --type
|
set -l needbreak 0
|
||||||
if test $mode != quiet
|
while test -n $arg
|
||||||
set mode type
|
set -l flag $arg
|
||||||
end
|
set arg ''
|
||||||
|
switch $flag
|
||||||
|
case '--*'
|
||||||
|
# do nothing; this just prevents it matching the next case
|
||||||
|
case '-??*'
|
||||||
|
# combined flags
|
||||||
|
set -l IFS
|
||||||
|
echo -n $flag | read _ flag arg
|
||||||
|
set flag -$flag
|
||||||
|
set arg -$arg
|
||||||
|
end
|
||||||
|
switch $flag
|
||||||
|
case -t --type
|
||||||
|
if test $mode != quiet
|
||||||
|
set mode type
|
||||||
|
end
|
||||||
|
|
||||||
case -p --path
|
case -p --path
|
||||||
if test $mode != quiet
|
if test $mode != quiet
|
||||||
set mode path
|
set mode path
|
||||||
end
|
end
|
||||||
|
|
||||||
case -P --force-path
|
case -P --force-path
|
||||||
if test $mode != quiet
|
if test $mode != quiet
|
||||||
set mode path
|
set mode path
|
||||||
end
|
end
|
||||||
set selection files
|
set selection files
|
||||||
|
|
||||||
case -a --all
|
case -a --all
|
||||||
set multi yes
|
set multi yes
|
||||||
|
|
||||||
case -f --no-functions
|
case -f --no-functions
|
||||||
set selection files
|
set selection files
|
||||||
|
|
||||||
case -q --quiet
|
case -q --quiet
|
||||||
set mode quiet
|
set mode quiet
|
||||||
|
|
||||||
case -h --help
|
case -h --help
|
||||||
__fish_print_help type
|
__fish_print_help type
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
case --
|
case --
|
||||||
set names $argv[$i..-1]
|
set names $argv[$i..-1]
|
||||||
set -e names[1]
|
set -e names[1]
|
||||||
break
|
set needbreak 1
|
||||||
|
break
|
||||||
|
|
||||||
case '*'
|
case '*'
|
||||||
set names $argv[$i..-1]
|
set names $argv[$i..-1]
|
||||||
break
|
set needbreak 1
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if test $needbreak -eq 1
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -96,9 +117,9 @@ function type --description "Print the type of a command"
|
||||||
|
|
||||||
set -l paths
|
set -l paths
|
||||||
if test $multi != yes
|
if test $multi != yes
|
||||||
set paths (command -s $i)
|
set paths (command -s -- $i)
|
||||||
else
|
else
|
||||||
set paths (which -a $i ^/dev/null)
|
set paths (which -a -- $i ^/dev/null)
|
||||||
end
|
end
|
||||||
for path in $paths
|
for path in $paths
|
||||||
set res 0
|
set res 0
|
||||||
|
|
Loading…
Reference in a new issue