Visitar URL original
Add support for escape char ESC via `e. (#2920) · Thatgfsj-contribs/PowerShell@af2a8b9 · GitHub
Skip to content

Commit af2a8b9

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

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎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)