summaryrefslogtreecommitdiff
path: root/completions/gzip
diff options
context:
space:
mode:
authorDavid Paleino <dapal@debian.org>2011-11-03 12:32:52 +0100
committerDavid Paleino <dapal@debian.org>2011-11-03 12:32:52 +0100
commit2c8171c38d87ddef31c92a76547d3fdf773a1337 (patch)
tree5e720d5a06ead72ed55454bf6647a712a761ed91 /completions/gzip
parent9920a8faedf704420571d8072ccab27e9dac40ba (diff)
downloadbash-completion-2c8171c38d87ddef31c92a76547d3fdf773a1337.tar.gz
Imported Upstream version 1.90upstream/1.90
Diffstat (limited to 'completions/gzip')
-rw-r--r--completions/gzip28
1 files changed, 7 insertions, 21 deletions
diff --git a/completions/gzip b/completions/gzip
index f7aec17e..87219630 100644
--- a/completions/gzip
+++ b/completions/gzip
@@ -1,13 +1,9 @@
-# bash completion for gzip
+# bash completion for gzip -*- shell-script -*-
-have gzip || have pigz &&
_gzip()
{
- local cur prev xspec helpopts
-
- COMPREPLY=()
- _get_comp_words_by_ref cur prev
- helpopts=`_parse_help ${COMP_WORDS[0]}`
+ local cur prev words cword
+ _init_completion || return
case $prev in
-b|--blocksize|-p|--processes|-S|--suffix|-h|--help|-V|--version)
@@ -16,14 +12,14 @@ _gzip()
esac
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W "$helpopts -1 -2 -3 -4 -5 -6 -7 -8 -9" \
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) {-1..-9}' \
-- "$cur" ) )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
return 0
fi
- local IFS=$'\n'
+ local IFS=$'\n' xspec="*.@(gz|t[ag]z)"
- xspec="*.@(gz|t[ag]z)"
if [[ "$prev" == --* ]]; then
[[ "$prev" == --decompress || \
"$prev" == --list || \
@@ -32,24 +28,14 @@ _gzip()
elif [[ "$prev" == -* ]]; then
[[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
[[ "$prev" == -*f* ]] && xspec=
- elif [[ "$prev" == '>' || "$prev" == '>>' ]]; then
- xspec=
- elif [ "$prev" = '<' ]; then
- xspec=
fi
_expand || return 0
- _compopt_o_filenames
+ compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
} &&
complete -F _gzip gzip pigz
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
# ex: ts=4 sw=4 et filetype=sh