]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Replacement function for buggy fgrep.
authorDarren Tucker <dtucker@dtucker.net>
Thu, 23 Sep 2021 22:04:14 +0000 (08:04 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Thu, 23 Sep 2021 22:06:48 +0000 (08:06 +1000)
GNU (f)grep <=2.18, as shipped by FreeBSD<=12 and NetBSD<=9 will
occasionally fail to find ssh host keys in the hostkey-rotate test.
If we have those versions, use awk instead.

regress/test-exec.sh

index 415422ef5573bcfd674722c1c2bdc9f886567ccf..5fcc3fcfcca4448a2662350ceea31fbf0728d214 100644 (file)
@@ -79,6 +79,25 @@ if test "x${EGREP}" != "x"; then
 }
 fi
 
+#
+# GNU (f)grep <=2.18, as shipped by FreeBSD<=12 and NetBSD<=9 will occasionally
+# fail to find ssh host keys in the hostkey-rotate test.  If we have those
+# versions, use awk instead.
+# See # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258616
+#
+case `grep --version 2>&1 | awk '/GNU grep/{print $4}'` in
+2.19)                  fgrep=good ;;
+1.*|2.?|2.?.?|2.1?)    fgrep=bad ;;    # stock GNU grep
+2.5.1*)                        fgrep=bad ;;    # FreeBSD and NetBSD
+*)                     fgrep=good ;;
+esac
+if test "x$fgrep" = "xbad"; then
+       fgrep()
+{
+       awk 'BEGIN{e=1} {if (index($0,"'$1'")>0){e=0;print}} END{exit e}' $2
+}
+fi
+
 SRC=`dirname ${SCRIPT}`
 
 # defaults