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\ |
2239
|
113 [--help] [--info-file file] [--info-program prog] [--interactive]\n\ |
3180
|
114 [--no-history] [--no-init-file] [--no-line-editing] [--no-site-file]\n\ |
|
115 [-p path] [--path path] [--silent] [--traditional] [--verbose]\n\ |
|
116 [--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 |
1103
|
123 // Long options. See the comments in getopt.h for the meanings of the |
|
124 // fields in this structure. |
1613
|
125 #define EXEC_PATH_OPTION 1 |
|
126 #define INFO_FILE_OPTION 2 |
|
127 #define INFO_PROG_OPTION 3 |
2240
|
128 #define NO_INIT_FILE_OPTION 4 |
|
129 #define NO_LINE_EDITING_OPTION 5 |
|
130 #define NO_SITE_FILE_OPTION 6 |
|
131 #define TRADITIONAL_OPTION 7 |
1817
|
132 long_options long_opts[] = |
139
|
133 { |
1855
|
134 { "debug", prog_args::no_arg, 0, 'd' }, |
2277
|
135 { "braindead", prog_args::no_arg, 0, TRADITIONAL_OPTION }, |
1855
|
136 { "echo-commands", prog_args::no_arg, 0, 'x' }, |
|
137 { "exec-path", prog_args::required_arg, 0, EXEC_PATH_OPTION }, |
|
138 { "help", prog_args::no_arg, 0, 'h' }, |
|
139 { "info-file", prog_args::required_arg, 0, INFO_FILE_OPTION }, |
|
140 { "info-program", prog_args::required_arg, 0, INFO_PROG_OPTION }, |
|
141 { "interactive", prog_args::no_arg, 0, 'i' }, |
3180
|
142 { "no-history", prog_args::no_arg, 0, 'H' }, |
2239
|
143 { "no-init-file", prog_args::no_arg, 0, NO_INIT_FILE_OPTION }, |
1855
|
144 { "no-line-editing", prog_args::no_arg, 0, NO_LINE_EDITING_OPTION }, |
2239
|
145 { "no-site-file", prog_args::no_arg, 0, NO_SITE_FILE_OPTION }, |
1855
|
146 { "norc", prog_args::no_arg, 0, 'f' }, |
|
147 { "path", prog_args::required_arg, 0, 'p' }, |
|
148 { "quiet", prog_args::no_arg, 0, 'q' }, |
|
149 { "silent", prog_args::no_arg, 0, 'q' }, |
|
150 { "traditional", prog_args::no_arg, 0, TRADITIONAL_OPTION }, |
|
151 { "verbose", prog_args::no_arg, 0, 'V' }, |
|
152 { "version", prog_args::no_arg, 0, 'v' }, |
3019
|
153 { 0, 0, 0, 0 } |
139
|
154 }; |
1
|
155 |
1355
|
156 // Store the command-line options for later use. |
|
157 |
|
158 static void |
|
159 intern_argv (int argc, char **argv) |
|
160 { |
4233
|
161 bind_builtin_variable ("nargin", argc-1, 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 ()) |
4101
|
194 odb = Vdata_dir + file_ops::dir_sep_str + "octave:" |
|
195 + Vlibexec_dir + file_ops::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 |
4101
|
245 std::string home_rc = home_dir + file_ops::dir_sep_str + initfile; |
4100
|
246 std::string local_rc |
4101
|
247 = octave_env::getcwd () + file_ops::dir_sep_str + initfile; |
2239
|
248 |
2926
|
249 if (! home_dir.empty ()) |
2239
|
250 { |
2897
|
251 parse_and_execute (home_rc, verbose); |
2239
|
252 |
|
253 // Names alone are not enough. |
|
254 |
|
255 file_stat fs_home_rc (home_rc); |
|
256 |
|
257 if (fs_home_rc) |
|
258 { |
2512
|
259 file_stat fs_dot_rc (local_rc); |
2239
|
260 |
|
261 if (fs_dot_rc && fs_home_rc.ino () == fs_dot_rc.ino ()) |
|
262 home_rc_already_executed = 1; |
|
263 } |
|
264 } |
|
265 |
|
266 if (! home_rc_already_executed) |
2897
|
267 parse_and_execute (local_rc, verbose); |
2239
|
268 } |
315
|
269 |
2985
|
270 unwind_protect::run_frame ("execute_startup_files"); |
1
|
271 } |
|
272 |
581
|
273 // Usage message with extra help. |
|
274 |
1
|
275 static void |
|
276 verbose_usage (void) |
|
277 { |
3922
|
278 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_AND_WARRANTY "\n\ |
1613
|
279 \n\ |
|
280 Usage: octave [options]\n\ |
|
281 \n\ |
|
282 Options:\n\ |
1119
|
283 \n\ |
3180
|
284 --debug, -d Enter parser debugging mode.\n\ |
|
285 --echo-commands, -x Echo commands as they are executed.\n\ |
1613
|
286 --exec-path PATH Set path for executing subprograms.\n\ |
3180
|
287 --help, -h, -? Print short help message and exit.\n\ |
1613
|
288 --info-file FILE Use top-level info file FILE.\n\ |
|
289 --info-program PROGRAM Use PROGRAM for reading info files.\n\ |
3180
|
290 --interactive, -i Force interactive behavior.\n\ |
|
291 --no-history, -H Don't save commands to the history list\n\ |
2470
|
292 --no-init-file Don't read the ~/.octaverc or .octaverc files.\n\ |
2212
|
293 --no-line-editing Don't use readline for command-line editing.\n\ |
2470
|
294 --no-site-file Don't read the site-wide octaverc file.\n\ |
3238
|
295 --norc, -f Don't read any initialization files.\n\ |
3180
|
296 --path PATH, -p PATH Set initial LOADPATH to PATH.\n\ |
|
297 --silent, -q Don't print message at startup.\n\ |
1613
|
298 --traditional Set compatibility variables.\n\ |
3180
|
299 --verbose, -V Enable verbose output in some cases.\n\ |
|
300 --version, -v Print version number and exit.\n\ |
1119
|
301 \n\ |
1613
|
302 FILE Execute commands from FILE.\n\ |
2375
|
303 \n\ |
|
304 Additional information about Octave is available via the WWW at\n\ |
3917
|
305 http://www.octave.org.\n\ |
2375
|
306 \n\ |
3917
|
307 Please report bugs to the bug-octave@bevo.che.wisc.edu mailing list.\n"; |
285
|
308 |
613
|
309 exit (0); |
1
|
310 } |
|
311 |
581
|
312 // Terse usage messsage. |
|
313 |
1
|
314 static void |
|
315 usage (void) |
|
316 { |
3531
|
317 std::cerr << "usage: " << usage_string << "\n"; |
1
|
318 exit (1); |
|
319 } |
|
320 |
|
321 static void |
|
322 print_version_and_exit (void) |
|
323 { |
3922
|
324 std::cout << OCTAVE_NAME_VERSION_COPYRIGHT_COPYING_WARRANTY_AND_BUGS "\n"; |
1
|
325 exit (0); |
|
326 } |
|
327 |
721
|
328 static void |
|
329 initialize_error_handlers () |
|
330 { |
|
331 set_liboctave_error_handler (error); |
3325
|
332 set_liboctave_warning_handler (warning); |
721
|
333 } |
|
334 |
1410
|
335 // What happens on --traditional. |
|
336 |
|
337 static void |
|
338 maximum_braindamage (void) |
|
339 { |
|
340 bind_builtin_variable ("PS1", ">> "); |
|
341 bind_builtin_variable ("PS2", ""); |
2402
|
342 bind_builtin_variable ("beep_on_error", 1.0); |
3189
|
343 bind_builtin_variable ("crash_dumps_octave_core", 0.0); |
2993
|
344 bind_builtin_variable ("default_eval_print_flag", 0.0); |
3156
|
345 bind_builtin_variable ("default_global_variable_value", Matrix ()); |
1410
|
346 bind_builtin_variable ("default_save_format", "mat-binary"); |
2402
|
347 bind_builtin_variable ("define_all_return_values", 1.0); |
|
348 bind_builtin_variable ("do_fortran_indexing", 1.0); |
3105
|
349 bind_builtin_variable ("fixed_point_format", 1.0); |
3110
|
350 bind_builtin_variable ("implicit_num_to_str_ok", 1.0); |
2402
|
351 bind_builtin_variable ("implicit_str_to_num_ok", 1.0); |
3156
|
352 bind_builtin_variable ("initialize_global_variables", 1.0); |
2402
|
353 bind_builtin_variable ("ok_to_lose_imaginary_part", 1.0); |
|
354 bind_builtin_variable ("page_screen_output", 0.0); |
|
355 bind_builtin_variable ("prefer_column_vectors", 0.0); |
|
356 bind_builtin_variable ("print_empty_dimensions", 0.0); |
|
357 bind_builtin_variable ("treat_neg_dim_as_zero", 1.0); |
|
358 bind_builtin_variable ("warn_function_name_clash", 0.0); |
1410
|
359 bind_builtin_variable ("whitespace_in_literal_matrix", "traditional"); |
|
360 } |
|
361 |
581
|
362 // You guessed it. |
|
363 |
1
|
364 int |
4113
|
365 octave_main (int argc, char **argv) |
1
|
366 { |
3019
|
367 octave_env::set_program_name (argv[0]); |
|
368 |
3024
|
369 dir_path::set_program_name (argv[0]); |
|
370 |
2205
|
371 // The order of these calls is important. The call to |
2926
|
372 // install_defaults must come before install_builtins because |
3019
|
373 // default variable values must be available for the variables to be |
2205
|
374 // installed, and the call to install_builtins must come before the |
|
375 // options are processed because some command line options override |
|
376 // defaults by calling bind_builtin_variable. |
721
|
377 |
1
|
378 sysdep_init (); |
|
379 |
4159
|
380 // The idea here is to force xerbla to be referenced so that we will |
|
381 // link to our own version instead of the one provided by the BLAS |
|
382 // library. But octave_NaN should never be -1, so we should never |
|
383 // actually call xerbla. |
|
384 |
|
385 if (octave_NaN == -1) |
|
386 F77_FUNC (xerbla, XERBLA) ("octave", 13, 6L); |
|
387 |
721
|
388 initialize_error_handlers (); |
223
|
389 |
2926
|
390 install_defaults (); |
1
|
391 |
1792
|
392 initialize_pathsearch (); |
1744
|
393 |
2205
|
394 install_signal_handlers (); |
|
395 |
|
396 initialize_file_io (); |
|
397 |
2375
|
398 initialize_symbol_tables (); |
|
399 |
|
400 install_types (); |
|
401 |
|
402 install_ops (); |
2205
|
403 |
|
404 install_builtins (); |
|
405 |
1817
|
406 prog_args args (argc, argv, short_opts, long_opts); |
|
407 |
139
|
408 int optc; |
1817
|
409 while ((optc = args.getopt ()) != EOF) |
1
|
410 { |
139
|
411 switch (optc) |
1
|
412 { |
3180
|
413 case 'H': |
|
414 bind_builtin_variable ("saving_history", 0.0); |
|
415 break; |
|
416 |
793
|
417 case 'V': |
2239
|
418 verbose_flag = true; |
793
|
419 break; |
|
420 |
1
|
421 case 'd': |
|
422 yydebug++; |
|
423 break; |
777
|
424 |
1
|
425 case 'f': |
2239
|
426 read_init_files = false; |
|
427 read_site_files = false; |
1
|
428 break; |
777
|
429 |
1
|
430 case 'h': |
|
431 case '?': |
|
432 verbose_usage (); |
|
433 break; |
777
|
434 |
1
|
435 case 'i': |
3019
|
436 forced_interactive = true; |
1
|
437 break; |
777
|
438 |
1
|
439 case 'p': |
1817
|
440 if (args.optarg ()) |
2205
|
441 bind_builtin_variable ("LOADPATH", args.optarg ()); |
1
|
442 break; |
777
|
443 |
1
|
444 case 'q': |
2239
|
445 inhibit_startup_message = true; |
1
|
446 break; |
777
|
447 |
1
|
448 case 'x': |
2205
|
449 { |
|
450 double tmp = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_CMD_LINE); |
|
451 bind_builtin_variable ("echo_executing_commands", tmp); |
|
452 } |
1
|
453 break; |
777
|
454 |
1
|
455 case 'v': |
|
456 print_version_and_exit (); |
|
457 break; |
777
|
458 |
1613
|
459 case EXEC_PATH_OPTION: |
1817
|
460 if (args.optarg ()) |
2205
|
461 bind_builtin_variable ("EXEC_PATH", args.optarg ()); |
1613
|
462 break; |
|
463 |
186
|
464 case INFO_FILE_OPTION: |
1817
|
465 if (args.optarg ()) |
2205
|
466 bind_builtin_variable ("INFO_FILE", args.optarg ()); |
186
|
467 break; |
777
|
468 |
1613
|
469 case INFO_PROG_OPTION: |
1817
|
470 if (args.optarg ()) |
2205
|
471 bind_builtin_variable ("INFO_PROGRAM", args.optarg ()); |
1613
|
472 break; |
|
473 |
2239
|
474 case NO_INIT_FILE_OPTION: |
|
475 read_init_files = false; |
|
476 break; |
|
477 |
1821
|
478 case NO_LINE_EDITING_OPTION: |
3019
|
479 line_editing = false; |
2239
|
480 break; |
|
481 |
|
482 case NO_SITE_FILE_OPTION: |
|
483 read_site_files = 0; |
1821
|
484 break; |
|
485 |
1410
|
486 case TRADITIONAL_OPTION: |
2239
|
487 traditional = true; |
1410
|
488 break; |
|
489 |
1
|
490 default: |
|
491 usage (); |
|
492 break; |
|
493 } |
|
494 } |
|
495 |
1651
|
496 #if defined (HAVE_ATEXIT) || defined (HAVE_ON_EXIT) |
2077
|
497 // Make sure we clean up when we exit. Also allow users to register |
|
498 // functions. If we don't have atexit or on_exit, we're going to |
|
499 // leave some junk files around if we exit abnormally. |
|
500 |
|
501 atexit (do_octave_atexit); |
318
|
502 #endif |
1
|
503 |
1358
|
504 // These can come after command line args since none of them set any |
|
505 // defaults that might be changed by command line options. |
581
|
506 |
2926
|
507 initialize_command_input (); |
315
|
508 |
578
|
509 if (! inhibit_startup_message) |
3538
|
510 std::cout << OCTAVE_STARTUP_MESSAGE "\n" << std::endl; |
578
|
511 |
1410
|
512 if (traditional) |
|
513 maximum_braindamage (); |
|
514 |
4217
|
515 octave_interpreter_ready = true; |
|
516 |
|
517 execute_default_pkg_add_files (); |
|
518 |
2239
|
519 execute_startup_files (); |
1651
|
520 |
2926
|
521 command_history::read (false); |
1
|
522 |
578
|
523 if (! inhibit_startup_message && reading_startup_message_printed) |
3538
|
524 std::cout << std::endl; |
578
|
525 |
1358
|
526 // Avoid counting commands executed from startup files. |
|
527 |
2926
|
528 command_editor::reset_current_command_number (1); |
1
|
529 |
1358
|
530 // If there is an extra argument, see if it names a file to read. |
|
531 // Additional arguments are taken as command line options for the |
|
532 // script. |
1
|
533 |
1817
|
534 int last_arg_idx = args.optind (); |
3019
|
535 |
1817
|
536 int remaining_args = argc - last_arg_idx; |
3019
|
537 |
1355
|
538 if (remaining_args > 0) |
149
|
539 { |
3019
|
540 reading_script_file = true; |
|
541 |
1817
|
542 curr_fcn_file_name = argv[last_arg_idx]; |
1608
|
543 curr_fcn_file_full_name = curr_fcn_file_name; |
1411
|
544 |
984
|
545 FILE *infile = get_input_from_file (curr_fcn_file_name); |
1411
|
546 |
529
|
547 if (infile) |
287
|
548 { |
3019
|
549 input_from_command_line_file = true; |
1516
|
550 |
1411
|
551 bind_builtin_variable ("program_invocation_name", |
|
552 curr_fcn_file_name); |
|
553 |
4101
|
554 size_t pos |
|
555 = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars); |
1755
|
556 |
3523
|
557 std::string tmp = (pos != NPOS) |
1755
|
558 ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; |
1411
|
559 |
|
560 bind_builtin_variable ("program_name", tmp); |
|
561 |
1817
|
562 intern_argv (remaining_args, argv+last_arg_idx); |
1411
|
563 |
2926
|
564 command_editor::blink_matching_paren (false); |
|
565 |
287
|
566 switch_to_buffer (create_buffer (infile)); |
|
567 } |
529
|
568 else |
|
569 clean_up_and_exit (1); |
1
|
570 } |
|
571 else |
|
572 { |
1355
|
573 // Is input coming from a terminal? If so, we are probably |
|
574 // interactive. |
1
|
575 |
|
576 interactive = (isatty (fileno (stdin)) && isatty (fileno (stdout))); |
1355
|
577 |
|
578 intern_argv (argc, argv); |
|
579 |
|
580 switch_to_buffer (create_buffer (get_input_from_stdin ())); |
1
|
581 } |
|
582 |
1358
|
583 // Force input to be echoed if not really interactive, but the user |
|
584 // has forced interactive behavior. |
1
|
585 |
1907
|
586 if (! interactive && forced_interactive) |
287
|
587 { |
2926
|
588 command_editor::blink_matching_paren (false); |
1588
|
589 |
|
590 // XXX FIXME XXX -- is this the right thing to do? |
|
591 |
4233
|
592 bind_builtin_variable ("echo_executing_commands", ECHO_CMD_LINE); |
287
|
593 } |
1
|
594 |
1410
|
595 if (! interactive) |
3019
|
596 line_editing = false; |
1
|
597 |
1907
|
598 int retval = main_loop (); |
1
|
599 |
1005
|
600 if (retval == 1 && ! error_state) |
|
601 retval = 0; |
|
602 |
1
|
603 clean_up_and_exit (retval); |
4247
|
604 |
|
605 return 0; |
1
|
606 } |
|
607 |
560
|
608 /* |
1
|
609 ;;; Local Variables: *** |
|
610 ;;; mode: C++ *** |
|
611 ;;; End: *** |
|
612 */ |