I'm trying to use a Whiptail radiolist dialog to initialise a variable in a Bash function.
The radiolist appears correctly when I use this example:
simple_radiolist() {
whiptail --title "Radiolist without variable assignment" --radiolist \
"Select:" 20 80 4 \
"a" "select a" ON \
"b" "select b" OFF
}
The selection ("a" or "b") is output to the terminal.
When I try to assign the selection to a variable as in the following example, the radiolist does not appear and the terminal freezes until I press enter, and the invisible selection ("a" or "b") is output to the terminal.
simple_radiolist() {
sel=$(whiptail --title "Radiolist with attempted variable assignment" --radiolist \
"Select:" 20 80 4 \
"a" "select a" ON \
"b" "select b" OFF)
echo $sel
}
Why doesn't the radiolist appear with the second example? How can I make it work?