我已经创建了一个循环来通过一些新用户的虚拟机设置功能,它经历了像添加主机名,IP地址等东西。但是,如果我点击'取消'按钮在任何whiptail窗口中,它只是移动到循环中的下一个whiptail元素。如果选择Cancel
,我该如何设置它来取消循环并返回到主菜单窗口?Whiptail输入框取消不起作用
while true
do
OPTION=$(whiptail --title "Configuration Menu" --menu "Choose an option" 20 78 10 \
"1" "Show current configuration." \
"2" "Setup Wizard." \
...
"0" "EXIT" 3>&1 1>&2 2>&3)
exitstatus=$?
case "$OPTION" in
...
2)
# Setup hostname
HOSTNAME=$(whiptail --inputbox "Hostname" 8 78 `hostname` --title "Serial Number" 3>&1 1>&2 2>&3)
...
# IP address configuration
IP_CONFIG=$(whiptail --title "Network Configuration" --radiolist "Choose a configuration option" 20 78 10 \
"DHCP" "Use Dynamic Host Protocol" ON \
"STATIC" "Configure Static IP" OFF 3>&1 1>&2 2>&3)
...
;;
esac
我应该放置'$退出状态='试验在每种情况下选项或正下方初步'$ exitstatus'变量? – Godzilla74
'$ exitstatus'应该在下面。 –
不,它仍会前进到下一个窗口,而不是返回主菜单 – Godzilla74