Quote paths and use platform separator so script works on Windows
[cev.git] / jev
blob2a94adfd1463296f40ea08081e18fb2d099664a7
1 #!/bin/bash -e
4 # Copyright (C) 2004 Robin Rosenberg.
6 # This program is available under the terms of the GNU Public License.
9 while [ "${1:0:1}" = "-" ]
11 case "$1" in
12 -*)
13 FLAGS="$FLAGS $1";
14 shift 1
16 esac
17 done
19 if [ "$OS" = "Windows_NT" ];then sep=";";else sep=":";fi
21 mkdir -p $HOME/.jev
22 if [ ! -f $HOME/.jev/stdimport ]
23 then
24 cat >$HOME/.jev/stdimport <<EOF
25 import java.io.*;
26 import java.util.*;
27 import java.awt.*;
28 import javax.swing.*;
29 import java.net.*;
30 import java.nio.*;
31 EOF
33 cp=
34 if [ -f $HOME/.jev/stdclasspath ]
35 then
36 while read p
38 cp="$cp${sep}$p"
39 done < $HOME/.jev/stdclasspath
42 TMP=${TMP:-/tmp}
43 class=jev$$
44 tmpf=$TMP/${class}.java
45 tmpx="$TMP/${class}.class $TMP/${class}\$*.class"
46 trap "cat $tmpf;rm -f $tmpf $tmpfx" 0
47 cat >$tmpf <$HOME/.jev/stdimport
48 cat >>$tmpf <<EOF
49 public class $class {
50 EOF
52 while [ $# -gt 1 ]
54 echo >>$tmpf "$1"
55 shift 1
56 done
58 cat >>$tmpf <<EOF
59 public static void main(String[] args) throws Throwable
61 $1;
64 EOF
65 javac -d $TMP -cp "$cp$sep$TMP" $tmpf
66 time java -cp "$cp$sep$TMP" $class
67 if [ ! -f $TMP/${class}.class ]
68 then
69 cat $tmpf
72 rm -f $(echo $tmpx)