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