This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Double Backslash/Space exec Argument Problem


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
#include <stdio.h>

int
main(int argc, char* argv[])
{
	char* s = argv[1];
	printf("argv[1] = (%s)\n", s);
}

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]