Skip to content

Commit bef7bb5

Browse files
Allow spaces in IDE install path on Linux
The startup bash script lacked quotes in some places, causing it to interpret part of the path to the splash image as the main class and fail to start: arduino: line 29: [: /home/a/Arduino: binary operator expected Error: Could not find or load main class IDE.lib.splash.png For the -splash option, simply adding quotes was not sufficient. If no splash screen was to be used (so when $SPLASH was empty), using "$SPLASH" would result in an empty argument being passed to java, which was then interpreted by java as the name of the base class. To allow spaces to occur in the -splash option, but also allow it to be omitted entirely, options to java are now passed through the $JAVA_OPTIONS array. By using the special "${JAVA_OPTIONS[@]}" syntax, each element in the array is expanded into a single argument, even when spaces are present inside (this is identical to what happens with "$@"). This fixes #3950
1 parent c1ce649 commit bef7bb5

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

build/linux/dist/arduino

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
APPDIR="$(dirname -- "$(readlink -f -- "${0}")" )"
44

55
for LIB in \
6-
$APPDIR/java/lib/rt.jar \
7-
$APPDIR/java/lib/tools.jar \
8-
$APPDIR/lib/*.jar \
6+
"$APPDIR"/java/lib/rt.jar \
7+
"$APPDIR"/java/lib/tools.jar \
8+
"$APPDIR"/lib/*.jar \
99
;
1010
do
1111
CLASSPATH="${CLASSPATH}:${LIB}"
@@ -17,18 +17,19 @@ export LD_LIBRARY_PATH
1717

1818
export PATH="${APPDIR}/java/bin:${PATH}"
1919

20-
if [[ "$@" == *"--upload"* || "$@" == *"--verify"* || "$@" == *"--get-pref"* || "$@" == *"--install-board"* || "$@" == *"--install-library"* ]] ; then
21-
SPLASH=""
22-
else
23-
SPLASH="-splash:$APPDIR/lib/splash.png"
24-
fi
25-
2620
export JAVA_TOOL_OPTIONS=`echo $JAVA_TOOL_OPTIONS | sed 's|-javaagent:/usr/share/java/jayatanaag.jar||g'`
2721

2822
JAVA=java
29-
if [ -x $APPDIR/java/bin/java ]; then
23+
if [ -x "$APPDIR/java/bin/java" ]; then
3024
JAVA=$APPDIR/java/bin/java
3125
fi
3226

33-
$JAVA -DAPP_DIR="$APPDIR" -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel $SPLASH processing.app.Base "$@"
27+
# Collect options to java in an array, to properly handle whitespace in options
28+
JAVA_OPTIONS=("-DAPP_DIR=$APPDIR" "-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel")
29+
30+
if [[ "$@" != *"--upload"* && "$@" != *"--verify"* && "$@" != *"--get-pref"* && "$@" != *"--install-board"* && "$@" != *"--install-library"* ]] ; then
31+
JAVA_OPTIONS+=("-splash:$APPDIR/lib/splash.png")
32+
fi
33+
34+
$JAVA "${JAVA_OPTIONS[@]}" processing.app.Base "$@"
3435

0 commit comments

Comments
 (0)