This is the mail archive of the cygwin 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]
Other format: [Raw text]

Re: Strange cygpath behavior.

Den 2011-06-26 17:57 skrev Andrey Repin:
> Greetings, Peter Rosin!
>> cygpath, at its core, calls some form of the cygwin_conv_path API. That
>> function takes either a POSIX path or a Win32 path and converts to the
>> other form. Anything interesting or useful that's happening when feeding
>> it a Win32 path and requesting it to convert from POSIX to Win32 is
>> purely coincidental and should not be relied upon.
> Right you are. But as I converting _to_ *NIX form, I should not suffer from
> issues, or at least not as long as the target of conversion is a cygwin
> utility. 

No, you seem to keep misunderstand what you are asking cygpath to do.

-u is the only option of cygpath that converts to POSIX form, and thus
the only option that makes it kosher to supply paths with backslashes to

All the other modes convert to Win32 form. Sometimes Win32 with forward
slashes (mixed mode) and sometimes Win32 with backslashes (windows and
dos modes). All these other modes expect POSIX paths as input, i.e. *no*
backslashes allowed.

When you convert to POSIX form, you need to supply a Win32 path, typically
\\DAEMON1\anrdaemon\.profile in your case, but I guess the forward slash
variant (//DAEMON1/anrdaemon/.profile) is also possible since Windows
in general (usually anyway) and cygpath in particular accepts that form

When you convert to one of the Win32 forms, you should supply POSIX
paths, //DAEMON1/anrdaemon/.profile in your case.

As you are apparently using the cmd "shell", the correct way to quote
arguments in order to preserve spaces etc, is to use double quotes
and escape all backslashes with an extra backslash.


cygpath -u \\DAEMON1\anrdaemon\.profile

is equivalent to

cygpath -u "\\\\DAEMON1\\anrdaemon\\.profile"


cygpath -m //DAEMON1/anrdaemon/.profile

is equivalent to

cygpath -m "//DAEMON1/anrdaemon/.profile"

>>  It you don't have a
>> desire to revisit your code later on and fix any breakage, that is...
> I don't. I code it with assumption that it could break, and if it will - i
> know where to look first. :)
>> (However, I'm not the cygpath author, but the src is readily available)
> Sure, I just don't know any of the C family languages enough to crawl through
> code for my answers. But I trust your explanation.
>> The fact that cygpath is not good for one-shot conversions from a Win32
>> path to some other form of Win32 path appears to not be explicitly
>> documented.

Let me correct myself, the user guide states this:

	"The cygpath program is a utility that converts Windows native
	filenames to Cygwin POSIX-style pathnames and vice versa."

Nothing there that hints at any usage where you can convert one Win32 form
to another Win32 form (without invoking cygpath twice, that is).

>>          But you should get the dos-file-warning if you try, which
>> should be a good hint that you are in murky waters.
> I've it disabled :P

Good for you ;-) BTW, why do you think it's there? Let me tell you; it's
there to let you know that you (or someone else) made a mistake and has
ventured into inadvisable territory. Putting your head in the sand doesn't
make the mistake go away.

> DOS file name warning popping up for cygpath trying to convert DOS-style name
> to UNIX style is somewhat... useless.

That's not when it's popping up. It pops up e.g. when you feed Win32 paths
to a POSIX-to-Win32 conversion.


Problem reports:
Unsubscribe info:

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