10000 Add support for escape char ESC via `e. (#2920) · PowerShell/PowerShell@cd743cc · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit cd743cc

Browse files
rkeithhilllzybkr
authored andcommitted
Add support for escape char ESC via `e. (#2920)
This change is a breaking change but falls into compat bucket #3 - unlikely grey area.
1 parent 821c965 commit cd743cc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/System.Management.Automation/engine/parser/tokenizer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ private static char Backtick(char c)
12361236
case '0': return '\0';
12371237
case 'a': return '\a';
12381238
case 'b': return '\b';
1239+
case 'e': return '\u001b';
12391240
case 'f': return '\f';
12401241
case 'n': return '\n';
12411242
case 'r': return '\r';

test/powershell/Language/Parser/Parser.Tests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ Describe "ParserTests (admin\monad\tests\monad\src\engine\core\ParserTests.cs)"
265265
$result | should be "foo bar"
266266
}
267267

268+
It "Test that escaping the character 'e' returns the ESC character (0x1b)." {
269+
$result = ExecuteCommand '"`e"'
270+
$result | should be ([char]0x1b)
271+
}
272+
268273
It "Test that escaping any character with no special meaning just returns that char. (line 602)" {
269274
$result = ExecuteCommand '"fo`obar"'
270275
$result | should be "foobar"

0 commit comments

Comments
 (0)
0