Use singular / plural form correctly.

This commit is contained in:
David Jones 2013-06-20 18:56:29 +01:00
parent 222ba59d69
commit 3062e58a75
1 changed files with 15 additions and 2 deletions

17
urchin
View File

@ -86,6 +86,18 @@ urchin_help() {
echo
}
plural () {
# Make $1 a plural according to the number $2.
# If $3 is supplied, use that instead of "${1}s".
# Result is written to stdout.
if [ "$2" = 1 ]
then
printf '%s\n' "$1"
else
printf '%s\n' "${3-${1}s}"
fi
}
urchin_go() {
echo Running tests
@ -93,8 +105,9 @@ urchin_go() {
recurse "$1" 0
echo Done
echo $(grep -e 'passed$' "$logfile"|wc -l) tests passed.
echo $(grep -e 'failed$' "$logfile"|wc -l) tests failed.
set -- $(grep -e 'passed$' "$logfile"|wc -l) $(grep -e 'failed$' "$logfile"|wc -l)
printf '%s\n' "$1 $(plural test "$1") passed."
printf '%s\n' "$2 $(plural test "$2") failed."
}
urchin_molly_guard() {