我正在编写一个 bash 脚本,在脚本启动之前提示用户输入几个信息。我正在寻找使用对话框让用户验证信息的最佳方法。我正在尝试修改以下示例:
#!/bin/bash
# dynbox.sh - Yes/No box demo
dialog --title "Delete file" \
--backtitle "Linux Shell Script Tutorial Example" \
--yesno "Are you sure you want to permanently delete \"/tmp/foo.txt\"?" 7 60
# Get exit status
# 0 means user hit [yes] button.
# 1 means user hit [no] button.
# 255 means user hit [Esc] key.
response=$?
case $response in
0) echo "File deleted.";;
1) echo "File not deleted.";;
255) echo "[ESC] key pressed.";;
esac
我在尝试创建它时遇到了一些错误。基本上我想要一个是/否对话框来表示
Please verify your entered information:
Install SSL : $InstallSSL
Domain Name : $DomainName
etc
左侧为静态文本,右侧显示变量。
答案1
您可以在双引号字符串中包含换行符,这也会扩展变量:
dialog --title "Verification" \
--yesno "Please verify your entered information:
Install SSL : $InstallSSL
Domain Name : $DomainName" 7 60