diff --git a/h2mm b/h2mm index dcc8e5a..09b3e3b 100755 --- a/h2mm +++ b/h2mm @@ -63,8 +63,12 @@ function get_mod_name_and_index() { fi if [[ -z "$entry" || -z "$mod_index" || -z "$mod_name" ]]; then - echo -e "${RED}Error${NC}: Mod not found." >&2 - exit 1 + if [[ "$1" == "--do-not-exit" ]]; then + mod_index=-1 + else + echo -e "${RED}Error${NC}: Mod not found." >&2 + exit 1 + fi fi status=$(echo "$entry" | awk -F, '{print $2}') @@ -662,6 +666,13 @@ function mod_install() { # verify minimum information required [[ -z "$mod_name" || ${#mod_files[@]} -eq 0 ]] && { echo -e "${RED}Error${NC}: Mod name and files are required." >&2; exit 1; } + get_mod_name_and_index "--do-not-exit" "$mod_name" "$do_not_exit" + + if [[ $mod_index -ne -1 ]]; then + echo -e "${RED}Error${NC}: The mod '$mod_name' is already installed."; + exit 1; + fi + # verify mod files exist for file in "${mod_files[@]}"; do [[ ! -f "$file" ]] && { echo -e "${RED}Error${NC}: Mod file $file does not exist." >&2; exit 1; }