help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

When is 'argv' initialized?


From: John W. Eaton
Subject: When is 'argv' initialized?
Date: Wed, 10 Sep 2008 12:43:23 -0400

On 10-Sep-2008, "Peter L." Søndergaard wrote:

| inspired by the recent discussion on calling "octave -q", I wanted to
| supress the starting banner from the ltfat-toolbox, when octave is
| called with --silent or -q. Code like this should work
| 
| args=argv;
| for ii=1:numel(args)
|   s=lower(args{ii});
|   if strcmp(s,'--silent') || strcmp(s,'-q')
|     printbanner=0;
|   end;
| end;
| 
| if printbanner
|   ... print the banner
| end;
| 
| The problem is that it does not work if the code is invoked from a
| startup script (called from ~/.octaverc) because then
| 
| argv = {}(0x0)
| 
| If the code is called later then argv is properly initialized.
| 
| Is this a bug or a feature, or just something that is too complicated to
| mess with?

See the intern_argv function in octave.cc, and the way it is used in
the octave_main function.

Maybe the following patch will solve the problem for you?

It's best to report bugs on the address@hidden list.

Thanks,

jwe

# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1221064684 14400
# Node ID e0a6e54f5a19b43362dbd09dc0e8b904dc71853e
# Parent  229bd50e6e8fc52e48bcdace9c1f0d59f6b50c23
octave.cc (octave_main): make all command-line arguments available to startup 
scripts

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-10  John W. Eaton  <address@hidden>
+
+       * octave.cc (octave_main): Make all command-line arguments
+       available to startup scripts and PKG_ADD files.
+
 2008-09-09  David Bateman  <address@hidden>
 
        * DLD-FUNCTIONS/regexp.cc (octregexp_list): Distinguish between
diff --git a/src/octave.cc b/src/octave.cc
--- a/src/octave.cc
+++ b/src/octave.cc
@@ -767,6 +767,11 @@
 
   initialize_version_info ();
 
+  // Make all command-line arguments available to startup files,
+  // including PKG_ADD files.
+
+  intern_argv (argc, argv);
+
   load_path::initialize (set_initial_path);
 
   execute_startup_files ();
@@ -795,10 +800,6 @@
 
   if (! code_to_eval.empty ())
     {
-      // We probably want all the args for an --eval option.
-
-      intern_argv (argc, argv);
-
       int parse_status = execute_eval_option_code (code_to_eval);
 
       if (! (persist || remaining_args > 0))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]