From 9374b6938e2bbff0ea26d9936ba7397b7b027214 Mon Sep 17 00:00:00 2001 From: Doan Tran Cong Danh Date: Sun, 12 May 2019 10:25:17 +0700 Subject: [PATCH] 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 --- common/environment/setup/vsed.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/environment/setup/vsed.sh b/common/environment/setup/vsed.sh index 0f249c4280b..ff59bdacb3c 100644 --- a/common/environment/setup/vsed.sh +++ b/common/environment/setup/vsed.sh @@ -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