forked from adamfisk/LittleProxy
/
shell.nw
31 lines (25 loc) · 806 Bytes
/
shell.nw
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
<<sh preamble>>=
#!/bin/sh
set -eu
die(){ ev=$1; shift; for msg in "$@"; do echo "${msg}"; done; exit "${ev}"; }
@
<<sh preamble and set PATH and CLASSPATH>>=
<<sh preamble>>
thispath=`perl -MCwd=realpath -le'print(realpath(\$ARGV[0]))' -- "${0}"`
thisprog=${thispath##*/}
if [ -r "${thispath%*.sh}-config.inc.sh" ]; then
. "${thispath%*.sh}-config.inc.sh"
classpath_file=${thispath%*.sh}.classpath
CLASSPATH=${thispath%*.sh}.jar
elif [ -r "target/${thisprog%*.sh}-config.inc.sh" ]; then
. "target/${thisprog%*.sh}-config.inc.sh"
classpath_file=target/mdep.classpath
CLASSPATH=target/classes
else
die 1 "Error, could not find ${thispath%*.sh}-config.inc.sh."
fi
CLASSPATH=${CLASSPATH}:`cat "${classpath_file}"`
export CLASSPATH
PATH=${JAVA_HOME}/bin:${PATH}
export PATH
@