Gentoo Archives: gentoo-user

From: Alex Schuster <wonko@×××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] $PATH
Date: Mon, 18 Dec 2006 00:15:05
Message-Id: 200612180110.37176.wonko@wonkology.org
In Reply to: Re: [gentoo-user] $PATH by "Jesús Guerrero" <6thpink@terra.es>
1 Jesús Guerrero writes:
2
3 > "Boris Fersing" <kernelsensei@g.o> escribió:
4 > > You don't need to export the variable...
5 >
6 > You do, unless you plan to use that variable only instead of the
7 > script, in this case, ~/.bashrc
8
9 But PATH is exported already, so there is no need to do this again I think.
10
11 > And one thing you should consider is to use something to check if the
12 > path has been already added. Otherwise you will end having a lot of
13 > times that same path in your ${PATH} variable.
14 >
15 > For example:
16 >
17 > if [[ -n `echo $PATH | grep "/insert/your/path/here"` ]]
18 > then
19 >
20 > : # Fallback
21 >
22 > else
23 > PATH=/usr/local/bin:$PATH
24 > export PATH
25 > fi
26
27 Or a little shorter:
28
29 path=/insert/your/path/here
30 [[ $PATH = *$path* ]] || PATH=$path:$PATH
31
32 Alex
33
34 --
35 gentoo-user@g.o mailing list