Error with whiptail / dialog linux arguments from bash variable

can someone explain why the code below is not working? I'm losing my mind trying to figure this out.

#!/bin/bash

TEST="M1 \"1-wire Interface\" ON"
echo $TEST
RESULT=$(dialog --title "Config Modules State" --checklist "Choose modules to activate" 20 50 1 $TEST)

He prints this in the output, as expected:

M1 "1-wire interface" ON

'dialog' gives an error message:

Error: expected 3 arguments, only 1 found.

'whiptail' does not give any error, but simply leaves the list of its options.

If I took the line that she printed, copy and paste it the same way as on the command line, it works:

dialog --title "Status of configuration modules" --checklist "Select the modules to activate" 20 50 1 M1 "1-wire interface" ON

with "dialogue" and "whiptail". What's happening?

System:

  • Linux raspberrypi 3.18.11+ # 781 PREEMPT
  • whiptail (newt): 0.52.14
  • : 1.1-20120215
+4
1

, - .

TEST=(M1 '1-wire Interface' ON)
TEST=( "${TEST[@]}" M2 'Other Interface' OFF )
echo ${TEST[@]}
dialog --title "Config Modules State" --checklist "Choose modules to activate" 20 50 2 "${TEST[@]}"
0

All Articles