X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd6ce4a90c11b54cc00799d0e4611d858739a749..d76bb2182d43ad5f4c87bdc29d7871b7ea5dd685:/src/unix/utilsunx.cpp diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index d8925aba2b..fb8c58bc90 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -205,15 +205,37 @@ long wxExecute( const wxString& command, bool sync, wxProcess *process ) return lRc; } -bool wxShell(const wxString& command) +// ---------------------------------------------------------------------------- +// wxShell +// ---------------------------------------------------------------------------- + +static wxString wxMakeShellCommand(const wxString& command) { wxString cmd; if ( !command ) + { + // just an interactive shell cmd = _T("xterm"); + } else - cmd = command; + { + // execute command in a shell + cmd << _T("/bin/sh -c '") << command << _T('\''); + } + + return cmd; +} + +bool wxShell(const wxString& command) +{ + return wxExecute(wxMakeShellCommand(command), TRUE /* sync */) == 0; +} + +bool wxShell(const wxString& command, wxArrayString& output) +{ + wxCHECK_MSG( !!command, FALSE, _T("can't exec shell non interactively") ); - return wxExecute(cmd) != 0; + return wxExecute(wxMakeShellCommand(command), output); } #if wxUSE_GUI