来自 bash 变量的 Linux whiptail/dialog 参数出错

Error with Linux whiptail/dialog arguments from bash variable

有人可以解释为什么下面的代码不起作用吗?我快要发疯了。

#!/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)

它按预期在输出中打印:

M1 "1-wire Interface" ON

'dialog' 给出错误提示:

Error: Expected 3 arguments, found only 1.

'whiptail' 没有给出任何错误,只是退出列出其选项。

如果我使用它打印的字符串,像这样复制并粘贴到命令行中,它会起作用:

dialog --title "Config Modules State" --checklist "Choose modules to activate" 20 50 1 M1 "1-wire Interface" ON

同时 'dialog' 和 'whiptail'。 这是怎么回事?

系统:

如果有人遇到这个问题,评论中的答案。

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[@]}"