git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Use 'grep -a' to fix some errors with non-GNU grep(1).

From
Bernd Ahlers <bernd@ba-net.org>
Date
Mar 28, 2008, 22:40 UTC
Message-ID
<20080328224011.GB5486@dengar.tuneafish.de>
This fixes test errors on OpenBSD.
Signed-off-by: Bernd Ahlers <bernd@ba-net.org>
---
 t/t4019-diff-wserror.sh        |   28 ++++++++++++++--------------
 t/t9200-git-cvsexportcommit.sh |    2 +-
 2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh
index 0d9cbb6..275b41a 100755
--- a/t/t4019-diff-wserror.sh
+++ b/t/t4019-diff-wserror.sh
@@ -22,8 +22,8 @@ blue_grep='7;34m' ;# ESC [ 7 ; 3 4 m
 test_expect_success default '
 
 	git diff --color >output
-	grep "$blue_grep" output >error
-	grep -v "$blue_grep" output >normal
+	grep -a "$blue_grep" output >error
+	grep -a -v "$blue_grep" output >normal
 
 	grep Eight normal >/dev/null &&
 	grep HT error >/dev/null &&
@@ -37,8 +37,8 @@ test_expect_success 'without -trail' '
 
 	git config core.whitespace -trail
 	git diff --color >output
-	grep "$blue_grep" output >error
-	grep -v "$blue_grep" output >normal
+	grep -a "$blue_grep" output >error
+	grep -a -v "$blue_grep" output >normal
 
 	grep Eight normal >/dev/null &&
 	grep HT error >/dev/null &&
@@ -53,8 +53,8 @@ test_expect_success 'without -trail (attribute)' '
 	git config --unset core.whitespace
 	echo "F whitespace=-trail" >.gitattributes
 	git diff --color >output
-	grep "$blue_grep" output >error
-	grep -v "$blue_grep" output >normal
+	grep -a "$blue_grep" output >error
+	grep -a -v "$blue_grep" output >normal
 
 	grep Eight normal >/dev/null &&
 	grep HT error >/dev/null &&
@@ -69,8 +69,8 @@ test_expect_success 'without -space' '
 	rm -f .gitattributes
 	git config core.whitespace -space
 	git diff --color >output
-	grep "$blue_grep" output >error
-	grep -v "$blue_grep" output >normal
+	grep -a "$blue_grep" output >error
+	grep -a -v "$blue_grep" output >normal
 
 	grep Eight normal >/dev/null &&
 	grep HT normal >/dev/null &&
@@ -85,8 +85,8 @@ test_expect_success 'without -space (attribute)' '
 	git config --unset core.whitespace
 	echo "F whitespace=-space" >.gitattributes
 	git diff --color >output
-	grep "$blue_grep" output >error
-	grep -v "$blue_grep" output >normal
+	grep -a "$blue_grep" output >error
+	grep -a -v "$blue_grep" output >normal
 
 	grep Eight normal >/dev/null &&
 	grep HT normal >/dev/null &&
@@ -101,8 +101,8 @@ test_expect_success 'with indent-non-tab only' '
 	rm -f .gitattributes
 	git config core.whitespace indent,-trailing,-space
 	git diff --color >output
-	grep "$blue_grep" output >error
-	grep -v "$blue_grep" output >normal
+	grep -a "$blue_grep" output >error
+	grep -a -v "$blue_grep" output >normal
 
 	grep Eight error >/dev/null &&
 	grep HT normal >/dev/null &&
@@ -117,8 +117,8 @@ test_expect_success 'with indent-non-tab only (attribute)' '
 	git config --unset core.whitespace
 	echo "F whitespace=indent,-trailing,-space" >.gitattributes
 	git diff --color >output
-	grep "$blue_grep" output >error
-	grep -v "$blue_grep" output >normal
+	grep -a "$blue_grep" output >error
+	grep -a -v "$blue_grep" output >normal
 
 	grep Eight error >/dev/null &&
 	grep HT normal >/dev/null &&
diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
index 42b144b..d3bd48c 100755
--- a/t/t9200-git-cvsexportcommit.sh
+++ b/t/t9200-git-cvsexportcommit.sh
@@ -30,7 +30,7 @@ exit 1
 
 check_entries () {
 	# $1 == directory, $2 == expected
-	grep '^/' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual
+	grep -a '^/' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual
 	if test -z "$2"
 	then
 		>expected
-- 
1.5.4.5
Next: Jeff King
Message 1 of 2 in “Use 'grep -a' to fix some errors with non-GNU grep(1).”
  1. Use 'grep -a' to fix some errors with non-GNU grep(1).Bernd Ahlers, Mar 28, 2008
  2. Jeff KingMar 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.