-
Notifications
You must be signed in to change notification settings - Fork 209
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
Support spaces in arguments (eg spaces in file path) #1154
base: master
Are you sure you want to change the base?
Conversation
It was so very much ago when I made this script, haha! Can't believe someone actually tagged me. I should contribute more lately... sorry guys. well, that social experiment is complete! (please don't tag me anymore lol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change seems good on paper, but I'm not familiar enough with all the different quirks & considerations one would have to think of to properly review shell script changes, especially for the syntax being used here.
How confident are you that this should run on any system the script has previously been working on?
Happy to merge this once I have more confidence it actually does what it appears to be doing, I'm assuming you've tested this at least on your system?
I have tested this on my system and it works with spaces in game path and profile name. |
For completeness sake; I tested on linux native Valheim installed at the windows default path (because of shared drive) which includes The `start_server_bepinex.sh` has the same issue of not working with spaces so I updated it with the same bash array stuff I did in this PR:Note that this script does not update every time you restart r2modman unlike the script this PR fixes, so it's not that bothersome to patch. #!/bin/sh
# BepInEx running script
#
# HOW TO USE:
# 1. Make this script executable with `chmod u+x ./start_game_bepinex.sh`
# 2. In Steam, go to game's preferences and change game's launch args to:
# ./start_game_bepinex.sh %command%
# 3. Start the game via Steam
#
# Note that you won't get a console this way
#
# NOTE: Edit the script only if you know what you're doing!
# Resolve base directory relative to this script
# Hopefully this resolves relative paths and links
a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BASEDIR=$(cd "$a"; pwd -P)
# Special case: program is launched via Steam
# In that case rerun the script via their bootstrapper to ensure Steam overlay works
# if [ "$2" = "SteamLaunch" ]; then
# echo "start_game_bepinex.sh: SteamLaunch"
# cmd=( $1 $2 $3 $4 $0 )
# shift 4
# exec "${cmd[@]}" $@
# exit
# fi
exec="$BASEDIR/valheim.x86_64"
rest=()
export DOORSTOP_ENABLE=TRUE
export DOORSTOP_INVOKE_DLL_PATH="$BASEDIR/BepInEx/core/BepInEx.Preloader.dll"
export DOORSTOP_CORLIB_OVERRIDE_PATH="$BASEDIR/unstripped_corlib"
# Allow to specify --doorstop-enable true|false
# Everything else is passed as-is to `exec`
while :; do
case $1 in
--doorstop-enable)
if [ -n "$2" ]; then
export DOORSTOP_ENABLE=$(echo "$2" | tr a-z A-Z)
shift
else
echo "No --doorstop-enable value specified, using default!"
fi
;;
--doorstop-target)
if [ -n "$2" ]; then
export DOORSTOP_INVOKE_DLL_PATH="$2"
shift
else
echo "No --doorstop-target value specified, using default!"
fi
;;
--doorstop-dll-search-override)
if [ -n "$2" ]; then
export DOORSTOP_CORLIB_OVERRIDE_PATH="$2"
shift
else
echo "No --doorstop-dll-search-override value specified, using default!"
fi
;;
*)
if [ -z "$1" ]; then
break
fi
if [ -z "$launch" ]; then
launch="$1"
else
rest+=( "$1" )
fi
;;
esac
shift
done
export LD_LIBRARY_PATH="$BASEDIR/doorstop_libs:$LD_LIBRARY_PATH"
export LD_PRELOAD="libdoorstop_x64.so:$LD_PRELOAD"
# Run the main executable
# Don't quote here since $exec may contain args passed by Steam
if [ -n "$launch" ]; then
echo "start_game_bepinex.sh: SteamLaunch"
exec "$launch" "${rest[@]}"
else
echo "start_game_bepinex.sh: "
exec "$exec"
fi |
tbf it looks good to me, but since they're using arrays instead of strings this bumps up the BTW: I'd recommend using https://github.com/koalaman/shellcheck to check for patterns that can lead to potential errors. Also, this problem can be resolved in I think another way and it by using |
This fixes spaces in file paths for me from r2modmanPlus side (bepinex also doesn't support this but those scripts dont update every time you restart r2modman so manual patches stay there).
I think this might also fix #995 as I have spaces in my profile name and it works but this needs someone more experienced with the project to test.
@NyaomiDEV tag because the script says to blame you if something does not work