Skip to content

Commit 81cf0b6

Browse files
committed
Merge branch 'ls/filter-process'
Test portability improvements and optimization for an already-graduated topic. * ls/filter-process: t0021: compute file size with a single process instead of a pipeline t0021: expect more variations in the output of uniq -c
2 parents be5a750 + ec2e8b3 commit 81cf0b6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

t/t0021-conversion.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ generate_random_characters () {
2222
}
2323

2424
file_size () {
25-
cat "$1" | wc -c | sed "s/^[ ]*//"
25+
perl -e 'print -s $ARGV[0]' "$1"
2626
}
2727

2828
filter_git () {
@@ -40,10 +40,9 @@ test_cmp_count () {
4040
actual=$2
4141
for FILE in "$expect" "$actual"
4242
do
43-
sort "$FILE" | uniq -c | sed "s/^[ ]*//" |
44-
sed "s/^\([0-9]\) IN: clean/x IN: clean/" |
45-
sed "s/^\([0-9]\) IN: smudge/x IN: smudge/" >"$FILE.tmp" &&
46-
mv "$FILE.tmp" "$FILE"
43+
sort "$FILE" | uniq -c |
44+
sed -e "s/^ *[0-9][0-9]*[ ]*IN: /x IN: /" >"$FILE.tmp" &&
45+
mv "$FILE.tmp" "$FILE" || return
4746
done &&
4847
test_cmp "$expect" "$actual"
4948
}

0 commit comments

Comments
 (0)