[Bash-completion-devel] Ubuntu (new upstream) bash-completion 20060301-4ubuntu1

Ubuntu Merge-o-Matic mom at ubuntu.com
Fri Jun 20 03:31:34 UTC 2008


This e-mail has been sent due to an upload to Ubuntu of a new upstream
version which still contains Ubuntu changes.  It contains the difference
between the Ubuntu version and the equivalent base version in Debian, note
that this difference may include the upstream changes.
-------------- next part --------------
Format: 1.7
Date: Thu, 19 Jun 2008 11:58:17 -0700
Source: bash-completion
Binary: bash-completion
Architecture: source
Version: 20060301-4ubuntu1
Distribution: intrepid
Urgency: low
Maintainer: Ubuntu MOTU Developers <ubuntu-motu at lists.ubuntu.com>
Changed-By: Bryce Harrington <bryce at ubuntu.com>
Description: 
 bash-completion - programmable completion for the bash shell
Closes: 351913 400380 435117 452083 468254 471249 471666
Changes: 
 bash-completion (20060301-4ubuntu1) intrepid; urgency=low
 .
   * Merge from debian unstable, remaining changes:
    - Don't use ucf for handling the bash_completion config file. (LP: 210013)
    - Fix _get_cword more
    - Fix _command function to correctly prune the command line (LP: 103395)
    - Remove newline from options pattern for dpkg (LP: 138312)
    - Start readline-quoting arguments to compgen (LP: 123665)
    - Save and restore -v shell option (LP: 205444)
    - Prevent glob expansion in _filedir function (LP: 194419)
    - Quote glob expression in tar completion function (LP: 194419)
    - Complete AAS/SSA files for mplayer -sub (LP: 151086)
    - Disable completion of postgresql users and databases (LP: 164772)
    - Use files from UserKnownHostsFile options in addition to standard ones
      (LP: 211180)
    - Fixed completion of hostnames and files with scp
    - Fix tar completion to handle "tar rf" the same as "tar cf" (LP: 94407)
    - Complete .divx and .flv for media players (LP: 127605)
    - Complete all files for "gzip ... <" (LP: 127605)
    - Allow whitespace in front of GlobalKnownHostsFile etc. (LP: 128866)
    - Complete compressed files for vim (LP: 149494)
    - Always use /etc/hosts and $HOSTFILE for host completion too (LP: 184175)
    - Modify Maintainer value to match the DebianMaintainerField
      specification.
 .
 bash-completion (20060301-4) unstable; urgency=low
 .
   * Add some fixes from Ubuntu:
   * Fix completion of filenames with spaces (Closes: #468254).
   * Fix parsing of SSH config files (Closes: #435117).
   * Change priority to standard (Closes: #471666).
   * Add some more completions for xine (Closes: #452083, #471249).
   * Fix completion of gzip (Closes: #351913).
   * Also use $HOSTFILE in hostname completion (Closes: #400380).
Files: 
 b2ead33bec88616a442e45263dab6bbb 1117 shells standard bash-completion_20060301-4ubuntu1.dsc
 89eece2e2492ab28248ea73581f37b8c 20360 shells standard bash-completion_20060301-4ubuntu1.diff.gz
Original-Maintainer: Luk Claes <luk at debian.org>
-------------- next part --------------
diff -pruN 20060301-4/bash_completion 20060301-4ubuntu1/bash_completion
--- 20060301-4/bash_completion	2008-06-20 04:17:09.000000000 +0100
+++ 20060301-4ubuntu1/bash_completion	2008-06-20 04:15:11.000000000 +0100
@@ -25,7 +25,17 @@
 #
 #   RELEASE: 20060301
 
-[ -n "${BASH_COMPLETION_DEBUG:-}" ] && set -v || set +v
+if [[ $- == *v* ]]; then
+	BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
+else
+	BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
+fi
+
+if [[ -n $BASH_COMPLETION_DEBUG ]]; then
+	set -v
+else
+	set +v
+fi
 
 # Alter the following to reflect the location of this file.
 #
@@ -177,6 +187,27 @@ _rl_enabled() 
     [[ "$( bind -v )" = *$1+([[:space:]])on* ]]
 }
 
+# This function shell-quotes the argument
+quote()
+{
+	echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
+}
+
+# This function quotes the argument in a way so that readline dequoting
+# results in the original argument
+quote_readline()
+{
+	local t="${1//\\/\\\\}"
+	echo \'${t//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
+}
+
+# This function shell-dequotes the argument
+dequote()
+{
+	eval echo "$1"
+}
+
+
 # Get the word to complete
 # This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases
 # where the user is completing in the middle of a word.
@@ -189,29 +220,32 @@ _rl_enabled() 
 # for things like scp where we want to return host:path and not only path.
 _get_cword()
 {
-	local i
-	local WORDBREAKS=${COMP_WORDBREAKS}
-	if [ -n $1 ]; then
-		for (( i=0; i<${#1}; ++i )); do
-			local char=${1:$i:1}
-			WORDBREAKS=${WORDBREAKS//$char/}
+	if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
+		echo "${COMP_WORDS[COMP_CWORD]}"
+	else
+		local i
+		local cur="$COMP_LINE"
+		local index="$COMP_POINT"
+		for (( i = 0; i <= COMP_CWORD; ++i )); do
+			while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
+				cur="${cur:1}"
+				index="$(( index - 1 ))"
+			done
+			if [[ "$i" -lt "$COMP_CWORD" ]]; then
+				local old_size="${#cur}"
+				cur="${cur#${COMP_WORDS[i]}}"
+				local new_size="${#cur}"
+				index="$(( index - old_size + new_size ))"
+			fi
 		done
-	fi
-	local cur=${COMP_LINE:0:$COMP_POINT}
-	local tmp="${cur}"
-	local word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
-	while [ "$word_start" -ge 2 ]; do
-        	local char=${cur:$(( $word_start - 2 )):1}
-		if [ "$char" != "\\" ]; then
-			break
-		fi
-		tmp=${COMP_LINE:0:$(( $word_start - 2 ))}
-		word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
-	done
 
-
-	cur=${cur:$word_start}
-	echo $cur
+		if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
+			# We messed up! At least return the whole word so things keep working
+			echo "${COMP_WORDS[COMP_CWORD]}"
+		else
+			echo "${cur:0:$index}"
+		fi
+	fi
 }
 
 
@@ -222,23 +256,23 @@ _get_cword()
 #
 _filedir()
 {
-	local IFS=$'\t\n' xspec #glob
+	local IFS=$'\t\n' xspec
 
 	_expand || return 0
 
-	#glob=$(set +o|grep noglob) # save glob setting.
-	#set -f		 # disable pathname expansion (globbing)
-
-	if [ "${1:-}" = -d ]; then
-		COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -d -- $cur ) )
-		#eval "$glob"    # restore glob setting.
-		return 0
+	local toks=( ) tmp
+	while read -r tmp; do
+		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
+	done < <( compgen -d -- "$(quote_readline "$cur")" )
+
+	if [[ "$1" != -d ]]; then
+		xspec=${1:+"!*.$1"}
+		while read -r tmp; do
+			[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
+		done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" )
 	fi
 
-	xspec=${1:+"!*.$1"}	# set only if glob passed in as $1
-	COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \
-		    $( compgen -d -- "$cur" ) )
-	#eval "$glob"    # restore glob setting.
+	COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
 }
 
 # This function completes on signal names
@@ -307,12 +341,12 @@ _available_interfaces()
 #
 _expand()
 {
-	[ "$cur" != "${cur%\\}" ] && cur="$cur\\"
+	# FIXME: Why was this here?
+	# [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
 
 	# expand ~username type directory specifications
 	if [[ "$cur" == \~*/* ]]; then
 		eval cur=$cur
-		
 	elif [[ "$cur" == \~* ]]; then
 		cur=${cur#\~}
 		COMPREPLY=( $( compgen -P '~' -u $cur ) )
@@ -386,7 +420,7 @@ _services()
 	COMPREPLY=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) )
 
 	if [ -d $famdir ]; then
-		COMPREPLY=( ${COMPREPLY[@]} $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
+		COMPREPLY=( "${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
 	fi
 
 	COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
@@ -1042,7 +1076,7 @@ _find()
 			    # remove word from list of completions
 			    COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
 			done
-			echo ${COMPREPLY[@]})
+			echo "${COMPREPLY[@]}")
 		  ) )
 	
 	_filedir
@@ -1071,7 +1105,7 @@ _iwconfig()
 		essid)
 			COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
 			if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
-				COMPREPLY=( ${COMPREPLY[@]:-} \
+				COMPREPLY=( "${COMPREPLY[@]}" \
 					$( iwlist ${COMP_WORDS[1]} scan | \
 					awk -F '"' '/ESSID/ {print $2}' | \
 					grep "^$cur" ))
@@ -1098,7 +1132,7 @@ _iwconfig()
 		ap)
 			COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
 			if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
-				COMPREPLY=( ${COMPREPLY[@]:-} \
+				COMPREPLY=( "${COMPREPLY[@]}" \
 					$( iwlist ${COMP_WORDS[1]} scan | \
 					awk -F ': ' '/Address/ {print $2}' | \
 					grep "^$cur" ) )
@@ -1107,7 +1141,7 @@ _iwconfig()
 			;;
 		rate)
 			COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) )
-			COMPREPLY=( ${COMPREPLY[@]:-} \
+			COMPREPLY=( "${COMPREPLY[@]}" \
 				$( iwlist ${COMP_WORDS[1]} rate | \
 				awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \
 				grep "^$cur" ) )
@@ -1392,7 +1426,7 @@ _postcat()
 	fi
 
 	qfile=0
-	for idx in ${COMP_WORDS[@]}; do
+	for idx in "${COMP_WORDS[@]}"; do
 		[[ "$idx" = -q ]] && qfile=1 && break
 	done
 	if [[ $qfile == 1 ]]; then
@@ -1536,7 +1570,7 @@ _cvs()
 	cur=`_get_cword`
 
 	count=0
-	for i in ${COMP_WORDS[@]}; do
+	for i in "${COMP_WORDS[@]}"; do
 		[ $count -eq $COMP_CWORD ] && break
 		# Last parameter was the CVSROOT, now go back to mode selection
 		if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
@@ -1606,7 +1640,7 @@ _cvs()
 				;;
 			esac
 		elif [[ "$i" = -* ]]; then
-			flags=( ${flags[@]:-} $i )
+			flags=( "${flags[@]}" $i )
 		fi
 		count=$((++count))
 	done
@@ -1620,7 +1654,7 @@ _cvs()
 				[ -z "$cur" ] && \
 				files=$( command ls -Ad !(CVS) ) || \
 				files=$( command ls -d ${cur}* 2>/dev/null )
-				for i in ${entries[@]:-}; do
+				for i in "${entries[@]}"; do
 					files=( ${files[@]/#$i//} )
 				done
 				COMPREPLY=( $( compgen -W '${files[@]}' -- \
@@ -1714,8 +1748,8 @@ _cvs()
 			if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
 				get_entries
 				# find out what files are missing
-				for i in ${entries[@]}; do
-					[ ! -r "$i" ] && miss=( ${miss[@]:-} $i )
+				for i in "${entries[@]}"; do
+					[ ! -r "$i" ] && miss=( "${miss[@]}" $i )
 				done
 				COMPREPLY=( $(compgen -W '${miss[@]:-}' -- $cur) )
 			fi
@@ -1806,7 +1840,7 @@ _rpm_groups()
 	COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
 		       grep "^$cur" ) )
 	# backslash escape spaces and translate newlines to tabs
-	COMPREPLY=( $( echo ${COMPREPLY[@]} | sed 's/ /\\ /g' | tr '\n' '\t' ) )
+	COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
 }
 
 # rpm(8) completion
@@ -2477,33 +2511,29 @@ _known_hosts()
 	    user_kh=$( eval echo $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) )
 	fi
 
-	# choose which global known hosts file to use
-	if [ -r "$global_kh" ]; then
-	    kh=( "$global_kh" )
-	else
-	    [ -r /etc/ssh/ssh_known_hosts ] &&
-	      kh=( ${kh[@]} /etc/ssh/ssh_known_hosts )
-	    [ -r /etc/ssh/ssh_known_hosts2 ] &&
-	      kh=( ${kh[@]} /etc/ssh/ssh_known_hosts2 )
-	    [ -r /etc/known_hosts ] &&
-	      kh=( ${kh[@]} /etc/known_hosts )
-	    [ -r /etc/known_hosts2 ] &&
-	      kh=( ${kh[@]} /etc/known_hosts2 )
-	    [ -d /etc/ssh2/knownhosts ] &&
-	      khd=( ${khd[@]} /etc/ssh2/knownhosts/*pub )
-	fi
-
-	# choose which user known hosts file to use
-	if [ -r "$user_kh" ]; then
-	    kh=( ${kh[@]} "$user_kh" )
-	else
-	    [ -r ~/.ssh/known_hosts ] &&
-	      kh=( ${kh[@]} ~/.ssh/known_hosts )
-	    [ -r ~/.ssh/known_hosts2 ] &&
-	      kh=( ${kh[@]} ~/.ssh/known_hosts2 )
-	    [ -d ~/.ssh2/hostkeys ] &&
-	      khd=( ${khd[@]} ~/.ssh2/hostkeys/*pub )
-	fi
+	# Global known_hosts files
+	[ -r "$global_kh" ] &&
+	    kh=( "${kh[@]}" "$global_kh" )
+	[ -r /etc/ssh/ssh_known_hosts ] &&
+	    kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
+	[ -r /etc/ssh/ssh_known_hosts2 ] &&
+	    kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
+	[ -r /etc/known_hosts ] &&
+	    kh=( "${kh[@]}" /etc/known_hosts )
+	[ -r /etc/known_hosts2 ] &&
+	    kh=( "${kh[@]}" /etc/known_hosts2 )
+	[ -d /etc/ssh2/knownhosts ] &&
+	    khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
+
+	# User known_hosts files
+	[ -r "$user_kh" ] &&
+	    kh=( "${kh[@]}" "$user_kh" )
+	[ -r ~/.ssh/known_hosts ] &&
+	    kh=( "${kh[@]}" ~/.ssh/known_hosts )
+	[ -r ~/.ssh/known_hosts2 ] &&
+	    kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
+	[ -d ~/.ssh2/hostkeys ] &&
+	    khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
 
 	# If we have known_hosts files to use
 	if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
@@ -2533,30 +2563,31 @@ _known_hosts()
 				/^[^|]/ {for (i=1; i<=2; ++i) { \
 				       gsub(" .*$", "", $i); \
 				       if ($i ~ /'$cur'/) {print $i} \
-				}}' ${kh[@]} 2>/dev/null ) )
+				}}' "${kh[@]}" 2>/dev/null ) )
 	    fi
 	    if [ ${#khd[@]} -gt 0 ]; then
 		# Needs to look for files called
 		# .../.ssh2/key_22_<hostname>.pub
 		# dont fork any processes, because in a cluster environment, 
 		# there can be hundreds of hostkeys
-		for i in ${khd[@]} ; do
+		for i in "${khd[@]}" ; do
 		    if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ] ; then
 			host=${i/#*key_22_/}
 			host=${host/%.pub/}
-			COMPREPLY=( ${COMPREPLY[@]} $host )
+			COMPREPLY=( "${COMPREPLY[@]}" $host )
 		    fi
 		done
 	    fi
+
 	    # append any available aliases from config files
 	    if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
-		local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']*\([^*?]*\)$/\2/p' "${config[@]}" )
+		local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" )
 		hosts=$( compgen -W "$host_aliases" -- $ocur )
-		COMPREPLY=( ${COMPREPLY[@]} $hosts )
+		COMPREPLY=( "${COMPREPLY[@]}" $hosts )
 	    fi
 
 	    # Now add results of normal hostname completion
-	    COMPREPLY=( ${COMPREPLY[@]} $( compgen -A hostname -- $ocur ) )
+	    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ) )
 
 	    # apply suffix
 	    for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
@@ -2599,7 +2630,7 @@ _ssh()
 	    _known_hosts -a
 
 	    [ $COMP_CWORD -eq 1 ] || \
-		COMPREPLY=( ${COMPREPLY[@]} $( compgen -c -- $cur ) )
+		COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
 	esac
 
 	return 0
@@ -2640,7 +2671,7 @@ _scp()
 
 	[[ "$cur" == */* ]] || _known_hosts -c -a
 		local IFS=$'\t\n'
-		COMPREPLY=( ${COMPREPLY[@]} $( command ls -aF1d $cur* \
+		COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
 			    2>/dev/null | sed \
 			    -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
 			    -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
@@ -2772,7 +2803,7 @@ _route()
 			   # remove word from list of completions
 			   COMPREPLY=( ${COMPREPLY/ $i / } )
 			done
-		       echo ${COMPREPLY[@]})
+		       echo "${COMPREPLY[@]}")
 		  ) )
 	return 0
 }
@@ -2931,7 +2962,7 @@ _tar()
 	fi
 
 	# file completion on relevant files
-	_filedir $ext
+	_filedir "$ext"
 
 	return 0
 }
@@ -3103,7 +3134,7 @@ _cd()
 	# we have a CDPATH, so loop on its contents
 	for i in ${CDPATH//:/$'\t'}; do
 		# create an array of matched subdirs
-		k=${#COMPREPLY[@]}
+		k="${#COMPREPLY[@]}"
 		for j in $( compgen -d $i/$cur ); do
 			if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
 				j="${j}/"
@@ -3129,6 +3160,37 @@ else
     complete -F _cd $nospace $filenames cd
 fi
 
+_remove_comp_word()
+{
+	if [[ COMP_CWORD -eq 0 ]]; then
+		return
+	elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
+		local old_cw0="${COMP_WORDS[0]}"
+		local new_cw0="${COMP_WORDS[1]}"
+		local old_length="${#COMP_LINE}"
+		COMP_LINE=${COMP_LINE#${old_cw0}}
+		local head=${COMP_LINE:0:${#new_cw0}}
+		local i=1
+		while [[ $head != $new_cw0 ]]; do
+			COMP_LINE=${COMP_LINE:1}
+			head=${COMP_LINE:0:${#new_cw0}}
+			if (( ++i > 10 )); then
+				break
+			fi
+		done
+		local new_length="${#COMP_LINE}"
+		COMP_POINT=$(( COMP_POINT + new_length - old_length))
+
+		COMP_CWORD=$(( COMP_CWORD - 1 ))
+		for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do
+			COMP_WORDS[i]="${COMP_WORDS[i+1]}"
+		done
+		unset COMP_WORDS[${#COMP_WORDS[@]}-1]
+	else
+		return
+	fi
+}
+
 # A meta-command completion function for commands like sudo(8), which need to
 # first complete on a command, then complete according to that command's own
 # completion definition - currently not quite foolproof (e.g. mount and umount
@@ -3139,63 +3201,45 @@ _command()
 	local cur func cline cspec noglob cmd done i \
 	      _COMMAND_FUNC _COMMAND_FUNC_ARGS
 
+	_remove_comp_word
 	COMPREPLY=()
 	cur=`_get_cword`
 	# If the the first arguments following our meta-command-invoker are
 	# switches, get rid of them. Most definitely not foolproof.
 	done=
 	while [ -z $done ] ; do
-	    cmd=${COMP_WORDS[1]}
-	    if [[ "$cmd" == -* ]] && [ $COMP_CWORD -gt 1 ]; then
-		for (( i=1 ; i<COMP_CWORD ; i++)) ; do
-		    COMP_WORDS[i]=${COMP_WORDS[i+1]}
-		done
-		COMP_CWORD=$(($COMP_CWORD-1))
+	    cmd=${COMP_WORDS[0]}
+	    if [[ "$cmd" == -* ]] && [ $COMP_CWORD -ge 1 ]; then
+	        _remove_comp_word
+	    elif [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then
+		return
 	    else 
 		done=1
 	    fi
 	done
 
-	if [ $COMP_CWORD -eq 1 ]; then
+	if [ $COMP_CWORD -eq 0 ]; then
 		COMPREPLY=( $( compgen -c -- $cur ) )
 	elif complete -p $cmd &>/dev/null; then
 		cspec=$( complete -p $cmd )
 		if [ "${cspec#* -F }" != "$cspec" ]; then
-			# complete -F <function>
-			#
 			# COMP_CWORD and COMP_WORDS() are not read-only,
 			# so we can set them before handing off to regular
 			# completion routine
 
-			# set current token number to 1 less than now
-			COMP_CWORD=$(( $COMP_CWORD - 1 ))
-
 			# get function name
 			func=${cspec#*-F }
 			func=${func%% *}
-			# get current command line minus initial command
-			cline="${COMP_LINE#*( )$1 }"
-			# save noglob state
-		      	shopt -qo noglob; noglob=$?
-			# turn on noglob, as things like 'sudo ls *<Tab>'
-			# don't work otherwise
-		  	shopt -so noglob
-			# split current command line tokens into array
-			COMP_WORDS=( $cline )
-			# reset noglob if necessary
-			[ $noglob -eq 1 ] && shopt -uo noglob
-			$func $cline
-			# This is needed in case user finished entering
-			# command and pressed tab (e.g. sudo ls <Tab>)
-			COMP_CWORD=$(( $COMP_CWORD > 0 ? $COMP_CWORD : 1 ))
-			cur=`_get_cword`
-			_COMMAND_FUNC=$func
-			_COMMAND_FUNC_ARGS=( $cmd $2 $3 )
-			COMP_LINE=$cline
-			COMP_POINT=$(( ${COMP_POINT} - ${#1} - 1 ))
-			$func $cmd $2 $3
+
+			if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
+				$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"
+			else
+				$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"
+			fi
+
 			# remove any \: generated by a command that doesn't
 			# default to filenames or dirnames (e.g. sudo chown)
+			# FIXME: I'm pretty sure this does not work!
 			if [ "${cspec#*-o }" != "$cspec" ]; then
 				cspec=${cspec#*-o }
 				cspec=${cspec%% *}
@@ -3312,7 +3356,7 @@ _mysqladmin()
 	COMPREPLY=( $( compgen -W '-# -f -? -C -h -p -P -i -r -E -s -S -t -u \
 					      -v -V -w' -- $cur ) )
 
-	COMPREPLY=( ${COMPREPLY[@]} \
+	COMPREPLY=( "${COMPREPLY[@]}" \
 		    $( compgen -W 'create drop extended-status flush-hosts \
 				   flush-logs flush-status flush-tables \
 				   flush-threads flush-privileges kill \
@@ -4010,6 +4054,7 @@ complete -F _gdb $filenames gdb
 have psql && {
 _pg_databases() 
 {
+	return
 	COMPREPLY=( $( psql -l 2>/dev/null | \
 			sed -e '1,/^-/d' -e '/^(/,$d' | \
 			awk '{print $1}' | grep "^$cur" ) )
@@ -4017,9 +4062,10 @@ _pg_databases() 
 
 _pg_users()
 {
-	COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
-			grep "^ $cur" ) )
-	[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )
+	#COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
+	#		grep "^ $cur" ) )
+	#[ ${#COMPREPLY[@]} -eq 0 ] &&
+	COMPREPLY=( $( compgen -u -- $cur ) )
 }
 
 # createdb(1) completion
@@ -4276,8 +4322,7 @@ _dpkg()
 	fi
 
 	case "$prev" in 
-	-@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info| \
-			  fsys-tarfile|field|control|extract)))
+	-@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract)))
 		_filedir '?(u)deb'
 		return 0
 		;;
@@ -4597,17 +4642,17 @@ _java_classes()
 	for i in ${classpath//:/ }; do
 		if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
 			if type zipinfo &> /dev/null; then
-				COMPREPLY=( ${COMPREPLY[@]} $( zipinfo -1 \
+				COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
 				"$i" | grep "^$cur" | grep '\.class$' | \
 				grep -v "\\$" ) )
 			else
-				COMPREPLY=( ${COMPREPLY[@]} $( jar tf "$i" \
+				COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \
 				"$cur" | grep "\.class$" | grep -v "\\$" ) )
 			fi
 
 		elif [ -d $i ]; then
 			i=${i%/}
-			COMPREPLY=( ${COMPREPLY[@]} $( find "$i" -type f \
+			COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \
 			-path "$i/$cur*.class" 2>/dev/null | \
 			grep -v "\\$" | sed -e "s|^$i/||" ) )
 		fi
@@ -4632,12 +4677,12 @@ _java_packages()
 	# parse each sourcepath element for packages
 	for i in ${sourcepath//:/ }; do
 		if [ -d $i ]; then
-			COMPREPLY=( ${COMPREPLY[@]} $( command ls -F -d \
+			COMPREPLY=( "${COMPREPLY[@]}" $( command ls -F -d \
 				$i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ) )
 		fi
 	done
 	# keep only packages
-	COMPREPLY=( $( echo ${COMPREPLY[@]} | tr " " "\n" | grep "/$" ) )
+	COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) )
 	# remove packages extension
 	COMPREPLY=( ${COMPREPLY[@]%/} )
 	# convert path syntax to package syntax
@@ -4821,7 +4866,7 @@ _muttconffiles()
 	shift
 	while [[ "$1" ]]; do
 	    newconffiles=( $(sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $(eval echo $1) ) )
-	    for file in ${newconffiles[@]}; do
+	    for file in "${newconffiles[@]}"; do
 		[[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
 		    continue
 		sofar="$sofar $file"
@@ -4844,8 +4889,8 @@ _muttaliases()
 
 	conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
 	aliases=( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \
-			$(eval echo ${conffiles[@]}) ) )
-	COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "${aliases[*]}" -- $cur ) )
+			$(eval echo "${conffiles[@]}") ) )
+	COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- $cur ) )
 
 	return 0
 }
@@ -4864,7 +4909,7 @@ _muttquery()
 	      sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
 	fi
 
-	COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "${queryresults[*]}" \
+	COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \
 			-- $cur ) )
 
 	return 0
@@ -5320,7 +5365,7 @@ _perldoc()
 	    ;;
 	*)
 	    _perlmodules
-	    COMPREPLY=( ${COMPREPLY[@]} $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
+	    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
 
 	    return 0
 	    ;;
@@ -5550,7 +5595,7 @@ _portinstall()
 	COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
 			cut -d'|' -f2 ) )
 	COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
-	COMPREPLY=( ${COMPREPLY[@]} ${COMPREPLY2[@]} )
+	COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
 
 	return 0
 } &&
@@ -5654,13 +5699,13 @@ _mplayer()
 			return 0
 			;;
 		-sub)
-			_filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js)'
+			_filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)'
 			return 0
 			;;
 		-vobsub)
 			_filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
 			IFS=$'\t\n' 
-			COMPREPLY=( $( for i in ${COMPREPLY[@]}; do
+			COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
 						if [ -f $i -a -r $i ]; then
 							echo ${i%.*}
 						else
@@ -5897,7 +5942,7 @@ _mplayer()
 					-bps -oldpp -nozoom -noflip -nounicode \
 					-noutf8' -- $cur ) )
 			# add mplayer specific options
-			[[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( ${COMPREPLY[@]} \
+			[[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( "${COMPREPLY[@]}" \
 				$(compgen -W '-autoq -autosync -benchmark \
 					-framedrop -h -help -hardframedrop \
 					-identify -input -lircconf -loop \
@@ -5928,7 +5973,7 @@ _mplayer()
 					-aaosdcolor -aasubcolor -aadriver \
 					-aaextended -aaeight' -- $cur) )
 			# add mencoder specific options
-			[[ "$cmd" = mencoder ]] && COMPREPLY=( ${COMPREPLY[@]} \
+			[[ "$cmd" = mencoder ]] && COMPREPLY=( "${COMPREPLY[@]}" \
 				$(compgen -W '-audio-density -audio-delay \
 					-audio-preload -divx4opts -endpos \
 					-ffourcc -include -info -lameopts \
@@ -5938,7 +5983,7 @@ _mplayer()
 					-xvidencopts -of --verbose' -- $cur) )
 			;;
 		*)
-			_filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|m4v|M4V|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV|divx|DIVX)'
+			_filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|flv|FLV|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|m4v|M4V|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV|divx|DIVX)'
 			;;
 	esac
 
@@ -6036,7 +6081,7 @@ _gpg() 
 	-@(r|-recipient))
 		COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1 at p')" -- "$cur" ))
 		if [ -e ~/.gnupg/gpg.conf ]; then
-			COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1 at p' ~/.gnupg/gpg.conf  )" -- "$cur") )
+			COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1 at p' ~/.gnupg/gpg.conf  )" -- "$cur") )
 		fi
 		return 0
 		;;
@@ -6216,10 +6261,10 @@ _cdrecord()
 	# files are always eligible completion
 	_filedir
 	# track options are always available
-	COMPREPLY=( ${COMPREPLY[@]} $( compgen -W '${track_options[@]}' -- $cur ) )
+	COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- $cur ) )
 	# general options are no more available after file or track option
 	if [ $track_mode -eq 0 ]; then
-		COMPREPLY=( ${COMPREPLY[@]} \
+		COMPREPLY=( "${COMPREPLY[@]}" \
 			    $( compgen -W '${generic_options[@]}' -- $cur ) )
 	fi
 
@@ -6948,7 +6993,7 @@ _aspell()
 	fi
 
 }
-complete -F _aspell $default aspell
+complete -F _aspell $filenames aspell
 }
 
 # xmms(1) completion
@@ -9299,9 +9344,17 @@ _filedir_xspec()
 	xspec=${xspec#*-X }
 	xspec=${xspec%% *}
 
-	COMPREPLY=( $( eval compgen -f -X "$xspec" -- \
-		    \"${cur#[\`\"\']}\" 2>/dev/null ) \
-		    $( compgen -d -- $cur ) )
+	local toks=( ) tmp
+
+	while read -r tmp; do
+		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
+	done < <( compgen -d -- "$(quote_readline "$cur")" )
+
+	while read -r tmp; do
+		[[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
+	done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" )
+
+	COMPREPLY=( "${toks[@]}" )
 }
 list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
 	  $BASH_COMPLETION | \
@@ -9314,16 +9367,16 @@ list=( $( sed -ne '/^# START exclude/,/^
 		line=${line%# START exclude*}
 		line=${line%# FINISH exclude*}
 		line=${line##*\'}
-		list=( ${list[@]:-} $line )
+		list=( "${list[@]}" $line )
 	done
-	echo ${list[@]}
+	echo "${list[@]}"
 	)
      ) )
 # remove previous compspecs
 if [ ${#list[@]} -gt 0 ]; then
     eval complete -r ${list[@]}
     # install new compspecs
-    eval complete -F _filedir_xspec $filenames ${list[@]}
+    eval complete -F _filedir_xspec $filenames "${list[@]}"
 fi
 unset list
 
@@ -9344,6 +9397,9 @@ unset -f have
 unset UNAME RELEASE default dirnames filenames have nospace bashdefault \
       plusdirs
 
+set $BASH_COMPLETION_ORIGINAL_V_VALUE
+unset BASH_COMPLETION_ORIGINAL_V_VALUE
+
 ###  Local Variables:
 ###  mode: shell-script
 ###  End:
diff -pruN 20060301-4/debian/changelog 20060301-4ubuntu1/debian/changelog
--- 20060301-4/debian/changelog	2008-06-20 04:17:09.000000000 +0100
+++ 20060301-4ubuntu1/debian/changelog	2008-06-20 04:15:11.000000000 +0100
@@ -1,3 +1,30 @@
+bash-completion (20060301-4ubuntu1) intrepid; urgency=low
+
+  * Merge from debian unstable, remaining changes:
+   - Don't use ucf for handling the bash_completion config file. (LP: 210013)
+   - Fix _get_cword more
+   - Fix _command function to correctly prune the command line (LP: 103395)
+   - Remove newline from options pattern for dpkg (LP: 138312)
+   - Start readline-quoting arguments to compgen (LP: 123665)
+   - Save and restore -v shell option (LP: 205444)
+   - Prevent glob expansion in _filedir function (LP: 194419)
+   - Quote glob expression in tar completion function (LP: 194419)
+   - Complete AAS/SSA files for mplayer -sub (LP: 151086)
+   - Disable completion of postgresql users and databases (LP: 164772)
+   - Use files from UserKnownHostsFile options in addition to standard ones
+     (LP: 211180)
+   - Fixed completion of hostnames and files with scp
+   - Fix tar completion to handle "tar rf" the same as "tar cf" (LP: 94407)
+   - Complete .divx and .flv for media players (LP: 127605)
+   - Complete all files for "gzip ... <" (LP: 127605)
+   - Allow whitespace in front of GlobalKnownHostsFile etc. (LP: 128866)
+   - Complete compressed files for vim (LP: 149494)
+   - Always use /etc/hosts and $HOSTFILE for host completion too (LP: 184175)
+   - Modify Maintainer value to match the DebianMaintainerField
+     specification.
+
+ -- Bryce Harrington <bryce at ubuntu.com>  Thu, 19 Jun 2008 11:58:17 -0700
+
 bash-completion (20060301-4) unstable; urgency=low
 
   * Add some fixes from Ubuntu:
@@ -10,6 +37,53 @@ bash-completion (20060301-4) unstable; u
 
  -- Luk Claes <luk at debian.org>  Sat, 22 Mar 2008 23:10:30 +0000
 
+bash-completion (20060301-3ubuntu3) hardy; urgency=low
+
+  * Don't use ucf for handling the bash_completion config file. Avoids
+    prompting the user for a changed config file, if the config file is
+    unchanged (and only moved to the bash-completion package). LP: #210013.
+
+ -- Matthias Klose <doko at ubuntu.com>  Tue, 15 Apr 2008 01:21:38 +0200
+
+bash-completion (20060301-3ubuntu2) hardy; urgency=low
+
+  * Bugfix release:
+   - Fix _get_cword more
+   - Fix _command function to correctly prune the command line (LP: #103395)
+   - Remove newline from options pattern for dpkg (LP: #138312)
+   - Start readline-quoting arguments to compgen (LP: #123665)
+   - Save and restore -v shell option (LP: #205444)
+   - Prevent glob expansion in _filedir function (LP: #194419)
+   - Quote glob expression in tar completion function (LP: #194419)
+   - Complete AAS/SSA files for mplayer -sub (LP: #151086)
+   - Disable completion of postgresql users and databases (LP: #164772)
+   - Use files from UserKnownHostsFile options in addition to standard ones
+     (LP: #211180)
+
+ -- Mika Fischer <mika.fischer at zoopnet.de>  Sat, 05 Apr 2008 16:09:34 +0200
+
+bash-completion (20060301-3ubuntu1) hardy; urgency=low
+
+  * Bug fix upload (LP: #194860)
+   - Fixed completion of filenames with spaces
+   - Fixed completion of hostnames with scp
+   - Fixed completion of filenames with scp
+   - Fixed parsing of SSH config files to parse Host and HostName lines
+     correctly. Previously "HostName host" lines were parsed as two hosts:
+     "Name" and "host".
+  * More bugfixes:
+   - Fix tar completion to handle "tar rf" the same as "tar cf" (LP: #94407)
+   - Complete .m4v and .M4V for media players (LP: #115224)
+   - Complete .divx and .flv for media players (LP: #127605)
+   - Complete all files for "gzip ... <" (LP: #127605)
+   - Allow whitespace in front of GlobalKnownHostsFile etc. (LP: #128866)
+   - Complete compressed files for vim (LP: #149494)
+   - Always use /etc/hosts and $HOSTFILE for host completion too (LP: #184175)
+  * Modify Maintainer value to match the DebianMaintainerField
+    specification.
+
+ -- Mika Fischer <mika.fischer at zoopnet.de>  Sat, 15 Mar 2008 19:46:17 +0100
+
 bash-completion (20060301-3) unstable; urgency=low
 
   * Fix kpdf completion (Closes: #468163, #413374).
diff -pruN 20060301-4/debian/control 20060301-4ubuntu1/debian/control
--- 20060301-4/debian/control	2008-06-20 04:17:09.000000000 +0100
+++ 20060301-4ubuntu1/debian/control	2008-06-20 04:15:11.000000000 +0100
@@ -1,7 +1,8 @@
 Source: bash-completion
 Section: shells
 Priority: standard
-Maintainer: Luk Claes <luk at debian.org>
+XSBC-Original-Maintainer: Luk Claes <luk at debian.org>
+Maintainer: Ubuntu MOTU Developers <ubuntu-motu at lists.ubuntu.com>
 Build-Depends: debhelper (>= 5)
 Standards-Version: 3.7.3
 
diff -pruN 20060301-4/debian/postinst 20060301-4ubuntu1/debian/postinst
--- 20060301-4/debian/postinst	2008-06-20 04:17:09.000000000 +0100
+++ 20060301-4ubuntu1/debian/postinst	2008-06-20 04:15:11.000000000 +0100
@@ -4,14 +4,19 @@ set -e
 
 case "$1" in
     configure)
-	ucf /usr/share/bash/bash_completion /etc/bash_completion
-	ucfr bash-completion /etc/bash_completion
+	# remove ucf configury
+	if which ucf >/dev/null; then
+	    ucf --purge /etc/bash_completion
+	fi
+	if which ucfr >/dev/null; then
+	    ucfr --purge bash-completion /etc/bash_completion
+	fi
 	;;
     abort-upgrade|abort-remove|abort-deconfigure)
 	;;
     *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
+	echo "postinst called with unknown argument \`$1'" >&2
+	exit 1
     ;;
 esac
 
diff -pruN 20060301-4/debian/postrm 20060301-4ubuntu1/debian/postrm
--- 20060301-4/debian/postrm	2008-06-20 04:17:09.000000000 +0100
+++ 20060301-4ubuntu1/debian/postrm	2008-06-20 04:15:11.000000000 +0100
@@ -5,12 +5,6 @@ set -e
 case "$1" in
     purge)
 	rm -f /etc/bash_completion
-	if which ucf >/dev/null; then
-	    ucf --purge /etc/bash_completion
-	fi
-	if which ucfr >/dev/null; then
-	    ucfr --purge bash-completion /etc/bash_completion
-	fi
 	;;
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
 	;;
diff -pruN 20060301-4/debian/rules 20060301-4ubuntu1/debian/rules
--- 20060301-4/debian/rules	2008-06-20 04:17:09.000000000 +0100
+++ 20060301-4ubuntu1/debian/rules	2008-06-20 04:15:11.000000000 +0100
@@ -15,18 +15,18 @@ clean:
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp
-	dh_clean 
+	dh_clean
 
 install: build
 	dh_testdir
 	dh_testroot
-	dh_clean -k 
+	dh_clean -k
 	dh_installdirs \
 		etc/bash_completion.d \
 		usr/share/bash \
 		usr/share/doc/bash \
 		usr/share/doc/bash-completion
-	cp -p bash_completion $(d)/usr/share/bash/
+	cp -p bash_completion $(d)/etc/
 	cp -a contrib $(d)/usr/share/doc/bash-completion/
 	ln -sf ../bash-completion/contrib \
 		$(d)/usr/share/doc/bash/completion-contrib


More information about the Bash-completion-devel mailing list