有人可以解释为什么下面的代码不起作用吗?我快要发疯了。
#!/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
同时使用“对话”和“鞭尾”。 这是怎么回事?
系统:
- Linux 树莓派 3.18.11+ #781 抢占
- 鞭尾鱼(蝾螈):0.52.14
- 对话版本:1.1-20120215
最佳答案
如果有人遇到这个问题,评论中的答案。
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 - 来自 bash 变量的 Linux whiptail/dialog 参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30146241/