]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] check: in recipes, don't use pipe when redirection suffices
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 22 Jul 2012 09:31:32 +0000 (11:31 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 22 Jul 2012 11:21:46 +0000 (13:21 +0200)
Instead of the botched idiom:

    while read c; do echo $c; done <file | command

use the simpler and much better one:

    command <file

Not only the latter is simpler and marginally more efficient, but is also
better at catching possible unexpected I/O errors; while in the former,
the exit status of the while loop (which might have revealed such errors)
was lost in the pipeline.

* lib/am/parallel-tests.am ($(TEST_SUITE_LOG), recheck): Use the better
idiom.

Co-authored-by: Akim Demaille <akim@lrde.epita.fr>
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
lib/am/parallel-tests.am

index 048cdfada57c239e1cf70dc841ce587897496123..39e75e700d1030445172e291c4b04f6e4822f305 100644 (file)
@@ -406,8 +406,7 @@ $(TEST_SUITE_LOG): $(am__test_logs) $(am__test_results)
          echo;                                                         \
          echo ".. contents:: :depth: 2";                               \
          echo;                                                         \
-         while read b; do echo $$b; done <$$workdir/bases              \
-           | $(am__create_global_log);                                 \
+         $(am__create_global_log) <$$workdir/bases;                    \
        } >$(TEST_SUITE_LOG).tmp; then                                  \
          mv -f $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                \
        else                                                            \
@@ -471,9 +470,8 @@ recheck: all %CHECK_DEPS%
        @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
 ## If running a "make recheck", we must only consider tests that had an
 ## unexpected outcome (FAIL or XPASS) in the earlier run.
-       @bases=`while read b; do echo $$b; done \
-                 <$(am.test-harness.workdir)/bases \
-                | $(am__list_recheck_tests)` || exit 1; \
+       @bases=`$(am__list_recheck_tests) \
+                 <$(am.test-harness.workdir)/bases` || exit 1; \
 ## Remove newlines and normalize whitespace.
        bases=`echo $$bases`; \
 ## Re-run the relevant tests, without hitting command-line length limits.