In my script i created a file that i want to use as an input source for dialog program, in order to populate the menu dialog.
In the file every line contain a number and a menu title.
INPUT=""
rm result
while read LINE
do
case $LINE in
'/ >'*|---*|'/ > '*)
continue;;
esac
# echo "1 $LINE "
echo -n " 1 \"$LINE\"" >>result
done < tmpfile
#printf "%s " $INPUT
DIALOG --menu "Latest news " 20 50 30 `cat result`
DIALOG is a function, and this is the source:
DIALOG () {
dialog --backtitle "$TITLE" "$@"
return $?
}
Every menu item for dialog need an identifie (in my example is the number) and a label (between double quotes “, if it is more than one word).
The problem is that even if the file content has the correct format:
1 "item number 1" 2 "item number 2" ...
The dialog command doesn’t recognize the \” as a label delimiter, but it consider it as a part of the string, resulting in a messed up menu, where i have a menu voice for every word.
but if i try to copy and pastethe same file content directly into the shell command (not using a script), the menu is showed correctly.
Any idea?
You can use an array to keep the results, then use proper quoting to send it to
dialog:You probably do not have to create a temp file at all, you can populate the array right ahead.