kiss: remove subshell usage with sh256

This commit is contained in:
Dylan Araps 2021-07-05 15:10:48 +03:00
parent 88f74d2d21
commit b674becc82
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C

13
kiss
View File

@ -151,7 +151,8 @@ sh256() {
digest -a sha256 "$1" digest -a sha256 "$1"
) 2>/dev/null ) 2>/dev/null
printf '%s\n' "${hash%% *}" hash=${hash%% *}
printf '%s\n' "$hash"
fi fi
} }
@ -1083,10 +1084,10 @@ pkg_remove_files() {
# functions allows us to stop duplicating code. # functions allows us to stop duplicating code.
while read -r file; do while read -r file; do
case $file in /etc/?*[!/]) case $file in /etc/?*[!/])
sum_sys=$(sh256 "$KISS_ROOT/$file") sh256 "$KISS_ROOT/$file" >/dev/null
sum_old=$(grep -F "$sum_sys" "$mak_dir/c") sum_old=$(grep -F "$hash" "$mak_dir/c")
[ "$sum_sys" = "$sum_old" ] || { [ "$hash" = "$sum_old" ] || {
printf 'Skipping %s (modified)\n' "$file" printf 'Skipping %s (modified)\n' "$file"
continue continue
} }
@ -1130,8 +1131,8 @@ pkg_etc() (
find etc ! -type d | sort | while read -r file; do find etc ! -type d | sort | while read -r file; do
i=$((i + 1)) i=$((i + 1))
{ sum_new=$(sh256 "$file") { sh256 "$file"; sum_new=$hash
sum_sys=$(sh256 "$KISS_ROOT/$file") sh256 "$KISS_ROOT/$file"; sum_sys=$hash
sum_old=$(awk "NR == $i" "$mak_dir/c"); } 2>/dev/null || : sum_old=$(awk "NR == $i" "$mak_dir/c"); } 2>/dev/null || :
log "$pkg_name" "Doing 3-way handshake for $file" log "$pkg_name" "Doing 3-way handshake for $file"