[Bash-completion-commits] [SCM] bash-completion branch, master, updated. f294219990569082b20e08643b6e46256ca0862f
Crestez Dan Leonard
cdleonard at gmail.com
Mon Feb 15 13:40:19 UTC 2010
The following commit has been merged in the master branch:
commit f294219990569082b20e08643b6e46256ca0862f
Merge: 72a8cb5b49ad222e74f1d97ad10f85e3a002cf38 91f7e8274e90632c95527bf0fc1407e9abd0b539
Author: Crestez Dan Leonard <cdleonard at gmail.com>
Date: Mon Feb 15 15:36:58 2010 +0200
Merge branch 'mount-fix'
Fix mount handling of escapes (Alioth: #311410, Launchpad: #219971)
Conflicts:
CHANGES
diff --combined CHANGES
index bfa254f,aca7bfe..a6cdaaf
--- a/CHANGES
+++ b/CHANGES
@@@ -25,10 -25,9 +25,10 @@@ bash-completion (2.x
* Apply cardctl completion to pccardctl too.
* Apply pine completion to alpine too.
* Remove many unnecessary short option completions where long ones exist.
- * Improve chsh, configure, cvs, gkrellm, gzip, lftp, look, make, mdadm,
- modprobe, mplayer, mysqladmin, rsync, screen, service, scp, ssh, sshfs,
- update-alternatives, vncviewer, yp-tools, and general hostname completions.
+ * Improve chsh, chgrp, chown, configure, cvs, gkrellm, gzip, lftp, look,
+ make, mdadm, modprobe, mplayer, mysqladmin, rsync, screen, service, scp,
+ ssh, sshfs, update-alternatives, vncviewer, yp-tools, and general hostname
+ completions.
* Add abook and wtf completion, based on work by Raphaël Droz.
* Add cvsps, dragon, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake,
pack200, unpack200, pbzip2, pbunzip2, pbzcat, pigz and unpigz completions.
@@@ -69,8 -68,7 +69,9 @@@
* Improve ssh -o suboption completion (Alioth: #312122).
* Fix NFS mounts completion (Alioth: #312285).
* Fix completion of usernames (Alioth: #311396, Debian: #511788).
+ * Fix chown test crashing on systems with no root group (Alioth: #312306).
+ * Fixed tests when BASH_COMPLETION or TESTDIR contain spaces.
+ * Fix mount handling of escapes (Alioth: #311410, Launchpad: #219971).
[ Raphaël Droz ]
* Add xsltproc completion (Alioth: #311843).
diff --combined contrib/mount
index 1f0d8a4,26b78ea..0c7fad8
--- a/contrib/mount
+++ b/contrib/mount
@@@ -7,6 -7,74 +7,74 @@@
have mount &&
{
+ # Just like COMPREPLY=(`compgen -W "${COMPREPLY[*]}" -- "$cur"`), only better!
+ #
+ # This will correctly escape special characters in COMPREPLY.
+ _reply_compgen_array()
+ {
+ # Create the argument for compgen -W by escaping twice.
+ #
+ # One round of escape is because we want to reply with escaped arguments. A
+ # second round is required because compgen -W will helpfully expand it's
+ # argument.
+ local i wlist
+ for i in ${!COMPREPLY[*]}; do
+ local q=$(quote "$(printf %q "${COMPREPLY[$i]}")")
+ wlist+=$q$'\n'
+ done
+
+ # We also have to add another round of escaping to $cur.
+ local ecur="$cur"
+ ecur="${ecur//\\/\\\\}"
+ ecur="${ecur//\'/\'}"
+
+ # Actually generate completions.
+ local oldifs=$IFS
+ IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)'
+ IFS=$oldifs
+ }
+
+ # Unescape strings in the linux fstab(5) format (with octal escapes).
+ __linux_fstab_unescape() {
+ eval $1="'${!1//\'/\047}'"
+ eval $1="'${!1/%\\/\\\\}'"
+ eval "$1=$'${!1}'"
+ }
+
+ # Complete linux fstab entries.
+ #
+ # Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab
+ # and /proc/mounts.
+ _linux_fstab()
+ {
+ COMPREPLY=()
+
+ # Read and unescape values into COMPREPLY
+ local fs_spec fs_file fs_other
+ local oldifs="$IFS"
+ while read -r fs_spec fs_file fs_other; do
+ if [[ $fs_spec = [#]* ]]; then continue; fi
+ if [[ $1 == -L ]]; then
+ local fs_label=${fs_spec/#LABEL=}
+ if [[ $fs_label != "$fs_spec" ]]; then
+ __linux_fstab_unescape fs_label
+ IFS=$'\0'
+ COMPREPLY+=("$fs_label")
+ IFS=$oldifs
+ fi
+ else
+ __linux_fstab_unescape fs_spec
+ __linux_fstab_unescape fs_file
+ IFS=$'\0'
+ [[ $fs_spec = */* ]] && COMPREPLY+=("$fs_spec")
+ [[ $fs_file = */* ]] && COMPREPLY+=("$fs_file")
+ IFS=$oldifs
+ fi
+ done
+
+ _reply_compgen_array
+ }
+
_mount()
{
local cur sm host prev
@@@ -17,7 -85,7 +85,7 @@@
[[ "$cur" == \\ ]] && cur="/"
if [[ "$cur" == *:* ]]; then
- for sm in $(type -P showmount) {,/usr}/{,s}bin/showmount; do
+ for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
[ -x "$sm" ] || continue
COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \
awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) )
@@@ -44,11 -112,11 +112,11 @@@
else
# probably Linux
if [ $prev = -L ]; then
- COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*LABEL=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- "$cur" ) )
+ _linux_fstab -L < /etc/fstab
elif [ $prev = -U ]; then
COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- "$cur" ) )
else
- COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab )" -- "$cur" ) )
+ _linux_fstab < /etc/fstab
fi
fi
@@@ -62,12 -130,18 +130,18 @@@ complete -F _mount -o default -o dirnam
have umount &&
_umount()
{
- local cur IFS=$'\n'
-
COMPREPLY=()
- cur=`_get_cword`
- COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) )
+ local cur=`_get_cword`
+
+ if [[ $(uname -s) = Linux && -r /proc/mounts ]]; then
+ # Linux /proc/mounts is properly quoted. This is important when
+ # unmounting usb devices with pretty names.
+ _linux_fstab < /proc/mounts
+ else
+ local IFS=$'\n'
+ COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- "$cur" ) )
+ fi
return 0
} &&
--
bash-completion
More information about the Bash-completion-commits
mailing list