help-octave
[Top][All Lists]
Advanced

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

Re: octave and shell commands


From: John W. Eaton
Subject: Re: octave and shell commands
Date: Wed, 20 Apr 2005 20:45:29 -0400

On 20-Apr-2005, Paul Kienzle <address@hidden> wrote:

| Here's a hack:
| 
|    function s(varargin),
|       b=varargin;
|       b{2,:}='" "';
|       system(['"',b{:},'"']);
|    end
|    octave> mark_as_command s
|    octave> s sh -c "echo hello"
|    hello
| 
| It will work better with new octave and mark_as_command.

I think you meant mark_as_rawcommand.

How about the following change?  Would this cause any trouble?  Then
you could write

  function $ (varargin)
    system (sprintf ("%s ", varargin{:}));
  endfunction
  mark_as_rawcommand

and have $ work as a shell escape character (as you suggested
recently).  Everything after the $ up to the following newline
character would be passed verbatim to the shell.

I suspect that it is too late to consider changing the meaning of ! to
work in a compatible way.

jwe


src/ChangeLog:

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

        * lex.l (IDENT): Allow $ in identifiers.
        * utils.cc (valid_identifier): Likewise.


Index: src/lex.l
===================================================================
RCS file: /cvs/octave/src/lex.l,v
retrieving revision 1.223
diff -u -r1.223 lex.l
--- src/lex.l   12 Apr 2005 21:55:31 -0000      1.223
+++ src/lex.l   21 Apr 2005 00:36:49 -0000
@@ -286,7 +286,7 @@
 NOT    ((\~)|(\!))
 POW     ((\*\*)|(\^))
 EPOW    (\.{POW})
-IDENT  ([_a-zA-Z][_a-zA-Z0-9]*)
+IDENT  ([_$a-zA-Z][_$a-zA-Z0-9]*)
 EXPON  ([DdEe][+-]?{D}+)
 NUMBER (({D}+\.?{D}*{EXPON}?)|(\.{D}+{EXPON}?)|(0[xX][0-9a-fA-F]+))
 %%
Index: src/utils.cc
===================================================================
RCS file: /cvs/octave/src/utils.cc,v
retrieving revision 1.174
diff -u -r1.174 utils.cc
--- src/utils.cc        8 Apr 2005 16:07:37 -0000       1.174
+++ src/utils.cc        21 Apr 2005 00:36:49 -0000
@@ -83,11 +83,11 @@
 bool
 valid_identifier (const char *s)
 {
-  if (! s || ! (isalpha (*s) || *s == '_'))
+  if (! s || ! (isalpha (*s) || *s == '_' || *s == '$'))
      return false;
 
   while (*++s != '\0')
-    if (! (isalnum (*s) || *s == '_'))
+    if (! (isalnum (*s) || *s == '_' || *s == '$'))
       return false;
 
   return true;



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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