Mercurial > octave
annotate libinterp/octave.cc @ 15290:99db33cae82b
don't start the GUI if window system is disabled
* libinterp/octave.cc (octave_starting_gui): Check no_window_system.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Tue, 04 Sep 2012 18:43:28 -0400 |
parents | ad1a980b0cb5 |
children | b055fc077224 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14074
diff
changeset
|
3 Copyright (C) 1993-2012 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
23 // Born February 20, 1992. | |
24 | |
240 | 25 #ifdef HAVE_CONFIG_H |
1192 | 26 #include <config.h> |
1 | 27 #endif |
28 | |
1355 | 29 #include <cassert> |
30 #include <cstdlib> | |
31 #include <cstring> | |
32 #include <ctime> | |
33 | |
3503 | 34 #include <iostream> |
1355 | 35 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
36 #include <getopt.h> |
12335
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
37 #include <sys/types.h> |
6e9f100c0d61
include <unistd.h> in octave.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
38 #include <unistd.h> |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
39 |
2926 | 40 #include "cmd-edit.h" |
3690 | 41 #include "f77-fcn.h" |
4097 | 42 #include "file-ops.h" |
2926 | 43 #include "file-stat.h" |
240 | 44 #include "lo-error.h" |
2926 | 45 #include "oct-env.h" |
3019 | 46 #include "pathsearch.h" |
1907 | 47 #include "str-vec.h" |
223 | 48 |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
49 #include "defaults.h" |
3933 | 50 #include "Cell.h" |
1355 | 51 #include "defun.h" |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
52 #include "display.h" |
1355 | 53 #include "error.h" |
54 #include "file-io.h" | |
1 | 55 #include "input.h" |
56 #include "lex.h" | |
5832 | 57 #include "load-path.h" |
4113 | 58 #include "octave.h" |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
59 #include "oct-conf.h" |
1742 | 60 #include "oct-hist.h" |
5654 | 61 #include "oct-map.h" |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
62 #include "oct-mutex.h" |
3195 | 63 #include "oct-obj.h" |
2375 | 64 #include "ops.h" |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
65 #include "ov.h" |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
66 #include "ov-range.h" |
1670 | 67 #include "toplev.h" |
1 | 68 #include "parse.h" |
562 | 69 #include "procstream.h" |
1355 | 70 #include "sighandlers.h" |
71 #include "sysdep.h" | |
1 | 72 #include "unwind-prot.h" |
1355 | 73 #include "utils.h" |
74 #include "variables.h" | |
2492 | 75 #include <version.h> |
1 | 76 |
4159 | 77 // Kluge. |
5990 | 78 extern "C" F77_RET_T |
11518 | 79 F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DECL, |
80 const octave_idx_type& | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
81 F77_CHAR_ARG_LEN_DECL); |
4159 | 82 |
2910 | 83 extern void install_builtins (void); |
84 | |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
85 int octave_cmdline_argc; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
86 char **octave_cmdline_argv; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
87 int octave_embedded; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
88 |
1907 | 89 // The command-line options. |
90 static string_vector octave_argv; | |
1 | 91 |
5780 | 92 // The name used to invoke Octave. |
93 static std::string | |
94 octave_program_invocation_name; | |
95 | |
96 // The last component of octave_program_invocation_name. | |
97 static std::string octave_program_name; | |
98 | |
2239 | 99 // TRUE means we read ~/.octaverc and ./.octaverc. |
100 // (--norc; --no-init-file; -f) | |
101 static bool read_init_files = true; | |
102 | |
103 // TRUE means we read the site-wide octaverc files. | |
104 // (--norc; --no-site-file; -f) | |
2240 | 105 static bool read_site_files = true; |
1 | 106 |
6365 | 107 // TRUE means we set the initial path to configured defaults. |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
108 // (--no-init-path) |
6365 | 109 static bool set_initial_path = true; |
110 | |
3019 | 111 // TRUE means we don't print the usual startup message. |
616 | 112 // (--quiet; --silent; -q) |
2239 | 113 static bool inhibit_startup_message = false; |
1 | 114 |
3019 | 115 // TRUE means we turn on compatibility options. |
1410 | 116 // (--traditional) |
2239 | 117 static bool traditional = false; |
1410 | 118 |
3019 | 119 // If TRUE, print verbose info in some cases. |
1825 | 120 // (--verbose; -V) |
2239 | 121 static bool verbose_flag = false; |
1825 | 122 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
123 // If TRUE, force the GUI to start. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
124 // (--force-gui) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
125 static bool force_gui_option = false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
126 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
127 // If TRUE don't start the GUI. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
128 // (--no-gui) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
129 static bool no_gui_option = false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
130 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
131 // If TRUE, force readline command line editing. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
132 // (--line-editing) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
133 static bool forced_line_editing = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
134 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
135 // If TRUE, initialize history list from saved history file. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
136 // (--no-history; -H) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
137 static bool read_history_file = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
138 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
139 // The value of "path" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
140 // (--path; -p) |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
141 static std::list<std::string> command_line_path; |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
142 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
143 // Flags used to determine what commands should be echoed when they are |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
144 // parsed and executed. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
145 // (--echo-commands; -x) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
146 static int echo_executing_commands = 0; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
147 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
148 // The file used for the doc string cache. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
149 // (--doc-cache-file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
150 static std::string doc_cache_file; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
151 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
152 // The value for "EXEC_PATH" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
153 // (--exec-path) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
154 static std::string exec_path; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
155 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
156 // The value for "IMAGE_PATH" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
157 // (--image-path) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
158 static std::string image_path; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
159 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
160 // The value for "info_file" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
161 // (--info-file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
162 static std::string info_file; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
163 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
164 // The value for "info_program" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
165 // (--info-program) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
166 static std::string info_program; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
167 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
168 // If TRUE, ignore the window system even if it is available. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
169 // (--no-window-system) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
170 static bool no_window_system = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
171 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
172 // The value for "texi_macros_file" specified on the command line. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
173 // (--texi-macros-file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
174 static std::string texi_macros_file; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
175 |
1 | 176 // Usage message |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
177 static const char *usage_string = |
11140 | 178 "octave [-HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\ |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
179 [--exec-path path] [--force-gui] [--help] [--image-path path]\n\ |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
180 [--info-file file] [--info-program prog] [--interactive]\n\ |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
181 [--line-editing] [--no-gui] [--no-history] [--no-init-file]\n\ |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
182 [--no-init-path] [--no-line-editing] [--no-site-file]\n\ |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
183 [--no-window-system] [-p path] [--path path] [--silent]\n\ |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
184 [--traditional] [--verbose] [--version] [file]"; |
1 | 185 |
1358 | 186 // This is here so that it's more likely that the usage message and |
1410 | 187 // the real set of options will agree. Note: the `+' must come first |
188 // to prevent getopt from permuting arguments! | |
11140 | 189 static const char *short_opts = "+HVdfhip:qvx"; |
139 | 190 |
5189 | 191 // The code to evaluate at startup (--eval CODE) |
192 static std::string code_to_eval; | |
193 | |
194 // If TRUE, don't exit after evaluating code given by --eval option. | |
195 static bool persist = false; | |
4356 | 196 |
1103 | 197 // Long options. See the comments in getopt.h for the meanings of the |
198 // fields in this structure. | |
8861 | 199 #define DOC_CACHE_FILE_OPTION 1 |
200 #define EVAL_OPTION 2 | |
201 #define EXEC_PATH_OPTION 3 | |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
202 #define FORCE_GUI_OPTION 4 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
203 #define IMAGE_PATH_OPTION 5 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
204 #define INFO_FILE_OPTION 6 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
205 #define INFO_PROG_OPTION 7 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
206 #define LINE_EDITING_OPTION 8 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
207 #define NO_GUI_OPTION 9 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
208 #define NO_INIT_FILE_OPTION 10 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
209 #define NO_INIT_PATH_OPTION 11 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
210 #define NO_LINE_EDITING_OPTION 12 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
211 #define NO_SITE_FILE_OPTION 13 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
212 #define NO_WINDOW_SYSTEM_OPTION 14 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
213 #define PERSIST_OPTION 15 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
214 #define TEXI_MACROS_FILE_OPTION 16 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
215 #define TRADITIONAL_OPTION 17 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
216 struct option long_opts[] = |
139 | 217 { |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
218 { "braindead", no_argument, 0, TRADITIONAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
219 { "debug", no_argument, 0, 'd' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
220 { "doc-cache-file", required_argument, 0, DOC_CACHE_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
221 { "echo-commands", no_argument, 0, 'x' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
222 { "eval", required_argument, 0, EVAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
223 { "exec-path", required_argument, 0, EXEC_PATH_OPTION }, |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
224 { "force-gui", no_argument, 0, FORCE_GUI_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
225 { "help", no_argument, 0, 'h' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
226 { "image-path", required_argument, 0, IMAGE_PATH_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
227 { "info-file", required_argument, 0, INFO_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
228 { "info-program", required_argument, 0, INFO_PROG_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
229 { "interactive", no_argument, 0, 'i' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
230 { "line-editing", no_argument, 0, LINE_EDITING_OPTION }, |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
231 { "no-gui", no_argument, 0, NO_GUI_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
232 { "no-history", no_argument, 0, 'H' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
233 { "no-init-file", no_argument, 0, NO_INIT_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
234 { "no-init-path", no_argument, 0, NO_INIT_PATH_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
235 { "no-line-editing", no_argument, 0, NO_LINE_EDITING_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
236 { "no-site-file", no_argument, 0, NO_SITE_FILE_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
237 { "no-window-system", no_argument, 0, NO_WINDOW_SYSTEM_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
238 { "norc", no_argument, 0, 'f' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
239 { "path", required_argument, 0, 'p' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
240 { "persist", no_argument, 0, PERSIST_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
241 { "quiet", no_argument, 0, 'q' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
242 { "silent", no_argument, 0, 'q' }, |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14564
diff
changeset
|
243 { "texi-macros-file", required_argument, 0, TEXI_MACROS_FILE_OPTION }, |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
244 { "traditional", no_argument, 0, TRADITIONAL_OPTION }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
245 { "verbose", no_argument, 0, 'V' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
246 { "version", no_argument, 0, 'v' }, |
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
247 { 0, 0, 0, 0 } |
139 | 248 }; |
1 | 249 |
1355 | 250 // Store the command-line options for later use. |
251 | |
252 static void | |
253 intern_argv (int argc, char **argv) | |
254 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
255 assert (symbol_table::at_top_level ()); |
4892 | 256 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
257 symbol_table::varref (".nargin.") = argc - 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
258 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
259 symbol_table::mark_hidden (".nargin."); |
3195 | 260 |
10485
b4e14e628fc9
Truncate argv() for scripts used without command line parameters. Bug #29423
Judd Storrs <jstorrs@gmail.com>
parents:
10370
diff
changeset
|
261 if (argc > 0) |
1355 | 262 { |
7336 | 263 octave_argv.resize (argc - 1); |
3933 | 264 |
2495 | 265 // Skip program name in argv. |
3933 | 266 int i = argc; |
267 while (--i > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
268 octave_argv[i-1] = *(argv+i); |
1355 | 269 } |
270 } | |
271 | |
1792 | 272 static void |
273 initialize_pathsearch (void) | |
274 { | |
275 // This may seem odd, but doing it this way means that we don't have | |
276 // to modify the kpathsea library... | |
277 | |
3523 | 278 std::string odb = octave_env::getenv ("OCTAVE_DB_PATH"); |
3141 | 279 |
280 // For backward compatibility. | |
1792 | 281 |
2926 | 282 if (odb.empty ()) |
3141 | 283 odb = octave_env::getenv ("OCTAVE_DB_DIR"); |
1792 | 284 |
3141 | 285 if (odb.empty ()) |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
286 odb = Vdata_dir + file_ops::dir_sep_str () + "octave:" |
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
287 + Vlibexec_dir + file_ops::dir_sep_str () + "octave"; |
1792 | 288 } |
289 | |
5654 | 290 DEFUN (__version_info__, args, , |
291 "-*- texinfo -*-\n\ | |
6678 | 292 @deftypefn {Built-in Function} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})\n\ |
6945 | 293 Undocumented internal function.\n\ |
5654 | 294 @end deftypefn") |
295 { | |
296 octave_value retval; | |
297 | |
11066
e678346a47d9
toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
298 static octave_map vinfo; |
5654 | 299 |
300 int nargin = args.length (); | |
301 | |
5658 | 302 if (nargin == 4) |
5654 | 303 { |
6639 | 304 if (vinfo.nfields () == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
305 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
306 vinfo.assign ("Name", args (0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
307 vinfo.assign ("Version", args (1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
308 vinfo.assign ("Release", args (2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
309 vinfo.assign ("Date", args (3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
310 } |
5781 | 311 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
312 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
313 octave_idx_type n = vinfo.numel () + 1; |
5654 | 314 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
315 vinfo.resize (dim_vector (n, 1)); |
5781 | 316 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
317 octave_value idx (n); |
5781 | 318 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
319 vinfo.assign (idx, "Name", Cell (octave_value (args (0)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
320 vinfo.assign (idx, "Version", Cell (octave_value (args (1)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
321 vinfo.assign (idx, "Release", Cell (octave_value (args (2)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
322 vinfo.assign (idx, "Date", Cell (octave_value (args (3)))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
323 } |
5654 | 324 } |
325 else if (nargin == 0) | |
326 retval = vinfo; | |
327 else | |
5823 | 328 print_usage (); |
5654 | 329 |
330 return retval; | |
331 } | |
332 | |
333 static void | |
334 initialize_version_info (void) | |
335 { | |
336 octave_value_list args; | |
337 | |
5658 | 338 args(3) = OCTAVE_RELEASE_DATE; |
339 args(2) = OCTAVE_RELEASE; | |
5654 | 340 args(1) = OCTAVE_VERSION; |
341 args(0) = "GNU Octave"; | |
342 | |
343 F__version_info__ (args, 0); | |
344 } | |
345 | |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
346 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
347 gripe_safe_source_exception (const std::string& file, const std::string& msg) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
348 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
349 std::cerr << "error: " << msg << "\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
350 << "error: execution of " << file << " failed\n" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
351 << "error: trying to make my way to a command prompt" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
352 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
353 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
354 |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
355 // Execute commands from a file and catch potential exceptions in a |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
356 // consistent way. This function should be called anywhere we might |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
357 // parse and execute commands from a file before before we have entered |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
358 // the main loop in toplev.cc. |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
359 |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
360 static void |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
361 safe_source_file (const std::string& file_name, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
362 const std::string& context = std::string (), |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
363 bool verbose = false, bool require_file = true, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
364 const std::string& warn_for = std::string ()) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
365 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
366 try |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
367 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
368 source_file (file_name, context, verbose, require_file, warn_for); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
369 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
370 catch (octave_interrupt_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
371 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
372 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
373 octave_stdout << "\n"; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
374 if (quitting_gracefully) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
375 clean_up_and_exit (exit_status); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
376 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
377 catch (octave_execution_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
378 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
379 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
380 gripe_safe_source_exception (file_name, "unhandled execution exception"); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
381 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
382 } |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
383 |
581 | 384 // Initialize by reading startup files. |
385 | |
1 | 386 static void |
387 execute_startup_files (void) | |
388 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
389 unwind_protect frame; |
315 | 390 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
391 frame.protect_var (input_from_startup_file); |
1651 | 392 |
3019 | 393 input_from_startup_file = true; |
315 | 394 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
395 std::string context; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
396 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
397 bool verbose = (verbose_flag && ! inhibit_startup_message); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
398 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
399 bool require_file = false; |
578 | 400 |
2239 | 401 if (read_site_files) |
1 | 402 { |
2239 | 403 // Execute commands from the site-wide configuration file. |
404 // First from the file $(prefix)/lib/octave/site/m/octaverc | |
405 // (if it exists), then from the file | |
3597 | 406 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755 | 407 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
408 safe_source_file (Vlocal_site_defaults_file, context, verbose, |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
409 require_file); |
1755 | 410 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
411 safe_source_file (Vsite_defaults_file, context, verbose, require_file); |
1 | 412 } |
413 | |
2239 | 414 if (read_init_files) |
415 { | |
2512 | 416 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
417 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc | |
418 // is assumed. | |
2239 | 419 |
4804 | 420 bool home_rc_already_executed = false; |
2512 | 421 |
3523 | 422 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512 | 423 |
2926 | 424 if (initfile.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
425 initfile = ".octaverc"; |
2512 | 426 |
3523 | 427 std::string home_dir = octave_env::get_home_directory (); |
2926 | 428 |
4804 | 429 std::string home_rc = octave_env::make_absolute (initfile, home_dir); |
430 | |
431 std::string local_rc; | |
2239 | 432 |
5781 | 433 if (! home_rc.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
434 { |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
435 safe_source_file (home_rc, context, verbose, require_file); |
2239 | 436 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
437 // Names alone are not enough. |
2239 | 438 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
439 file_stat fs_home_rc (home_rc); |
2239 | 440 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
441 if (fs_home_rc) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
442 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
443 // We want to check for curr_dir after executing home_rc |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
444 // because doing that may change the working directory. |
4804 | 445 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
446 local_rc = octave_env::make_absolute (initfile); |
4804 | 447 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
448 home_rc_already_executed = same_file (home_rc, local_rc); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
449 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
450 } |
2239 | 451 |
452 if (! home_rc_already_executed) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
453 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
454 if (local_rc.empty ()) |
10250 | 455 local_rc = octave_env::make_absolute (initfile); |
4804 | 456 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
457 safe_source_file (local_rc, context, verbose, require_file); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
458 } |
2239 | 459 } |
1 | 460 } |
461 | |
5189 | 462 static int |
463 execute_eval_option_code (const std::string& code) | |
464 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
465 unwind_protect frame; |
5189 | 466 |
7202 | 467 octave_save_signal_mask (); |
468 | |
469 can_interrupt = true; | |
470 | |
471 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
472 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
473 octave_bad_alloc_hook = 0; |
7202 | 474 |
475 octave_catch_interrupts (); | |
476 | |
477 octave_initialized = true; | |
478 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
479 frame.protect_var (interactive); |
5189 | 480 |
481 interactive = false; | |
482 | |
483 int parse_status = 0; | |
484 | |
6487 | 485 try |
486 { | |
487 eval_string (code, false, parse_status, 0); | |
488 } | |
7202 | 489 catch (octave_interrupt_exception) |
490 { | |
491 recover_from_exception (); | |
492 octave_stdout << "\n"; | |
9383 | 493 if (quitting_gracefully) |
494 clean_up_and_exit (exit_status); | |
7202 | 495 } |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
496 catch (octave_execution_exception) |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
497 { |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
498 recover_from_exception (); |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
499 std::cerr << "error: unhandled execution exception -- eval failed" |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
500 << std::endl; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
501 } |
5189 | 502 |
503 return parse_status; | |
504 } | |
505 | |
506 static void | |
507 execute_command_line_file (const std::string& fname) | |
508 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
509 unwind_protect frame; |
5189 | 510 |
7202 | 511 octave_save_signal_mask (); |
512 | |
513 can_interrupt = true; | |
514 | |
515 octave_signal_hook = octave_signal_handler; | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
516 octave_interrupt_hook = 0; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
517 octave_bad_alloc_hook = 0; |
7202 | 518 |
519 octave_catch_interrupts (); | |
520 | |
521 octave_initialized = true; | |
522 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
523 frame.protect_var (interactive); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
524 frame.protect_var (reading_script_file); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
525 frame.protect_var (input_from_command_line_file); |
5189 | 526 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
527 frame.protect_var (curr_fcn_file_name); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
528 frame.protect_var (curr_fcn_file_full_name); |
5189 | 529 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
530 frame.protect_var (octave_program_invocation_name); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9999
diff
changeset
|
531 frame.protect_var (octave_program_name); |
5189 | 532 |
533 interactive = false; | |
534 reading_script_file = true; | |
535 input_from_command_line_file = true; | |
536 | |
537 curr_fcn_file_name = fname; | |
538 curr_fcn_file_full_name = curr_fcn_file_name; | |
539 | |
5780 | 540 octave_program_invocation_name = curr_fcn_file_name; |
5189 | 541 |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
542 size_t pos = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
543 |
8021 | 544 std::string tmp = (pos != std::string::npos) |
5189 | 545 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
546 | |
5780 | 547 octave_program_name = tmp; |
5189 | 548 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
549 std::string context; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
550 bool verbose = false; |
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
551 bool require_file = true; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
552 |
11368
944b7e20fc5a
improve handling of exceptions for startup files
John W. Eaton <jwe@octave.org>
parents:
11234
diff
changeset
|
553 safe_source_file (fname, context, verbose, require_file, "octave"); |
5189 | 554 } |
555 | |
581 | 556 // Usage message with extra help. |
557 | |
1 | 558 static void |
559 verbose_usage (void) | |
560 { | |
3922 | 561 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613 | 562 \n\ |
10731
f5dbac015606
Add [FILE] to octave usage string (bug #30258).
Rik <octave@nomad.inbox5.com>
parents:
10613
diff
changeset
|
563 Usage: octave [options] [FILE]\n\ |
1613 | 564 \n\ |
565 Options:\n\ | |
1119 | 566 \n\ |
3180 | 567 --debug, -d Enter parser debugging mode.\n\ |
8923
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
568 --doc-cache-file FILE Use doc cache file FILE.\n\ |
3180 | 569 --echo-commands, -x Echo commands as they are executed.\n\ |
5191 | 570 --eval CODE Evaluate CODE. Exit when done unless --persist.\n\ |
1613 | 571 --exec-path PATH Set path for executing subprograms.\n\ |
15223
6ec6ddebb1a6
include --force-gui and --no-gui options in --help output
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
572 --force-gui Force graphical user interface to start.\n\ |
11140 | 573 --help, -h, Print short help message and exit.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
574 --image-path PATH Add PATH to head of image search path.\n\ |
1613 | 575 --info-file FILE Use top-level info file FILE.\n\ |
576 --info-program PROGRAM Use PROGRAM for reading info files.\n\ | |
3180 | 577 --interactive, -i Force interactive behavior.\n\ |
6938 | 578 --line-editing Force readline use for command-line editing.\n\ |
15223
6ec6ddebb1a6
include --force-gui and --no-gui options in --help output
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
579 --no-gui Disable the graphical user interface.\n\ |
3180 | 580 --no-history, -H Don't save commands to the history list\n\ |
2470 | 581 --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
582 --no-init-path Don't initialize function search path.\n\ |
2212 | 583 --no-line-editing Don't use readline for command-line editing.\n\ |
2470 | 584 --no-site-file Don't read the site-wide octaverc file.\n\ |
9335
f2d354df53ee
new option, --no-window-system
John W. Eaton <jwe@octave.org>
parents:
9321
diff
changeset
|
585 --no-window-system Disable window system, including graphics.\n\ |
3238 | 586 --norc, -f Don't read any initialization files.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
587 --path PATH, -p PATH Add PATH to head of function search path.\n\ |
5189 | 588 --persist Go interactive after --eval or reading from FILE.\n\ |
3180 | 589 --silent, -q Don't print message at startup.\n\ |
14619
be12c85c6ce7
Print useful help message for texi_macros_file on command line.
Rik <octave@nomad.inbox5.com>
parents:
14614
diff
changeset
|
590 --texi-macros-file FILE Use Texinfo macros in FILE for makeinfo command.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
591 --traditional Set variables for closer MATLAB compatibility.\n\ |
3180 | 592 --verbose, -V Enable verbose output in some cases.\n\ |
593 --version, -v Print version number and exit.\n\ | |
1119 | 594 \n\ |
5190 | 595 FILE Execute commands from FILE. Exit when done\n\ |
5191 | 596 unless --persist is also specified.\n\ |
4829 | 597 \n" |
598 OCTAVE_WWW_STATEMENT "\n\ | |
4356 | 599 \n" |
600 OCTAVE_CONTRIB_STATEMENT "\n\ | |
601 \n" | |
602 OCTAVE_BUGS_STATEMENT "\n"; | |
285 | 603 |
613 | 604 exit (0); |
1 | 605 } |
606 | |
581 | 607 // Terse usage messsage. |
608 | |
1 | 609 static void |
610 usage (void) | |
611 { | |
11140 | 612 std::cerr << "\nusage: " << usage_string << "\n\n"; |
1 | 613 exit (1); |
614 } | |
615 | |
616 static void | |
617 print_version_and_exit (void) | |
618 { | |
3922 | 619 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1 | 620 exit (0); |
621 } | |
622 | |
721 | 623 static void |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
624 lo_error_handler (const char *fmt, ...) |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
625 { |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
626 va_list args; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
627 va_start (args, fmt); |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9724
diff
changeset
|
628 verror_with_cfn (fmt, args); |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
629 va_end (args); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
630 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
631 octave_throw_execution_exception (); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
632 } |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
633 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
634 static void |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
635 lo_error_with_id_handler (const char *id, const char *fmt, ...) |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
636 { |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
637 va_list args; |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
638 va_start (args, fmt); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
639 verror_with_id_cfn (id, fmt, args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
640 va_end (args); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
641 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
642 octave_throw_execution_exception (); |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
643 } |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
644 |
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
645 static void |
721 | 646 initialize_error_handlers () |
647 { | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
648 set_liboctave_error_handler (lo_error_handler); |
10370
9c4daf174387
implement IDs for common liboctave exceptions
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
649 set_liboctave_error_with_id_handler (lo_error_with_id_handler); |
3325 | 650 set_liboctave_warning_handler (warning); |
5781 | 651 set_liboctave_warning_with_id_handler (warning_with_id); |
721 | 652 } |
653 | |
1410 | 654 // What happens on --traditional. |
655 | |
656 static void | |
657 maximum_braindamage (void) | |
658 { | |
5189 | 659 persist = true; |
660 | |
5794 | 661 bind_internal_variable ("PS1", ">> "); |
662 bind_internal_variable ("PS2", ""); | |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
663 bind_internal_variable ("allow_noninteger_range_as_index", true); |
5794 | 664 bind_internal_variable ("beep_on_error", true); |
8473
4dd0213bb883
octave.cc (maximum_braindamage): set confirm_recursive_rmdir to false
John W. Eaton <jwe@octave.org>
parents:
8347
diff
changeset
|
665 bind_internal_variable ("confirm_recursive_rmdir", false); |
5794 | 666 bind_internal_variable ("crash_dumps_octave_core", false); |
667 bind_internal_variable ("default_save_options", "-mat-binary"); | |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11066
diff
changeset
|
668 bind_internal_variable ("do_braindead_shortcircuit_evaluation", true); |
5794 | 669 bind_internal_variable ("fixed_point_format", true); |
670 bind_internal_variable ("history_timestamp_format_string", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
671 "%%-- %D %I:%M %p --%%"); |
5794 | 672 bind_internal_variable ("page_screen_output", false); |
673 bind_internal_variable ("print_empty_dimensions", false); | |
5904 | 674 |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9383
diff
changeset
|
675 disable_warning ("Octave:abbreviated-property-match"); |
6159 | 676 disable_warning ("Octave:fopen-file-in-path"); |
5904 | 677 disable_warning ("Octave:function-name-clash"); |
6159 | 678 disable_warning ("Octave:load-file-in-path"); |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
11066
diff
changeset
|
679 disable_warning ("Octave:possible-matlab-short-circuit-operator"); |
1410 | 680 } |
681 | |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
682 // EMBEDDED is declared int instead of bool because this function is |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
683 // declared extern "C". |
581 | 684 |
1 | 685 int |
4368 | 686 octave_main (int argc, char **argv, int embedded) |
1 | 687 { |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
688 octave_process_command_line (argc, argv); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
689 |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
690 install_defaults (); |
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
691 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
692 octave_initialize_interpreter (argc, argv, embedded); |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
693 |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
694 return octave_execute_interpreter (); |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
695 } |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
696 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
697 void |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
698 octave_process_command_line (int argc, char **argv) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
699 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
700 octave_cmdline_argc = argc; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
701 octave_cmdline_argv = argv; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
702 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
703 while (true) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
704 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
705 int long_idx; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
706 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
707 int optc = getopt_long (argc, argv, short_opts, long_opts, &long_idx); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
708 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
709 if (optc < 0) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
710 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
711 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
712 switch (optc) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
713 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
714 case '?': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
715 // Unrecognized option. getopt_long already printed a |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
716 // message about that, so we will just print the usage string |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
717 // and exit. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
718 usage (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
719 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
720 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
721 case 'H': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
722 read_history_file = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
723 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
724 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
725 case 'V': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
726 verbose_flag = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
727 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
728 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
729 case 'd': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
730 // This is the same as yydebug in parse.y. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
731 octave_debug++; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
732 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
733 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
734 case 'f': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
735 read_init_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
736 read_site_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
737 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
738 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
739 case 'h': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
740 verbose_usage (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
741 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
742 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
743 case 'i': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
744 forced_interactive = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
745 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
746 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
747 case 'p': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
748 if (optarg) |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
749 command_line_path.push_back (optarg); |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
750 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
751 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
752 case 'q': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
753 inhibit_startup_message = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
754 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
755 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
756 case 'x': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
757 echo_executing_commands |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
758 = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
759 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
760 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
761 case 'v': |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
762 print_version_and_exit (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
763 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
764 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
765 case DOC_CACHE_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
766 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
767 doc_cache_file = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
768 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
769 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
770 case EVAL_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
771 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
772 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
773 if (code_to_eval.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
774 code_to_eval = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
775 else |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
776 code_to_eval += std::string (" ") + optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
777 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
778 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
779 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
780 case EXEC_PATH_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
781 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
782 exec_path = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
783 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
784 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
785 case FORCE_GUI_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
786 force_gui_option = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
787 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
788 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
789 case IMAGE_PATH_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
790 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
791 image_path = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
792 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
793 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
794 case INFO_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
795 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
796 info_file = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
797 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
798 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
799 case INFO_PROG_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
800 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
801 info_program = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
802 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
803 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
804 case LINE_EDITING_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
805 forced_line_editing = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
806 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
807 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
808 case NO_INIT_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
809 read_init_files = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
810 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
811 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
812 case NO_GUI_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
813 no_gui_option = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
814 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
815 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
816 case NO_INIT_PATH_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
817 set_initial_path = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
818 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
819 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
820 case NO_LINE_EDITING_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
821 line_editing = false; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
822 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
823 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
824 case NO_SITE_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
825 read_site_files = 0; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
826 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
827 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
828 case NO_WINDOW_SYSTEM_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
829 no_window_system = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
830 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
831 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
832 case PERSIST_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
833 persist = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
834 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
835 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
836 case TEXI_MACROS_FILE_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
837 if (optarg) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
838 texi_macros_file = optarg; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
839 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
840 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
841 case TRADITIONAL_OPTION: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
842 traditional = true; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
843 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
844 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
845 default: |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
846 // getopt_long should print a message about unrecognized |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
847 // options and return '?', which is handled above. So if we |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
848 // end up here, it is because there was an option but we |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
849 // forgot to handle it. That should be fatal. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
850 panic_impossible (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
851 break; |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
852 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
853 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
854 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
855 if (force_gui_option && no_gui_option) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
856 { |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
857 error ("error: only one of --force-gui and --no-gui may be used"); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
858 usage (); |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
859 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
860 } |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
861 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
862 // EMBEDDED is declared int instead of bool because this function is |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
863 // declared extern "C". |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
864 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
865 void |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
866 octave_initialize_interpreter (int argc, char **argv, int embedded) |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
867 { |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
868 octave_embedded = embedded; |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
869 |
3019 | 870 octave_env::set_program_name (argv[0]); |
871 | |
5780 | 872 octave_program_invocation_name = octave_env::get_program_invocation_name (); |
873 octave_program_name = octave_env::get_program_name (); | |
874 | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
875 octave_thread::init (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13239
diff
changeset
|
876 |
2205 | 877 // The order of these calls is important. The call to |
15262
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
878 // install_builtins must come before the option settings are processed |
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
879 // because some command line options override defaults by calling |
ad1a980b0cb5
install default values before initializing interpreter (bug #37161)
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
880 // bind_internal_variable. |
721 | 881 |
5844 | 882 init_signals (); |
883 | |
1 | 884 sysdep_init (); |
885 | |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
886 octave_ieee_init (); |
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11157
diff
changeset
|
887 |
4159 | 888 // The idea here is to force xerbla to be referenced so that we will |
889 // link to our own version instead of the one provided by the BLAS | |
890 // library. But octave_NaN should never be -1, so we should never | |
891 // actually call xerbla. | |
892 | |
893 if (octave_NaN == -1) | |
11157
c75130f19440
octave.cc: fix call to xerbla
John W. Eaton <jwe@octave.org>
parents:
11140
diff
changeset
|
894 F77_FUNC (xerbla, XERBLA) ("octave", 13 F77_CHAR_ARG_LEN (6)); |
4159 | 895 |
721 | 896 initialize_error_handlers (); |
223 | 897 |
5794 | 898 initialize_default_warning_state (); |
899 | |
1792 | 900 initialize_pathsearch (); |
1744 | 901 |
4368 | 902 if (! embedded) |
903 install_signal_handlers (); | |
9255
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
904 else |
1c2d2c9f4a8d
don't allow quit() in embedded mode by default, make configurable
Jaroslav Hajek <highegg@gmail.com>
parents:
9217
diff
changeset
|
905 quit_allowed = false; |
2205 | 906 |
907 initialize_file_io (); | |
908 | |
2375 | 909 install_types (); |
910 | |
911 install_ops (); | |
2205 | 912 |
913 install_builtins (); | |
914 | |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
915 if (! read_history_file) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
916 bind_internal_variable ("saving_history", false); |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
917 |
15225
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
918 for (std::list<std::string>::const_iterator it = command_line_path.begin (); |
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
919 it != command_line_path.end (); it++) |
2d337a9869e9
correctly handle multiple --path command line arguments
John W. Eaton <jwe@octave.org>
parents:
15224
diff
changeset
|
920 load_path::set_command_line_path (*it); |
777 | 921 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
922 if (echo_executing_commands) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
923 bind_internal_variable ("echo_executing_commands", |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
924 echo_executing_commands); |
777 | 925 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
926 if (! doc_cache_file.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
927 bind_internal_variable ("doc_cache_file", doc_cache_file); |
8861 | 928 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
929 if (! exec_path.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
930 set_exec_path (exec_path); |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
931 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
932 if (! image_path.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
933 set_exec_path (image_path); |
777 | 934 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
935 if (! info_file.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
936 bind_internal_variable ("info_file", info_file); |
2239 | 937 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
938 if (! info_program.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
939 bind_internal_variable ("info_program", info_program); |
9336
98c6b3aa0b7b
octave.cc: keep long options in alphabetized
John W. Eaton <jwe@octave.org>
parents:
9335
diff
changeset
|
940 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
941 if (no_window_system) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
942 display_info::no_window_system (); |
1410 | 943 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
944 if (! texi_macros_file.empty ()) |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
945 bind_internal_variable ("texi_macros_file", texi_macros_file); |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
946 |
2077 | 947 // Make sure we clean up when we exit. Also allow users to register |
948 // functions. If we don't have atexit or on_exit, we're going to | |
949 // leave some junk files around if we exit abnormally. | |
950 | |
951 atexit (do_octave_atexit); | |
1 | 952 |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
953 // Is input coming from a terminal? If so, we are probably |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
954 // interactive. |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
955 |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9753
diff
changeset
|
956 // If stdin is not a tty, then we are reading commands from a pipe or |
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9753
diff
changeset
|
957 // a redirected file. |
14160 | 958 stdin_is_tty = gnulib::isatty (fileno (stdin)); |
9999
653716f3d976
get_debug_input: force interactive input mode; don't get user input unless stdin is a tty
John W. Eaton <jwe@octave.org>
parents:
9753
diff
changeset
|
959 |
14160 | 960 interactive = (! embedded && stdin_is_tty |
961 && gnulib::isatty (fileno (stdout))); | |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
962 |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
963 if (! interactive && ! forced_line_editing) |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
964 line_editing = false; |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
965 |
9321
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
966 // Force default line editor if we don't want readline editing. |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
967 if (! line_editing) |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
968 command_editor::force_default_editor (); |
9b87aeb24ea9
avoid using readline at all when line editing suppressed or interpreter embedded
Jaroslav Hajek <highegg@gmail.com>
parents:
9320
diff
changeset
|
969 |
1358 | 970 // These can come after command line args since none of them set any |
971 // defaults that might be changed by command line options. | |
581 | 972 |
9320
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
973 if (line_editing) |
080dc45ea682
don't garble readline settings when line editing is disabled
Jaroslav Hajek <highegg@gmail.com>
parents:
9260
diff
changeset
|
974 initialize_command_input (); |
315 | 975 |
1410 | 976 if (traditional) |
977 maximum_braindamage (); | |
978 | |
4217 | 979 octave_interpreter_ready = true; |
980 | |
5654 | 981 initialize_version_info (); |
982 | |
8099
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
983 // Make all command-line arguments available to startup files, |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
984 // including PKG_ADD files. |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
985 |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
986 intern_argv (argc, argv); |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
987 |
6365 | 988 load_path::initialize (set_initial_path); |
4217 | 989 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
990 initialize_history (read_history_file); |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
991 } |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
992 |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
993 int |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
994 octave_execute_interpreter (void) |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
995 { |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
996 if (! inhibit_startup_message) |
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
997 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
1651 | 998 |
13239
3109c8b0cff4
Initialise history before executing startup files (bug #32900)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12855
diff
changeset
|
999 execute_startup_files (); |
1 | 1000 |
578 | 1001 if (! inhibit_startup_message && reading_startup_message_printed) |
3538 | 1002 std::cout << std::endl; |
578 | 1003 |
1358 | 1004 // If there is an extra argument, see if it names a file to read. |
1005 // Additional arguments are taken as command line options for the | |
1006 // script. | |
1 | 1007 |
10195
b49d47b637b7
use getopt directly instead of the (mostly useless) prog_args wrapper class
John W. Eaton <jwe@octave.org>
parents:
10191
diff
changeset
|
1008 int last_arg_idx = optind; |
3019 | 1009 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1010 int remaining_args = octave_cmdline_argc - last_arg_idx; |
3019 | 1011 |
5189 | 1012 if (! code_to_eval.empty ()) |
149 | 1013 { |
5189 | 1014 int parse_status = execute_eval_option_code (code_to_eval); |
1015 | |
5242 | 1016 if (! (persist || remaining_args > 0)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1017 clean_up_and_exit (parse_status || error_state ? 1 : 0); |
1 | 1018 } |
1019 | |
5189 | 1020 if (remaining_args > 0) |
1021 { | |
1022 // If we are running an executable script (#! /bin/octave) then | |
1023 // we should only see the args passed to the script. | |
1024 | |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1025 intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx); |
5189 | 1026 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1027 execute_command_line_file (octave_cmdline_argv[last_arg_idx]); |
5189 | 1028 |
1029 if (! persist) | |
14074
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1030 { |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1031 quitting_gracefully = true; |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1032 |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1033 clean_up_and_exit (error_state ? 1 : 0); |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1034 } |
5189 | 1035 } |
1036 | |
1037 // Avoid counting commands executed from startup files. | |
1038 | |
1039 command_editor::reset_current_command_number (1); | |
1040 | |
1041 // Now argv should have the full set of args. | |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1042 intern_argv (octave_cmdline_argc, octave_cmdline_argv); |
5189 | 1043 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1044 if (! octave_embedded) |
5189 | 1045 switch_to_buffer (create_buffer (get_input_from_stdin ())); |
1046 | |
1358 | 1047 // Force input to be echoed if not really interactive, but the user |
1048 // has forced interactive behavior. | |
1 | 1049 |
1907 | 1050 if (! interactive && forced_interactive) |
287 | 1051 { |
2926 | 1052 command_editor::blink_matching_paren (false); |
1588 | 1053 |
5775 | 1054 // FIXME -- is this the right thing to do? |
1588 | 1055 |
5794 | 1056 bind_internal_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287 | 1057 } |
1 | 1058 |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
14619
diff
changeset
|
1059 if (octave_embedded) |
5502 | 1060 { |
5775 | 1061 // FIXME -- do we need to do any cleanup here before |
5502 | 1062 // returning? If we don't, what will happen to Octave functions |
1063 // that have been registered to execute with atexit, for example? | |
1064 | |
1065 return 1; | |
1066 } | |
4368 | 1067 |
5189 | 1068 int retval = main_loop (); |
1 | 1069 |
1005 | 1070 if (retval == 1 && ! error_state) |
1071 retval = 0; | |
1072 | |
14074
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1073 quitting_gracefully = true; |
f90c3facfac3
don't reset parser when exiting (bug #35120)
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1074 |
1 | 1075 clean_up_and_exit (retval); |
4247 | 1076 |
1077 return 0; | |
1 | 1078 } |
1079 | |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1080 // Return int instead of bool because this function is declared |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1081 // extern "C". |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1082 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1083 int |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1084 octave_starting_gui (void) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1085 { |
15290
99db33cae82b
don't start the GUI if window system is disabled
Mike Miller <mtmiller@ieee.org>
parents:
15262
diff
changeset
|
1086 if (no_window_system || ! display_info::display_available ()) |
15160
973296940c89
don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
1087 return false; |
973296940c89
don't start GUI if display is not available
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
1088 |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1089 if (force_gui_option) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1090 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1091 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1092 if (no_gui_option) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1093 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1094 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1095 if (persist) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1096 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1097 |
15224
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1098 // If stdin is not a tty, then assume we are reading commands from a |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1099 // pipe or a redirected file and the GUI should not start. If this is |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1100 // not the case (for example, starting from a desktop "launcher" with |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1101 // no terminal) and you want to start the GUI, you may use the |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1102 // --force-gui option to start the GUI. |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1103 |
a44e4a08fc55
perform fewer actions before starting GUI
John W. Eaton <jwe@octave.org>
parents:
15223
diff
changeset
|
1104 if (! gnulib::isatty (fileno (stdin))) |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1105 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1106 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1107 // If we have code to eval or execute from a file, and we are going to |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1108 // exit immediately after executing it, don't start the gui. |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1109 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1110 int last_arg_idx = optind; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1111 int remaining_args = octave_cmdline_argc - last_arg_idx; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1112 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1113 if (! code_to_eval.empty () || remaining_args > 0) |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1114 return false; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1115 |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1116 return true; |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1117 } |
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
1118 |
5780 | 1119 DEFUN (argv, args, , |
1120 "-*- texinfo -*-\n\ | |
1121 @deftypefn {Built-in Function} {} argv ()\n\ | |
1122 Return the command line arguments passed to Octave. For example,\n\ | |
1123 if you invoked Octave using the command\n\ | |
1124 \n\ | |
1125 @example\n\ | |
1126 octave --no-line-editing --silent\n\ | |
1127 @end example\n\ | |
1128 \n\ | |
1129 @noindent\n\ | |
1130 @code{argv} would return a cell array of strings with the elements\n\ | |
10840 | 1131 @option{--no-line-editing} and @option{--silent}.\n\ |
5780 | 1132 \n\ |
1133 If you write an executable Octave script, @code{argv} will return the\n\ | |
1134 list of arguments passed to the script. @xref{Executable Octave Programs},\n\ | |
1135 for an example of how to create an executable Octave script.\n\ | |
1136 @end deftypefn") | |
1137 { | |
1138 octave_value retval; | |
1139 | |
1140 if (args.length () == 0) | |
1141 retval = Cell (octave_argv); | |
1142 else | |
5823 | 1143 print_usage (); |
5780 | 1144 |
1145 return retval; | |
1146 } | |
1147 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1148 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1149 %!assert (iscellstr (argv ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1150 %!error argv (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1151 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1152 |
5780 | 1153 DEFUN (program_invocation_name, args, , |
1154 "-*- texinfo -*-\n\ | |
9724
f22bbc5d56e9
Fix various incorrect usages of TeXinfo deffn and deftypefn macros
Rik <rdrider0-list@yahoo.com>
parents:
9584
diff
changeset
|
1155 @deftypefn {Built-in Function} {} program_invocation_name ()\n\ |
5780 | 1156 Return the name that was typed at the shell prompt to run Octave.\n\ |
1157 \n\ | |
1158 If executing a script from the command line (e.g., @code{octave foo.m})\n\ | |
1159 or using an executable Octave script, the program name is set to the\n\ | |
1160 name of the script. @xref{Executable Octave Programs}, for an example of\n\ | |
1161 how to create an executable Octave script.\n\ | |
1162 @seealso{program_name}\n\ | |
1163 @end deftypefn") | |
1164 { | |
1165 octave_value retval; | |
1166 | |
1167 if (args.length () == 0) | |
1168 retval = octave_program_invocation_name; | |
1169 else | |
5823 | 1170 print_usage (); |
5780 | 1171 |
1172 return retval; | |
1173 } | |
1174 | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1175 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1176 %!assert (ischar (program_invocation_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1177 %!error program_invocation_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1178 */ |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1179 |
5780 | 1180 DEFUN (program_name, args, , |
1181 "-*- texinfo -*-\n\ | |
1182 @deftypefn {Built-in Function} {} program_name ()\n\ | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8273
diff
changeset
|
1183 Return the last component of the value returned by\n\ |
5780 | 1184 @code{program_invocation_name}.\n\ |
1185 @seealso{program_invocation_name}\n\ | |
1186 @end deftypefn") | |
1187 { | |
1188 octave_value retval; | |
1189 | |
1190 if (args.length () == 0) | |
1191 retval = octave_program_name; | |
1192 else | |
5823 | 1193 print_usage (); |
5780 | 1194 |
1195 return retval; | |
1196 } | |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1197 |
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1198 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1199 %!assert (ischar (program_name ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14160
diff
changeset
|
1200 %!error program_name (1) |
12848
e3323dda983b
codesprint: new tests for octave.cc
John W. Eaton <jwe@octave.org>
parents:
12335
diff
changeset
|
1201 */ |