Posix path conversion

For any executable not dependent on msys-1.0.dll, MSYS will convert POSIX paths that are used as arguments to Win32 paths. This page attempts to document the heuristics MSYS uses to decide which arguments are POSIX paths and how they should be converted based on the source of msys_p2w in path.cc.

The following rules are applied in order: earlier rules take precedence over later ones.

  • Arguments starting with a drive specifier (eg C:) are considered to be Windows paths and are not converted.
  • Arguments containing a ; are considered to be Windows path lists and are not converted.
  • An argument starting with 2 or more / is considered an escaped Windows style switch and will be passed with the leading / removed and all \ changed to /.
    • Except that if there is a / following the leading block of /, the argument is considered to be a UNC path and the leading / is not removed.
  • If an argument has a leading / followed by a drive specfier, the / is removed and all \ are changed to /.
  • If an argument has a = it is considered a variable assignment. The right hand side is converted according to these rules and the left hand side has all \ converted to /, unless the right hand side starts with a drive specifier.
  • An argument that doesn't start with -, ", ', or @ and contains a : followed by /, :, or .; and a / is considered a POSIX path list. Every :-separated element is converted according to these rules, and the : are replaced with ;. Any / are converted to \.
    • Unless the : is followed by //: then it is considered a URL and not converted.
  • An argument with a leading / is converted up to the first /...
  • If an argument has a leading - and a ,, the part after the , is converted according to these rules and the whole argument has \ converted to / unless the path starts with a drive specifier.
  • If an argument has a leading - and the second character is a /, the part from the / onward is converted according to these rules.
  • An argument with a leading @ is considered a response file argument and the text following the @ is converted according to these rules.
  • An argument inside ' or " is processed according to these rules with the quotes ignored.

Examples

Argument from MSYS program Sent to native Windows program as Note
C:\foo\bar C:\foo\bar
/foo/bar; /foo/bar; has a ;, no conversion
//foobar /foobar double / prevents conversion
//foo\bar /foo/bar \ converted to /
//foo/bar //foo/bar interpreted as UNC path, leading / not removed
/c:\foo\bar c:/foo/bar
foo=/bar foo=C:/MinGW/msys/1.0/bar
-foo,/bar -foo,C:/MinGW/msys/1.0/bar
-I/foo,/bar -I/foo,C:/MinGW/msys/1.0/bar only the part after the , is converted as POSIX path
-I/foo -IC:/MinGW/msys/1.0/foo
/ C:/MinGW/msys/1.0
/.. /.. only convert up to first /..
x:x:/x x:x:/x no /, ., or : after first :
x::x:/x x;x;C:\MinGW\msys\1.0\x
x::x/z:x x;x\z;x / converted to \

Site Status

Site maintenance completed May 25th, 2012 at 12:38 UTC