vsed: strip non-digest part before comparing

Accidentally, this change also fixs a potential bug
if `XBPS_DIGEST_CMD` is changed to something other than
its current value: `xbps-uhelper digest'.

Because the old code compares:
- non-stripped old digest; and
- stripped new digest
This commit is contained in:
Doan Tran Cong Danh 2019-05-12 10:25:17 +07:00 committed by Enno Boland
parent c384f85d2b
commit 9374b6938e
1 changed files with 3 additions and 1 deletions

View File

@ -47,6 +47,7 @@ vsed() {
for rx in "${regexes[@]}"; do
for f in "${files[@]}"; do
olddigest="$($XBPS_DIGEST_CMD "$f")"
olddigest="${olddigest%% *}"
sed -i "$f" -e "$rx" || {
msg_red "$pkgver: vsed: sed call failed with regex \"$rx\" on file \"$f\"\n"
@ -54,8 +55,9 @@ vsed() {
}
newdigest="$($XBPS_DIGEST_CMD "$f")"
newdigest="${newdigest%% *}"
if [ "$olddigest" = "${newdigest%% *}" ]; then
if [ "$olddigest" = "$newdigest" ]; then
msg_warn "$pkgver: vsed: regex \"$rx\" didn't change file \"$f\"\n"
fi
done