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