错误与bash的变量Linux的鞭尾/对话框参数 [英] Error with Linux whiptail/dialog arguments from bash variable
问题描述
有人能解释为什么code以下无法正常工作?我要疯了试图找出。
could someone explain why the code below doesn't work? I'm going crazy trying to find 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)
这本打印的输出,符合市场预期:
It prints this at the output, as expected:
M11线接口
对话给出了一个错误说:
'dialog' gives an error saying:
错误:预计3个参数,发现只有1
Error: Expected 3 arguments, found only 1.
鞭尾'不给任何错误,但刚刚上市退出其选项。
'whiptail' doesn't give any error but just exits listing out its options.
如果我是采取该字符串,它的印刷,复制和粘贴像这样在命令行上,它的工作原理:
If I were to take the string that it printed, copy and paste it like this on the command line, it works:
对话框--title配置模块状态--checklist选择模块激活20 50 1 M11线接口
dialog --title "Config Modules State" --checklist "Choose modules to activate" 20 50 1 M1 "1-wire Interface" ON
既对话和鞭尾。
这是怎么回事?
with both 'dialog' and 'whiptail'. What is going on?
系统:
- Linux的树莓派3.18.11+#781 preEMPT
- 鞭尾(蝾螈):0.52.14
- 对话框版本:1.1-20120215
推荐答案
从意见的答案,如果有人遇到这一点。
The answer from the comments if somebody comes across this.
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[@]}"
这篇关于错误与bash的变量Linux的鞭尾/对话框参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!