bugGNU Octave - Bugs: bug #47239, calling system without shell

 
 

bug #47239: calling system without shell

Submitter:  Carnë Draug <carandraug>
Submitted:  Tue 23 Feb 2016 07:10:44 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Feature Request
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 27 Mar 2016 03:15:14 AM UTC, comment #4: 


> At least for Linux, this looks pretty easy.


Yes, I made a trivial test patch that worked on Linux.

However, for Windows it was not so simple. As far as I could find, there was no way to do it. All the documentation I found recommended use of CreateProcess https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx to handle this. But this function does not accept a list of arguments. We would end up having to concatenate the arguments, which would require we escape characters, which does not solve the original problem --- not having to escape things which is business trickier than it looks like.

My notes point to https://stackoverflow.com/questions/4243880/substitute-for-forking-in-windows

Carnë Draug <carandraug>
Group Member
Sun 27 Mar 2016 01:03:45 AM UTC, comment #3: 

At least for Linux, this looks pretty easy.  The system function is in toplev.cc and it does a fork followed by execl.  If a cell array is present it could copy the arguments to a buffer and then call execv and it should work just fine.

Rik <rik5>
Group administrator
Tue 01 Mar 2016 08:08:35 AM UTC, comment #2: 

It might be better to do this with a separate function to avoid potential compatibility issues.

John W. Eaton <jwe>
Group administrator
Mon 29 Feb 2016 11:49:31 PM UTC, comment #1: 

Any extension would need to preserve compatibility with Matlab (http://www.mathworks.com/help/matlab/ref/system.html).  It seems that this would be possibly because Matlab expects a string as the first argument.  You could check for a cell array of strings and if that is found run the other style of 'system' call.

Rik <rik5>
Group administrator
Tue 23 Feb 2016 07:10:44 PM UTC, original submission:  

Would be nice to call system without having to worry about the shell. This is mainly for security reasons but makes it easier not have to worry about escaping arguments (when a regular expression is an argument it becomes very tricky).

Perl accepts a list for this, and python's functions from the subprocess module have a Shell=False option.

I would propose that if system is called with a cell array of strings, the first element is the program and the rest of elements are its arguments.

Just noting down this feature request on which I would like to work on one day.

Carnë Draug <carandraug>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by carandraug (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code