- make chown completion work, whether or not the colon between user and

group name is escaped (fix from Oliver Kiddle <okiddle@yahoo.co.uk>)
This commit is contained in:
ianmacd 2003-08-18 07:54:07 +00:00
parent 943f46c373
commit fd904666c5

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05b # bash_completion - some programmable completion functions for bash 2.05b
# #
# $Id: bash_completion,v 1.612 2003/08/18 09:33:29 ianmacd Exp $ # $Id: bash_completion,v 1.613 2003/08/18 09:54:07 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -459,11 +459,9 @@ _service()
# #
_chown() _chown()
{ {
local cur prev user group i local user
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=() local prev=${COMP_WORDS[COMP_CWORD-1]}
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
# options completion # options completion
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
@ -473,22 +471,19 @@ _chown()
return 0 return 0
fi fi
# first parameter on line or first since an option? if (( COMP_CWORD == 1 )) || [[ "$prev" == -* ]]; then
if [ $COMP_CWORD -eq 1 ] || [[ "$prev" == -* ]]; then if [[ $cur = *@(\\:|.)* ]] && \
if [[ "$cur" == [a-zA-Z]*[.:]* ]] && \
[[ ${BASH_VERSINFO[1]} > 04 ]]; then [[ ${BASH_VERSINFO[1]} > 04 ]]; then
user=${cur%%?(\\)[.:]*} user=${cur%%*([^:.])}
group=${cur#*[.:]} COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) )
COMPREPLY=( $( compgen -P $user':' \ elif [[ $cur = *:* ]] && [[ ${BASH_VERSINFO[1]} > 04 ]]; then
-g -- $group 2>/dev/null) ) COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) )
else else
COMPREPLY=( $( compgen -S ':' -u $cur ) ) COMPREPLY=( $( compgen -S : -u -- $cur ) )
fi fi
else else
_filedir _filedir
fi fi
return 0
} }
complete -F _chown $filenames chown complete -F _chown $filenames chown