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