Skip to content

Commit 569ab5f

Browse files
committed
backend/launcher: don't try to pass empty string as additional argument if falsy (empty, null, ...)
If the additional command line arguments are unset/set to an empty string, the sideload command launcher likewise used to pass an empty argument to the launched application. While that is usually harmless, some applications try to parse this argument and (rightfully) complain and usually exit with an error. Make sure that we only pass additional arguments if they are actually set, fixing that issue. This has been encountered with Palia's launcher. While at it, also fix a log line by including additional arguments and a typo in a comment.
1 parent dac5965 commit 569ab5f

File tree

1 file changed

+6
-6
lines changed
  • src/backend/storeManagers/storeManagerCommon

1 file changed

+6
-6
lines changed

src/backend/storeManagers/storeManagerCommon/games.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export async function launchGame(
123123

124124
const gameSettings = await getAppSettings(appName)
125125
const { launcherArgs } = gameSettings
126+
const extraArgs = shlex.split(launcherArgs ?? '')
126127

127128
if (executable) {
128129
const isNative = gameManagerMap[runner].isNative(appName)
@@ -160,15 +161,15 @@ export async function launchGame(
160161
// Native
161162
if (isNative) {
162163
logInfo(
163-
`launching native sideloaded game: ${executable} ${launcherArgs ?? ''}`,
164+
`launching native sideloaded game: ${executable} ${extraArgs.join(' ')}`,
164165
LogPrefix.Backend
165166
)
166167

167168
try {
168169
await access(executable, FS_CONSTANTS.X_OK)
169170
} catch (error) {
170171
logWarning(
171-
'File not executable, changing permissions temporarilly',
172+
'File not executable, changing permissions temporarily',
172173
LogPrefix.Backend
173174
)
174175
// On Mac, it gives an error when changing the permissions of the file inside the app bundle. But we need it for other executables like scripts.
@@ -177,15 +178,14 @@ export async function launchGame(
177178
}
178179
}
179180

180-
const commandParts = shlex.split(launcherArgs ?? '')
181181
const env = {
182182
...process.env,
183183
...setupWrapperEnvVars({ appName, appRunner: runner }),
184184
...setupEnvVars(gameSettings)
185185
}
186186

187187
await callRunner(
188-
commandParts,
188+
extraArgs,
189189
{
190190
name: runner,
191191
logPrefix: LogPrefix.Backend,
@@ -210,12 +210,12 @@ export async function launchGame(
210210
}
211211

212212
logInfo(
213-
`launching non-native sideloaded: ${executable}}`,
213+
`launching non-native sideloaded: ${executable} ${extraArgs.join(' ')}`,
214214
LogPrefix.Backend
215215
)
216216

217217
await runWineCommand({
218-
commandParts: [executable, launcherArgs ?? ''],
218+
commandParts: [executable, ...extraArgs],
219219
gameSettings,
220220
wait: false,
221221
startFolder: dirname(executable),

0 commit comments

Comments
 (0)