Skip to content

Commit 245ad5e

Browse files
committed
run.sh: Update SteamLaunch check with a more futureproof check
1 parent 730400c commit 245ad5e

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

assets/nix/run.sh

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,38 @@ corlib_dir=""
6363

6464
# Special case: program is launched via Steam
6565
# In that case rerun the script via their bootstrapper to ensure Steam overlay works
66-
if [ "$2" = "SteamLaunch" ]; then
67-
steam="$1 $2 $3 $4 $0 $5"
68-
shift 5
69-
$steam "$@"
70-
exit
71-
fi
66+
steam_arg_helper() {
67+
if [ "$executable_name" != "" ] && [ "$1" != "${1%"$executable_name"}" ]; then
68+
return 0
69+
elif [ "$executable_name" = "" ] && [ "$1" != "${1%.x86_64}" ]; then
70+
return 0
71+
elif [ "$executable_name" = "" ] && [ "$1" != "${1%.x86}" ]; then
72+
return 0
73+
else
74+
return 1
75+
fi
76+
}
77+
for a in "$@"; do
78+
if [ "$a" = "SteamLaunch" ]; then
79+
rotated=0; max=$#
80+
while [ $rotated -lt $max ]; do
81+
if steam_arg_helper "$1"; then
82+
to_rotate=$(($# - rotated))
83+
set -- "$@" "$0"
84+
while [ $((to_rotate-=1)) -ge 0 ]; do
85+
set -- "$@" "$1"
86+
shift
87+
done
88+
exec "$@"
89+
else
90+
set -- "$@" "$1"
91+
shift
92+
rotated=$((rotated+1))
93+
fi
94+
done
95+
exit 1
96+
fi
97+
done
7298

7399
# Handle first param being executable name
74100
if [ -x "$1" ] ; then

0 commit comments

Comments
 (0)