-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·55 lines (45 loc) · 1.3 KB
/
run.sh
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
#!/bin/bash
declare MEMORY="5M"
declare sql=""
declare connection="$1"
declare parameter=""
declare -r ABSPATH="$(dirname $0)"
declare -r current_path="$(pwd)"
cd $ABSPATH
declare SP=";"
if [ "$(uname)" == "Darwin" ]; then
SP=":"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
SP=":"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
SP=";"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
SP=";"
fi
declare JAVA_OPTS="-Xmx${MEMORY} -client"
function setup()
{
if [ ! -d "target/" ]; then
mvn package dependency:copy-dependencies
else
if [ ! -d "target/dependency/" ]; then
mvn dependency:copy-dependencies
fi
fi
}
setup
if [ -e "$2" ]; then
parameter="$1 < $2"
java $JAVA_OPTS -cp "target/classes/${SP}./target/dependency/\*" com.edgardleal.sqlshell.Main $1 < $2
else
if [ "$#" == "1" ]; then
# tmp_file="$(mktemp -t sqlshell).sql"
tmp_file="$(mktemp).sql"
trap "rm $tmp_file; exit" 0 1 2 3 15
vim $tmp_file
java $JAVA_OPTS -cp "target/classes/${SP}./target/dependency/\*" com.edgardleal.sqlshell.Main $1 < $tmp_file
else
java $JAVA_OPTS -cp "target/classes/${SP}./target/dependency/\*" com.edgardleal.sqlshell.Main "$1" "$2"
fi
fi
cd $current_path