mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Make printf support \e as the escape character
https://github.com/fish-shell/fish-shell/issues/910
This commit is contained in:
parent
cabebd9f51
commit
d3bb2a718a
1 changed files with 7 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
||||||
\a = alert (bell)
|
\a = alert (bell)
|
||||||
\b = backspace
|
\b = backspace
|
||||||
\c = produce no further output
|
\c = produce no further output
|
||||||
|
\e = escape
|
||||||
\f = form feed
|
\f = form feed
|
||||||
\n = new line
|
\n = new line
|
||||||
\r = carriage return
|
\r = carriage return
|
||||||
|
@ -319,6 +320,9 @@ void builtin_printf_state_t::print_esc_char(wchar_t c)
|
||||||
case L'c': /* Cancel the rest of the output. */
|
case L'c': /* Cancel the rest of the output. */
|
||||||
this->early_exit = true;
|
this->early_exit = true;
|
||||||
break;
|
break;
|
||||||
|
case L'e': /* Escape */
|
||||||
|
this->append_output(L'\x1B');
|
||||||
|
break;
|
||||||
case L'f': /* Form feed. */
|
case L'f': /* Form feed. */
|
||||||
this->append_output(L'\f');
|
this->append_output(L'\f');
|
||||||
break;
|
break;
|
||||||
|
@ -369,8 +373,10 @@ long builtin_printf_state_t::print_esc(const wchar_t *escstart, bool octal_0)
|
||||||
esc_value = esc_value * 8 + octal_to_bin(*p);
|
esc_value = esc_value * 8 + octal_to_bin(*p);
|
||||||
this->append_format_output(L"%c", esc_value);
|
this->append_format_output(L"%c", esc_value);
|
||||||
}
|
}
|
||||||
else if (*p && wcschr(L"\"\\abcfnrtv", *p))
|
else if (*p && wcschr(L"\"\\abcefnrtv", *p))
|
||||||
|
{
|
||||||
print_esc_char(*p++);
|
print_esc_char(*p++);
|
||||||
|
}
|
||||||
else if (*p == L'u' || *p == L'U')
|
else if (*p == L'u' || *p == L'U')
|
||||||
{
|
{
|
||||||
wchar_t esc_char = *p;
|
wchar_t esc_char = *p;
|
||||||
|
|
Loading…
Reference in a new issue