comparison libinterp/corefcn/interpreter.cc @ 22184:a032ffb80704

don't print startup message for --eval (bug #48620) * interpreter.cc (interpreter::interpreter): Don't attempt to modify command line options. (interpreter::execute): Avoid printing startup message if session is not interactive.
author John W. Eaton <jwe@octave.org>
date Tue, 26 Jul 2016 09:49:56 -0400
parents 8de49f15e182
children dc20b737ee79
comparison
equal deleted inserted replaced
22183:bfb1b089c230 22184:a032ffb80704
614 m_interactive = (! m_embedded 614 m_interactive = (! m_embedded
615 && ! m_app_context->is_octave_program () 615 && ! m_app_context->is_octave_program ()
616 && stdin_is_tty 616 && stdin_is_tty
617 && octave_isatty_wrapper (fileno (stdout))); 617 && octave_isatty_wrapper (fileno (stdout)));
618 618
619 // Check if the user forced an interactive session. If he 619 // Check if the user forced an interactive session.
620 // unnecessarily did so, reset forced_interactive to false.
621 if (options.forced_interactive ()) 620 if (options.forced_interactive ())
622 { 621 m_interactive = true;
623 if (m_interactive) 622
624 options.forced_interactive (false); 623 bool line_editing = options.line_editing ();
625 else
626 m_interactive = true;
627 }
628
629 if ((! m_interactive || options.forced_interactive ()) 624 if ((! m_interactive || options.forced_interactive ())
630 && ! options.forced_line_editing ()) 625 && ! options.forced_line_editing ())
631 options.line_editing (false); 626 line_editing = false;
632
633 // Also skip start-up message unless session is interactive.
634 if (! m_interactive)
635 options.inhibit_startup_message (true);
636 627
637 // Force default line editor if we don't want readline editing. 628 // Force default line editor if we don't want readline editing.
638 if (! options.line_editing ()) 629 if (line_editing)
639 octave::command_editor::force_default_editor (); 630 octave::command_editor::force_default_editor ();
640 631
641 // These can come after command line args since none of them set any 632 // These can come after command line args since none of them set any
642 // defaults that might be changed by command line options. 633 // defaults that might be changed by command line options.
643 634
644 if (options.line_editing ()) 635 if (line_editing )
645 initialize_command_input (); 636 initialize_command_input ();
646 637
647 octave_interpreter_ready = true; 638 octave_interpreter_ready = true;
648 639
649 initialize_version_info (); 640 initialize_version_info ();
660 651
661 int interpreter::execute (void) 652 int interpreter::execute (void)
662 { 653 {
663 cmdline_options options = m_app_context->options (); 654 cmdline_options options = m_app_context->options ();
664 655
665 if (! options.inhibit_startup_message ()) 656 if (m_interactive && ! options.inhibit_startup_message ())
666 std::cout << octave_startup_message () << "\n" << std::endl; 657 std::cout << octave_startup_message () << "\n" << std::endl;
667 658
668 octave_prepare_hdf5 (); 659 octave_prepare_hdf5 ();
669 660
670 execute_startup_files (options.read_site_files (), 661 execute_startup_files (options.read_site_files (),
671 options.read_init_files (), 662 options.read_init_files (),
672 options.verbose_flag (), 663 options.verbose_flag (),
673 options.inhibit_startup_message ()); 664 options.inhibit_startup_message ());
674 665
675 if (! options.inhibit_startup_message () 666 if (m_interactive && ! options.inhibit_startup_message ()
676 && reading_startup_message_printed) 667 && reading_startup_message_printed)
677 std::cout << std::endl; 668 std::cout << std::endl;
678 669
679 // Execute any code specified with --eval 'CODE' 670 // Execute any code specified with --eval 'CODE'
680 std::string code_to_eval = options.code_to_eval (); 671 std::string code_to_eval = options.code_to_eval ();