fix: function return typo, trailing slashes removed from paths (#13)

This commit is contained in:
v4n
2025-02-05 16:23:32 +02:00
committed by GitHub
parent 388afe69b7
commit 0ab273977e
+8 -11
View File
@@ -96,7 +96,7 @@ function find_game_directory() {
echo "$saved_dir" echo "$saved_dir"
return return
else 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
fi fi
@@ -107,22 +107,18 @@ function find_game_directory() {
if [[ -z "$game_dir" ]]; then if [[ -z "$game_dir" ]]; then
echo "Could not find the Helldivers 2 data directory automatically." >&2 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 IFS= read -ep "Please enter the path to the Helldivers 2 data directory: " game_dir
if [[ ! -d "$game_dir" ]]; then game_dir="$(realpath "${game_dir/#\~/$HOME}")"
echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2
exit 1 [[ ! -d "$game_dir" ]] && { echo -e "${RED}Error${NC}: Provided path is not a valid directory." >&2; exit 1; }
fi
fi fi
mkdir -p "$(dirname "$H2PATH")" # save path
echo "$game_dir" > "$H2PATH" echo "$game_dir" > "$H2PATH"
if [[ $? -eq 0 ]]; then [[ $? -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 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
# return the directory
echo "$game_dir" echo "$game_dir"
} }
@@ -134,6 +130,7 @@ function initialize_directories() {
touch "$DB_FILE" touch "$DB_FILE"
[[ $? -ne 0 ]] && { echo -e "${RED}Error${NC}: Could not create database file." >&2; exit 1; } [[ $? -ne 0 ]] && { echo -e "${RED}Error${NC}: Could not create database file." >&2; exit 1; }
echo "$VERSION" | awk -F. '{print $2}' > "$DB_FILE" echo "$VERSION" | awk -F. '{print $2}' > "$DB_FILE"
echo -e "Database file ${GREEN}created${NC}: $DB_FILE" &>2 echo -e "Database file ${GREEN}created${NC}: $DB_FILE" &>2
fi fi