t0090: be prepared that 'wc -l' writes leading blanks
authorJohannes Sixt <j6t@kdbg.org>
Tue, 20 Dec 2011 08:24:21 +0000 (09:24 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Dec 2011 19:15:16 +0000 (11:15 -0800)
Use 'printf %d $(whatever|wc -l)' so that the shell removes the blanks
for us.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Acked-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0090-cache-tree.sh

index f97256292e9f7d3f6cc69e790284382e09584921..6c33e28ee8df4d239dd6d1c1d98c324b01c70ed3 100755 (executable)
@@ -17,15 +17,13 @@ cmp_cache_tree () {
 # test-dump-cache-tree already verifies that all existing data is
 # correct.
 test_shallow_cache_tree () {
-       echo "SHA " \
-           "($(git ls-files|wc -l) entries, 0 subtrees)" >expect &&
+       printf "SHA  (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >expect &&
        cmp_cache_tree expect
 }
 
 test_invalid_cache_tree () {
        echo "invalid                                   (0 subtrees)" >expect &&
-       echo "SHA #(ref) " \
-           "($(git ls-files|wc -l) entries, 0 subtrees)" >>expect &&
+       printf "SHA #(ref)  (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >>expect &&
        cmp_cache_tree expect
 }