-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathsetenv
74 lines (64 loc) · 1.55 KB
/
setenv
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
#!/bin/sh
case "$-" in
*i*);;
*) exit 1;;
esac
if test -n "${VIRTUAL_ENV}"; then
echo >&2 "You are already in a VIRTUAL_ENV: ${VIRTUAL_ENV}."
return 1
fi
__old_pwd="$(pwd)"
if ! test -f "${__old_pwd}/setenv"; then
echo >&2 "This does not look like the QUISP directory."
return 1
fi
if which omnetpp >/dev/null 2>/dev/null; then
eval "activate () {
export PATH=\"${__old_pwd}/bin:$PATH\"
export HOSTNAME
export HOST
export VIRTUAL_ENV=\"quisp\"
deactivate () {
export PATH=\"$PATH\"
unset VIRTUAL_ENV
unset -f deactivate
}
unset -f activate
}"
else
while true; do
cd ..
__omnetpp_setenv="$(find -L . -maxdepth 2 -type f -name 'setenv' -path '*omnetpp*' 2>/dev/null | head -n1)"
if [ -n "${__omnetpp_setenv}" ]; then
# __omnetpp_root="$(realpath "$(dirname "${__omnetpp_setenv}")")"
__omnetpp_root="$(cd "$(dirname "${__omnetpp_setenv}")" && pwd)"
cd "${__old_pwd}"
break
fi
if [ "$(pwd)" = "/" ]; then
cd "${__old_pwd}"
echo "Could not find OmNET++"
return 1
fi
done
eval "activate () {
if [ `uname` = \"Darwin\" ]; then
export PATH=\"${__omnetpp_root}/tools/macosx/bin:$PATH\"
export QT_PLUGIN_PATH=\"${__omnetpp_root}/tools/macosx/plugins\"
else
export PATH=\"$PATH\"
fi
export PATH=\"${__old_pwd}/bin:${__omnetpp_root}/bin:\$PATH\"
export HOSTNAME
export HOST
export VIRTUAL_ENV=\"quisp\"
deactivate () {
export PATH=\"$PATH\"
unset QT_PLUGIN_PATH ||true
unset VIRTUAL_ENV
unset -f deactivate
}
unset -f activate
}"
fi
activate