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

[PATCH] test-lib-functions: avoid non POSIX ERE in test_dir_is_empty()

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
Aug 26, 2021, 03:17 UTC
Message-ID
<20210826031710.32980-1-carenas@gmail.com>

0be7d9b73d (test-lib: add test_dir_is_empty(), 2014-06-19) uses an ERE through the egrep tool (which is not POSIX) using an ? operator that isn't either.

replace invocation with two equivalent simpler BRE instead.
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 t/test-lib-functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index e28411bb75..2803c97df3 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -790,7 +790,7 @@ test_path_exists () {
 test_dir_is_empty () {
 	test "$#" -ne 1 && BUG "1 param"
 	test_path_is_dir "$1" &&
-	if test -n "$(ls -a1 "$1" | egrep -v '^\.\.?$')"
+	if test -n "$(ls -a1 "$1" | grep -v '^\.$' | grep -v '^\.\.$')"
 	then
 		echo "Directory '$1' is not empty, it contains:"
 		ls -la "$1"
-- 
2.33.0.481.g26d3bed244
Next: Taylor Blau
Message 1 of 6 in “test-lib-functions: avoid non POSIX ERE in test_dir_is_empty()”
  1. test-lib-functions: avoid non POSIX ERE in test_dir_is_empty()Carlo Marcelo Arenas Belón, Aug 26, 2021
  2. Taylor BlauAug 26, 2021
  3. Junio C HamanoAug 26, 2021
  4. Carlo ArenasAug 26, 2021
  5. Carlo ArenasAug 26, 2021
  6. Junio C HamanoAug 26, 2021

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.