-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoo
More file actions
111 lines (96 loc) · 2.88 KB
/
foo
File metadata and controls
111 lines (96 loc) · 2.88 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# This file must be sourced from bash
# You cannot run it directly
#
# This sets up environment variables for a custom build environment
deactivate_foo () {
# reset old environment variables
if [ -n "${_OLD_FOO_PATH+set}" ] ; then
PATH="$_OLD_FOO_PATH"
export PATH
unset _OLD_FOO_PATH
fi
if [ -n "${_OLD_FOO_MANPATH+set}" ] ; then
MANPATH="$_OLD_FOO_MANPATH"
export MANPATH
unset _OLD_FOO_MANPATH
fi
if [ -n "${_OLD_FOO_CFLAGS+set}" ] ; then
CFLAGS="$_OLD_FOO_CFLAGS"
export CFLAGS
unset _OLD_FOO_CFLAGS
fi
if [ -n "${_OLD_FOO_CXXFLAGS+set}" ] ; then
CXXFLAGS="$_OLD_FOO_CXXFLAGS"
export CXXFLAGS
unset _OLD_FOO_CXXFLAGS
fi
if [ -n "${_OLD_FOO_LDFLAGS+set}" ] ; then
LDFLAGS="$_OLD_FOO_LDFLAGS"
export LDFLAGS
unset _OLD_FOO_LDFLAGS
fi
if [ -n "${_OLD_FOO_LD_RUN_PATH+set}" ] ; then
LD_RUN_PATH="$_OLD_FOO_LD_RUN_PATH"
export LD_RUN_PATH
unset _OLD_FOO_LD_RUN_PATH
fi
if [ -n "${_OLD_FOO_MAKEFLAGS+set}" ] ; then
MAKEFLAGS="$_OLD_FOO_MAKEFLAGS"
export MAKEFLAGS
unset _OLD_FOO_MAKEFLAGS
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi
if [ -n "$_OLD_FOO_PS1" ] ; then
PS1="$_OLD_FOO_PS1"
export PS1
unset _OLD_FOO_PS1
fi
unset FOO_ENV
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate_foo
fi
}
# unset irrelavent variables
deactivate_foo nondestructive
FOO_ENV="$HOME/local"
export FOO_ENV
_OLD_FOO_PATH="$PATH"
PATH="$FOO_ENV/usr/bin:$PATH"
export PATH
_OLD_FOO_MANPATH="$MANPATH"
MANPATH="$FOO_ENV/usr/share/man:$MANPATH"
export MANPATH
_OLD_FOO_CFLAGS="$CFLAGS"
CFLAGS="-I$FOO_ENV/usr/include $CFLAGS"
export CFLAGS
_OLD_FOO_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-I$FOO_ENV/usr/include $CXXFLAGS"
export CXXFLAGS
_OLD_FOO_LDFLAGS="$LDFLAGS"
LDFLAGS="-L$FOO_ENV/usr/lib -Wl,-rpath,$FOO_ENV/usr/lib $LDFLAGS"
export LDFLAGS
_OLD_FOO_LD_RUN_PATH="$LD_RUN_PATH"
LD_RUN_PATH="$FOO_ENV/usr/lib:$LD_RUN_PATH"
export LD_RUN_PATH
_OLD_FOO_MAKEFLAGS="$MAKEFLAGS"
MAKEFLAGS="-j1 $MAKEFLAGS"
export MAKEFLAGS
if [ -z "$FOO_ENV_DISABLE_PROMPT" ] &&
[ -z "$PATHIFY_DISABLE_PROMPT" ] ; then
_OLD_FOO_PS1="$PS1"
# Add env name before first non-whitespace PS1 char
PS1=$(echo "$PS1" | sed -e '0,/\S/s//[foo] &/')
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi