]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t0021: expect more variations in the output of uniq -c
authorJohannes Sixt <j6t@kdbg.org>
Thu, 3 Nov 2016 20:12:13 +0000 (21:12 +0100)
committerJeff King <peff@peff.net>
Tue, 8 Nov 2016 20:26:40 +0000 (15:26 -0500)
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 <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
t/t0021-conversion.sh

index a20b9f58e3fe1de2932046d5d7f692b45e3ac854..db71acacb39121663b6dee03bcf13c46e0b11b24 100755 (executable)
@@ -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"
 }