libgo: make a couple of sed uses POSIX compliant

Patch from Jonathan Wakely.

Change-Id: If1351da48ee2e787a082855d8c0b85d9af81d89b
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/401054
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index e0a1eec..a5d4b6a 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -1305,7 +1305,7 @@
 	if test "$$untested" -ne "0"; then \
 	  echo "# of untested testcases		$$untested" >> libgo.sum; \
 	fi; \
-	echo `echo $(GOC) | sed -e 's/ .*//'`  `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> libgo.sum; \
+	echo `echo $(GOC) | sed -e 's/ .*//'`  `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*\)$$/\1/p'` >> libgo.sum; \
 	echo >> libgo.log; \
 	echo "runtest completed at `date`" >> libgo.log; \
 	if test "$$fail" -ne "0"; then \
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index 7bef5df..22f48a5 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -3189,7 +3189,7 @@
 	if test "$$untested" -ne "0"; then \
 	  echo "# of untested testcases		$$untested" >> libgo.sum; \
 	fi; \
-	echo `echo $(GOC) | sed -e 's/ .*//'`  `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> libgo.sum; \
+	echo `echo $(GOC) | sed -e 's/ .*//'`  `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*\)$$/\1/p'` >> libgo.sum; \
 	echo >> libgo.log; \
 	echo "runtest completed at `date`" >> libgo.log; \
 	if test "$$fail" -ne "0"; then \
diff --git a/libgo/match.sh b/libgo/match.sh
index 139d0cd..7ed587f 100755
--- a/libgo/match.sh
+++ b/libgo/match.sh
@@ -100,7 +100,7 @@
 
 gobuild() {
     line=$(echo "$1" | sed -e 's|//go:build ||')
-    line=$(echo "$line" | sed -e 's/go1\.[0-9]\+/1/g' -e 's/goexperiment\./goexperiment/')
+    line=$(echo "$line" | sed -e 's/go1\.[0-9][0-9]*/1/g' -e 's/goexperiment\./goexperiment/')
     line=" $line "
     wrap='[ ()!&|]'
     for ones in $goarch $goos $cgotag $cmdlinetag gccgo goexperimentfieldtrack; do