Mercurial > hg > octave-lojdl
annotate src/octave.cc @ 9132:eb1747dbd360
Update help strings for command line options
Add documentation for --no-init-path option
Add documentation for environment variables OCTAVE_SITE_INITFILE, OCTAVE_VERSION_INITFILE
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Fri, 17 Apr 2009 14:53:17 -0700 |
parents | da58ec8f62e8 |
children | ee7cf4d963f3 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
8920 | 4 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
24 // Born February 20, 1992. | |
25 | |
240 | 26 #ifdef HAVE_CONFIG_H |
1192 | 27 #include <config.h> |
1 | 28 #endif |
29 | |
1355 | 30 #include <cassert> |
31 #include <cstdlib> | |
32 #include <cstring> | |
33 #include <ctime> | |
34 | |
3503 | 35 #include <fstream> |
36 #include <iostream> | |
1355 | 37 |
38 #ifdef HAVE_UNISTD_H | |
2442 | 39 #ifdef HAVE_SYS_TYPES_H |
1 | 40 #include <sys/types.h> |
2442 | 41 #endif |
139 | 42 #include <unistd.h> |
43 #endif | |
1355 | 44 |
2926 | 45 #include "cmd-edit.h" |
3690 | 46 #include "f77-fcn.h" |
4097 | 47 #include "file-ops.h" |
2926 | 48 #include "file-stat.h" |
240 | 49 #include "lo-error.h" |
2926 | 50 #include "oct-env.h" |
3019 | 51 #include "pathsearch.h" |
1907 | 52 #include "str-vec.h" |
223 | 53 |
2492 | 54 #include <defaults.h> |
3933 | 55 #include "Cell.h" |
1355 | 56 #include "defun.h" |
57 #include "error.h" | |
58 #include "file-io.h" | |
1 | 59 #include "input.h" |
60 #include "lex.h" | |
5832 | 61 #include "load-path.h" |
4113 | 62 #include "octave.h" |
1742 | 63 #include "oct-hist.h" |
5654 | 64 #include "oct-map.h" |
3195 | 65 #include "oct-obj.h" |
2375 | 66 #include "ops.h" |
1670 | 67 #include "toplev.h" |
1 | 68 #include "parse.h" |
562 | 69 #include "procstream.h" |
1817 | 70 #include "prog-args.h" |
1355 | 71 #include "sighandlers.h" |
72 #include "sysdep.h" | |
2375 | 73 #include "ov.h" |
1 | 74 #include "unwind-prot.h" |
1355 | 75 #include "utils.h" |
76 #include "variables.h" | |
2492 | 77 #include <version.h> |
1 | 78 |
4159 | 79 // Kluge. |
5990 | 80 extern "C" F77_RET_T |
81 F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DECL, const octave_idx_type& | |
82 F77_CHAR_ARG_LEN_DECL); | |
4159 | 83 |
2910 | 84 extern void install_builtins (void); |
85 | |
1704 | 86 #if !defined (HAVE_ATEXIT) && defined (HAVE_ON_EXIT) |
87 extern "C" int on_exit (); | |
88 #define atexit on_exit | |
89 #endif | |
90 | |
1907 | 91 // The command-line options. |
92 static string_vector octave_argv; | |
1 | 93 |
5780 | 94 // The name used to invoke Octave. |
95 static std::string | |
96 octave_program_invocation_name; | |
97 | |
98 // The last component of octave_program_invocation_name. | |
99 static std::string octave_program_name; | |
100 | |
2239 | 101 // TRUE means we read ~/.octaverc and ./.octaverc. |
102 // (--norc; --no-init-file; -f) | |
103 static bool read_init_files = true; | |
104 | |
105 // TRUE means we read the site-wide octaverc files. | |
106 // (--norc; --no-site-file; -f) | |
2240 | 107 static bool read_site_files = true; |
1 | 108 |
6365 | 109 // 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
|
110 // (--no-init-path) |
6365 | 111 static bool set_initial_path = true; |
112 | |
3019 | 113 // TRUE means we don't print the usual startup message. |
616 | 114 // (--quiet; --silent; -q) |
2239 | 115 static bool inhibit_startup_message = false; |
1 | 116 |
3019 | 117 // TRUE means we turn on compatibility options. |
1410 | 118 // (--traditional) |
2239 | 119 static bool traditional = false; |
1410 | 120 |
3019 | 121 // If TRUE, print verbose info in some cases. |
1825 | 122 // (--verbose; -V) |
2239 | 123 static bool verbose_flag = false; |
1825 | 124 |
1 | 125 // Usage message |
139 | 126 static const char *usage_string = |
5189 | 127 "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\ |
5814 | 128 [--exec-path path] [--help] [--image-path path] [--info-file file]\n\ |
6938 | 129 [--info-program prog] [--interactive] [--line-editing] [--no-history] [--no-init-file]\n\ |
6365 | 130 [--no-line-editing] [--no-site-file] [--no-init-path] [-p path]\n\ |
131 [--path path] [--silent] [--traditional] [--verbose] [--version] [file]"; | |
1 | 132 |
1358 | 133 // This is here so that it's more likely that the usage message and |
1410 | 134 // the real set of options will agree. Note: the `+' must come first |
135 // to prevent getopt from permuting arguments! | |
3180 | 136 static const char *short_opts = "+?HVdfhip:qvx"; |
139 | 137 |
5189 | 138 // The code to evaluate at startup (--eval CODE) |
139 static std::string code_to_eval; | |
140 | |
141 // If TRUE, don't exit after evaluating code given by --eval option. | |
142 static bool persist = false; | |
4356 | 143 |
1103 | 144 // Long options. See the comments in getopt.h for the meanings of the |
145 // fields in this structure. | |
8861 | 146 #define DOC_CACHE_FILE_OPTION 1 |
147 #define EVAL_OPTION 2 | |
148 #define EXEC_PATH_OPTION 3 | |
149 #define IMAGE_PATH_OPTION 4 | |
150 #define INFO_FILE_OPTION 5 | |
151 #define INFO_PROG_OPTION 6 | |
152 #define NO_INIT_FILE_OPTION 7 | |
153 #define NO_LINE_EDITING_OPTION 8 | |
154 #define NO_SITE_FILE_OPTION 9 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
155 #define NO_INIT_PATH_OPTION 10 |
8861 | 156 #define PERSIST_OPTION 11 |
157 #define TRADITIONAL_OPTION 12 | |
158 #define LINE_EDITING_OPTION 13 | |
1817 | 159 long_options long_opts[] = |
139 | 160 { |
1855 | 161 { "debug", prog_args::no_arg, 0, 'd' }, |
2277 | 162 { "braindead", prog_args::no_arg, 0, TRADITIONAL_OPTION }, |
8861 | 163 { "doc-cache-file", prog_args::required_arg, 0, DOC_CACHE_FILE_OPTION }, |
1855 | 164 { "echo-commands", prog_args::no_arg, 0, 'x' }, |
5189 | 165 { "eval", prog_args::required_arg, 0, EVAL_OPTION }, |
1855 | 166 { "exec-path", prog_args::required_arg, 0, EXEC_PATH_OPTION }, |
167 { "help", prog_args::no_arg, 0, 'h' }, | |
5814 | 168 { "image-path", prog_args::required_arg, 0, IMAGE_PATH_OPTION }, |
1855 | 169 { "info-file", prog_args::required_arg, 0, INFO_FILE_OPTION }, |
170 { "info-program", prog_args::required_arg, 0, INFO_PROG_OPTION }, | |
171 { "interactive", prog_args::no_arg, 0, 'i' }, | |
6938 | 172 { "line-editing", prog_args::no_arg, 0, LINE_EDITING_OPTION }, |
3180 | 173 { "no-history", prog_args::no_arg, 0, 'H' }, |
2239 | 174 { "no-init-file", prog_args::no_arg, 0, NO_INIT_FILE_OPTION }, |
1855 | 175 { "no-line-editing", prog_args::no_arg, 0, NO_LINE_EDITING_OPTION }, |
2239 | 176 { "no-site-file", prog_args::no_arg, 0, NO_SITE_FILE_OPTION }, |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
177 { "no-init-path", prog_args::no_arg, 0, NO_INIT_PATH_OPTION }, |
1855 | 178 { "norc", prog_args::no_arg, 0, 'f' }, |
179 { "path", prog_args::required_arg, 0, 'p' }, | |
5189 | 180 { "persist", prog_args::no_arg, 0, PERSIST_OPTION }, |
1855 | 181 { "quiet", prog_args::no_arg, 0, 'q' }, |
182 { "silent", prog_args::no_arg, 0, 'q' }, | |
183 { "traditional", prog_args::no_arg, 0, TRADITIONAL_OPTION }, | |
184 { "verbose", prog_args::no_arg, 0, 'V' }, | |
185 { "version", prog_args::no_arg, 0, 'v' }, | |
3019 | 186 { 0, 0, 0, 0 } |
139 | 187 }; |
1 | 188 |
1355 | 189 // Store the command-line options for later use. |
190 | |
191 static void | |
192 intern_argv (int argc, char **argv) | |
193 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
194 assert (symbol_table::at_top_level ()); |
4892 | 195 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
196 symbol_table::varref (".nargin.") = argc - 1; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
197 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
198 symbol_table::mark_hidden (".nargin."); |
3195 | 199 |
1355 | 200 if (argc > 1) |
201 { | |
7336 | 202 octave_argv.resize (argc - 1); |
3933 | 203 |
2495 | 204 // Skip program name in argv. |
3933 | 205 int i = argc; |
206 while (--i > 0) | |
5780 | 207 octave_argv[i-1] = *(argv+i); |
1355 | 208 } |
209 } | |
210 | |
1792 | 211 static void |
212 initialize_pathsearch (void) | |
213 { | |
214 // This may seem odd, but doing it this way means that we don't have | |
215 // to modify the kpathsea library... | |
216 | |
3523 | 217 std::string odb = octave_env::getenv ("OCTAVE_DB_PATH"); |
3141 | 218 |
219 // For backward compatibility. | |
1792 | 220 |
2926 | 221 if (odb.empty ()) |
3141 | 222 odb = octave_env::getenv ("OCTAVE_DB_DIR"); |
1792 | 223 |
3141 | 224 if (odb.empty ()) |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
225 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
|
226 + Vlibexec_dir + file_ops::dir_sep_str () + "octave"; |
1792 | 227 } |
228 | |
5654 | 229 DEFUN (__version_info__, args, , |
230 "-*- texinfo -*-\n\ | |
6678 | 231 @deftypefn {Built-in Function} {retval =} __version_info__ (@var{name}, @var{version}, @var{release}, @var{date})\n\ |
6945 | 232 Undocumented internal function.\n\ |
5654 | 233 @end deftypefn") |
234 { | |
235 octave_value retval; | |
236 | |
237 static Octave_map vinfo; | |
238 | |
239 int nargin = args.length (); | |
240 | |
5658 | 241 if (nargin == 4) |
5654 | 242 { |
6639 | 243 if (vinfo.nfields () == 0) |
5781 | 244 { |
245 vinfo.assign ("Name", args (0)); | |
246 vinfo.assign ("Version", args (1)); | |
247 vinfo.assign ("Release", args (2)); | |
248 vinfo.assign ("Date", args (3)); | |
249 } | |
250 else | |
251 { | |
252 octave_idx_type n = vinfo.numel () + 1; | |
5654 | 253 |
5781 | 254 vinfo.resize (dim_vector (n, 1)); |
255 | |
256 octave_value idx (n); | |
257 | |
258 vinfo.assign (idx, "Name", Cell (octave_value (args (0)))); | |
259 vinfo.assign (idx, "Version", Cell (octave_value (args (1)))); | |
260 vinfo.assign (idx, "Release", Cell (octave_value (args (2)))); | |
261 vinfo.assign (idx, "Date", Cell (octave_value (args (3)))); | |
262 } | |
5654 | 263 } |
264 else if (nargin == 0) | |
265 retval = vinfo; | |
266 else | |
5823 | 267 print_usage (); |
5654 | 268 |
269 return retval; | |
270 } | |
271 | |
272 static void | |
273 initialize_version_info (void) | |
274 { | |
275 octave_value_list args; | |
276 | |
5658 | 277 args(3) = OCTAVE_RELEASE_DATE; |
278 args(2) = OCTAVE_RELEASE; | |
5654 | 279 args(1) = OCTAVE_VERSION; |
280 args(0) = "GNU Octave"; | |
281 | |
282 F__version_info__ (args, 0); | |
283 } | |
284 | |
581 | 285 // Initialize by reading startup files. |
286 | |
1 | 287 static void |
288 execute_startup_files (void) | |
289 { | |
2985 | 290 unwind_protect::begin_frame ("execute_startup_files"); |
315 | 291 |
3019 | 292 unwind_protect_bool (input_from_startup_file); |
1651 | 293 |
3019 | 294 input_from_startup_file = true; |
315 | 295 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
296 std::string context; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
297 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
298 bool verbose = (verbose_flag && ! inhibit_startup_message); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
299 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
300 bool require_file = false; |
578 | 301 |
2239 | 302 if (read_site_files) |
1 | 303 { |
2239 | 304 // Execute commands from the site-wide configuration file. |
305 // First from the file $(prefix)/lib/octave/site/m/octaverc | |
306 // (if it exists), then from the file | |
3597 | 307 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755 | 308 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
309 source_file (Vlocal_site_defaults_file, context, verbose, require_file); |
1755 | 310 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
311 source_file (Vsite_defaults_file, context, verbose, require_file); |
1 | 312 } |
313 | |
2239 | 314 if (read_init_files) |
315 { | |
2512 | 316 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
317 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc | |
318 // is assumed. | |
2239 | 319 |
4804 | 320 bool home_rc_already_executed = false; |
2512 | 321 |
3523 | 322 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512 | 323 |
2926 | 324 if (initfile.empty ()) |
2512 | 325 initfile = ".octaverc"; |
326 | |
3523 | 327 std::string home_dir = octave_env::get_home_directory (); |
2926 | 328 |
4804 | 329 std::string home_rc = octave_env::make_absolute (initfile, home_dir); |
330 | |
331 std::string local_rc; | |
2239 | 332 |
5781 | 333 if (! home_rc.empty ()) |
2239 | 334 { |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
335 source_file (home_rc, context, verbose, require_file); |
2239 | 336 |
337 // Names alone are not enough. | |
338 | |
339 file_stat fs_home_rc (home_rc); | |
340 | |
341 if (fs_home_rc) | |
342 { | |
4804 | 343 // We want to check for curr_dir after executing home_rc |
344 // because doing that may change the working directory. | |
345 | |
346 std::string curr_dir = octave_env::getcwd (); | |
347 | |
348 local_rc = octave_env::make_absolute (initfile, curr_dir); | |
349 | |
6598 | 350 home_rc_already_executed = same_file (home_rc, local_rc); |
2239 | 351 } |
352 } | |
353 | |
354 if (! home_rc_already_executed) | |
4804 | 355 { |
356 if (local_rc.empty ()) | |
357 { | |
358 std::string curr_dir = octave_env::getcwd (); | |
359 | |
360 local_rc = octave_env::make_absolute (initfile, curr_dir); | |
361 } | |
362 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
363 source_file (local_rc, context, verbose, require_file); |
4804 | 364 } |
2239 | 365 } |
315 | 366 |
2985 | 367 unwind_protect::run_frame ("execute_startup_files"); |
1 | 368 } |
369 | |
9009
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
370 static void |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
371 unmark_forced_vars (void *arg) |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
372 { |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
373 // Unmark any symbols that may have been tagged as local variables |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
374 // while parsing (for example, by force_local_variable in lex.l). |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
375 |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
376 symbol_table::scope_id *pscope = static_cast <symbol_table::scope_id *> (arg); |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
377 |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
378 if (pscope) |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
379 symbol_table::unmark_forced_variables (*pscope); |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
380 } |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
381 |
5189 | 382 static int |
383 execute_eval_option_code (const std::string& code) | |
384 { | |
385 unwind_protect::begin_frame ("execute_eval_option_code"); | |
386 | |
7202 | 387 octave_save_signal_mask (); |
388 | |
389 can_interrupt = true; | |
390 | |
391 octave_signal_hook = octave_signal_handler; | |
392 octave_interrupt_hook = unwind_protect::run_all; | |
393 octave_bad_alloc_hook = unwind_protect::run_all; | |
394 | |
395 octave_catch_interrupts (); | |
396 | |
397 octave_initialized = true; | |
398 | |
5189 | 399 unwind_protect_bool (interactive); |
400 | |
9009
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
401 // Do this with an unwind-protect cleanup function so that the |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
402 // forced variables will be unmarked in the event of an interrupt. |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
403 symbol_table::scope_id scope = symbol_table::top_scope (); |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
404 unwind_protect::add (unmark_forced_vars, &scope); |
da58ec8f62e8
tag bug don't define forced variables
John W. Eaton <jwe@octave.org>
parents:
8923
diff
changeset
|
405 |
5189 | 406 interactive = false; |
407 | |
408 int parse_status = 0; | |
409 | |
6487 | 410 try |
411 { | |
412 eval_string (code, false, parse_status, 0); | |
413 } | |
7202 | 414 catch (octave_interrupt_exception) |
415 { | |
416 recover_from_exception (); | |
417 octave_stdout << "\n"; | |
418 } | |
6487 | 419 catch (std::bad_alloc) |
420 { | |
6680 | 421 std::cerr << "error: memory exhausted or requested size too large for range of Octave's index type -- eval failed" |
422 << std::endl; | |
6487 | 423 } |
5189 | 424 |
425 unwind_protect::run_frame ("execute_eval_option_code"); | |
426 | |
427 return parse_status; | |
428 } | |
429 | |
430 static void | |
431 execute_command_line_file (const std::string& fname) | |
432 { | |
433 unwind_protect::begin_frame ("execute_command_line_file"); | |
434 | |
7202 | 435 octave_save_signal_mask (); |
436 | |
437 can_interrupt = true; | |
438 | |
439 octave_signal_hook = octave_signal_handler; | |
440 octave_interrupt_hook = unwind_protect::run_all; | |
441 octave_bad_alloc_hook = unwind_protect::run_all; | |
442 | |
443 octave_catch_interrupts (); | |
444 | |
445 octave_initialized = true; | |
446 | |
5189 | 447 unwind_protect_bool (interactive); |
448 unwind_protect_bool (reading_script_file); | |
449 unwind_protect_bool (input_from_command_line_file); | |
450 | |
451 unwind_protect_str (curr_fcn_file_name); | |
452 unwind_protect_str (curr_fcn_file_full_name); | |
453 | |
5780 | 454 unwind_protect_str (octave_program_invocation_name); |
455 unwind_protect_str (octave_program_name); | |
5189 | 456 |
457 interactive = false; | |
458 reading_script_file = true; | |
459 input_from_command_line_file = true; | |
460 | |
461 curr_fcn_file_name = fname; | |
462 curr_fcn_file_full_name = curr_fcn_file_name; | |
463 | |
5780 | 464 octave_program_invocation_name = curr_fcn_file_name; |
5189 | 465 |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
466 size_t pos = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars ()); |
5189 | 467 |
8021 | 468 std::string tmp = (pos != std::string::npos) |
5189 | 469 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
470 | |
5780 | 471 octave_program_name = tmp; |
5189 | 472 |
6504 | 473 try |
474 { | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
475 std::string context; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
476 bool verbose = false; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
477 bool require_file = true; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
478 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7481
diff
changeset
|
479 source_file (fname, context, verbose, require_file, "octave"); |
6504 | 480 } |
7202 | 481 catch (octave_interrupt_exception) |
482 { | |
483 recover_from_exception (); | |
484 octave_stdout << "\n"; | |
485 } | |
6504 | 486 catch (std::bad_alloc) |
487 { | |
6680 | 488 std::cerr << "error: memory exhausted or requested size too large for range of Octave's index type -- execution of " |
489 << fname << " failed" << std::endl; | |
6504 | 490 } |
5189 | 491 |
492 unwind_protect::run_frame ("execute_command_line_file"); | |
493 } | |
494 | |
581 | 495 // Usage message with extra help. |
496 | |
1 | 497 static void |
498 verbose_usage (void) | |
499 { | |
3922 | 500 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613 | 501 \n\ |
502 Usage: octave [options]\n\ | |
503 \n\ | |
504 Options:\n\ | |
1119 | 505 \n\ |
3180 | 506 --debug, -d Enter parser debugging mode.\n\ |
8923
d47290508a55
document --doc-cache-file option
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
507 --doc-cache-file FILE Use doc cache file FILE.\n\ |
3180 | 508 --echo-commands, -x Echo commands as they are executed.\n\ |
5191 | 509 --eval CODE Evaluate CODE. Exit when done unless --persist.\n\ |
1613 | 510 --exec-path PATH Set path for executing subprograms.\n\ |
3180 | 511 --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
|
512 --image-path PATH Add PATH to head of image search path.\n\ |
1613 | 513 --info-file FILE Use top-level info file FILE.\n\ |
514 --info-program PROGRAM Use PROGRAM for reading info files.\n\ | |
3180 | 515 --interactive, -i Force interactive behavior.\n\ |
6938 | 516 --line-editing Force readline use for command-line editing.\n\ |
3180 | 517 --no-history, -H Don't save commands to the history list\n\ |
2470 | 518 --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
|
519 --no-init-path Don't initialize function search path.\n\ |
2212 | 520 --no-line-editing Don't use readline for command-line editing.\n\ |
2470 | 521 --no-site-file Don't read the site-wide octaverc file.\n\ |
3238 | 522 --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
|
523 --path PATH, -p PATH Add PATH to head of function search path.\n\ |
5189 | 524 --persist Go interactive after --eval or reading from FILE.\n\ |
3180 | 525 --silent, -q Don't print message at startup.\n\ |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
526 --traditional Set variables for closer MATLAB compatibility.\n\ |
3180 | 527 --verbose, -V Enable verbose output in some cases.\n\ |
528 --version, -v Print version number and exit.\n\ | |
1119 | 529 \n\ |
5190 | 530 FILE Execute commands from FILE. Exit when done\n\ |
5191 | 531 unless --persist is also specified.\n\ |
4829 | 532 \n" |
533 OCTAVE_WWW_STATEMENT "\n\ | |
4356 | 534 \n" |
535 OCTAVE_CONTRIB_STATEMENT "\n\ | |
536 \n" | |
537 OCTAVE_BUGS_STATEMENT "\n"; | |
285 | 538 |
613 | 539 exit (0); |
1 | 540 } |
541 | |
581 | 542 // Terse usage messsage. |
543 | |
1 | 544 static void |
545 usage (void) | |
546 { | |
3531 | 547 std::cerr << "usage: " << usage_string << "\n"; |
1 | 548 exit (1); |
549 } | |
550 | |
551 static void | |
552 print_version_and_exit (void) | |
553 { | |
3922 | 554 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1 | 555 exit (0); |
556 } | |
557 | |
721 | 558 static void |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
559 lo_error_handler (const char *fmt, ...) |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
560 { |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
561 va_list args; |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
562 va_start (args, fmt); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
563 verror (fmt, args); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
564 va_end (args); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
565 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
566 octave_throw_execution_exception (); |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
567 } |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
568 |
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
569 static void |
721 | 570 initialize_error_handlers () |
571 { | |
7481
78f3811155f7
use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
572 set_liboctave_error_handler (lo_error_handler); |
3325 | 573 set_liboctave_warning_handler (warning); |
5781 | 574 set_liboctave_warning_with_id_handler (warning_with_id); |
721 | 575 } |
576 | |
1410 | 577 // What happens on --traditional. |
578 | |
579 static void | |
580 maximum_braindamage (void) | |
581 { | |
5189 | 582 persist = true; |
583 | |
5794 | 584 bind_internal_variable ("PS1", ">> "); |
585 bind_internal_variable ("PS2", ""); | |
586 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
|
587 bind_internal_variable ("confirm_recursive_rmdir", false); |
5794 | 588 bind_internal_variable ("crash_dumps_octave_core", false); |
589 bind_internal_variable ("default_save_options", "-mat-binary"); | |
590 bind_internal_variable ("fixed_point_format", true); | |
591 bind_internal_variable ("history_timestamp_format_string", | |
5305 | 592 "%%-- %D %I:%M %p --%%"); |
5794 | 593 bind_internal_variable ("page_screen_output", false); |
594 bind_internal_variable ("print_empty_dimensions", false); | |
5904 | 595 |
6159 | 596 disable_warning ("Octave:fopen-file-in-path"); |
5904 | 597 disable_warning ("Octave:function-name-clash"); |
6159 | 598 disable_warning ("Octave:load-file-in-path"); |
1410 | 599 } |
600 | |
581 | 601 // You guessed it. |
602 | |
1 | 603 int |
4368 | 604 octave_main (int argc, char **argv, int embedded) |
1 | 605 { |
3019 | 606 octave_env::set_program_name (argv[0]); |
607 | |
5780 | 608 octave_program_invocation_name = octave_env::get_program_invocation_name (); |
609 octave_program_name = octave_env::get_program_name (); | |
610 | |
2205 | 611 // The order of these calls is important. The call to |
2926 | 612 // install_defaults must come before install_builtins because |
3019 | 613 // default variable values must be available for the variables to be |
2205 | 614 // installed, and the call to install_builtins must come before the |
615 // options are processed because some command line options override | |
5794 | 616 // defaults by calling bind_internal_variable. |
721 | 617 |
5844 | 618 init_signals (); |
619 | |
1 | 620 sysdep_init (); |
621 | |
4159 | 622 // The idea here is to force xerbla to be referenced so that we will |
623 // link to our own version instead of the one provided by the BLAS | |
624 // library. But octave_NaN should never be -1, so we should never | |
625 // actually call xerbla. | |
626 | |
627 if (octave_NaN == -1) | |
628 F77_FUNC (xerbla, XERBLA) ("octave", 13, 6L); | |
629 | |
721 | 630 initialize_error_handlers (); |
223 | 631 |
5794 | 632 initialize_default_warning_state (); |
633 | |
2926 | 634 install_defaults (); |
1 | 635 |
1792 | 636 initialize_pathsearch (); |
1744 | 637 |
4368 | 638 if (! embedded) |
639 install_signal_handlers (); | |
2205 | 640 |
641 initialize_file_io (); | |
642 | |
2375 | 643 install_types (); |
644 | |
645 install_ops (); | |
2205 | 646 |
647 install_builtins (); | |
648 | |
1817 | 649 prog_args args (argc, argv, short_opts, long_opts); |
650 | |
6938 | 651 bool forced_line_editing = false; |
652 | |
8273
2c1ba965b486
skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents:
8099
diff
changeset
|
653 bool read_history_file = true; |
2c1ba965b486
skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents:
8099
diff
changeset
|
654 |
139 | 655 int optc; |
1817 | 656 while ((optc = args.getopt ()) != EOF) |
1 | 657 { |
139 | 658 switch (optc) |
1 | 659 { |
3180 | 660 case 'H': |
8273
2c1ba965b486
skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents:
8099
diff
changeset
|
661 read_history_file = false; |
5794 | 662 bind_internal_variable ("saving_history", false); |
3180 | 663 break; |
664 | |
793 | 665 case 'V': |
2239 | 666 verbose_flag = true; |
793 | 667 break; |
668 | |
1 | 669 case 'd': |
4753 | 670 // This is the same as yydebug in parse.y. |
671 octave_debug++; | |
1 | 672 break; |
777 | 673 |
1 | 674 case 'f': |
2239 | 675 read_init_files = false; |
676 read_site_files = false; | |
1 | 677 break; |
777 | 678 |
1 | 679 case 'h': |
680 case '?': | |
681 verbose_usage (); | |
682 break; | |
777 | 683 |
1 | 684 case 'i': |
3019 | 685 forced_interactive = true; |
1 | 686 break; |
777 | 687 |
1 | 688 case 'p': |
1817 | 689 if (args.optarg ()) |
5832 | 690 load_path::set_command_line_path (args.optarg ()); |
1 | 691 break; |
777 | 692 |
1 | 693 case 'q': |
2239 | 694 inhibit_startup_message = true; |
1 | 695 break; |
777 | 696 |
1 | 697 case 'x': |
2205 | 698 { |
699 double tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); | |
5794 | 700 bind_internal_variable ("echo_executing_commands", tmp); |
2205 | 701 } |
1 | 702 break; |
777 | 703 |
1 | 704 case 'v': |
705 print_version_and_exit (); | |
706 break; | |
777 | 707 |
8861 | 708 case DOC_CACHE_FILE_OPTION: |
709 if (args.optarg ()) | |
710 bind_internal_variable ("doc_cache_file", args.optarg ()); | |
711 break; | |
712 | |
5189 | 713 case EVAL_OPTION: |
714 if (args.optarg ()) | |
5193 | 715 { |
716 if (code_to_eval.empty ()) | |
717 code_to_eval = args.optarg (); | |
718 else | |
719 code_to_eval += std::string (" ") + args.optarg (); | |
720 } | |
5189 | 721 break; |
722 | |
1613 | 723 case EXEC_PATH_OPTION: |
1817 | 724 if (args.optarg ()) |
5814 | 725 set_exec_path (args.optarg ()); |
726 break; | |
727 | |
728 case IMAGE_PATH_OPTION: | |
729 if (args.optarg ()) | |
730 set_image_path (args.optarg ()); | |
1613 | 731 break; |
732 | |
186 | 733 case INFO_FILE_OPTION: |
1817 | 734 if (args.optarg ()) |
5794 | 735 bind_internal_variable ("info_file", args.optarg ()); |
186 | 736 break; |
777 | 737 |
1613 | 738 case INFO_PROG_OPTION: |
1817 | 739 if (args.optarg ()) |
5794 | 740 bind_internal_variable ("info_program", args.optarg ()); |
1613 | 741 break; |
742 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
743 case LINE_EDITING_OPTION: |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
744 forced_line_editing = true; |
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
745 break; |
6938 | 746 |
2239 | 747 case NO_INIT_FILE_OPTION: |
748 read_init_files = false; | |
749 break; | |
750 | |
1821 | 751 case NO_LINE_EDITING_OPTION: |
3019 | 752 line_editing = false; |
2239 | 753 break; |
754 | |
755 case NO_SITE_FILE_OPTION: | |
756 read_site_files = 0; | |
1821 | 757 break; |
758 | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
9009
diff
changeset
|
759 case NO_INIT_PATH_OPTION: |
6365 | 760 set_initial_path = false; |
761 break; | |
762 | |
1410 | 763 case TRADITIONAL_OPTION: |
2239 | 764 traditional = true; |
1410 | 765 break; |
766 | |
5189 | 767 case PERSIST_OPTION: |
768 persist = true; | |
769 break; | |
770 | |
1 | 771 default: |
772 usage (); | |
773 break; | |
774 } | |
775 } | |
776 | |
1651 | 777 #if defined (HAVE_ATEXIT) || defined (HAVE_ON_EXIT) |
2077 | 778 // Make sure we clean up when we exit. Also allow users to register |
779 // functions. If we don't have atexit or on_exit, we're going to | |
780 // leave some junk files around if we exit abnormally. | |
781 | |
782 atexit (do_octave_atexit); | |
318 | 783 #endif |
1 | 784 |
1358 | 785 // These can come after command line args since none of them set any |
786 // defaults that might be changed by command line options. | |
581 | 787 |
2926 | 788 initialize_command_input (); |
315 | 789 |
578 | 790 if (! inhibit_startup_message) |
3538 | 791 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
578 | 792 |
1410 | 793 if (traditional) |
794 maximum_braindamage (); | |
795 | |
4217 | 796 octave_interpreter_ready = true; |
797 | |
5654 | 798 initialize_version_info (); |
799 | |
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
|
800 // 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
|
801 // 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
|
802 |
e0a6e54f5a19
octave.cc (octave_main): make all command-line arguments available to startup scripts
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
803 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
|
804 |
6365 | 805 load_path::initialize (set_initial_path); |
4217 | 806 |
2239 | 807 execute_startup_files (); |
1651 | 808 |
8273
2c1ba965b486
skip reading history file with --no-history option
John W. Eaton <jwe@octave.org>
parents:
8099
diff
changeset
|
809 initialize_history (read_history_file); |
1 | 810 |
578 | 811 if (! inhibit_startup_message && reading_startup_message_printed) |
3538 | 812 std::cout << std::endl; |
578 | 813 |
5189 | 814 // Is input coming from a terminal? If so, we are probably |
815 // interactive. | |
1358 | 816 |
5189 | 817 interactive = (! embedded |
818 && isatty (fileno (stdin)) && isatty (fileno (stdout))); | |
819 | |
6938 | 820 if (! interactive && ! forced_line_editing) |
5189 | 821 line_editing = false; |
1 | 822 |
1358 | 823 // If there is an extra argument, see if it names a file to read. |
824 // Additional arguments are taken as command line options for the | |
825 // script. | |
1 | 826 |
1817 | 827 int last_arg_idx = args.optind (); |
3019 | 828 |
1817 | 829 int remaining_args = argc - last_arg_idx; |
3019 | 830 |
5189 | 831 if (! code_to_eval.empty ()) |
149 | 832 { |
5189 | 833 int parse_status = execute_eval_option_code (code_to_eval); |
834 | |
5242 | 835 if (! (persist || remaining_args > 0)) |
5502 | 836 clean_up_and_exit (parse_status || error_state ? 1 : 0); |
1 | 837 } |
838 | |
5189 | 839 if (remaining_args > 0) |
840 { | |
841 // If we are running an executable script (#! /bin/octave) then | |
842 // we should only see the args passed to the script. | |
843 | |
844 intern_argv (remaining_args, argv+last_arg_idx); | |
845 | |
846 execute_command_line_file (argv[last_arg_idx]); | |
847 | |
848 if (! persist) | |
5502 | 849 clean_up_and_exit (error_state ? 1 : 0); |
5189 | 850 } |
851 | |
852 // Avoid counting commands executed from startup files. | |
853 | |
854 command_editor::reset_current_command_number (1); | |
855 | |
856 // Now argv should have the full set of args. | |
857 intern_argv (argc, argv); | |
858 | |
859 if (! embedded) | |
860 switch_to_buffer (create_buffer (get_input_from_stdin ())); | |
861 | |
1358 | 862 // Force input to be echoed if not really interactive, but the user |
863 // has forced interactive behavior. | |
1 | 864 |
1907 | 865 if (! interactive && forced_interactive) |
287 | 866 { |
2926 | 867 command_editor::blink_matching_paren (false); |
1588 | 868 |
5775 | 869 // FIXME -- is this the right thing to do? |
1588 | 870 |
5794 | 871 bind_internal_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287 | 872 } |
1 | 873 |
4368 | 874 if (embedded) |
5502 | 875 { |
5775 | 876 // FIXME -- do we need to do any cleanup here before |
5502 | 877 // returning? If we don't, what will happen to Octave functions |
878 // that have been registered to execute with atexit, for example? | |
879 | |
880 return 1; | |
881 } | |
4368 | 882 |
5189 | 883 int retval = main_loop (); |
1 | 884 |
1005 | 885 if (retval == 1 && ! error_state) |
886 retval = 0; | |
887 | |
1 | 888 clean_up_and_exit (retval); |
4247 | 889 |
890 return 0; | |
1 | 891 } |
892 | |
5780 | 893 DEFUN (argv, args, , |
894 "-*- texinfo -*-\n\ | |
895 @deftypefn {Built-in Function} {} argv ()\n\ | |
896 Return the command line arguments passed to Octave. For example,\n\ | |
897 if you invoked Octave using the command\n\ | |
898 \n\ | |
899 @example\n\ | |
900 octave --no-line-editing --silent\n\ | |
901 @end example\n\ | |
902 \n\ | |
903 @noindent\n\ | |
904 @code{argv} would return a cell array of strings with the elements\n\ | |
905 @code{--no-line-editing} and @code{--silent}.\n\ | |
906 \n\ | |
907 If you write an executable Octave script, @code{argv} will return the\n\ | |
908 list of arguments passed to the script. @xref{Executable Octave Programs},\n\ | |
909 for an example of how to create an executable Octave script.\n\ | |
910 @end deftypefn") | |
911 { | |
912 octave_value retval; | |
913 | |
914 if (args.length () == 0) | |
915 retval = Cell (octave_argv); | |
916 else | |
5823 | 917 print_usage (); |
5780 | 918 |
919 return retval; | |
920 } | |
921 | |
922 DEFUN (program_invocation_name, args, , | |
923 "-*- texinfo -*-\n\ | |
924 @deftypefn {Built-in Function} program_invocation_name ()\n\ | |
925 Return the name that was typed at the shell prompt to run Octave.\n\ | |
926 \n\ | |
927 If executing a script from the command line (e.g., @code{octave foo.m})\n\ | |
928 or using an executable Octave script, the program name is set to the\n\ | |
929 name of the script. @xref{Executable Octave Programs}, for an example of\n\ | |
930 how to create an executable Octave script.\n\ | |
931 @seealso{program_name}\n\ | |
932 @end deftypefn") | |
933 { | |
934 octave_value retval; | |
935 | |
936 if (args.length () == 0) | |
937 retval = octave_program_invocation_name; | |
938 else | |
5823 | 939 print_usage (); |
5780 | 940 |
941 return retval; | |
942 } | |
943 | |
944 DEFUN (program_name, args, , | |
945 "-*- texinfo -*-\n\ | |
946 @deftypefn {Built-in Function} {} program_name ()\n\ | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
8273
diff
changeset
|
947 Return the last component of the value returned by\n\ |
5780 | 948 @code{program_invocation_name}.\n\ |
949 @seealso{program_invocation_name}\n\ | |
950 @end deftypefn") | |
951 { | |
952 octave_value retval; | |
953 | |
954 if (args.length () == 0) | |
955 retval = octave_program_name; | |
956 else | |
5823 | 957 print_usage (); |
5780 | 958 |
959 return retval; | |
960 } | |
961 | |
560 | 962 /* |
1 | 963 ;;; Local Variables: *** |
964 ;;; mode: C++ *** | |
965 ;;; End: *** | |
966 */ |