首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >惠普尔尾巴以命令的形式检测连字符。

惠普尔尾巴以命令的形式检测连字符。
EN

Ask Ubuntu用户
提问于 2018-01-09 16:55:58
回答 1查看 106关注 0票数 0

我试图使用whiptail做一个检查表,但是当我输入其中一个选项时,它会检测到它是一个命令,尽管它是用引号表示的。这个清单的要点是对文件进行bash处理,并在bash期间将变量添加到shell命令的末尾,即

代码语言:javascript
复制
bash something.sh -cached_var_here

下面是代码和错误:

代码语言:javascript
复制
BENCH=$(whiptail --title "Choose Benchmark Options" --checklist "Choose:" 20 
30 15 \
 "-info" "System Information" off \
 "-io" "System I/O Test" off \
 "-cdn" "CDN Test Download (200MB)" off \
 "-northamerica" "North-American Server Test Download (800MB)" off \
 "-europe" "European Server Test Download (900MB)" off \
 "-asia" "Asian Server Test Download (400MB)" off \
 "-b" "System Information, CDN Download Test & I/O Test" off \
 "-speed" "Network Speedtest Using speedtest-cli" off \
 "-share" "Share Your Results With Others!" off \
 "-help" "Help Menu. Do NOT Execute This With Other Options!" off \
 "-about" "Show About-Info. Do NOT Execute This With Other Options!" off \
3>&1 1>&2 2>&3)

echo "You chose the following options: $BENCH"
echo

echo "Do you want to run CUSTOM benchmark and information? (y/n)? "
old_stty_cfg=$(stty -g)
stty raw -echo
answer=$( while ! head -c 1 | grep -i '[ny]' ;do true ;done )
stty $old_stty_cfg
if echo "$answer" | grep -iq "^y" ;then
  echo Yes;

  curl -LsO raw.githubusercontent.com/sayem314/serverreviewbenchmark/master/bench.sh; chmod +x bench.sh
  echo
  ./bench.sh $BENCH

我知道这个错误:

代码语言:javascript
复制
You chose the following options: -info: unknown option
EN

回答 1

Ask Ubuntu用户

发布于 2018-01-09 17:11:43

让我们参考man whiptail

whiptail将以虚线"-“开头的参数解释为参数。为了避免这种情况,并在例如菜单框项目中使用破折号开始一些文本,whiptail遵守接受特殊参数"--“的getopt约定,这意味着下面所有带有破折号的参数都将被逐字处理,而不是被解析为选项。

因此,以下方法应该像魅力一样发挥作用:

代码语言:javascript
复制
whiptail --title "Choose Benchmark Options" --checklist -- Choose: 20 30 15 -info "System Information" off
票数 4
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/993965

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档