Am 17.10.2016 um 01:20 schrieb larsxschneider@xxxxxxxxx: > +# Compare two files and ensure that `clean` and `smudge` respectively are > +# called at least once if specified in the `expect` file. The actual > +# invocation count is not relevant because their number can vary. > +# c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxx/ > +test_cmp_count () { > + expect=$1 > + 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" && This is not sufficiently portable. Some versions of uniq write the count left-adjusted, not right-adjusted. How about this on top: diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index a20b9f58e3..f60858c517 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" } -- Hannes