bash: Correctly expanding parameters from variable for dialog -


i've been struggling expanding flags variable bash command dialog.

i have following input (reduced):

~/ $ pacmd list-sinks 2 sink(s) available.     index: 0          ...             alsa.name = "hdmi 0"             ...     index: 1          ...             alsa.name = "alc3232 analog"             ... 

i'm piping through following:

grep "alsa.name\|index" | sed "s/^[ \*\t]*//g" | sed "s/ =/:/g" | awk -f ': ' '{print $2}' | paste -s -d ' ' 

this gets me like:

0 "hdmi 0" 2 "alc3232 analog" 

now, want use these menu items dialog. ultimately, want like:

dialog --title "interface" --menu "please choose option:" $args 3 "exit"  

becomes

dialog --title "interface" --menu "please choose option:" 0 "hdmi 0" 2 "alc3232 analog" 3 "exit" 

but, when like

eval "dialog --title \"interface\" --menu \"please choose option:\" $args 3 \"exit\"" 

i get

error: expected 2 arguments, found 1. use --help list options. 

i've tried many, many approaches, all seem fail. i've tried eval approach , i've tried putting 0 "hdmi 0" 2 "alc3232 analog" array, i'm running low on ideas.

if run desired output, works great. help!

i solved own problem!

it turns out omitted few arguments dialog itself. command should have been

eval "dialog --title \"interface\" --menu \"please choose option:\" 15 50 5 $args 3 \"exit\"" 

rather than

eval "dialog --title \"interface\" --menu \"please choose option:\" $args 3 \"exit\"" 

Comments