octave-maintainers
[Top][All Lists]
Advanced

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

Re: retaining interpreter when running script from command line


From: John W. Eaton
Subject: Re: retaining interpreter when running script from command line
Date: Fri, 4 Mar 2005 09:24:43 -0500

On  4-Mar-2005, Andy Adler <address@hidden> wrote:

| On Thu, 3 Mar 2005, John W. Eaton wrote:
| 
| > Finally, should we also warn about using more than one --eval option?
| > Currently, only the last one will be evaluated and no warning will be
| > issued.
| 
| Perl will concatenate the strings (adding whitespace) before evaluation
|     $ perl -e'print 2+' -e'2'
|     4
| Could octave do this?

Sure, that is pretty simple.

| Would it make sense?

It has to be better than losing all but the last --eval argument...

With the following change, you can write things like

  octave --silent --eval "1" --eval "+" --eval "1"

which will cause Octave to evaluate "1 + 1".

jwe


src/ChangeLog:

2005-03-04  John W. Eaton  <address@hidden>

        * octave.cc (octave_main): Concatenate all --eval arguments.


Index: src/octave.cc
===================================================================
RCS file: /cvs/octave/src/octave.cc,v
retrieving revision 1.206
diff -u -r1.206 octave.cc
--- src/octave.cc       4 Mar 2005 03:00:35 -0000       1.206
+++ src/octave.cc       4 Mar 2005 14:09:11 -0000
@@ -538,7 +538,12 @@
 
        case EVAL_OPTION:
          if (args.optarg ())
-           code_to_eval = args.optarg ();
+           {
+             if (code_to_eval.empty ())
+               code_to_eval = args.optarg ();
+             else
+               code_to_eval += std::string (" ") + args.optarg ();
+           }
          break;
 
        case EXEC_PATH_OPTION:



reply via email to

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