delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/29/07:48:31

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <3D452B78.9090400@attbi.com>
Date: Mon, 29 Jul 2002 06:48:08 -0500
From: "Cyber.Zombie" <Cyber DOT Zombie AT attbi DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1b) Gecko/20020721
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: "Gerrit P. Haase" <gp AT familiehaase DOT de>
CC: cygwin AT cygwin DOT com
Subject: Re: Useful Cygwinism #2: PATH Despacifier/Deduplicateifier
References: <NCBBIHCHBLCMLBLOBONKCEOEDCAA DOT g DOT r DOT vansickle AT worldnet DOT att DOT net> <3D44C20F DOT 7030005 AT attbi DOT com> <6234073304 DOT 20020729074838 AT familiehaase DOT de>

/usr/local/bin>diff -b despaceify.pl~ despaceify.pl
1a2
 > #
6,12c7,9
< @pathcomps = split(/:/, shift);
< for(@pathcomps)
< {
<        if(!exists($comps_seen_already{$_}))
<        {
<                my $path;
<                $path='"'.$_.'"';
---
 > @pathcomps=split(/:/, shift);
 > for(@pathcomps) {
 >       my $path='"'.$_.'"';
14a12
 >       if(!exists($comps_seen_already{$path})) {
15a14
 >               $comps_seen_already{$path}=1;
17d15
<        $comps_seen_already{$_}=1;

Gerrit P. Haase wrote:

>Hallo Cyber.Zombie,
>
>Am Montag, 29. Juli 2002 um 06:18 schriebst du:
>
>  
>
>>A suggested improvement:  Sometimes multiple paths are mount points to 
>>the same directory and won't get noticed until the path has been 
>>corrected.  The following rework will further cleanup $PATH:
>>    
>>
>
>  
>
>>#!/usr/bin/perl -w
>>#
>>use strict;
>>my @pathcomps;
>>my @pathcomps_out;
>>my %comps_seen_already;
>>@pathcomps = split(/:/, shift);
>>for(@pathcomps) {
>>        my $path='"'.$_.'"';
>>        $path=qx(cygpath -u \$(cygpath -ws $path));
>>        $path=~tr/\n//d;
>>        if(!exists($comps_seen_already{$path})) {
>>                push(@pathcomps_out, $path);
>>                $comps_seen_already{$path}=1;
>>        }
>>}
>>print join(":", @pathcomps_out);
>>    
>>
>
>Where is the difference now to the first version?
>
>  
>
>>>=========================================================
>>>#!/usr/bin/perl -w
>>>use strict;
>>>my @pathcomps;
>>>my @pathcomps_out;
>>>my %comps_seen_already;
>>>@pathcomps = split(/:/, shift);
>>>for(@pathcomps)
>>>{
>>>       if(!exists($comps_seen_already{$_}))
>>>       {
>>>               my $path;
>>>               $path='"'.$_.'"';
>>>               $path=qx(cygpath -u \$(cygpath -ws $path));
>>>               $path=~tr/\n//d;
>>>               push(@pathcomps_out, $path);
>>>       }
>>>       $comps_seen_already{$_}=1;
>>>}
>>>print join(":", @pathcomps_out);
>>>==========================================================
>>>      
>>>
>
>
>  
>





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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