[Bash-completion-commits] [SCM] bash-completion branch, mount-fix, updated. 4375c4b94ea7bdd370cd771aeb3483f36a42bd9f
Crestez Dan Leonard
cdleonard at gmail.com
Tue Feb 9 13:45:11 UTC 2010
The following commit has been merged in the mount-fix branch:
commit 4375c4b94ea7bdd370cd771aeb3483f36a42bd9f
Author: Crestez Dan Leonard <cdleonard at gmail.com>
Date: Tue Feb 9 15:11:05 2010 +0200
(mount) Split __linux_fstab_unescape function. Deal with \ at the end of strings.
diff --git a/contrib/mount b/contrib/mount
index 1896dde..e4a7437 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -34,6 +34,13 @@ _reply_compgen_array()
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
@@ -45,11 +52,13 @@ _linux_fstab()
# Read and unescape values into COMPREPLY
local fs_spec fs_file fs_other
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 = */* ]] && eval "COMPREPLY+=( $'${fs_spec//\'/\047}' )";
- [[ $fs_file = */* ]] && eval "COMPREPLY+=( $'${fs_file//\'/\047}' )";
+ [[ $fs_spec = */* ]] && COMPREPLY+=("$fs_spec");
+ [[ $fs_file = */* ]] && COMPREPLY+=("$fs_file");
IFS="$oldifs"
done
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
index 869452b..4473c70 100644
--- a/test/lib/completions/mount.exp
+++ b/test/lib/completions/mount.exp
@@ -57,6 +57,23 @@ assert_bash_exec {PATH="$OLDPATH"; unset -v OLDPATH}
sync_after_int
+set test "Testing internal __linux_fstab_unescape function for mount"
+# One round of slashes is for bash.
+assert_bash_exec {var=one\'two\\040three\\}
+assert_bash_exec {__linux_fstab_unescape var}
+set cmd {echo $var}
+send "$cmd\r"
+expect {
+ -ex "$cmd\r\none'two three\\" { pass $test }
+# default { fail $test }
+}
+assert_bash_exec {unset var}
+
+
+sync_after_int
+
+
+# Begin testing through mnt (see setup_dummy_mnt).
assert_complete {/mnt/nice-test-path} {mnt /mnt/nice-test-p}
sync_after_int
--
bash-completion
More information about the Bash-completion-commits
mailing list