changeset 19884:f81a1da191e4

Script file or eval code are not interactive session so keep Octave quiet. * libinterp/octave.cc: add a new static variable an_octave_program to keep track when this is called for an Octave program and not for an Octave interactive session. The main point of this patch is so that octave_startup_message() on octave_execute_interpreter() is not called. A continuation work from csets 6ba5f1ff041e and f3ac54ac2c6a which also aimed at doing this. The idea is to have an_octave_program inherit other features of a non-interactive session (such as being canceled by forcing an interactive session or not starting readline).
author Carnë Draug <carandraug@octave.org>
date Tue, 24 Feb 2015 19:47:22 +0000
parents 1c9ed5b4c73d
children 059a05bc398c
files libinterp/octave.cc
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave.cc	Tue Feb 24 17:09:42 2015 +0000
+++ b/libinterp/octave.cc	Tue Feb 24 19:47:22 2015 +0000
@@ -172,6 +172,11 @@
 // (--traditional)
 static bool traditional = false;
 
+// TRUE if this is a program and no interpreter and interaction is
+// needed.  For example, an octave program with shebang line, or code
+// from eval without persist.
+static bool an_octave_program = false;
+
 // Store the command-line options for later use.
 
 static void
@@ -703,13 +708,14 @@
     }
 
   bool script_file = (argc - optind) > 0;
-
   if (! code_to_eval.empty () && script_file)
     {
       error ("--eval \"CODE\" and script file are mutually exclusive options");
 
       octave_print_terse_usage_and_exit ();
     }
+  an_octave_program = (script_file || ! code_to_eval.empty ()) && ! persist;
+
 }
 
 // EMBEDDED is declared int instead of bool because this function is
@@ -788,7 +794,7 @@
   // a redirected file.
   bool stdin_is_tty = gnulib::isatty (fileno (stdin));
 
-  interactive = (! embedded && stdin_is_tty
+  interactive = (! embedded && ! an_octave_program && stdin_is_tty
                  && gnulib::isatty (fileno (stdout)));
 
   // Check if the user forced an interactive session.  If he