- # the sed converts spaces to commas, but leaves the last space
- # alone, so the line doesn't end with a comma.
- echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
+ # echo is used to convert newlines to spaces, since it doesn't
+ # introduce a trailing space as using "tr '\n' ' '" does
+ echo $(tr -s " " "\n" <<< $* | sort -b -u) | tr ' ' ','