On 2025-02-03 22:15, Splitline Huang via Cygwin wrote: > Hello Cygwin team, > > I am splitline from DEVCORE research team. I recently have observed an > inconsistency > in how Cygwin handles command-line parsing compared to Microsoft’s > implementation.
Hi, I maintain a small fork of the Cygwin DLL called Cygnal. https://www.kylheku.com/cygnal/ The purpose of Cygnal is to leverage Cygwin as a run-time for "native" Windows applications. It gives us a beautfiful development workflow: you simply write your program under Cygwin as a Cygwin program, compiling with the Cygwin GCC suite. You can test your program and make sure it functions as a Cygwin application. Then you can slide the cygwin1.dll under it, which brings back certain Windows-like behaviors. Test it that way and ship it to Windows users who don't know anything about POSIX or Cygwin. (And also ship it as Cygwin program to Cygwin people too!) In the Cygnal project, I /do/ care about interoperability with Windows programs. I'd like a Cygnal program to accept arguments the same way as something that calls CommandLineToArgvW, or the same way as a Visual C++ program that begins with wmain. I don't want Cygnal programs to be susceptible to the alleged argument injection when invoked by non-Cygwin applications that are following the Microsoft-recommended command line convention. Therefore, if you produce a good patch for this issue, I will likely merge it in the Cygnal project, even if Cygwin doesn't want it. The patch has to address both generation of arguments when invoking processes, as well as parsing. Quite recently, Cygwin developer Corina Vinschen pointed me (via a post in this mailing list) to where the commanda rgument parsing logic takes place. It's under the function dll_crt0_1 in the file dcrt0.cc. Here, I think: https://cygwin.com/cgit/newlib-cygwin/tree/winsup/cygwin/dcrt0.cc#n800 This calls something called build_argv, in the same file. In the Cygnal project, I don't care for having argv[0] massaged for POSIX conventions, either. Somewhere under the exec family of functions there is code for the reverse: encoding arguments into a Windows sommand line. Cheers ... -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple