Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# $HOME/bin/functions
# usage $HOME/bin/functions [unset]
if [ "$1" = "unset" ]; then
# UNSET the functions used
unset pathmunge pathremmunge
else
# .... loading ....
################################################################################
################################################################################
# Functions - notice no indenting for ease of reading
################################################################################
################################################################################
# pathmunge (from /etc/profile)
# default is to APPEND though!!!
pathmunge () {
# check for not existing
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "prepend" ] ; then
PATH=$1:$PATH
else
PATH=$PATH:$1
fi
fi
}
pathremmunge () {
# check for existing
if echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "remove" ] ; then
local IFS=::
NEW=
for d in $PATH ; do
if [ "$1" != "$d" ] ; then
# echo
NEW=$NEW$d:
fi
done
PATH=$NEW
fi
else
# didn't exist, maybe called by mistake
# might as well call pathmunge
pathmunge $1 $2
fi
}
fi