Skip to content

Commit

Permalink
Escape \ only for common escape sequences.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebattista committed Oct 11, 2019
1 parent 65e5c08 commit 131b5d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion WslInterop.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@ function global:Format-WslArgument([string]$arg, [bool]$interactive) {
#>

$arg = $arg.Trim()

if ($interactive -and $arg.Contains(" ")) {
return "'$arg'"
} else {
return $arg -replace "([ ()\\|;])", ('\$1', '`$1')[$interactive]
$arg = $arg -replace "([ ()|;])", ('\$1', '`$1')[$interactive]
$arg = $arg -replace '(\\[abefnrtv])', '\$1'
return $arg
}
}

0 comments on commit 131b5d5

Please sign in to comment.