(mount) Split __linux_fstab_unescape function. Deal with \ at the end of strings.
This commit is contained in:
parent
2f61acd068
commit
4375c4b94e
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user