Revision of Posix path conversion from 2011, March 14 - 01:40

Printer-friendly version

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 multiple /s is an escaped of a Windows style switched and will be passed with the leading / removed and all \s changed to /s.
    • Except that if there is a / following the leading block of /s, 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 \s are changed to /s.
  • 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 \s converted to /s, 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 \s converted to /s 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 's or "s 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 \
This wiki is not a forum for discussion of usage issues. Please use the mingw-users@lists.osdn.me list instead. We do not allow creation of comments by anonymous or untrusted users, on any page.
 
Site Status

Site maintenance performed successfully, site online Dec 13th 12:00 AM Eastern.