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

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

From
Carlo Arenas <carenas@gmail.com>
Date
Aug 26, 2021, 07:48 UTC
Message-ID
<CAPUEspj4F6=c_WPnb==enx6n1wY6LgOXbRm_kZCSnoOf5qcNsg@mail.gmail.com>
In-Reply-To
<xmqqlf4ohgdv.fsf@gitster.g>
On Wed, Aug 25, 2021 at 11:25 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> Taylor Blau <me@ttaylorr.com> writes:
> >> -    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.

note that will be an issue at least in a future release of GNU grep where the deprecated {e,f}grep commands won't be available.

> "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".

I misread the POSIX specification, and had confirmed that the ? operator works fine in BSD and busybox grep so apologies and will see to resubmit this change together with the others that will be required to deal with the deprecated binaries.

Show 7 quoted lines
> 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.

was hoping to deal with fgrep using a function (just like is done with perl), but was also hoping that a compatibility layer wouldn't be needed. testing on AIX (that seems to stick around) will definitely be needed.

Carlo
Previous: Junio C HamanoNext: Carlo Arenas
Message 4 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.