bash < 3 support removal step 1: drop unneeded conditional sections.

This commit is contained in:
Ville Skyttä 2009-10-22 11:15:27 +03:00
parent bc6ad9b75b
commit 6862bb45c1
5 changed files with 21 additions and 30 deletions

View File

@ -23,6 +23,7 @@ bash-completion (1.x)
* Speed up installed rpm package completion on SUSE, based on work by
Marco Poletti (Alioth: #312021).
* Improve sourcing snippets from completion dirs.
* Drop support for bash < 3.
-- David Paleino <d.paleino@gmail.com> Sun, 11 Oct 2009 11:11:57 +0200

View File

@ -662,10 +662,10 @@ _usergroup()
{
local IFS=$'\n'
cur=${cur//\\\\ / }
if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then
if [[ $cur = *@(\\:|.)* ]]; then
user=${cur%%*([^:.])}
COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) )
elif [[ $cur = *:* ]] && [ -n "$bash205" ]; then
elif [[ $cur = *:* ]]; then
COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) )
else
COMPREPLY=( $( compgen -S : -u -- "$cur" ) )
@ -845,7 +845,7 @@ _chgrp()
# first parameter on line or first since an option?
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
[[ "$prev" == -* ]] && [ -n "$bash205" ]; then
[[ "$prev" == -* ]]; then
local IFS=$'\n'
COMPREPLY=( $( compgen -g "$cur" 2>/dev/null ) )
else

View File

@ -73,7 +73,7 @@ complete -F _function function declare typeset
#
_complete()
{
local cur prev options
local cur prev
COMPREPLY=()
cur=`_get_cword`
@ -81,10 +81,8 @@ _complete()
case $prev in
-o)
options="default dirnames filenames"
[ -n "$bash205b" ] && options="$options nospace"
[ -n "$bash3" ] && options="$options bashdefault plusdirs"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
COMPREPLY=( $( compgen -W 'bashdefault default dirnames filenames \
nospace plusdirs' -- "$cur" ) )
return 0
;;
@ -115,9 +113,8 @@ _complete()
if [[ "$cur" == -* ]]; then
# relevant options completion
options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
[ -n "$bash205" ] && options="$options -o"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
COMPREPLY=( $( compgen -W '-a -b -c -d -e -f -g -j -k -o -s -v -u -A \
-G -W -P -S -X -F -C' -- "$cur" ) )
else
COMPREPLY=( $( compgen -A command -- "$cur" ) )
fi

View File

@ -32,9 +32,7 @@ _find()
return 0
;;
-group)
if [ -n "$bash205" ]; then
COMPREPLY=( $( compgen -g -- $cur 2>/dev/null) )
fi
COMPREPLY=( $( compgen -g -- "$cur" 2>/dev/null) )
return 0
;;
-?(x)type)

View File

@ -24,14 +24,12 @@ _useradd()
;;
-g|--gid)
_gids
[ -n "$bash205" ] && \
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -g ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \
-- "$cur" ) )
return 0
;;
-G|--groups)
[ -n "$bash205" ] && \
COMPREPLY=( $( compgen -g -- "$cur" ) )
COMPREPLY=( $( compgen -g -- "$cur" ) )
return 0
;;
-s|--shell)
@ -73,14 +71,12 @@ _usermod()
;;
-g|--gid)
_gids
[ -n "$bash205" ] && \
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -g ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $( compgen -g )' \
-- "$cur" ) )
return 0
;;
-G|--groups)
[ -n "$bash205" ] && \
COMPREPLY=( $( compgen -g -- "$cur" ) )
COMPREPLY=( $( compgen -g -- "$cur" ) )
return 0
;;
-s|--shell)
@ -316,11 +312,11 @@ _groupmod()
return 0
fi
[ -n "$bash205" ] && COMPREPLY=( $( compgen -g -- "$cur" ) )
COMPREPLY=( $( compgen -g -- "$cur" ) )
} &&
complete -F _groupmod groupmod
[ -n "$bash205" ] && complete -g groupdel
complete -g groupdel
have newgrp &&
_newgrp()
@ -330,7 +326,7 @@ _newgrp()
COMPREPLY=( - )
fi
} &&
complete ${bash205:+-g} -F _newgrp newgrp
complete -g -F _newgrp newgrp
have gpasswd &&
_gpasswd()
@ -353,7 +349,7 @@ _gpasswd()
return 0
fi
[ -n "$bash205" ] && COMPREPLY=( $( compgen -g -- "$cur" ) )
COMPREPLY=( $( compgen -g -- "$cur" ) )
} &&
complete -F _gpasswd gpasswd
@ -372,8 +368,7 @@ _groupmems()
return 0
;;
-g)
[ -n "$bash205" ] && \
COMPREPLY=( $( compgen -g -- "$cur" ) )
COMPREPLY=( $( compgen -g -- "$cur" ) )
return 0
;;
esac