From 4896db1e5de02e3aee10b53e519aeb88f2738d10 Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Tue, 29 Oct 2024 21:54:54 -0400 Subject: [PATCH] Add sanity checks --- lug-helper.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lug-helper.sh b/lug-helper.sh index 2e09417..a55f674 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -2405,10 +2405,22 @@ update_launcher() { # Backup the file cp "$wine_prefix/$wine_launch_script_name" "$wine_prefix/$(basename "$wine_launch_script_name" .sh).bak" + # Backup the variables we know we need bak_wineprefix="$(grep "^export WINEPREFIX=" "$wine_prefix/$wine_launch_script_name" | awk -F '=' '{print $2}')" bak_winepath="$(grep -e "^export wine_path=" -e "^wine_path=" "$wine_prefix/$wine_launch_script_name" | awk -F '=' '{print $2}')" + # If wineprefix isn't found in the file, something is wrong and we shouldn't proceed + if [ -z "$bak_wineprefix" ]; then + message error "The WINEPREFIX env var was not found in your launch script. Unable to proceed!\n\n$wine_prefix/$wine_launch_script_name" + return 1 + fi + + # If wine_path is empty, it may be an older version of the launch script. Default to system wine + if [ -z "$bak_winepath" ]; then + bak_winepath="$(command -v wine | xargs dirname)" + fi + # Copy in the new launch script cp "$wine_launch_script" "$wine_prefix"