comparison installer-files/octave.bat @ 4645:56a712112482

octave.bat: Rewrite to set QT_PLUGIN_PATH (bug #53419). * octave.bat: Set QT_PLUGIN_PATH to avoid segfault. Use if/else/if tree to parse arguments rather than more complicated strategy with goto statements. Indent code for clarity.
author Rik <rik@octave.org>
date Tue, 27 Mar 2018 16:56:01 -0700
parents b0cb0218813c
children 89a9c9a80669
comparison
equal deleted inserted replaced
4644:c3950e2b4066 4645:56a712112482
1 @echo off 1 @echo off
2 Rem Find Octave's install directory through cmd.exe variables. 2 Rem Find Octave's install directory through cmd.exe variables.
3 Rem This batch file should reside in Octaves installation subdir! 3 Rem This batch file should reside in Octaves installation subdir!
4 Rem 4 Rem
5 Rem This trick finds the location where the batch file resides. 5 Rem This trick finds the location where the batch file resides.
6 Rem Note: the result ends with a backslash 6 Rem Note: the result ends with a backslash.
7 set OCT_HOME=%~dp0 7 set OCT_HOME=%~dp0
8 Rem Coonvert to 8.3 format so dont have to worry about spaces 8 Rem Convert to 8.3 format so we don't have to worry about spaces.
9 for %%I in ("%OCT_HOME%") do set OCT_HOME=%%~sI 9 for %%I in ("%OCT_HOME%") do set OCT_HOME=%%~sI
10 10
11 Rem Set up PATH. Make sure the octave bin dir 11 Rem Set up PATH. Make sure the octave bin dir comes first.
12 Rem comes first.
13 12
14 set PATH=%OCT_HOME%qt5\bin;%OCT_HOME%bin;%PATH% 13 set PATH=%OCT_HOME%qt5\bin;%OCT_HOME%bin;%PATH%
15 14
16 Rem Set up any environment vars we may need 15 Rem Set up any environment vars we may need.
17 16
18 set TERM=cygwin 17 set TERM=cygwin
19 set GNUTERM=wxt 18 set GNUTERM=wxt
20 set GS=gs.exe 19 set GS=gs.exe
20
21 Rem QT_PLUGIN_PATH must be set to avoid segfault (bug #53419).
22 IF EXIST "%OCT_HOME%\qt5\bin\" (
23 set QT_PLUGIN_PATH=%OCT_HOME%\qt5\plugins
24 ) ELSE (
25 set QT_PLUGIN_PATH=%OCT_HOME%\plugins
26 )
21 27
22 Rem set home if not already set 28 Rem set home if not already set
23 if "%HOME%"=="" set HOME=%USERPROFILE% 29 if "%HOME%"=="" set HOME=%USERPROFILE%
24 if "%HOME%"=="" set HOME=%HOMEDRIVE%%HOMEPATH% 30 if "%HOME%"=="" set HOME=%HOMEDRIVE%%HOMEPATH%
25 Rem set HOME to 8.3 format 31 Rem set HOME to 8.3 format
26 for %%I in ("%HOME%") do set HOME=%%~sI 32 for %%I in ("%HOME%") do set HOME=%%~sI
27 33
28 Rem Check for args to see if we are told to start GUI 34 Rem Check for args to see if we are told to start GUI (--gui, --force-gui)
29 Rem with the --force-gui option or not (--no-gui) 35 Rem or not (--no-gui).
30 Rem Otherwise assume starting as command line 36 Rem If nothing is specified, start the GUI.
31 set GUI_MODE=1 37 set GUI_MODE=1
32 :checkargs 38 :checkargs
33 if -%1-==-- goto noargs 39 if -%1-==-- goto args_done
34 if NOT %1==--force-gui goto notguiarg 40
35 set GUI_MODE=1 41 if %1==--gui (
36 :notguiarg 42 set GUI_MODE=1
37 if NOT %1==--no-gui goto notnoguiarg 43 ) else (
38 set GUI_MODE=0 44 if %1==--force-gui (
39 :notnoguiarg 45 set GUI_MODE=1
40 shift 46 ) else (
41 goto checkargs 47 if %1==--no-gui (
42 :noargs 48 set GUI_MODE=0
49 )))
50
51 Rem move to next argument and continue processing
52 shift
53 goto checkargs
54
55 :args_done
43 56
44 Rem Start Octave (this detaches and immediately returns): 57 Rem Start Octave (this detaches and immediately returns):
45 if %GUI_MODE%==1 ( 58 if %GUI_MODE%==1 (
46 start octave-gui.exe --gui %* 59 start octave-gui.exe --gui %*
47 ) else ( 60 ) else (
48 start octave-cli.exe %* 61 start octave-cli.exe %*
49 ) 62 )
50 63
51 Rem Close the batch file's cmd.exe window 64 Rem Close the batch file's cmd.exe window
52 exit 65 exit