X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,TW_YG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Message-ID: <4E07A11F.4050405@lysator.liu.se> Date: Sun, 26 Jun 2011 23:14:07 +0200 From: Peter Rosin User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Strange cygpath behavior. References: <73619422 DOT 20110621092310 AT mtu-net DOT ru> <4E00321A DOT 30105 AT lysator DOT liu DOT se> <92658329 DOT 20110623165230 AT mtu-net DOT ru> <4E03492D DOT 40109 AT gmail DOT com> <1144668147 DOT 20110623190534 AT mtu-net DOT ru> <4E035F46 DOT 7000207 AT gmail DOT com> <1291997550 DOT 20110623220605 AT mtu-net DOT ru> <4E063FBF DOT 8040103 AT lysator DOT liu DOT se> <48666308 DOT 20110626195750 AT mtu-net DOT ru> In-Reply-To: <48666308.20110626195750@mtu-net.ru> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 cygpath. 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 too. 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. E.g cygpath -u \\DAEMON1\anrdaemon\.profile is equivalent to cygpath -u "\\\\DAEMON1\\anrdaemon\\.profile" and 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. Cheers, Peter -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple