RosettaCodeData/Task/Comma-quibbling/UNIX-Shell/comma-quibbling-1.sh
2024-04-19 16:56:29 -07:00

15 lines
255 B
Bash

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