From b674becc82c15e87865d6bb8598831dd936b61a5 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 5 Jul 2021 15:10:48 +0300 Subject: [PATCH] kiss: remove subshell usage with sh256 --- kiss | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kiss b/kiss index 086df22..3142e06 100755 --- a/kiss +++ b/kiss @@ -151,7 +151,8 @@ sh256() { digest -a sha256 "$1" ) 2>/dev/null - printf '%s\n' "${hash%% *}" + hash=${hash%% *} + printf '%s\n' "$hash" fi } @@ -1083,10 +1084,10 @@ pkg_remove_files() { # functions allows us to stop duplicating code. while read -r file; do case $file in /etc/?*[!/]) - sum_sys=$(sh256 "$KISS_ROOT/$file") - sum_old=$(grep -F "$sum_sys" "$mak_dir/c") + sh256 "$KISS_ROOT/$file" >/dev/null + sum_old=$(grep -F "$hash" "$mak_dir/c") - [ "$sum_sys" = "$sum_old" ] || { + [ "$hash" = "$sum_old" ] || { printf 'Skipping %s (modified)\n' "$file" continue } @@ -1130,8 +1131,8 @@ pkg_etc() ( find etc ! -type d | sort | while read -r file; do i=$((i + 1)) - { sum_new=$(sh256 "$file") - sum_sys=$(sh256 "$KISS_ROOT/$file") + { sh256 "$file"; sum_new=$hash + sh256 "$KISS_ROOT/$file"; sum_sys=$hash sum_old=$(awk "NR == $i" "$mak_dir/c"); } 2>/dev/null || : log "$pkg_name" "Doing 3-way handshake for $file"