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