Re: [PATCH] test-lib-functions: avoid non POSIX ERE in test_dir_is_empty()
From: Junio C Hamano <hidden>
Date: 2021-08-26 06:25:21
Taylor Blau [off-list ref] writes:
quoted
- if test -n "$(ls -a1 "$1" | egrep -v '^\.\.?$')" + if test -n "$(ls -a1 "$1" | grep -v '^\.$' | grep -v '^\.\.$')"This replacement is correct, but I'm not sure that I necessarily find it simpler. If we really are concerned about egrep usage, then if test -n "$(find "$1" | grep -v '^\.$')" would suffice. But it looks like we are fairly OK with egrep in t (`git grep 'egrep' -- t | wc -l` turns up 19 matches), so I'm not sure the change is necessary in the first place.
It is true that we have been OK with egrep. "grep -E" is in POSIX (so is "grep -F") and that you might be able to make an argument to use them instead of "egrep" and "fgrep", but at least at one point in the past, 87539416 (tests: grep portability fixes, 2008-09-30) favoured "fgrep" over "grep -F", claiming that the former was more widely available than the latter. The world may have changed since then, though. IIRC, the 2008's topic was mostly about portability to Solaris and AIX, and their peculiarity (or their relevance) may have waned.