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