Add try to the keywords list

This commit is contained in:
twangboy 2024-10-16 13:30:17 -06:00 committed by Daniel Wozniak
parent aeecd6b7b2
commit 905f8c9826
2 changed files with 2 additions and 1 deletions

View file

@ -293,7 +293,7 @@ def _prep_powershell_cmd(win_shell, cmd, encoded_cmd):
# Commands that are a specific keyword behave differently. They fail if
# you add a "&" to the front. Add those here as we find them:
keywords = ["$", "&", ".", "Configuration"]
keywords = ["$", "&", ".", "Configuration", "try"]
for keyword in keywords:
if cmd.startswith(keyword):

View file

@ -1064,6 +1064,7 @@ def test_prep_powershell_cmd_no_powershell():
[
("Write-Host foo", "& Write-Host foo"),
("$PSVersionTable", "$PSVersionTable"),
("try {this} catch {that}", "try {this} catch {that}"),
],
)
def test_prep_powershell_cmd(cmd, parsed):