From 1074e15a0fc28ce969f58b1c90392c16721d5c47 Mon Sep 17 00:00:00 2001 From: FriendlyNeighborhoodShane Date: Sun, 25 Jul 2021 14:56:42 +0530 Subject: [PATCH] Fix some shellcheck complaints --- res/util/func-resdl.sh | 2 +- res/util/script-addon.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/res/util/func-resdl.sh b/res/util/func-resdl.sh index 3f24bd4..52ce9d0 100755 --- a/res/util/func-resdl.sh +++ b/res/util/func-resdl.sh @@ -30,7 +30,7 @@ updatedelta() { echo " "; echo " - Checking resdl delta between updates..."; - for entry in $(grep -oE "FILE: [^,;]*" "$reldir/update-$newlog.log" | cut -d" " -f2); do + grep -oE "FILE: [^,;]*" "$reldir/update-$newlog.log" | cut -d" " -f2 | while read -r entry; do file="$entry"; line="$(grep "FILE: $file[,;]" "$reldir/update-$newlog.log" | head -n1)"; url="$(echo "$line" | grep -oE "URL: [^,;]*" | cut -d" " -f2)"; diff --git a/res/util/script-addon.sh b/res/util/script-addon.sh index 6415286..614d73b 100755 --- a/res/util/script-addon.sh +++ b/res/util/script-addon.sh @@ -51,13 +51,17 @@ translate_path() { done; } +delete_file() { + rm -rf "$1"; +} + case "$1" in backup) log " "; log "Backing up..."; save_files | translate_path | while read -r object; do [ "$object" ] && [ -e "$S/$object" ] || continue; - for file in $(find "$S/$object" -type f); do + find "$S/$object" -type f | while read -r file; do file="${file#$S/}"; backup_file "$S/$file"; log "BACKUPER: Object backed up ($file)"; @@ -69,7 +73,7 @@ case "$1" in log "Restoring..."; save_files | translate_path | while read -r object; do [ "$object" ] && [ -e "$C/$S/$object" ] || continue; - for file in $(find "$C/$S/$object" -type f); do + find "$C/$S/$object" -type f | while read -r file; do file="${file#$C/$S/}"; restore_file "$S/$file"; log "RESTORER: Object restored ($file)"; @@ -81,7 +85,7 @@ case "$1" in log "Debloating..."; delete_files | translate_path | while read -r object; do [ "$object" ] && [ -e "$S/$object" ] || continue; - rm -rf "$S/$object"; + delete_file "$S/$object"; log "DEBLOATER: Object debloated ($object)"; done; ;;