File: bshd

package info (click to toggle)
bsh 2.0b4-8
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,072 kB
  • ctags: 3,680
  • sloc: java: 23,424; xml: 4,484; sh: 134; makefile: 21
file content (59 lines) | stat: -rw-r--r-- 1,602 bytes parent folder | download | duplicates (22)
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
#!/bin/sh
#
# Run the BeanShell interpreter on a file with command line arguments.  If the
# user has bsh.Interpreter in their classpath then the interpreter is executed 
# with the user's classpath.  Otherwise, the default bsh path specified in 
# DEFAULTBSH is added to end of the user's path.
#
# If you wish to avoid the classpath test (which uses javap) then you can set
# the environment variable NOBSHCHECK to a value and the user classpath will
# always be used.
#

# The (hard coded) location of a default bsh jar.
# e.g. Win
#DEFAULTBSH=`cygpath --windows $HOME/pkg/bsh-1.3a1.jar`
# e.g. Unix
DEFAULTBSH=/home/pat/bin/bsh-1.3a1.jar

name=`basename $0`
if [ $name = "bshd" ]; then
	debug="-Ddebug=true"
fi

# Determine if we're running under Unix or Cygwin/windows
if uname | grep -i 'cygwin' 2>&1 > /dev/null
then
	# (Using cygpath has issues with drive letters, etc.)
	_PATHSEP=';'
	_CYGWIN=true;
else
	_PATHSEP=':'
fi

# Avoid adding the default bsh jar to the classpath unecessarily.
# For most purposes this wouldn't matter... but for testing bsh we'd like to
# avoid extra bsh junk.
#
if [ "$NOBSHCHECK" ] || javap bsh.Interpreter 2>&1 | 
	grep 'public class bsh.Interpreter extends' > /dev/null
then
	# Have bsh
	java $debug bsh.Interpreter $* 
else
	if [ ! -f $DEFAULTBSH ]; then
		echo "BeanShell not found at path: $DEFAULTBSH"
		exit;
	fi

	# Don't have bsh
	# Cygwin doesn't like an extra leading path separator, avoid it
	if [ "$CLASSPATH" ]; then
		path="${CLASSPATH}${_PATHSEP}${DEFAULTBSH}"
	else
		path=${DEFAULTBSH}
	fi

	java $debug -classpath $path bsh.Interpreter $* 
fi