Add Non-Steam Game: Fix StartDir when using GUI #942
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a problem found when investigating for #941.
Problem
When adding Non-Steam games from the GUI, we still pass
-sd
even though it's blank, meaning:${i#*=}
is always empty (``)NOSTEXEPATH
to""
(which the blank$QEP
variable wrapped in quotes)-z "${NOSTEXEDIR}"
will always fail, because it's set to""
(a set of empty quotes).When adding games from the commandline, this works because under normal circumstances,
-sd|--start-dir
is not passed. However, if a user passed--start-dir=""
, then the problem would be the same as above on the GUI.This means when adding Non-Steam games from the GUI, we end up always writing out
""
as the StartDir if the user didn't specify one, whereas we should have been writing out the directory of the EXE. For example,/home/gaben/Games/Sandtrix/sandtrix.exe
should have set the StartDir as/home/gaben/Games/Sandtrix
, but it isn't - It's using""
.The problem with this is that some games expect to have their working/launch directory be the same as the directory that the EXE is inside of. If StartDir is not set properly, Steam cannot
chdir
into the directory, and although the game will still launch it will not be using the EXE dir that the game might expect.Steam's default behaviour is also to use the EXE directory as StartDir when adding Non-Steam games from the client, so we should be following this behaviour regardless (although we were meant to be doing this in the first place, this is a fix for existing functionality).
Solution
The solution is to check to make sure
--start-dir
is actually defined and actually a directory, before setting it as the StartDir to use. This sanity check makes sure we don't write out invalid path values when adding the Non-Steam Game.Because of this check, we will also now correctly write out the default value for StartDir, it resolves the issue. Now we match the Steam default behaviour.
Tested this and it should work, so we should be good to merge right away.