1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
|
23 // Born February 20, 1992. |
|
24 |
240
|
25 #ifdef HAVE_CONFIG_H |
1192
|
26 #include <config.h> |
1
|
27 #endif |
|
28 |
1355
|
29 #include <cassert> |
|
30 #include <cstdlib> |
|
31 #include <cstring> |
|
32 #include <ctime> |
|
33 |
3503
|
34 #include <fstream> |
|
35 #include <iostream> |
1355
|
36 |
|
37 #ifdef HAVE_UNISTD_H |
2442
|
38 #ifdef HAVE_SYS_TYPES_H |
1
|
39 #include <sys/types.h> |
2442
|
40 #endif |
139
|
41 #include <unistd.h> |
|
42 #endif |
1355
|
43 |
2926
|
44 #include "cmd-edit.h" |
3690
|
45 #include "f77-fcn.h" |
4097
|
46 #include "file-ops.h" |
2926
|
47 #include "file-stat.h" |
240
|
48 #include "lo-error.h" |
2926
|
49 #include "oct-env.h" |
3019
|
50 #include "pathsearch.h" |
1907
|
51 #include "str-vec.h" |
223
|
52 |
2492
|
53 #include <defaults.h> |
3933
|
54 #include "Cell.h" |
1355
|
55 #include "defun.h" |
|
56 #include "error.h" |
|
57 #include "file-io.h" |
1
|
58 #include "input.h" |
|
59 #include "lex.h" |
4113
|
60 #include "octave.h" |
1742
|
61 #include "oct-hist.h" |
3195
|
62 #include "oct-obj.h" |
2375
|
63 #include "ops.h" |
1670
|
64 #include "toplev.h" |
1
|
65 #include "parse.h" |
2982
|
66 #include "pt-plot.h" |
562
|
67 #include "procstream.h" |
1817
|
68 #include "prog-args.h" |
1355
|
69 #include "sighandlers.h" |
|
70 #include "sysdep.h" |
2375
|
71 #include "ov.h" |
1
|
72 #include "unwind-prot.h" |
1355
|
73 #include "utils.h" |
|
74 #include "variables.h" |
2492
|
75 #include <version.h> |
1
|
76 |
4159
|
77 // Kluge. |
|
78 extern "C" void F77_FUNC (xerbla, XERBLA) (const char *, int, long); |
|
79 |
2910
|
80 extern void install_builtins (void); |
|
81 |
1704
|
82 #if !defined (HAVE_ATEXIT) && defined (HAVE_ON_EXIT) |
|
83 extern "C" int on_exit (); |
|
84 #define atexit on_exit |
|
85 #endif |
|
86 |
1907
|
87 // The command-line options. |
|
88 static string_vector octave_argv; |
1
|
89 |
2239
|
90 // TRUE means we read ~/.octaverc and ./.octaverc. |
|
91 // (--norc; --no-init-file; -f) |
|
92 static bool read_init_files = true; |
|
93 |
|
94 // TRUE means we read the site-wide octaverc files. |
|
95 // (--norc; --no-site-file; -f) |
2240
|
96 static bool read_site_files = true; |
1
|
97 |
3019
|
98 // TRUE means we don't print the usual startup message. |
616
|
99 // (--quiet; --silent; -q) |
2239
|
100 static bool inhibit_startup_message = false; |
1
|
101 |
3019
|
102 // TRUE means we turn on compatibility options. |
1410
|
103 // (--traditional) |
2239
|
104 static bool traditional = false; |
1410
|
105 |
3019
|
106 // If TRUE, print verbose info in some cases. |
1825
|
107 // (--verbose; -V) |
2239
|
108 static bool verbose_flag = false; |
1825
|
109 |
1
|
110 // Usage message |
139
|
111 static const char *usage_string = |
3180
|
112 "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--exec-path path]\n\ |
4356
|
113 [--funcall FUNC] [--help] [--info-file file] [--info-program prog]\n\ |
|
114 [--interactive] [--no-history] [--no-init-file] [--no-line-editing]\n\ |
|
115 [--no-site-file] [-p path] [--path path] [--silent] [--traditional]\n\ |
|
116 [--verbose] [--version] [file]"; |
1
|
117 |
1358
|
118 // This is here so that it's more likely that the usage message and |
1410
|
119 // the real set of options will agree. Note: the `+' must come first |
|
120 // to prevent getopt from permuting arguments! |
3180
|
121 static const char *short_opts = "+?HVdfhip:qvx"; |
139
|
122 |
4356
|
123 // The name of the optional initial function to call at startup. |
|
124 // (--funcall FUNC) |
|
125 static std::string fun_to_call; |
|
126 |
1103
|
127 // Long options. See the comments in getopt.h for the meanings of the |
|
128 // fields in this structure. |
1613
|
129 #define EXEC_PATH_OPTION 1 |
4356
|
130 #define FUNCALL_OPTION 2 |
|
131 #define INFO_FILE_OPTION 3 |
|
132 #define INFO_PROG_OPTION 4 |
|
133 #define NO_INIT_FILE_OPTION 5 |
|
134 #define NO_LINE_EDITING_OPTION 6 |
|
135 #define NO_SITE_FILE_OPTION 7 |
|
136 #define TRADITIONAL_OPTION 8 |
1817
|
137 long_options long_opts[] = |
139
|
138 { |
1855
|
139 { "debug", prog_args::no_arg, 0, 'd' }, |
2277
|
140 { "braindead", prog_args::no_arg, 0, TRADITIONAL_OPTION }, |
1855
|
141 { "echo-commands", prog_args::no_arg, 0, 'x' }, |
|
142 { "exec-path", prog_args::required_arg, 0, EXEC_PATH_OPTION }, |
4356
|
143 { "funcall", prog_args::required_arg, 0, FUNCALL_OPTION }, |
1855
|
144 { "help", prog_args::no_arg, 0, 'h' }, |
|
145 { "info-file", prog_args::required_arg, 0, INFO_FILE_OPTION }, |
|
146 { "info-program", prog_args::required_arg, 0, INFO_PROG_OPTION }, |
|
147 { "interactive", prog_args::no_arg, 0, 'i' }, |
3180
|
148 { "no-history", prog_args::no_arg, 0, 'H' }, |
2239
|
149 { "no-init-file", prog_args::no_arg, 0, NO_INIT_FILE_OPTION }, |
1855
|
150 { "no-line-editing", prog_args::no_arg, 0, NO_LINE_EDITING_OPTION }, |
2239
|
151 { "no-site-file", prog_args::no_arg, 0, NO_SITE_FILE_OPTION }, |
1855
|
152 { "norc", prog_args::no_arg, 0, 'f' }, |
|
153 { "path", prog_args::required_arg, 0, 'p' }, |
|
154 { "quiet", prog_args::no_arg, 0, 'q' }, |
|
155 { "silent", prog_args::no_arg, 0, 'q' }, |
|
156 { "traditional", prog_args::no_arg, 0, TRADITIONAL_OPTION }, |
|
157 { "verbose", prog_args::no_arg, 0, 'V' }, |
|
158 { "version", prog_args::no_arg, 0, 'v' }, |
3019
|
159 { 0, 0, 0, 0 } |
139
|
160 }; |
1
|
161 |
1355
|
162 // Store the command-line options for later use. |
|
163 |
|
164 static void |
|
165 intern_argv (int argc, char **argv) |
|
166 { |
4700
|
167 bind_builtin_variable ("__nargin__", argc-1, true, true, 0); |
3195
|
168 |
4587
|
169 Cell args; |
3195
|
170 |
1355
|
171 if (argc > 1) |
|
172 { |
3933
|
173 Array<octave_value> tmp (argc-1); |
|
174 |
2495
|
175 // Skip program name in argv. |
3933
|
176 int i = argc; |
|
177 while (--i > 0) |
|
178 tmp(i-1) = octave_value (*(argv+i)); |
1411
|
179 |
4587
|
180 args = Cell (tmp, argc-1, 1); |
1355
|
181 } |
1907
|
182 |
4587
|
183 bind_builtin_constant ("argv", args, true, true); |
1355
|
184 } |
|
185 |
1792
|
186 static void |
|
187 initialize_pathsearch (void) |
|
188 { |
|
189 // This may seem odd, but doing it this way means that we don't have |
|
190 // to modify the kpathsea library... |
|
191 |
3523
|
192 std::string odb = octave_env::getenv ("OCTAVE_DB_PATH"); |
3141
|
193 |
|
194 // For backward compatibility. |
1792
|
195 |
2926
|
196 if (odb.empty ()) |
3141
|
197 odb = octave_env::getenv ("OCTAVE_DB_DIR"); |
1792
|
198 |
3141
|
199 if (odb.empty ()) |
4101
|
200 odb = Vdata_dir + file_ops::dir_sep_str + "octave:" |
|
201 + Vlibexec_dir + file_ops::dir_sep_str + "octave"; |
1792
|
202 } |
|
203 |
581
|
204 // Initialize by reading startup files. |
|
205 |
1
|
206 static void |
|
207 execute_startup_files (void) |
|
208 { |
2985
|
209 unwind_protect::begin_frame ("execute_startup_files"); |
315
|
210 |
1651
|
211 // XXX FIXME XXX -- need to make it possible to set this in startup |
|
212 // files. |
1588
|
213 |
3019
|
214 unwind_protect_bool (input_from_startup_file); |
1651
|
215 |
3019
|
216 input_from_startup_file = true; |
315
|
217 |
793
|
218 int verbose = (verbose_flag && ! inhibit_startup_message); |
578
|
219 |
2239
|
220 if (read_site_files) |
1
|
221 { |
2239
|
222 // Execute commands from the site-wide configuration file. |
|
223 // First from the file $(prefix)/lib/octave/site/m/octaverc |
|
224 // (if it exists), then from the file |
3597
|
225 // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). |
1755
|
226 |
2897
|
227 parse_and_execute (Vlocal_site_defaults_file, verbose); |
1755
|
228 |
2897
|
229 parse_and_execute (Vsite_defaults_file, verbose); |
1
|
230 } |
|
231 |
2239
|
232 if (read_init_files) |
|
233 { |
2512
|
234 // Try to execute commands from $HOME/$OCTAVE_INITFILE and |
|
235 // $OCTAVE_INITFILE. If $OCTAVE_INITFILE is not set, .octaverc |
|
236 // is assumed. |
2239
|
237 |
|
238 int home_rc_already_executed = 0; |
2512
|
239 |
3523
|
240 std::string initfile = octave_env::getenv ("OCTAVE_INITFILE"); |
2512
|
241 |
2926
|
242 if (initfile.empty ()) |
2512
|
243 initfile = ".octaverc"; |
|
244 |
3523
|
245 std::string home_dir = octave_env::get_home_directory (); |
2926
|
246 |
4101
|
247 std::string home_rc = home_dir + file_ops::dir_sep_str + initfile; |
4100
|
248 std::string local_rc |
4101
|
249 = octave_env::getcwd () + file_ops::dir_sep_str + initfile; |
2239
|
250 |
2926
|
251 if (! home_dir.empty ()) |
2239
|
252 { |
2897
|
253 parse_and_execute (home_rc, verbose); |
2239
|
254 |
|
255 // Names alone are not enough. |
|
256 |
|
257 file_stat fs_home_rc (home_rc); |
|
258 |
|
259 if (fs_home_rc) |
|
260 { |
2512
|
261 file_stat fs_dot_rc (local_rc); |
2239
|
262 |
|
263 if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) |
|
264 home_rc_already_executed = 1; |
|
265 } |
|
266 } |
|
267 |
|
268 if (! home_rc_already_executed) |
2897
|
269 parse_and_execute (local_rc, verbose); |
2239
|
270 } |
315
|
271 |
2985
|
272 unwind_protect::run_frame ("execute_startup_files"); |
1
|
273 } |
|
274 |
581
|
275 // Usage message with extra help. |
|
276 |
1
|
277 static void |
|
278 verbose_usage (void) |
|
279 { |
3922
|
280 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613
|
281 \n\ |
|
282 Usage: octave [options]\n\ |
|
283 \n\ |
|
284 Options:\n\ |
1119
|
285 \n\ |
3180
|
286 --debug, -d Enter parser debugging mode.\n\ |
|
287 --echo-commands, -x Echo commands as they are executed.\n\ |
1613
|
288 --exec-path PATH Set path for executing subprograms.\n\ |
4356
|
289 --funcall FUNC Call Octave function FUNC with no arguments.\n\ |
3180
|
290 --help, -h, -? Print short help message and exit.\n\ |
1613
|
291 --info-file FILE Use top-level info file FILE.\n\ |
|
292 --info-program PROGRAM Use PROGRAM for reading info files.\n\ |
3180
|
293 --interactive, -i Force interactive behavior.\n\ |
|
294 --no-history, -H Don't save commands to the history list\n\ |
2470
|
295 --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ |
2212
|
296 --no-line-editing Don't use readline for command-line editing.\n\ |
2470
|
297 --no-site-file Don't read the site-wide octaverc file.\n\ |
3238
|
298 --norc, -f Don't read any initialization files.\n\ |
3180
|
299 --path PATH, -p PATH Set initial LOADPATH to PATH.\n\ |
|
300 --silent, -q Don't print message at startup.\n\ |
1613
|
301 --traditional Set compatibility variables.\n\ |
3180
|
302 --verbose, -V Enable verbose output in some cases.\n\ |
|
303 --version, -v Print version number and exit.\n\ |
1119
|
304 \n\ |
1613
|
305 FILE Execute commands from FILE.\n\ |
2375
|
306 \n\ |
|
307 Additional information about Octave is available via the WWW at\n\ |
3917
|
308 http://www.octave.org.\n\ |
4356
|
309 \n" |
|
310 OCTAVE_CONTRIB_STATEMENT "\n\ |
|
311 \n" |
|
312 OCTAVE_BUGS_STATEMENT "\n"; |
285
|
313 |
613
|
314 exit (0); |
1
|
315 } |
|
316 |
581
|
317 // Terse usage messsage. |
|
318 |
1
|
319 static void |
|
320 usage (void) |
|
321 { |
3531
|
322 std::cerr << "usage: " << usage_string << "\n"; |
1
|
323 exit (1); |
|
324 } |
|
325 |
|
326 static void |
|
327 print_version_and_exit (void) |
|
328 { |
3922
|
329 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1
|
330 exit (0); |
|
331 } |
|
332 |
721
|
333 static void |
|
334 initialize_error_handlers () |
|
335 { |
|
336 set_liboctave_error_handler (error); |
3325
|
337 set_liboctave_warning_handler (warning); |
721
|
338 } |
|
339 |
1410
|
340 // What happens on --traditional. |
|
341 |
|
342 static void |
|
343 maximum_braindamage (void) |
|
344 { |
|
345 bind_builtin_variable ("PS1", ">> "); |
|
346 bind_builtin_variable ("PS2", ""); |
4324
|
347 bind_builtin_variable ("beep_on_error", true); |
|
348 bind_builtin_variable ("crash_dumps_octave_core", false); |
1410
|
349 bind_builtin_variable ("default_save_format", "mat-binary"); |
4324
|
350 bind_builtin_variable ("fixed_point_format", true); |
|
351 bind_builtin_variable ("page_screen_output", false); |
|
352 bind_builtin_variable ("print_empty_dimensions", false); |
|
353 bind_builtin_variable ("warn_function_name_clash", false); |
4476
|
354 bind_builtin_variable ("warn_matlab_incompatible", true); |
1410
|
355 } |
|
356 |
581
|
357 // You guessed it. |
|
358 |
1
|
359 int |
4368
|
360 octave_main (int argc, char **argv, int embedded) |
1
|
361 { |
3019
|
362 octave_env::set_program_name (argv[0]); |
|
363 |
2205
|
364 // The order of these calls is important. The call to |
2926
|
365 // install_defaults must come before install_builtins because |
3019
|
366 // default variable values must be available for the variables to be |
2205
|
367 // installed, and the call to install_builtins must come before the |
|
368 // options are processed because some command line options override |
|
369 // defaults by calling bind_builtin_variable. |
721
|
370 |
1
|
371 sysdep_init (); |
|
372 |
4159
|
373 // The idea here is to force xerbla to be referenced so that we will |
|
374 // link to our own version instead of the one provided by the BLAS |
|
375 // library. But octave_NaN should never be -1, so we should never |
|
376 // actually call xerbla. |
|
377 |
|
378 if (octave_NaN == -1) |
|
379 F77_FUNC (xerbla, XERBLA) ("octave", 13, 6L); |
|
380 |
721
|
381 initialize_error_handlers (); |
223
|
382 |
2926
|
383 install_defaults (); |
1
|
384 |
1792
|
385 initialize_pathsearch (); |
1744
|
386 |
4368
|
387 if (! embedded) |
|
388 install_signal_handlers (); |
2205
|
389 |
|
390 initialize_file_io (); |
|
391 |
2375
|
392 initialize_symbol_tables (); |
|
393 |
|
394 install_types (); |
|
395 |
|
396 install_ops (); |
2205
|
397 |
|
398 install_builtins (); |
|
399 |
1817
|
400 prog_args args (argc, argv, short_opts, long_opts); |
|
401 |
139
|
402 int optc; |
1817
|
403 while ((optc = args.getopt ()) != EOF) |
1
|
404 { |
139
|
405 switch (optc) |
1
|
406 { |
3180
|
407 case 'H': |
4324
|
408 bind_builtin_variable ("saving_history", false); |
3180
|
409 break; |
|
410 |
793
|
411 case 'V': |
2239
|
412 verbose_flag = true; |
793
|
413 break; |
|
414 |
1
|
415 case 'd': |
|
416 yydebug++; |
|
417 break; |
777
|
418 |
1
|
419 case 'f': |
2239
|
420 read_init_files = false; |
|
421 read_site_files = false; |
1
|
422 break; |
777
|
423 |
1
|
424 case 'h': |
|
425 case '?': |
|
426 verbose_usage (); |
|
427 break; |
777
|
428 |
1
|
429 case 'i': |
3019
|
430 forced_interactive = true; |
1
|
431 break; |
777
|
432 |
1
|
433 case 'p': |
1817
|
434 if (args.optarg ()) |
2205
|
435 bind_builtin_variable ("LOADPATH", args.optarg ()); |
1
|
436 break; |
777
|
437 |
1
|
438 case 'q': |
2239
|
439 inhibit_startup_message = true; |
1
|
440 break; |
777
|
441 |
1
|
442 case 'x': |
2205
|
443 { |
|
444 double tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); |
|
445 bind_builtin_variable ("echo_executing_commands", tmp); |
|
446 } |
1
|
447 break; |
777
|
448 |
1
|
449 case 'v': |
|
450 print_version_and_exit (); |
|
451 break; |
777
|
452 |
1613
|
453 case EXEC_PATH_OPTION: |
1817
|
454 if (args.optarg ()) |
2205
|
455 bind_builtin_variable ("EXEC_PATH", args.optarg ()); |
1613
|
456 break; |
|
457 |
4356
|
458 case FUNCALL_OPTION: |
|
459 if (args.optarg ()) |
|
460 fun_to_call = args.optarg (); |
|
461 break; |
|
462 |
186
|
463 case INFO_FILE_OPTION: |
1817
|
464 if (args.optarg ()) |
2205
|
465 bind_builtin_variable ("INFO_FILE", args.optarg ()); |
186
|
466 break; |
777
|
467 |
1613
|
468 case INFO_PROG_OPTION: |
1817
|
469 if (args.optarg ()) |
2205
|
470 bind_builtin_variable ("INFO_PROGRAM", args.optarg ()); |
1613
|
471 break; |
|
472 |
2239
|
473 case NO_INIT_FILE_OPTION: |
|
474 read_init_files = false; |
|
475 break; |
|
476 |
1821
|
477 case NO_LINE_EDITING_OPTION: |
3019
|
478 line_editing = false; |
2239
|
479 break; |
|
480 |
|
481 case NO_SITE_FILE_OPTION: |
|
482 read_site_files = 0; |
1821
|
483 break; |
|
484 |
1410
|
485 case TRADITIONAL_OPTION: |
2239
|
486 traditional = true; |
1410
|
487 break; |
|
488 |
1
|
489 default: |
|
490 usage (); |
|
491 break; |
|
492 } |
|
493 } |
|
494 |
1651
|
495 #if defined (HAVE_ATEXIT) || defined (HAVE_ON_EXIT) |
2077
|
496 // Make sure we clean up when we exit. Also allow users to register |
|
497 // functions. If we don't have atexit or on_exit, we're going to |
|
498 // leave some junk files around if we exit abnormally. |
|
499 |
|
500 atexit (do_octave_atexit); |
318
|
501 #endif |
1
|
502 |
1358
|
503 // These can come after command line args since none of them set any |
|
504 // defaults that might be changed by command line options. |
581
|
505 |
2926
|
506 initialize_command_input (); |
315
|
507 |
578
|
508 if (! inhibit_startup_message) |
3538
|
509 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
578
|
510 |
1410
|
511 if (traditional) |
|
512 maximum_braindamage (); |
|
513 |
4217
|
514 octave_interpreter_ready = true; |
|
515 |
|
516 execute_default_pkg_add_files (); |
|
517 |
2239
|
518 execute_startup_files (); |
1651
|
519 |
2926
|
520 command_history::read (false); |
1
|
521 |
578
|
522 if (! inhibit_startup_message && reading_startup_message_printed) |
3538
|
523 std::cout << std::endl; |
578
|
524 |
1358
|
525 // Avoid counting commands executed from startup files. |
|
526 |
2926
|
527 command_editor::reset_current_command_number (1); |
1
|
528 |
1358
|
529 // If there is an extra argument, see if it names a file to read. |
|
530 // Additional arguments are taken as command line options for the |
|
531 // script. |
1
|
532 |
1817
|
533 int last_arg_idx = args.optind (); |
3019
|
534 |
1817
|
535 int remaining_args = argc - last_arg_idx; |
3019
|
536 |
1355
|
537 if (remaining_args > 0) |
149
|
538 { |
3019
|
539 reading_script_file = true; |
|
540 |
1817
|
541 curr_fcn_file_name = argv[last_arg_idx]; |
1608
|
542 curr_fcn_file_full_name = curr_fcn_file_name; |
1411
|
543 |
984
|
544 FILE *infile = get_input_from_file (curr_fcn_file_name); |
1411
|
545 |
529
|
546 if (infile) |
287
|
547 { |
3019
|
548 input_from_command_line_file = true; |
1516
|
549 |
1411
|
550 bind_builtin_variable ("program_invocation_name", |
|
551 curr_fcn_file_name); |
|
552 |
4101
|
553 size_t pos |
|
554 = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars); |
1755
|
555 |
3523
|
556 std::string tmp = (pos != NPOS) |
1755
|
557 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
1411
|
558 |
|
559 bind_builtin_variable ("program_name", tmp); |
|
560 |
1817
|
561 intern_argv (remaining_args, argv+last_arg_idx); |
1411
|
562 |
2926
|
563 command_editor::blink_matching_paren (false); |
|
564 |
287
|
565 switch_to_buffer (create_buffer (infile)); |
|
566 } |
529
|
567 else |
|
568 clean_up_and_exit (1); |
1
|
569 } |
|
570 else |
|
571 { |
1355
|
572 // Is input coming from a terminal? If so, we are probably |
|
573 // interactive. |
1
|
574 |
4368
|
575 interactive = (! embedded |
|
576 && isatty (fileno (stdin)) && isatty (fileno (stdout))); |
1355
|
577 |
|
578 intern_argv (argc, argv); |
|
579 |
4368
|
580 if (! embedded) |
|
581 switch_to_buffer (create_buffer (get_input_from_stdin ())); |
1
|
582 } |
|
583 |
1358
|
584 // Force input to be echoed if not really interactive, but the user |
|
585 // has forced interactive behavior. |
1
|
586 |
1907
|
587 if (! interactive && forced_interactive) |
287
|
588 { |
2926
|
589 command_editor::blink_matching_paren (false); |
1588
|
590 |
|
591 // XXX FIXME XXX -- is this the right thing to do? |
|
592 |
4233
|
593 bind_builtin_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287
|
594 } |
1
|
595 |
1410
|
596 if (! interactive) |
3019
|
597 line_editing = false; |
1
|
598 |
4368
|
599 if (embedded) |
|
600 return 1; |
|
601 |
4356
|
602 int retval = main_loop (fun_to_call); |
1
|
603 |
1005
|
604 if (retval == 1 && ! error_state) |
|
605 retval = 0; |
|
606 |
1
|
607 clean_up_and_exit (retval); |
4247
|
608 |
|
609 return 0; |
1
|
610 } |
|
611 |
560
|
612 /* |
1
|
613 ;;; Local Variables: *** |
|
614 ;;; mode: C++ *** |
|
615 ;;; End: *** |
|
616 */ |