Skip to main content

windows_quote

Function windows_quote 

Source
pub fn windows_quote(word: &str) -> String
Expand description

Quote for cmd and PowerShell. Backslashes stay single, because Windows paths use them.

Double quotes keep spaces and & | < > ; inside one argument in both shells, so a path such as C:\Program Files\... works in either one. Inside double quotes PowerShell still expands $ and backticks, and cmd expands % and !. A word with one of those characters, or with ", gets PowerShell single quotes (an inner ' doubled), which PowerShell reads literally. cmd has no literal quoting, so it can still expand %VAR% in such a word.