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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 25, 2021 at 11:25 PM Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Taylor Blau <me@xxxxxxxxxxxx> 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.

> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux