fix: confirm after auto-finding HD2 path (#51)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERSION="0.5.0"
|
VERSION="0.5.3"
|
||||||
|
|
||||||
# --- Globals ---
|
# --- Globals ---
|
||||||
|
|
||||||
@@ -194,12 +194,26 @@ function find_game_directory() {
|
|||||||
game_dir=$(timeout 10 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
|
game_dir=$(timeout 10 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
|
||||||
|
|
||||||
if [[ -z "$game_dir" ]]; then
|
if [[ -z "$game_dir" ]]; then
|
||||||
|
# if not found, ask user for the directory
|
||||||
log INFO "Could not find the Helldivers 2 data directory automatically."
|
log INFO "Could not find the Helldivers 2 data directory automatically."
|
||||||
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
|
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
|
||||||
IFS= read -e game_dir
|
IFS= read -e game_dir; unset IFS
|
||||||
game_dir="$(substitute_home "$game_dir")"
|
game_dir="$(substitute_home "$game_dir")"
|
||||||
|
|
||||||
[[ ! -d "$game_dir" ]] && { log ERROR "Provided path is not a valid directory."; exit 1; }
|
[[ ! -d "$game_dir" ]] && { log ERROR "Provided path is not a valid directory."; exit 1; }
|
||||||
|
else
|
||||||
|
# confirm with the user that the directory is ok
|
||||||
|
log INFO "Found Helldivers 2 data directory: $game_dir"
|
||||||
|
log PROMPT "Is this the correct directory? (Y/n): "
|
||||||
|
read confirm
|
||||||
|
|
||||||
|
if [[ "$confirm" != "y" && "$confirm" != "Y" && "$confirm" != "" ]]; then
|
||||||
|
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
|
||||||
|
IFS= read -e game_dir; unset IFS
|
||||||
|
game_dir="$(substitute_home "$game_dir")"
|
||||||
|
|
||||||
|
[[ ! -d "$game_dir" ]] && { log ERROR "Provided path is not a valid directory."; exit 1; }
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# save path
|
# save path
|
||||||
|
|||||||
+18
-7
@@ -130,9 +130,7 @@ if [[ $latest_major -gt $installed_major ]]; then
|
|||||||
# check if game directory is in ~/.config/h2mm/h2path
|
# check if game directory is in ~/.config/h2mm/h2path
|
||||||
if [[ -f "$HOME/.config/h2mm/h2path" ]]; then
|
if [[ -f "$HOME/.config/h2mm/h2path" ]]; then
|
||||||
game_dir=$(cat "$HOME/.config/h2mm/h2path")
|
game_dir=$(cat "$HOME/.config/h2mm/h2path")
|
||||||
[[ ! -d "$game_dir" ]] && { log ERROR "Helldivers 2 data directory in ~/.config/h2mm/h2path is not a valid directory." ; exit 1; }
|
[[ ! -d "$game_dir" ]] && { log ERROR "Helldivers 2 data directory is not valid: $game_dir." ; exit 1; }
|
||||||
|
|
||||||
log INFO "Helldivers 2 data directory found: $game_dir."
|
|
||||||
else
|
else
|
||||||
log INFO "Searching for the Helldivers 2 data directory... (10 seconds timeout)"
|
log INFO "Searching for the Helldivers 2 data directory... (10 seconds timeout)"
|
||||||
game_dir=$(timeout 10 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
|
game_dir=$(timeout 10 find "$search_dir" -type d -path "*/$target_dir" 2>/dev/null | head -n 1)
|
||||||
@@ -140,12 +138,25 @@ if [[ $latest_major -gt $installed_major ]]; then
|
|||||||
|
|
||||||
# if not found, prompt user
|
# if not found, prompt user
|
||||||
if [[ -z "$game_dir" ]]; then
|
if [[ -z "$game_dir" ]]; then
|
||||||
|
# if not found, ask user for the directory
|
||||||
log INFO "Could not find the Helldivers 2 data directory automatically."
|
log INFO "Could not find the Helldivers 2 data directory automatically."
|
||||||
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
|
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
|
||||||
IFS= read -e game_dir
|
IFS= read -e game_dir; unset IFS
|
||||||
if [[ ! -d "$game_dir" ]]; then
|
game_dir="$(substitute_home "$game_dir")"
|
||||||
log ERROR "Provided path is not a valid directory."
|
|
||||||
exit 1
|
[[ ! -d "$game_dir" ]] && { log ERROR "Provided path is not a valid directory."; exit 1; }
|
||||||
|
else
|
||||||
|
# confirm with the user that the directory is ok
|
||||||
|
log INFO "Found Helldivers 2 data directory: $game_dir"
|
||||||
|
log PROMPT "Is this the correct directory? (Y/n): "
|
||||||
|
read confirm
|
||||||
|
|
||||||
|
if [[ "$confirm" != "y" && "$confirm" != "Y" && "$confirm" != "" ]]; then
|
||||||
|
log PROMPT "Please enter the path to the Helldivers 2 data directory: "
|
||||||
|
IFS= read -e game_dir; unset IFS
|
||||||
|
game_dir="$(substitute_home "$game_dir")"
|
||||||
|
|
||||||
|
[[ ! -d "$game_dir" ]] && { log ERROR "Provided path is not a valid directory."; exit 1; }
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user