Add sanity checks

This commit is contained in:
the-sane 2024-10-29 21:54:54 -04:00
parent f5ee994599
commit 4896db1e5d

View File

@ -2405,10 +2405,22 @@ update_launcher() {
# Backup the file # Backup the file
cp "$wine_prefix/$wine_launch_script_name" "$wine_prefix/$(basename "$wine_launch_script_name" .sh).bak" cp "$wine_prefix/$wine_launch_script_name" "$wine_prefix/$(basename "$wine_launch_script_name" .sh).bak"
# Backup the variables we know we need # Backup the variables we know we need
bak_wineprefix="$(grep "^export WINEPREFIX=" "$wine_prefix/$wine_launch_script_name" | awk -F '=' '{print $2}')" 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}')" 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 # Copy in the new launch script
cp "$wine_launch_script" "$wine_prefix" cp "$wine_launch_script" "$wine_prefix"