Double Backslash/Space exec Argument Problem

Jason Tishler Jason.Tishler@dothill.com
Wed Oct 18 11:15:00 GMT 2000


Cygwin appears to double up backslashes in arguments containing spaces
when passed from a Cygwin program (e.g., bash) to a native Win32 program:

    $ foo 'C:\duda man'
    argv[1] = (C:\\duda man)
                  ^
                  +--- doubling

    $ foo 'C:\dudaman'
    argv[1] = (C:\dudaman)

However, when foo is run from cmd:

    H:\> foo "C:\duda man"
    argv[1] = (C:\duda man)

    H:\> foo "C:\dudaman"
    argv[1] = (C:\dudaman)

the doubling doesn't occur.

Note that foo.c compiled with gcc does not exhibit the doubling regardless
of the shell from which it is invoked.

See attached for foo.c.

Thanks,
Jason

P.S. The only reason that I stumbled across this, is that on Windows
98 the (non-leading) double backslashes are treated as UNC while on NT
they are not.  Hence, code that was running fine on NT started failing
with ERROR_BAD_NETPATH after long delays on 98.  Now I understand why
the Cygwin team holds Windows 9X in such high esteem! :,)

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation         Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com


More information about the Cygwin mailing list