[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [50 character or so descriptive subject here (for reference)]
From: |
Chris F.A. Johnson |
Subject: |
Re: [50 character or so descriptive subject here (for reference)] |
Date: |
Mon, 28 Jan 2002 15:13:32 GMT |
On Mon, 28 Jan 2002, Phil Benchoff wrote:
> On Mon, Jan 28, 2002 at 08:47:29AM -0500, Chet Ramey wrote:
> > > Machine Type: i586-mandrake-linux-gnu
> > >
> > > Bash Version: 2.05
> > > Patch Level: 1
> > > Release Status: release
> > >
> > > Description:
> > > :: on path causes cwd to be searched for executables, i.e. ::
> > > in the path acts like :.:
> >
> > This is not a bug. This is how Bourne-style shells have always behaved.
>
> Thanks for the reply. That is kind of an unfortunate behavior. It
> ended up on my path via an assortment of startup scripts that do
> things like
>
> PATH=$PATH:/some/new/dir
> or
> PATH=/some/new/dir:$PATH
>
> Anyway, I'll figure out where I'm getting it from and fix it.
>
> You may want to consider a builtin function that will remove :: from the
> path or maybe one that will prevent the current directory from being
> searched even if it is on the path.
It's easy to remove them:
PATH=${PATH//::/:}
A leading or trailing colon will also add the current directory to
your path. Remove them with:
PATH=${PATH%:}
PATH=${PATH#:}
Or you could use a function to add new directories to your path;
I use this (with some embellishments):
addpath ()
{
path="${PATH//:/
}";
for p in "$@"
do
case $path in
*$p*)
echo "$p already in path" >&2
return 1
;;
esac
if [ -d "$p" ]
then
PATH="$PATH:$p"
else
echo "addpath: $p is not a directory" >&2
return 1
fi
done
}
--
Chris F.A. Johnson bq933@torfree.net
=================================================================
c.f.a.johnson@rogers.com http://cfaj.freeshell.org
cfaj@freeshell.org http://members.rogers.com/c.f.a.johnson
- Re: [50 character or so descriptive subject here (for reference)], (continued)
[50 character or so descriptive subject here (for reference)], elk, 2002/01/21
[50 character or so descriptive subject here (for reference)], benchoff, 2002/01/25
Re: [50 character or so descriptive subject here (for reference)], Chet Ramey, 2002/01/28
Re: [50 character or so descriptive subject here (for reference)], Chet Ramey, 2002/01/28