Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Fix commands being interpreted as game launch if command included steamapps/common #1125

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
PREFIX="/usr"
PROGNAME="SteamTinkerLaunch"
NICEPROGNAME="Steam Tinker Launch"
PROGVERS="v14.0.20240619-1"
PROGVERS="v14.0.20240621-1"
PROGCMD="${0##*/}"
PROGINTERNALPROTNAME="Proton-stl"
SHOSTL="stl"
Expand Down Expand Up @@ -26840,6 +26840,7 @@ function main {
writelog "INFO" "${FUNCNAME[0]} - No arguments provided. See '$PROGCMD --help' for possible command line parameters" "E"
else
writelog "INFO" "${FUNCNAME[0]} - Checking command line: incoming arguments '${*}'"
writelog "INFO" "${FUNCNAME[0]} - Checking command line: first argument '${1}'"

if [ -n "$SteamAppId" ] && [ "$SteamAppId" -eq "0" ]; then
if grep -q "\"$1\"" <<< "$(sed -n "/^#STARTCMDLINE/,/^#ENDCMDLINE/p;/^#ENDCMDLINE/q" "$0" | grep if)"; then
Expand All @@ -26856,9 +26857,24 @@ function main {
fi
fi
elif grep -q "$SAC" <<< "$@" || grep -q "$L2EA" <<< "$@"; then
# We check if incoming commands contain 'steamapps/common' to interpret them as game launch commands
# But if $1 is a known command in this list, explicitly pass it to 'commandline' as we know it is NOT a game command
# This prevents commands which contain 'steamapps/common' ANYWHERE in their command (including as paths as parameters to other flags) from being interpreted as a game launch
#
# If $1 is a known steamtinkerlaunch command (with 'steamtinkerlaunch otr', $1 would be 'otr') then intervene and force this to the 'commandline' function as it is a known steamtinkerlaunch command
STLINCOMINGSKIPCOMMANDS="otr|onetimerun"

if grep -q "update" <<< "$@" || grep -q "^play" <<< "$@" ; then
commandline "$@"
# HACK: Since we check for steamapps/common ($SAC), commands which contain this (such as a one-time run path) will incorrectly get triggered as a game launch
# As a workaround, skip interpreting a hardcoded set of commands as start parameters and pass directly to commandline (i.e. if we have 'otr' as our first option, pass down to commandline function and run otr)
#
# We also check to make sure the first argument doesn't contain any slashes (i.e. game start commands' first argument could be a path, so it would contain a slash)
# This allows us to distinguish between '/home/otr' which could be a game launch command, and the 'steamtinkerlaunch otr' command (where $1 is 'otr')
elif grep -qwE "${STLINCOMINGSKIPCOMMANDS}" <<< "${1}" && [[ "${1}" != *"/"* ]]; then
commandline "$@"
else
# If we get here, this should be an actual game start command!
setGameVars "$@"
if [ "$ISGAME" -eq 2 ] || [ "$ISGAME" -eq 3 ]; then
prepareLaunch
Expand Down