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 -m behaviour change

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

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?

Robert@Shinji-PC ~
$ ls ../

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

Robert@Shinji-PC ~
$ cygpath -ma ..

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

Robert Pendell
A perfect world is one of chaos.

Problem reports:
Unsubscribe info:

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