From b921782385984b08b28da5d4af9fcc2e4ea3d82e Mon Sep 17 00:00:00 2001
From: Zheng Bao <fishbaozi@gmail.com>
Date: Mon, 15 Aug 2022 18:29:45 +0800
Subject: buildgcc: Match the string of downloading percentage more precisely

The command "wget" prints some hyperlink with "%", which will be
filtered in by previous regular expression. So we need to change to
match the string with exactly 3 digits and a percent symbol.

TEST:
echo 45%  | grep -o "\<[0-9]\{1,3\}%"
  45%
echo 1245% | grep -o "\<[0-9]\{1,3\}%"
  <empty>
echo aa%  | grep -o "\<[0-9]\{1,3\}%"
  <empty>

Change-Id: I6ef9e7c87fd4ee6cc707346954d91e6e3af3b939
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66743
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
---
 util/crossgcc/buildgcc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'util')

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 0a0462e2f6..5944b057e7 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -1076,7 +1076,7 @@ if searchtool wget "GNU" nofail > /dev/null; then
 		url=$1
 		printf "... ${red}  0%%"
 		wget --tries=3 "$url" 2>&1 | while read -r line; do
-			echo "$line" | grep -o "[0-9]\+%" | awk '{printf("\b\b\b\b%4s", $1)}'
+			echo "$line" | grep -o "\<[0-9]\{1,3\}%" | awk '{printf("\b\b\b\b%4s", $1)}'
 		done
 		printf "${NC}... "
 	}
-- 
cgit v1.2.3