I want to call dialog
à la:
dialog --menu Choose: 0 40 10 A '' B '' C ''
except A
, B
and C
are the result of a dynamic query, for the sake of this question the latter being { echo A; echo B; echo C; }
.
I can get the desired command line seemingly by:
{ echo A; echo B; echo C; } | sed -e "s/\$/ ''/;"
but:
echo $({ echo A; echo B; echo C; } | sed -e "s/\$/ ''/;")
and its output:
A '' B '' C ''
show that the result of the command substitution is only word-split, but ''
isn't interpreted as an empty argument, but passed verbosely to echo
(and thus, dialog
wouldn't display no descriptions for the menu items, but literally ''
s).
I can work around this in bash using arrays, but is there a simpler solution I'm missing?
Given
$ e() { printf "tag: [$1] item: [$2]"; }
$ e $(echo "A ''")
$ tag: [A] item: ['']
How can I change the $(...)
part, such that the item is []
instead of ['']
.