delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/07/26/12:51:17

X-Spam-Check-By: sourceware.org
Date: Wed, 26 Jul 2006 12:51:05 -0400
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Why are Windows paths broken in make 3.81?
Message-ID: <20060726165105.GA25656@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <9c2aabaf0607211629u4e29ffa1w5f09b3d8e5a923fc AT mail DOT gmail DOT com> <e9rrqr$6ei$1 AT sea DOT gmane DOT org> <9c2aabaf0607260912n4d17a340j533a049565234c00 AT mail DOT gmail DOT com> <20060726162609 DOT GA24491 AT trixie DOT casa DOT cgf DOT cx>
Mime-Version: 1.0
In-Reply-To: <20060726162609.GA24491@trixie.casa.cgf.cx>
User-Agent: Mutt/1.5.11
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
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

On Wed, Jul 26, 2006 at 12:26:09PM -0400, Christopher Faylor wrote:
>Maybe someone here would be willing to post a sed transformation which
>would change c:\some\dos\path to /cygdrive/c/some/dos/path.

Here are two simple, imperfect proof-of-concept perl scripts.

The first one just translates everything to /cygdrive/X/foo.  The second
one uses cygpath to get mount-table-aware paths.

And, to reiterate: I know that these aren't perfect and miss some cases
(like when part of a filename is located in a variable).  I merely offer
them as is as an example of what could be done.

cgf

#!/usr/bin/perl
while (<>) {
    s!\b([a-z]):((?:[/\\][^/\\\s]+)+)!"/cygdrive/$1" . &fixslash($2)!eg;
    print;
}

sub fixslash {
    my $x = shift;
    $x =~ s%\\%/%g;
    return $x;
}

#!/usr/bin/perl
while (<>) {
    s!\b([a-z]:(?:[/\\][^/\\\s]+)+)!&fix($1)!eg;
    print;
}

sub fix {
    my $x = `cygpath -u '$_[0]'`;
    chomp $x;
    return $x;
}

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