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
+9 -12
View File
@@ -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