From 35ff1076f33be77599442820f631215f8e069596 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Mon, 7 Mar 2022 16:39:16 -0600 Subject: [PATCH] add ansi escape (#4772) * add ansi escape * also add the ability to escape parens * add a few more escapes that could be problematic for the nushell lang --- crates/nu-parser/src/parser.rs | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 607637cbb8..b758650f54 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -2168,10 +2168,54 @@ pub fn unescape_string(bytes: &[u8], span: Span) -> (Vec, Option output.push(b'/'); idx += 1; } + Some(b'(') => { + output.push(b'('); + idx += 1; + } + Some(b')') => { + output.push(b')'); + idx += 1; + } + Some(b'{') => { + output.push(b'{'); + idx += 1; + } + Some(b'}') => { + output.push(b'}'); + idx += 1; + } + Some(b'$') => { + output.push(b'$'); + idx += 1; + } + Some(b'^') => { + output.push(b'^'); + idx += 1; + } + Some(b'#') => { + output.push(b'#'); + idx += 1; + } + Some(b'|') => { + output.push(b'|'); + idx += 1; + } + Some(b'~') => { + output.push(b'~'); + idx += 1; + } + Some(b'a') => { + output.push(0x7); + idx += 1; + } Some(b'b') => { output.push(0x8); idx += 1; } + Some(b'e') => { + output.push(0x1b); + idx += 1; + } Some(b'f') => { output.push(0xc); idx += 1;