The dialog box displays a menu with input from a file.

In my script, I created a file that I want to use as an input source for a dialog program to populate the menu dialog.

In the file, each line contains the number and name of the menu.

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 $?
}

For each menu item for dialogue, identification is required (in my example, this is a number) and a label (between double quotes), if it is a few words.

The problem is that even if the contents of the file are in the correct format:

1 "item number 1" 2 "item number 2" ...

The dialog command does not recognize \ "as a separator of labels, but treats it as part of a line, resulting in a confused menu where I have a menu voice for each word.

( script), .

?

+3
2

, dialog:

ar=()
while read n s ; do
    ar+=($n "$s")
done < result
dialog  --menu "Latest news " 20 50 30 "${ar[@]}"

, , .

+4

- . IFS = $'\n' , .

+2

All Articles