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: cygpath behaviour when input is not a path


On 01/06/2010 09:19, Gary . wrote:
> On 5/31/10, Dave Korn wrote:
>> On 30/05/2010 08:51, Gary wrote:
>>> Since the tool
>>> output is mixed paths and text, I'd hoped cygpath made "intelligent"
>>> guesses about what was and was not likely to be a path.
>>>
>>   Well, that is basically what it does; but, being a POSIX tool, the
>> consequence is that it assumes that a colon is just a char like any other in
>> a filename.
> 
> Okay. So I'm SOL with tool output like
> "Parse error: syntax error, unexpected '}' in
> C:\cygwin\home\jg\work\foo.php on line 10"
> then, short of parsing it myself :-(

  Hang on, isn't this is a bit far from your original question?  You wanted to
know what happens when cygpath is "given a PATH list ... without the -p
option".  Now you're telling me that you want to feed it a bunch of gibberish,
amongst which might or might not be a path, and have it spot that?  I think
you oversimplified the initial presentation a little there!

> Actually cygpath's response to the tool ouput in this instance was
> "cygpath: can't convert empty path"
> although that seems to be a barf on a previous, empty, line of output,
> because on testing just that line with cygpath -u I got
> "Parse error: syntax error, unexpected '}' in C:/cygwin/home/jg/work/foo.php on
> line 10"
> That is, the path is more posix-like, but certainly isn't "unixified".

  Well, have you ever heard the term GIGO?  That's basically what you're
getting here.  cygpath expects anything you pass it is a path, and given the
flexibility of the POSIX filename character set, it can't really be expected
to know better; how does it know you don't mean what you say?  After all, ...

> $ pushd /tmp/
> /tmp ~
> 
> $ mkdir posixpaths
> 
> $ cd posixpaths/
> 
> $ touch "Parse error: syntax error, unexpected '}' in"
> 
> $ ls -la
> total 0
> drwxr-xr-x+ 1 Admin None 0 2010-06-02 14:17 .
> drwxrwxrwt  1 Admin None 0 2010-06-02 14:17 ..
> -rw-r--r--  1 Admin None 0 2010-06-02 14:17 Parse error: syntax error, unexpec
> ted '}' in
> 
> $

... you might have a file by that name!  Sounds to me like you want to pipe it
through sed or grep (probably via d2u on the way) to extract just the
filenames and pass them to cygpath.

    cheers,
      DaveK


--
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


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