bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] maint.mk: Split long argument lists


From: Bruno Haible
Subject: Re: [PATCH 1/2] maint.mk: Split long argument lists
Date: Tue, 27 Nov 2018 19:40:24 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-138-generic; KDE/5.18.0; x86_64; ; )

Roman Bolshakov wrote:
>     if test -n "$$files"; then                                                
> \
>       if test -n "$$prohibit"; then                                   \
> -       grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
> +       echo "$$files" | xargs -n $(VC_ARG_MAX)                               
> \
> +         grep $$with_grep_options $(_ignore_case) -nE "$$prohibit"   \
>           | grep -vE "$${exclude:-^$$}"                                       
> \
>           && { msg="$$halt" $(_sc_say_and_exit) } || :;                       
> \

It is incorrect to transform

  grep OPTIONS FILES

to

  echo FILES | xargs -n N grep OPTIONS

because when the last chunk of FILES consists of just 1 file, 'grep'
produces different output. Instead, you need to transform it to

  echo FILES | xargs -n N grep OPTIONS /dev/null

See:

$ cd gnulib/modules

$ grep xalloc *-tests
acl-tests:xalloc
copy-file-tests:xalloc
c-xvasprintf-tests:xalloc
obstack-printf-tests:xalloc
regex-quote-tests:xalloc
userspec-tests:xalloc
xalloc-die-tests:tests/test-xalloc-die.c
xalloc-die-tests:tests/test-xalloc-die.sh
xalloc-die-tests:TESTS += test-xalloc-die.sh
xalloc-die-tests:check_PROGRAMS += test-xalloc-die
xalloc-die-tests:test_xalloc_die_LDADD = $(LDADD) @LIBINTL@

$ echo *-tests | xargs -n 1 grep xalloc
xalloc
xalloc
xalloc
xalloc
xalloc
xalloc
tests/test-xalloc-die.c
tests/test-xalloc-die.sh
TESTS += test-xalloc-die.sh
check_PROGRAMS += test-xalloc-die
test_xalloc_die_LDADD = $(LDADD) @LIBINTL@

$ echo *-tests | xargs -n 1 grep xalloc /dev/null
acl-tests:xalloc
copy-file-tests:xalloc
c-xvasprintf-tests:xalloc
obstack-printf-tests:xalloc
regex-quote-tests:xalloc
userspec-tests:xalloc
xalloc-die-tests:tests/test-xalloc-die.c
xalloc-die-tests:tests/test-xalloc-die.sh
xalloc-die-tests:TESTS += test-xalloc-die.sh
xalloc-die-tests:check_PROGRAMS += test-xalloc-die
xalloc-die-tests:test_xalloc_die_LDADD = $(LDADD) @LIBINTL@

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]