delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/01/30/17:44:45

X-Spam-Check-By: sourceware.org
Message-ID: <43DE9658.FBF4BF05@dessent.net>
Date: Mon, 30 Jan 2006 14:42:32 -0800
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: MSYS path behavior in Cygwin
References: <loom DOT 20060130T172329-717 AT post DOT gmane DOT org> <01a101c625bb$56eef210$a501a8c0 AT CAM DOT ARTIMI DOT COM> <loom DOT 20060130T174810-589 AT post DOT gmane DOT org> <loom DOT 20060130T212138-937 AT post DOT gmane DOT org>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019