cygpath -m behaviour change

Robert Pendell shinji+cygwin@elite-systems.org
Mon Sep 16 15:03:00 GMT 2013


On Mon, Sep 16, 2013 at 5:56 AM, David Griffiths <> wrote:
>> Yes, that's exactly right, assuming that 'boo' doesn't exist.
>
> Hi, it happens even if boo does exist. To put it in context, the
> script in question was attempting to determine the current directory:
>
> CURRENT_DIR=$(cygpath -ma "${0}"/../)
>
> (I didn't write this script but I assume they did this for performance reasons.)
>
> But anyway, as you can see ${0} always exists.
>
> I looked at the other thread but don't see an immediate connection as
> that was checking for non-existing path members.
>
> Cheers,
>
> Dave
>

I have no idea why they are doing that.  ${0} always gives back the
name of the program you ran.  It is very common to use $0 in scripts
in order to refer to itself in text given back to the user.

If you need to get the current directory $PWD is always available and
you don't need to use your own variable for it. (just like in linux,
unix, and other similar environments following that they are not
exactly equal)

For a reference point I'll give you what cygwin gave me when I ran the
command as you showed it.

Robert@Shinji-PC ~
$ cygpath -ma ${0}/../
cygpath: unknown option -- b
Try `cygpath --help' for more information.

That would be expected because for me ${0} (during echo) gave back
-bash as the output and cygpath will interpret that as additional
options.

I also checked to make sure cygpath is working as expected (at least
the way I think it should be working) and it tested ok.

Robert@Shinji-PC ~
$ uname -a
CYGWIN_NT-6.2-WOW64 Shinji-PC 1.7.25(0.270/5/3) 2013-08-31 20:39 i686 Cygwin

Robert@Shinji-PC ~
$ mkdir test

Robert@Shinji-PC ~
$ cygpath -m test/..
./

Robert@Shinji-PC ~
$ rmdir test

Robert@Shinji-PC ~
$ cygpath -m test/..
cygpath: error converting "test/.." - No such file or directory

I did find another odd bit with cygpath though.  It seems that if you
have .. to start the path to check it will translate it no matter
what.  A bug maybe?

(STC)
Robert@Shinji-PC ~
$ ls ../
Robert

Robert@Shinji-PC ~
$ ls ../test
ls: cannot access ../test: No such file or directory

Robert@Shinji-PC ~
$ cygpath -ma ..
D:/cygwin/home

Robert@Shinji-PC ~
$ cygpath -ma ../test
D:/cygwin/home/test


Robert Pendell
A perfect world is one of chaos.

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



More information about the Cygwin mailing list