You can change the IFS
(internal field separator)
$ IFS=, e $(echo "a,,")
tag: [a] item: []
Seems to work. Is it nice? I do not know but would give some array magic a try. By the way, you can often use ${parameter/pattern/string}
for substitution instead of calling sed
. Unfortunately it only operates on a variable, which makes it less usable.