annotate src/octave.cc @ 10485:b4e14e628fc9

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