[Bash-completion-commits] [SCM] bash-completion branch, mount-fix, updated. 4375c4b94ea7bdd370cd771aeb3483f36a42bd9f

Crestez Dan Leonard cdleonard at gmail.com
Tue Feb 9 13:45:10 UTC 2010


The following commit has been merged in the mount-fix branch:
commit 2f61acd068a67e630dd28ce04157908398dd8798
Author: Crestez Dan Leonard <cdleonard at gmail.com>
Date:   Mon Feb 8 09:50:39 2010 +0200

    (mount) Make mount work properly with ' in fstab

diff --git a/contrib/mount b/contrib/mount
index 6c94e3f..1896dde 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 7103644..b243417 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 ddeadab..869452b 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}

-- 
bash-completion



More information about the Bash-completion-commits mailing list