aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/type.fish
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-07-10 00:18:50 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-07-13 19:11:29 -0700
commit6f7a7459c1dadc88e793b558d5ce2668359e7bea (patch)
tree5aa82504e3830808913fddde1532614cd65ce52d /share/functions/type.fish
parent6b062b07b4758883c3d2b7bb28791a86b267ba0a (diff)
test: Add a new --quiet flag to suppress output
The --quiet flag is useful when only the exit status matters. Fix the documentation for the -t flag to no longer claim that `type` can print "keyword", as it never does that. Stop printing a blank line for functions/builtins when the -p flag has been passed. It's just not useful.
Diffstat (limited to 'share/functions/type.fish')
-rw-r--r--share/functions/type.fish24
1 files changed, 13 insertions, 11 deletions
diff --git a/share/functions/type.fish b/share/functions/type.fish
index 9cadcabc..c54997dd 100644
--- a/share/functions/type.fish
+++ b/share/functions/type.fish
@@ -13,13 +13,19 @@ function type --description "Print the type of a command"
for i in (seq (count $argv))
switch $argv[$i]
case -t --type
- set mode type
+ if test $mode != quiet
+ set mode type
+ end
case -p --path
- set mode path
+ if test $mode != quiet
+ set mode path
+ end
case -P --force-path
- set mode path
+ if test $mode != quiet
+ set mode path
+ end
set selection files
case -a --all
@@ -28,6 +34,9 @@ function type --description "Print the type of a command"
case -f --no-functions
set selection files
+ case -q --quiet
+ set mode quiet
+
case -h --help
__fish_print_help type
return 0
@@ -61,10 +70,6 @@ function type --description "Print the type of a command"
case type
echo (_ 'function')
-
- case path
- echo
-
end
if test $multi != yes
continue
@@ -81,9 +86,6 @@ function type --description "Print the type of a command"
case type
echo (_ 'builtin')
-
- case path
- echo
end
if test $multi != yes
continue
@@ -116,7 +118,7 @@ function type --description "Print the type of a command"
end
end
- if test $found = 0
+ if begin; test $found = 0; and test $mode != quiet; end
printf (_ "%s: Could not find '%s'\n") type $i >&2
end