From 31225dfdf03aff5797e734c136b5102817107d92 Mon Sep 17 00:00:00 2001 From: Sergeant Acoustic Date: Tue, 3 Feb 2026 23:07:45 +0000 Subject: [PATCH] Fix mrpacktool.sh If wget couldn't download a file from the provided url, the script would continue anyway and jq would write over modrinth.index.json with an empty file --- mrpacktool.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mrpacktool.sh b/mrpacktool.sh index e635236..3016216 100755 --- a/mrpacktool.sh +++ b/mrpacktool.sh @@ -29,10 +29,17 @@ function urldecode() { # Get file name from url trimmed by slash and url decoded mod_file="$(urldecode ${mod_url##*/})" -trap "rm ${mods_dir}/${mod_file}" HUP INT TERM EXIT +trap "rm \"${mods_dir}/${mod_file}\"" HUP INT TERM EXIT echo "Downloading file..." wget -N --no-verbose --directory-prefix "$mods_dir" "$mod_url" +# Exit if download failed +if [ $? != "0" ]; then + echo "$0: Could not download mod from provided URL" + trap "" HUP INT TERM EXIT # Unset trap as there's no file to delete + exit 1 +fi + # Collect data required by modrinth.index.json echo "Processing file info" mod_path="${mods_dir}/${mod_file}"