Skip to main content

normalize_windows_command_paths

Function normalize_windows_command_paths 

Source
pub fn normalize_windows_command_paths(command: &str) -> String
Expand description

Normalize Windows absolute path spellings before any POSIX-style splitter (shlex / shell_words) or glob-charset gate in this module:

  • Path::canonicalize on Windows embeds the verbatim prefix \\?\C:\... whose ? trips the glob-charset gates and whose backslashes the POSIX splitters eat as escapes; strip it so the remaining spelling resolves to the same location (device \\.\ paths are preserved verbatim);
  • double the backslashes of Windows-absolute-path-like words so the splitters round-trip the real path instead of C:\Users\... collapsing to C:Users....

Words that do not look like Windows absolute paths are untouched, so POSIX escapes and unix hosts are unaffected.