summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrestez Dan Leonard <cdleonard@gmail.com>2010-02-08 09:50:39 +0200
committerCrestez Dan Leonard <cdleonard@gmail.com>2010-02-09 15:28:28 +0200
commit2f61acd068a67e630dd28ce04157908398dd8798 (patch)
treed56c9d211a62e9ed69cecfbe624d44e4e46e43b4
parentc0b77a03f55f06fc9a00b766307335574cc79293 (diff)
downloadbash-completion-2f61acd068a67e630dd28ce04157908398dd8798.tar.gz
(mount) Make mount work properly with ' in fstab
-rw-r--r--contrib/mount9
-rw-r--r--test/fixtures/mount/test-fstab6
-rw-r--r--test/lib/completions/mount.exp6
3 files changed, 15 insertions, 6 deletions
diff --git a/contrib/mount b/contrib/mount
index 6c94e3f9..1896dded 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -19,13 +19,14 @@ _reply_compgen_array()
# argument.
local i wlist
for i in ${!COMPREPLY[*]}; do
- local q=`printf %q "${COMPREPLY[$i]}"`
- wlist+=$(quote "$q")$'\n'
+ 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
@@ -47,8 +48,8 @@ _linux_fstab()
if [[ $fs_spec = [#]* ]]; then continue; fi
local oldifs="$IFS"
IFS=$'\0'
- [[ $fs_spec = */* ]] && eval "COMPREPLY+=( $'$fs_spec' )";
- [[ $fs_file = */* ]] && eval "COMPREPLY+=( $'$fs_file' )";
+ [[ $fs_spec = */* ]] && eval "COMPREPLY+=( $'${fs_spec//\'/\047}' )";
+ [[ $fs_file = */* ]] && eval "COMPREPLY+=( $'${fs_file//\'/\047}' )";
IFS="$oldifs"
done
diff --git a/test/fixtures/mount/test-fstab b/test/fixtures/mount/test-fstab
index 71036441..b2434173 100644
--- a/test/fixtures/mount/test-fstab
+++ b/test/fixtures/mount/test-fstab
@@ -14,9 +14,11 @@ none /debug debugfs defaults,noauto 0 0
# Contains '\n' and '\ '
/mnt/nice\012test\040path /dev/null auto ro,noauto 0 0
+# Test apostrophe
+/mnt/nice'test-path /dev/null auto ro,noauto 0 0
+/mnt/other'test\040path /dev/null auto ro,noauto 0 0
+
# Test some labels
LABEL=Ubuntu\040Karmic /mnt/ubuntu auto no,noauto 0 0
LABEL=Fedora /mnt/fedora auto ro,noauto 0 0
LABEL=Debian-it's\040awesome /mnt/debian auto ro,noauto 0 0
-
-#/dev/null /mnt/nice'testxxxpath auto ro,noauto 0 0
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
index ddeadab5..869452b0 100644
--- a/test/lib/completions/mount.exp
+++ b/test/lib/completions/mount.exp
@@ -76,6 +76,12 @@ sync_after_int
assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$}
sync_after_int
+assert_complete {/mnt/nice\'test-path} {mnt /mnt/nice\'}
+sync_after_int
+
+assert_complete {/mnt/other\'test\ path} {mnt /mnt/other}
+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}