-
Notifications
You must be signed in to change notification settings - Fork 81
Updates to nix shell script #95
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This pull request updates the Unix/Linux shell script (run.sh) to address several user-reported issues and improve error handling. The changes focus on making the script more robust and providing better feedback when errors occur.
Changes:
- Added
set -eto halt execution on unexpected errors, preventing cascading failures - Simplified Steam executable detection by checking if arguments are prefixed with the working directory path
- Added explicit detection and error messaging for Windows PE32 executables
- Added fallback support for games that launch shell scripts instead of binaries
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
assets/nix/run.sh
Outdated
| # Test if argument is prefixed with the value of $PWD | ||
| if [ "$1" != "${1#"$PWD"}" ]; then |
Copilot
AI
Jan 30, 2026
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 prefix matching logic could incorrectly match paths with partially matching directory names. For example, if PWD is "/path/to/game" and an argument is "/path/to/gamer/executable", the string prefix "/path/to/game" would be removed, leaving "r/executable", causing the condition to match incorrectly.
While this is unlikely to occur in practice with Steam (which should only pass paths within the game directory), consider making the check more robust by testing if the argument starts with "$PWD/" to ensure it's matching a complete path component.
| # Test if argument is prefixed with the value of $PWD | |
| if [ "$1" != "${1#"$PWD"}" ]; then | |
| # Test if argument is prefixed with the value of $PWD followed by a path separator | |
| if [ "$1" != "${1#"$PWD"/}" ]; then |
…le located in the working directory
317ba2f to
6abda2f
Compare
Multiple updates to the nix run.sh mostly to correct for observed issues from users.
1. Add set -e to halt on any unexpected errors
At least one issue was observed where the file command was not available on a users system. An error was thrown but the script continued and threw more errors. Now it will just stop on any unexpected errors.
#91
2. Add error and exit when Windows executable is detected
This was included in the BepInEx 6 branch some time ago but never made it into upstream and back to BepInEx 5 or other branches. This is an extremely common user error that will now get a correct error message.
3. Allow the rare usage of Steam launching a shell script
There are a few rare games on Steam where the developers call a shell script instead of a binary. They might not work with this change but it at least provide a boilerplate spot for more game specific changes to be placed if needed.
4. Change Steam executable detection to a simpler check for a file located in the working directory
My original solution for a way that did not require executable_name to be set was overly complicated and depended on game executables having the default file extensions from Unity. This solution simply looks for an argument that has a matching prefix with the working directory. Before launching a game, Steam sets the working directory to the game directory then launches the executable in the game directory by absolute path.