diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-01-12 14:18:34 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-01-12 14:18:34 -0800 |
commit | dc37a8079e4b1a69300a4bf1bdd00f8e2c66e1d5 (patch) | |
tree | b2903cfe9c29a1c62d5a57250a8ef3c2d2b90878 /share/functions/type.fish | |
parent | 373cca0bf6834269c2b4fb6f27bcbf1c548ff983 (diff) |
Added a seq function that defers to the seq command if present
Diffstat (limited to 'share/functions/type.fish')
-rw-r--r-- | share/functions/type.fish | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/share/functions/type.fish b/share/functions/type.fish index 0c25b7ff..881bac04 100644 --- a/share/functions/type.fish +++ b/share/functions/type.fish @@ -5,25 +5,44 @@ function type --description "Print the type of a command" set -l res 1 set -l mode normal set -l selection all - + + set -l new_getopt + if not getopt -T > /dev/null + set new_getopt 1 + else + set new_getopt '' + end + # # Get options # - set -l shortopt -o tpPafh + set -l options + set -l shortopt tpPafh set -l longopt - if not getopt -T >/dev/null - set longopt -l type,path,force-path,all,no-functions,help - end - - if not getopt -n type -Q $shortopt $longopt -- $argv >/dev/null - return 1 + if test $new_getopt + # GNU getopt + set longopt type,path,force-path,all,no-functions,help + set options -o $shortopt -l $longopt -- + # Verify options + if not getopt -n type $options $argv >/dev/null + return 1 + end + else + # Old getopt, used on OS X + set options $shortopt + # Verify options + if not getopt $options $argv >/dev/null + return 1 + end end - set -l tmp (getopt $shortopt $longopt -- $argv) + # Do the real getopt invocation + set -l tmp (getopt $options $argv) + # Break tmp up into an array set -l opt eval set opt $tmp - + for i in $opt switch $i case -t --type |