@@ -122,18 +122,22 @@ class RunConfiguration(project: Project, factory: ConfigurationFactory, name: St
122122 private fun getRimworldState (environment : ExecutionEnvironment , debugInLinux : Boolean = false): CommandLineState {
123123 return object : CommandLineState (environment) {
124124 override fun startProcess (): ProcessHandler {
125- var pathToRun = getScriptName()
126- var arguments = getCommandLineOptions()
125+ val rimworldPath = getScriptName()
126+ var pathToRun = rimworldPath
127+ // Splitting on space will be a source of future bugs. In the future the arguments should be List as early as possible
128+ val arguments = getCommandLineOptions().split(' ' ).filter { it.isNotEmpty() }.toMutableList()
127129
128130 // If we're debugging in Rimworld, instead of /pwd/RimWorldLinux ...args we want to run /bin/sh /pwd/run.sh /pwd/RimWorldLinux ...args
129131 if (debugInLinux) {
130- val bashScriptPath = " ${Path (pathToRun).parent} /run.sh"
131- arguments = " $bashScriptPath $pathToRun $arguments "
132132 pathToRun = " /bin/sh"
133+ val bashScriptPath = " ${Path (rimworldPath).parent} /run.sh"
134+ arguments.add(0 , bashScriptPath)
133135 }
134136
137+ println (" Calling $pathToRun with arguments ${arguments.joinToString(" " )} with working directory ${Path (rimworldPath).parent} " )
135138 val commandLine = GeneralCommandLine (pathToRun)
136- .withParameters(arguments.split(' ' ).filter { it.isNotEmpty() })
139+ .withParameters(arguments)
140+ .withWorkingDirectory(Path (rimworldPath).parent)
137141
138142 EnvironmentVariablesData .create(getEnvData(), true ).configureCommandLine(commandLine, true )
139143
0 commit comments