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