help-octave
[Top][All Lists]
Advanced

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

system() implementation is somehow broken


From: John W. Eaton
Subject: system() implementation is somehow broken
Date: Wed, 20 Oct 2010 18:02:12 -0400

On 20-Oct-2010, Dr. Johannes Zellner wrote:

| I struggled accross the fact that console vim can't be used as editor.
| Apparently, this is due to the fact, that edit() uses system() and system() 
redirect stdout "sometimes".
| 
| The code in edit() which fails is
| system (sprintf (FUNCTION.EDITOR, strcat ("\"", path, "\"")), [], 
FUNCTION.MODE);
| 
| Here's what I observe:
| 
| system('vim tmp.txt') % -- works
| 
| all of the following do NOT work and give the message: "Vim: Warning: Output 
is not to a terminal"
| 
| system('vim tmp.txt', [])
| system('vim tmp.txt', [], 'sync')
| system('vim tmp.txt', 'sync')

The doc string for system could probably use some work, but it does
say

 -- Built-in Function:  system (STRING, RETURN_OUTPUT, TYPE)
     ...

     If two input arguments are given (the actual value of
     RETURN_OUTPUT is irrelevant) and the subprocess is started
     synchronously, or if SYSTEM is called with one input argument and
     one or more output arguments, the output from the command is
     returned.  Otherwise, if the subprocess is executed synchronously,
     its output is sent to the standard output.

You are giving it the RETURN_OUTPUT argument, so it is capturing the
output from the process and returning it.  So I think it is doing
exactly what it is documented to do.

FWIW, I don't see a problem with

  edit editor "emacs -nw"
  edit tmp.txt

so maybe the problem is with design of vim?

| so if more than one argument is supplied to system(), stdout seems to be 
redirected (even if it is not used).

I don't see how the system function could possibly determine whether
or not the subprocess will actually write to stdout.

| This is a bug in the system() implementation IMHO.

It looks more like the documented behavior of the system function to
me.

If there is a bug in Octave, I guess it might be in the way the edit
function is calling system.  If you think there's a bug, then the
right place to report it is in the bug tracker:

  https://savannah.gnu.org/bugs/?func=additem&group=octave

jwe


reply via email to

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