From 6a02e49b317f4286c31adb4384d7daf011760b73 Mon Sep 17 00:00:00 2001 From: v4n <105587619+v4n00@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:42:11 +0200 Subject: [PATCH] fix: downgrade logic, removed xargs --- h2mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/h2mm b/h2mm index e0c0a9a..42f623e 100755 --- a/h2mm +++ b/h2mm @@ -384,9 +384,10 @@ function mod_uninstall() { for file in "${!downgrades[@]}"; do # find all files that have the same base name, and are greater than the current version, and downgrade them base_name=$(get_basename "$file") - same_patches=$(ls "$MODS_DIR/${base_name}.patch_"* 2>/dev/null | grep -Eo "$base_name.*") + same_patches=$(ls "$MODS_DIR/${base_name}.patch_"* 2>/dev/null) for patch in $same_patches; do + patch=$(get_filename_without_path "$patch") patch_version=$(echo $patch | grep -oP '(?<=patch_)\d+') if [[ $patch_version -gt ${downgrades[$file]} ]]; then new_version=$((patch_version - 1)) @@ -426,7 +427,10 @@ function mod_export() { MODS_EXPORT_DIR="$OUT_DIR/Helldivers 2 Mods" mkdir -p "$MODS_EXPORT_DIR" cp "$DB_FILE" "$MODS_EXPORT_DIR" - ls "$MODS_DIR/" 2>/dev/null | grep -E 'patch_.*' | xargs -I {} cp "$MODS_DIR/{}" "$MODS_EXPORT_DIR" + + for file in $(ls "$MODS_DIR/" 2>/dev/null | grep -E 'patch_.*'); do + cp "$MODS_DIR/$file" "$MODS_EXPORT_DIR" + done if [[ $? -ne 0 ]]; then echo -e "${RED}Error${NC}: Could not export mods. Possibly because no mods are present." >&2