mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Make ESCAPE_NO_PRINTABLES behavior a bit less weird
Since the fix for #3892, this escaping style escapes \n to \\n as well as \\ to \\\\ \' to \\' I believe these two are the only printable characters that are escaped with ESCAPE_NO_PRINTABLES. The rationale is probably to keep the encoding unambiguous and reversible. However that doesn't justify escaping the single quote. Probably this was an accident, so let's revert that part. This has the nice effect that single quotes will no longer be escaped when rendered in the completion pager (which is consistent with other special characters). Try it: complete : -a "aaa\'\; aaaa\'\;" -f Also this makes the error output of builtin bind consistent: $ bind -e --preset \; $ bind -e --preset \' $ bind \; bind: No binding found for sequence “;” $ bind \' bind: No binding found for sequence “'” the last line is clearly better than the old version: bind: No binding found for sequence “\'” In general, the fact that ESCAPE_NO_PRINTABLES escapes the (printable) backslash is weird but I guess it's fine because it looks more consistent to users, even though the result is an undocumented subset of the fish language.
This commit is contained in:
parent
8729623cec
commit
83893558f9
@ -941,7 +941,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
|
||||
case L'\\':
|
||||
case L'\'': {
|
||||
need_escape = need_complex_escape = true;
|
||||
out += L'\\';
|
||||
if (escape_printables || c == L'\\') out += L'\\';
|
||||
out += *in;
|
||||
break;
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ set --show var1
|
||||
#CHECK: $var1: set in local scope, unexported, with 0 elements
|
||||
#CHECK: $var1: set in global scope, unexported, with 2 elements
|
||||
#CHECK: $var1[1]: |goodbye|
|
||||
#CHECK: $var1[2]: |and don\'t come back|
|
||||
#CHECK: $var1[2]: |and don't come back|
|
||||
#CHECK: $var1: set in universal scope, unexported, with 1 elements
|
||||
#CHECK: $var1[1]: |hello|
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user