From 038212c4c40c4cd9eb518fb1fbb5eb0d0d7d8f67 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Thu, 3 Nov 2016 21:12:13 +0100 Subject: [PATCH 1/2] t0021: expect more variations in the output of uniq -c Some versions of uniq -c write the count left-justified, other version write it right-justified. Be prepared for both kinds. Signed-off-by: Johannes Sixt Signed-off-by: Jeff King --- t/t0021-conversion.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index a20b9f58e3..db71acacb3 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -40,10 +40,9 @@ test_cmp_count () { actual=$2 for FILE in "$expect" "$actual" do - sort "$FILE" | uniq -c | sed "s/^[ ]*//" | - sed "s/^\([0-9]\) IN: clean/x IN: clean/" | - sed "s/^\([0-9]\) IN: smudge/x IN: smudge/" >"$FILE.tmp" && - mv "$FILE.tmp" "$FILE" + sort "$FILE" | uniq -c | + sed -e "s/^ *[0-9][0-9]*[ ]*IN: /x IN: /" >"$FILE.tmp" && + mv "$FILE.tmp" "$FILE" || return done && test_cmp "$expect" "$actual" } From ec2e8b3da21c884325c9764abc62251fcfbe6208 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 6 Nov 2016 20:31:19 +0100 Subject: [PATCH 2/2] t0021: compute file size with a single process instead of a pipeline Avoid unwanted coding patterns (prodigal use of pipelines), and in particular a useless use of cat. Signed-off-by: Johannes Sixt Signed-off-by: Jeff King --- t/t0021-conversion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index db71acacb3..cb72fa49de 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -22,7 +22,7 @@ generate_random_characters () { } file_size () { - cat "$1" | wc -c | sed "s/^[ ]*//" + perl -e 'print -s $ARGV[0]' "$1" } filter_git () {