From 304ba4dedc937b9138112fa9c03dc516bae09211 Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Thu, 20 May 2021 14:35:29 +0200 Subject: [PATCH] Add bash/csh for external scripts on linux. --- .../ProcessControl/RimProcess.cpp | 29 ++++++++++++------- .../ProcessControl/RimProcess.h | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp index df5851ce0b..d5f6e93dd6 100644 --- a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp @@ -164,14 +164,24 @@ bool RimProcess::execute() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimProcess::needsCommandInterpreter() const +QString RimProcess::optionalCommandInterpreter() const { -#ifdef WIN32 - if ( m_command.value().isNull() ) return false; - return m_command.value().endsWith( ".cmd", Qt::CaseInsensitive ) || - m_command.value().endsWith( ".bat", Qt::CaseInsensitive ); -#endif - return false; + if ( m_command.value().isNull() ) return ""; + + if ( m_command.value().endsWith( ".cmd", Qt::CaseInsensitive ) || + m_command.value().endsWith( ".bat", Qt::CaseInsensitive ) ) + { + return "cmd.exe /c "; + } + if ( m_command.value().endsWith( ".sh", Qt::CaseInsensitive ) ) + { + return "bash "; + } + if ( m_command.value().endsWith( ".csh", Qt::CaseInsensitive ) ) + { + return "csh "; + } + return ""; } //-------------------------------------------------------------------------------------------------- @@ -181,10 +191,7 @@ QString RimProcess::commandLine() const { QString cmdline; - if ( needsCommandInterpreter() ) - { - cmdline += "cmd.exe /c "; - } + cmdline += optionalCommandInterpreter(); cmdline += handleSpaces( m_command ); diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.h b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.h index 5156d9cc02..7257d8480c 100644 --- a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.h +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.h @@ -51,7 +51,7 @@ protected: caf::PdmFieldHandle* userDescriptionField() override; private: - bool needsCommandInterpreter() const; + QString optionalCommandInterpreter() const; QString handleSpaces( QString argument ) const; caf::PdmField m_command;