RosettaCodeData/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-2.sh

16 lines
263 B
Bash

quibble() {
printf '{'
while [ $# -gt 2 ]; do
printf '%s, ' "$1"
shift
done
if [ $# -gt 0 ]; then
printf '%s' "$1"
shift
fi
if [ $# -gt 0 ]; then
printf ' and %s' "$1"
fi
printf '%s\n' '}'
}