I'm facing an issue when testing a C program compiled with mingw in the MSYS2 shell: I wrote a command line parser that accepts options according to the windows convention (starting with /
). If I call my program like this to generate an output file:
./example.exe /o test
What ends up in argv[1]
is actually O:/
. It works fine when testing from a console window running CMD.EXE
. This truly minimal program demonstrates the behavior:
#include <stdio.h>
int main(int argc, char **argv)
{
if (argc > 1)
{
puts(argv[1]);
}
return 0;
}
$ ./example.exe /o
O:/
So I guess this is the MSYS2 shell trying to be helpful and replacing something that looks like a one-letter path below root into a drive-letter syntax. Is there a way to disable this behavior? It's a bit of a hassle to always launch CMD.EXE
for testing.