Skip to content

Commit a508c76

Browse files
committed
Improve the roboviz shell script
Instead of parsing the arguments and replacing the paths to the log files with absolute paths, we'll just keep the current working directory. We then refer to the Jar file through the already existing DIR variable. This also supports setting the Dock icon on macOS if the application is running inside of a bundled application. And on top of that, the script should now be compatible with other POSIX-compatible shells (not just bash).
1 parent b0e26b8 commit a508c76

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

scripts/roboviz.sh

+11-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

3-
args=""
4-
while [ $# -gt 0 ]
5-
do
6-
if [[ $1 == --logFile=* ]];
7-
then
8-
logFileName=${1#*=}
9-
DIR_LOGFILE="$( eval cd "$( dirname "$logFileName" )" && pwd )"
10-
LOGFILE=$DIR_LOGFILE/$(basename $logFileName)
11-
args="$args --logFile=$LOGFILE"
12-
else
13-
args="$args $1"
14-
fi
15-
shift 1
16-
done
3+
DIR="$( cd "$( dirname "$0" )" && pwd )"
174

18-
set -- $args
19-
20-
DIR="$( cd "$( dirname "$0" )" && pwd )"
21-
cd $DIR
22-
23-
if [[ `uname -s` == "Darwin" ]];
5+
VM_ARGS="-Xmx512m --add-exports=java.desktop/sun.awt=ALL-UNNAMED"
6+
if [ `uname -s` = "Darwin" ];
247
then
25-
java -Xmx512m --add-exports=java.desktop/sun.awt=ALL-UNNAMED -Xdock:name="RoboViz" -jar RoboViz.jar "$@"
26-
else
27-
java -Xmx512m --add-exports=java.desktop/sun.awt=ALL-UNNAMED -jar RoboViz.jar "$@"
8+
VM_ARGS="$VM_ARGS -Xdock:name=RoboViz"
9+
if [ -f "$DIR/../Resources/icon.icns" ];
10+
then
11+
VM_ARGS="$VM_ARGS -Xdock:icon=$DIR/../Resources/icon.icns"
12+
fi
2813
fi
14+
15+
java $VM_ARGS -jar "$DIR/RoboViz.jar" "$@"

0 commit comments

Comments
 (0)