Re: [PATCH] test-lib-functions: avoid non POSIX ERE in test_dir_is_empty()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 26, 2021, 19:21 UTC
- Message-ID
- <xmqqfsuwdnbk.fsf@gitster.g>
- In-Reply-To
- <CAPUEspjGkHhFNgTe3HnnUvkzwHfKqb9dYO3aCXDh_fRyFMRN6A@mail.gmail.com>
Carlo Arenas <carenas@gmail.com> writes:
> egrep (and also fgrep, which we intentionally support because it is > missing from some ancient AIX system[1]) will be removed in the > next[2] release of GNU grep.
It is not a reason not to nudge us to prepare for the eventual removal of these two commands, but we need to keep the facts straight in our log messages.
The way I read [2], they will only start giving a warning message nudging the users to use "grep -[EF]", and for them to be able to warn, I would imagine they have to stay in the release without getting removed.
> [1] 87539416fd (tests: grep portability fixes, 2008-09-30) > [2] https://git.savannah.gnu.org/cgit/grep.git/commit/?id=a9515624709865d480e3142fd959bccd1c9372d1
There are about 35 places in t/ we call egrep or fgrep; if we can add a pair of replacement shell functions in t/test-lib.sh for them to use whatever command GIT_TEST_EGREP and GIT_TEST_FGREP environment variables specify and fall back on "grep -E/-F" otherwise, we can prepare for the change without too much code churning.
Something along the lines of
# in test-lib-functions.sh
: ${GIT_TEST_EGREP:=grep -E} ${GIT_TEST_FGREP:=grep -F}
egrep () { $GIT_TEST_EGREP "$@" }
fgrep () { $GIT_TEST_FGREP "$@" }where people could do something silly like
GIT_TEST_FGREP='command fgrep' \ GIT_TEST_EGREP='command egrep' \ make test
perhaps?