Stop unescaping strings with commandline -b

The fix for #2075 inadvertently started unescaping the strings emitted
from `commandline -b`. Only strings emitted with the `-o` flag are
supposed to be unescaped.

Fixes #2210.
This commit is contained in:
Kevin Ballard 2016-01-10 17:13:08 -08:00
parent 43728fe7a0
commit 1dac0041d5
5 changed files with 40 additions and 3 deletions

View file

@ -234,9 +234,7 @@ static void write_part(const wchar_t *begin,
} }
// debug( 0, L"woot2 %ls -> %ls", buff, esc ); // debug( 0, L"woot2 %ls -> %ls", buff, esc );
wcstring tmp = wcstring(begin, end - begin); streams.out.append(begin, end - begin);
unescape_string_in_place(&tmp, UNESCAPE_INCOMPLETE);
streams.out.append(tmp);
streams.out.append(L"\n"); streams.out.append(L"\n");
} }

30
tests/commandline.expect Normal file
View file

@ -0,0 +1,30 @@
# vim: set filetype=expect:
spawn $fish
expect_prompt
send_line "bind '~' 'handle_tilde'"
expect_prompt
# printing the current buffer should not remove quoting
send_line "function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end"
expect_prompt
send_line {echo \en one "two three" four'five six'{7} 'eight~}
expect_prompt -re {\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n} {
puts "a:"
puts $expect_out(1,string)
} unmatched {
abort "Couldn't find guard 1"
}
# printing the buffer with -o should remove quoting
send_line "function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end"
expect_prompt
send_line {echo one "two three" four'five six'{7} 'eight~}
expect_prompt -re {\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n} {
puts "b:"
puts [string map {\r {}} $expect_out(1,string)]
} unmatched {
abort "Couldn't find guard 2"
}

View file

View file

@ -0,0 +1,8 @@
a:
echo \en one "two three" four'five six'{7} 'eight
b:
echo
one
two three
fourfive six{7}
eight

View file

@ -0,0 +1 @@
0