Notable bash $PATH behavior trivia

Kevin D. Clark kclark at CetaceanNetworks.com
Thu Jan 2 18:06:04 EST 2003


I offer the following snippet of code that you can stick in your
.profile -- among other things (*), I use this code to get around the
problem that you reported:

  # clean up paths
  if perl -e 'require 5' >/dev/null 2>&1 ; then
    PATH=`perl -e 'print join ":", grep {-d && !$d{$_}++} split /:/, $ENV{'PATH'}'`
    MANPATH=`perl -e 'print join ":", grep {-d && !$d{$_}++} split /:/, $ENV{'MANPATH'}'`
  fi

Place this near the end of your .profile .

*  This also preserves the order of things in your path, removes
   non-existent directories, and removes duplicates.


Regards,

--kevin
-- 
``It's a bivouac, man.  They sleep here.''
      - Perfect Tommy




More information about the gnhlug-discuss mailing list