[bug #68006] 'system' command unable to redirect stderr or stdout to "nul"

Markus Mützel <[email protected]>
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
Please use the bug tracker to post updates to a bug report.  The mailing list is intended as a read-only notification stream.  Info posted to this mailing list address won't appear in the tracker database where it is most useful.

Follow-up Comment #3, bug #68006 (group octave):

That wasn't meant as a recommendation for a work-around. It was meant as an
observation to help track down the issue.

The following change fixes the behavior for me:

diff --git a/liboctave/system/oct-sysdep.cc b/liboctave/system/oct-sysdep.cc
--- a/liboctave/system/oct-sysdep.cc
+++ b/liboctave/system/oct-sysdep.cc
@@ -82,8 +82,9 @@ system (const std::string& cmd_str)
   // avoid inheriting read end of the pipe
   SetHandleInformation (h_read, HANDLE_FLAG_INHERIT, 0);
 
-  // Create process with new console.
-  std::wstring wcmd_str =  u8_to_wstring (cmd_str);
+  // create process with new hidden console
+  std::wstring wcmd_str {L"cmd.exe /C "};
+  wcmd_str.append (u8_to_wstring (cmd_str));
   STARTUPINFOW si {};
   si.cb = sizeof (si);
   si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;


Essentially, this passes the command to the CMD shell which parses redirects
like `2> nul`.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68006>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaYNYYgAKCRCqLAuaBUf3
TqAdAPoCOuCRHGUNI6taoPhMVXbRAATJs0j8cy9odef5b8nURwEA50B18UOLGUp6
9crNw3/qJ/JFa46iJC/kPx1Bye5Flgo=
=6kll
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.