diff options
author | Kevin Ballard <kevin@sb.org> | 2014-07-10 00:07:58 -0700 |
---|---|---|
committer | Kevin Ballard <kevin@sb.org> | 2014-07-13 19:11:29 -0700 |
commit | 6b062b07b4758883c3d2b7bb28791a86b267ba0a (patch) | |
tree | 8dbe637b7ec8395a71b37832fa12f2bcb2e693c4 /share/functions/type.fish | |
parent | bfd3a47380f65e24ff568efd1570338298d56200 (diff) |
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.
Diffstat (limited to 'share/functions/type.fish')
-rw-r--r-- | share/functions/type.fish | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/share/functions/type.fish b/share/functions/type.fish index 2ddcc622..9cadcabc 100644 --- a/share/functions/type.fish +++ b/share/functions/type.fish @@ -4,6 +4,7 @@ function type --description "Print the type of a command" # Initialize set -l res 1 set -l mode normal + set -l multi no set -l selection all # Parse options @@ -22,7 +23,7 @@ function type --description "Print the type of a command" set selection files case -a --all - set selection multi + set multi yes case -f --no-functions set selection files @@ -65,7 +66,7 @@ function type --description "Print the type of a command" echo end - if test $selection != multi + if test $multi != yes continue end end @@ -84,7 +85,7 @@ function type --description "Print the type of a command" case path echo end - if test $selection != multi + if test $multi != yes continue end end @@ -92,7 +93,7 @@ function type --description "Print the type of a command" end set -l paths - if test $selection != multi + if test $multi != yes set paths (command -p $i) else set paths (which -a $i ^/dev/null) @@ -110,7 +111,7 @@ function type --description "Print the type of a command" case path echo $path end - if test $selection != multi + if test $multi != yes continue end end |