-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.profile_functions
29 lines (25 loc) · 1.01 KB
/
.profile_functions
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
#!/bin/bash
function add_prefix
{
for newPrefix in "$@"; do
while [ "$newPrefix" != "${newPrefix%/}" -o "$newPrefix" != "${newPrefix%/.}" ]; do
newPrefix=${newPrefix%.}
newPrefix=${newPrefix%/}
done
if [ -d "$newPrefix/bin" ]; then
export PATH="$(sed 's,\(\^\|\(:\)\)'"$newPrefix"'/bin\(\$\|\(:\)\),\2\4,;s/:\+/:/g'<<<"$PATH")"
[ -n "$PATH" ] && export PATH=":$PATH"
export PATH="$newPrefix/bin$PATH"
fi
if [ -d "$newPrefix/lib" ]; then
export LD_LIBRARY_PATH="$(sed 's,\(\^\|\(:\)\)'"$newPrefix"'/lib\(\$\|\(:\)\),\2\4,;s/:\+/:/g'<<<"$PATH")"
[ -n "$LD_LIBRARY_PATH" ] && export LD_LIBRARY_PATH=":$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$newPrefix/lib$LD_LIBRARY_PATH"
fi
if [ -d "$newPrefix/lib/pkgconfig" ]; then
export PKG_CONFIG_PATH="$(sed 's,\(\^\|\(:\)\)'"$newPrefix"'/lib/pkgconfig\(\$\|\(:\)\),\2\4,;s/:\+/:/g'<<<"$PATH")"
[ -n "$PKG_CONFIG_PATH" ] && export PKG_CONFIG_PATH=":$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="$newPrefix/lib/pkgconfig$PKG_CONFIG_PATH"
fi
done
}