-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCoDeS3D
executable file
·50 lines (43 loc) · 1.68 KB
/
CoDeS3D
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
#!/bin/sh
# Set up a CoDeS3D working environment. This should either run the CoDeS3D command directly
# or else drop the user to a shell where all CoDeS3D commands are accessible from anywhere in the filesystem.
# Currently only compatible with BaSH.
CODES3DPATH="$(readlink -f $0)"
while [ -h "$CODES3DPATH" ]; do
CODES3DDIR="$(cd -P "$(dirname "$CODES3DPATH" )" && pwd )"
CODES3DPATH="$(readlink "$CODES3DPATH")"
[[ $CODES3DPATH != /* ]] && SOURCE="$CURRDIR/$CODES3DPATH"
done
CODES3DDIR="$(cd -P "$(dirname "$CODES3DPATH" )" && pwd )"
if [ "$*" = "" ] ; then
# This script may be run as a symlink - need relative path from target if so
# In this instance, a CoDeS3D-enabled shell should be started
if [ `basename "$SHELL"` = "bash" ] ; then
#Set bash dot directory.
echo "Running $SHELL --rcfile $CODES3DDIR/docs/.env.codes3d"
CODES3DSHELL="$SHELL --rcfile $CODES3DDIR/docs/.env.codes3d"
else
if which bash > /dev/null ; then
echo "Running bash --rcfile $CODES3DDIR/docs/.bashrc"
CODES3DSHELL="bash --rcfile $CODES3DDIR/docs/.bashrc"
else
echo "To start a CoDeS3D shell, you must have the BaSH shell available"
echo "and in your path."
exit 1
fi
fi
echo """
Setting up CoDeS3D environment.
Type 'exit' or press Ctrl+D at any time to leave.
"""
# Add codes3d scripts to $PATH
export PATH="$PATH:$CODES3DDIR/codes3d"
# Run "CoDeS3D shell"
eval exec $CODES3DSHELL
else
# Otherwise, the user only wishes to run a single command
export PATH="$PATH:$CODES3DDIR/codes3d"
cmd=`basename "$1" .py`.py
shift
exec "$CODES3DDIR/codes3d/$cmd" "$@"
fi