Use _split_longopt in quota and friends.

This commit is contained in:
Ville Skyttä 2009-05-26 21:26:47 +03:00
parent 4e0c44027b
commit 90387f2355
2 changed files with 45 additions and 93 deletions

View File

@ -39,7 +39,8 @@ bash-completion (1.x)
take arguments in both "--foo bar" and "--foo=bar" formats. take arguments in both "--foo bar" and "--foo=bar" formats.
* Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig, * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig,
cpio, iptables, make, mc, mii-diag, mii-tool, mkinitrd, postgresql, cpio, iptables, make, mc, mii-diag, mii-tool, mkinitrd, postgresql,
samba, smartctl, and generic long option completion (Alioth: #311398). quota, samba, smartctl, and generic long option completion
(Alioth: #311398).
* Add chown --from and --reference value completions. * Add chown --from and --reference value completions.
* Add chgrp --reference value completion. * Add chgrp --reference value completion.
* Do not assume all --foo= options take filenames in generic long option * Do not assume all --foo= options take filenames in generic long option

View File

@ -35,32 +35,25 @@ _filesystems()
_quota() _quota()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-F) -F|--format)
_quota_formats _quota_formats
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == *=* ]]; then $split && return 0
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--format)
_quota_formats
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-F --format= -g --group -u --user -v --verbose \ COMPREPLY=( $( compgen -W '-F --format -g --group -u --user -v --verbose \
-s --human-readable -p --raw-grace -i --no-autofs -l --local-only \ -s --human-readable -p --raw-grace -i --no-autofs -l --local-only \
-A --all-nfs -m --no-mixed-pathnames -q --quiet -Q --quiet-refuse \ -A --all-nfs -m --no-mixed-pathnames -q --quiet -Q --quiet-refuse \
-w --no-wrap' -- $cur ) ) -w --no-wrap' -- $cur ) )
@ -72,33 +65,26 @@ complete -F _quota $default quota
_setquota() _setquota()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-F) -F|--format)
_quota_formats _quota_formats
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == *=* ]]; then $split && return 0
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--format)
_quota_formats
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \ COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
-F --format= -g --group -u --user -p --prototype= -b --batch \ -F --format -g --group -u --user -p --prototype -b --batch \
-c --continue-batch -t --edit-period -T --edit-times -a --all' -- $cur ) ) -c --continue-batch -t --edit-period -T --edit-times -a --all' -- $cur ) )
else else
_count_args _count_args
@ -118,14 +104,16 @@ complete -F _setquota $default setquota
_edquota() _edquota()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-F) -F|--format)
_quota_formats _quota_formats
return 0 return 0
;; ;;
@ -135,20 +123,11 @@ _edquota()
;; ;;
esac esac
if [[ "$cur" == *=* ]]; then $split && return 0
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--format)
_quota_formats
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \ COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
-g --group -u --user -p --prototype= -F --format= -f --filesystem \ -g --group -u --user -p --prototype -F --format -f --filesystem \
-t --edit-period -T --edit-times' -- $cur ) ) -t --edit-period -T --edit-times' -- $cur ) )
else else
_user_or_group _user_or_group
@ -158,35 +137,28 @@ complete -F _edquota $default edquota
_quotacheck() _quotacheck()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-F) -F|--format)
_quota_formats _quota_formats
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == *=* ]]; then $split && return 0
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--format)
_quota_formats
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b --backup -v --verbose -d --debug \ COMPREPLY=( $( compgen -W '-b --backup -v --verbose -d --debug \
-g --group -u --user -c --create-files -f --force -i \ -g --group -u --user -c --create-files -f --force -i \
--interactive -n --use-first-dquot -M --try-remount -m \ --interactive -n --use-first-dquot -M --try-remount -m \
--no-remount -R --exclude-root -F --format= -a --all' \ --no-remount -R --exclude-root -F --format -a --all' \
-- $cur ) ) -- $cur ) )
else else
_filesystems _filesystems
@ -196,35 +168,28 @@ complete -F _quotacheck $default quotacheck
_repquota() _repquota()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-F) -F|--format)
_quota_formats _quota_formats
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == *=* ]]; then $split && return 0
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--format)
_quota_formats
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -v --verbose -s --human-readable \ COMPREPLY=( $( compgen -W '-a --all -v --verbose -s --human-readable \
-c --batch-translation -C --no-batch-translation -t \ -c --batch-translation -C --no-batch-translation -t \
--truncate-names -n --no-names -p --raw-grace -i --no-autofs \ --truncate-names -n --no-names -p --raw-grace -i --no-autofs \
-u --user -g --group -F --format=' -- $cur ) ) -u --user -g --group -F --format' -- $cur ) )
else else
_filesystems _filesystems
fi fi
@ -233,33 +198,26 @@ complete -F _repquota $default repquota
_quotaon() _quotaon()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-F) -F|--format)
_quota_formats _quota_formats
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == *=* ]]; then $split && return 0
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--format)
_quota_formats
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \ COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
-g --group -f --off -p --print-state -F --format=' -- $cur ) ) -g --group -f --off -p --print-state -F --format' -- $cur ) )
else else
_filesystems _filesystems
fi fi
@ -268,14 +226,16 @@ complete -F _quotaon $default quotaon
_quotaoff() _quotaoff()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case $prev in case $prev in
-F) -F|--format)
_quota_formats _quota_formats
return 0 return 0
;; ;;
@ -285,20 +245,11 @@ _quotaoff()
;; ;;
esac esac
if [[ "$cur" == *=* ]]; then $split && return 0
prev=${cur/=*/}
cur=${cur/*=/}
case $prev in
--format)
_quota_formats
return 0
;;
esac
fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \ COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
-g --group -p --print-state -x --xfs-command -F --format=' \ -g --group -p --print-state -x --xfs-command -F --format' \
-- $cur ) ) -- $cur ) )
else else
_filesystems _filesystems