Add bash/csh for external scripts on linux.

This commit is contained in:
jonjenssen 2021-05-20 14:35:29 +02:00 committed by jonjenssen
parent 9c74e58510
commit 304ba4dedc
2 changed files with 19 additions and 12 deletions

View File

@ -164,14 +164,24 @@ bool RimProcess::execute()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimProcess::needsCommandInterpreter() const QString RimProcess::optionalCommandInterpreter() const
{ {
#ifdef WIN32 if ( m_command.value().isNull() ) return "";
if ( m_command.value().isNull() ) return false;
return m_command.value().endsWith( ".cmd", Qt::CaseInsensitive ) || if ( m_command.value().endsWith( ".cmd", Qt::CaseInsensitive ) ||
m_command.value().endsWith( ".bat", Qt::CaseInsensitive ); m_command.value().endsWith( ".bat", Qt::CaseInsensitive ) )
#endif {
return false; 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; QString cmdline;
if ( needsCommandInterpreter() ) cmdline += optionalCommandInterpreter();
{
cmdline += "cmd.exe /c ";
}
cmdline += handleSpaces( m_command ); cmdline += handleSpaces( m_command );

View File

@ -51,7 +51,7 @@ protected:
caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* userDescriptionField() override;
private: private:
bool needsCommandInterpreter() const; QString optionalCommandInterpreter() const;
QString handleSpaces( QString argument ) const; QString handleSpaces( QString argument ) const;
caf::PdmField<QString> m_command; caf::PdmField<QString> m_command;