33# SPDX-FileCopyrightText: 2025 Christoph Mewes, https://codeberg.org/xrstf/uget
44# SPDX-License-Identifier: MIT
55#
6- # µget 0.2.0 – your friendly downloader
6+ # µget 0.2.2 – your friendly downloader
77# -------------------------------------
88#
99# µget can download software as binaries, archives or Go modules.
@@ -121,7 +121,7 @@ uget::checksum::read() {
121121 local kvString=" $1 "
122122
123123 if [[ -f " $UGET_CHECKSUMS " ]]; then
124- awk -F' |' " { if (\ $ 1 == \" $BINARY \" && \ $ 2 == \" $kvString \" ) print \ $ 3 }" " $UGET_CHECKSUMS "
124+ awk -F' |' -v " binary= $BINARY " -v " kv= $kvString " ' { if ($1 == binary && $2 == kv ) print $3 }' " $UGET_CHECKSUMS "
125125 fi
126126}
127127
@@ -141,9 +141,9 @@ uget::checksum::write() {
141141 # (for better readability, do not invert the condition here);
142142 # grep will drop any empty lines
143143 awk \
144- -F' |' \
145- " { if (\ $ 1 == \" $BINARY \" && \ $ 2 == \" $kvString \" ) {} else print }" \
146- " $UGET_CHECKSUMS " | grep . > " $tempDir /checksums.txt"
144+ -F' |' -v " binary= $BINARY " -v " kv= $kvString " \
145+ ' { if ($1 == binary && $2 == kv ) {} else print }' \
146+ " $UGET_CHECKSUMS " | ( grep . || true) > " $tempDir /checksums.txt"
147147
148148 # add our new checksum
149149 echo " $BINARY |$kvString |$checksum " >> " $tempDir /checksums.txt"
@@ -469,7 +469,7 @@ if $UGET_UPDATE; then
469469
470470 # download binary into tempdir, update checksums, but then delete it again
471471 uget::update " $kvString " " $url "
472- done < <( awk -F' |' " { if (\ $ 1 == \" $BINARY \" ) print \ $ 2 }" " $UGET_CHECKSUMS " )
472+ done < <( awk -F' |' -v " binary= $BINARY " ' { if ($1 == binary ) print $2 }' " $UGET_CHECKSUMS " )
473473
474474 uget::log " All checksums were updated."
475475else
0 commit comments