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