[Bash-completion-commits] [SCM] bash-completion branch, master, updated. f294219990569082b20e08643b6e46256ca0862f
Crestez Dan Leonard
cdleonard at gmail.com
Mon Feb 15 13:40:17 UTC 2010
The following commit has been merged in the master branch:
commit 91f7e8274e90632c95527bf0fc1407e9abd0b539
Author: Crestez Dan Leonard <cdleonard at gmail.com>
Date: Mon Feb 15 15:33:10 2010 +0200
(mount) Handle escapes in LABEL= lines from fstab.
diff --git a/contrib/mount b/contrib/mount
index 6fbb24f..26b78ea 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -51,15 +51,25 @@ _linux_fstab()
# 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
- __linux_fstab_unescape fs_spec
- __linux_fstab_unescape fs_file
if [[ $fs_spec = [#]* ]]; then continue; fi
- local oldifs="$IFS"
- IFS=$'\0'
- [[ $fs_spec = */* ]] && COMPREPLY+=("$fs_spec");
- [[ $fs_file = */* ]] && COMPREPLY+=("$fs_file");
- IFS="$oldifs"
+ 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
@@ -102,7 +112,7 @@ _mount()
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
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
index 4473c70..9e98cc6 100644
--- a/test/lib/completions/mount.exp
+++ b/test/lib/completions/mount.exp
@@ -9,7 +9,7 @@ proc setup_dummy_mnt {} {
assert_bash_exec { \
_mnt() { \
local cur=$(_get_cword); \
- _linux_fstab < "$TESTDIR/fixtures/mount/test-fstab"; \
+ _linux_fstab $(_get_pword) < "$TESTDIR/fixtures/mount/test-fstab"; \
}; \
complete -F _mnt mnt \
}
@@ -99,6 +99,12 @@ sync_after_int
assert_complete {/mnt/other\'test\ path} {mnt /mnt/other}
sync_after_int
+assert_complete {Ubuntu\ Karmic} {mnt -L Ubu}
+sync_after_int
+
+assert_complete {Debian-it\'s\ awesome} {mnt -L Deb}
+sync_after_int
+
# This does not work. Proper support for this requires smarter parsing of
# $COMP_LINE and it's not worth doing just for mount.
#assert_complete {$'/mnt/nice\ntest-path'} {mnt $'/mnt/nice\n}
--
bash-completion
More information about the Bash-completion-commits
mailing list