0

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?

  • Thank you, and sorry I missed the solution at https://stackoverflow.com/questions/1970180/whiptail-how-to-redirect-output-to-environment-variable (your comment has disappeared and I thought I should post the link so others can find it). – Ivo Treszka Feb 25 '23 at 10:02

0 Answers0