diff --git a/h2mm b/h2mm index dfe9755..c075517 100755 --- a/h2mm +++ b/h2mm @@ -96,7 +96,7 @@ function find_game_directory() { echo "$saved_dir" return else - echo "Saved game directory is invalid." + echo -e "${RED}!${NC} Saved game directory is invalid. Proceeding to get a new directory." >&2 fi fi @@ -107,22 +107,18 @@ function find_game_directory() { if [[ -z "$game_dir" ]]; then echo "Could not find the Helldivers 2 data directory automatically." >&2 IFS= read -ep "Please enter the path to the Helldivers 2 data directory: " game_dir - if [[ ! -d "$game_dir" ]]; then - echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2 - exit 1 - fi + game_dir="$(realpath "${game_dir/#\~/$HOME}")" + + [[ ! -d "$game_dir" ]] && { echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2; exit 1; } fi - mkdir -p "$(dirname "$H2PATH")" + # save path echo "$game_dir" > "$H2PATH" - if [[ $? -eq 0 ]]; then - echo -e "Game directory ${GREEN}saved${NC}: $game_dir" >&2 - else - echo -e "${RED}Error${NC}: Could not save game directory." >&2 - exit 1 - fi + [[ $? -ne 0 ]] && { echo -e "${RED}Error${NC}: Could not save game directory." >&2; exit 1; } + echo -e "Game directory ${GREEN}saved${NC}: $game_dir" >&2 + # return the directory echo "$game_dir" } @@ -134,6 +130,7 @@ function initialize_directories() { touch "$DB_FILE" [[ $? -ne 0 ]] && { echo -e "${RED}Error${NC}: Could not create database file." >&2; exit 1; } + echo "$VERSION" | awk -F. '{print $2}' > "$DB_FILE" echo -e "Database file ${GREEN}created${NC}: $DB_FILE" &>2 fi