From 2f61acd068a67e630dd28ce04157908398dd8798 Mon Sep 17 00:00:00 2001 From: Crestez Dan Leonard Date: Mon, 8 Feb 2010 09:50:39 +0200 Subject: (mount) Make mount work properly with ' in fstab --- contrib/mount | 9 +++++---- test/fixtures/mount/test-fstab | 6 ++++-- test/lib/completions/mount.exp | 6 ++++++ 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} -- cgit v1.2.1