From 76ca015352211149435c11bcd19ad3816c638c48 Mon Sep 17 00:00:00 2001 From: overdodactyl Date: Fri, 23 Nov 2018 13:39:49 -0700 Subject: [PATCH] don't create empty diff files --- updater.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/updater.sh b/updater.sh index 5db2a4c..f32b60d 100755 --- a/updater.sh +++ b/updater.sh @@ -267,7 +267,7 @@ update_userjs () { cp user.js "$bakname" mv "${newfile}" user.js - echo -e "Status: ${GREEN}${filename} has been backed up and replaced with the latest version!${NC}" + echo -e "Status: ${GREEN}user.js has been backed up and replaced with the latest version!${NC}" # apply overrides if [ "$SKIPOVERRIDE" = false ]; then @@ -286,7 +286,13 @@ update_userjs () { remove_comments user.js $current_nocomments diffname="userjs_diffs/diff_$(date +"%Y-%m-%d_%H%M").txt" - diff -w -B -U 0 $past_nocomments $current_nocomments > "$diffname" + diff=$(diff -w -B -U 0 $past_nocomments $current_nocomments) + if [ ! -z "$diff" ]; then + echo "$diff" > "$diffname" + echo -e "Status: ${GREEN}A diff file was created:${NC} ${PWD}/${diffname}" + else + echo -e "Warning: ${ORANGE}Your new user.js file appears to be identical. No diff file was created."${NC} + fi rm $past_nocomments $current_nocomments $pastuserjs fi