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: MSYS path behavior in Cygwin


tom wrote:

> I guess the two will be mutually exclusive, unless you Cygwin devs see some
> reason to merge some of Earnie's work.  I'm have to believe there's some reason
> why it hasn't been done though.  I'm sure it's non-trivial to say the least.
> 
> Thanks for the help anyways!  Cygwin and msys make life in Win32land bearable.

To do that would go against the grain of what Cygwin is trying to
accomplish: provide a full posix environment.  So to have
argument-translation code sort of defeats that purpose since all Cygwin
programs are supposed to recognise posix paths.

Now in reality, everyone has to run a non-Cygwin program from time to
time, so of course there will be times where you run up against this. 
But the question becomes, when should the library translate paths, and
when should it leave them alone?  Because you can't just unconditionally
do it.  The way MSYS handles this is by assuming that everything in the
MSYS bin directory is a MSYS binary that can handle posix paths, and
that everything else is a win32/mingw app that needs win32 paths.  Now
that's a rather stark and arbitrary distinction.  It works for MSYS
since it's intended to be a rather minimal system, just enough to build
packages using auto{conf,make},libtool.  But I think for Cygwin this
would be way too restrictive.

The workaround that I think most people use is a wrapper script that
essentially just runs "cygpath -w" on each argument and then execs $1. 
So you can type "wrapper win32program /posix/path/to/file" and it ends
up running "win32program c:/win32/path/to/file".  If you do it right,
you can make this quite generic, so that you just prepend "wrapper" (or
whatever you want to call it.)

Below is one that I use in my .bashrc that calls perl.  It's probably
got bugs, and it's not perfect -- for example if you pass something like
-I/usr/local/bin it will not know how to translate that.  But it gets
the job done for most win32 programs, so that you can type "dodos
notepad /tmp/foobar" for example.  It should work with filenames/paths
with spaces in them.

dodos () {
    perl - "$@" <<'_EOF_'

    my @args = shift (@ARGV);
    
    foreach (@ARGV) {
            chomp(my $arg = `cygpath -w "$_" 2>/dev/null`);
            $arg = $_ if (length($arg) == 0);
            push @args, $arg;
    }
    exec @args;
_EOF_
}

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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