Whiptail 使用一种奇怪的语法来更新仪表文本。看看下面的脚本:
#!/bin/bash
{
sleep 0.5
echo -e "XXX\n0\nyum remove package_0... \nXXX"
sleep 2
echo -e "XXX\n25\nyum remove package_0... Done.\nXXX"
sleep 0.5
echo -e "XXX\n25\nyum remove package_1... \nXXX"
sleep 2
echo -e "XXX\n50\nyum remove package_1... Done.\nXXX"
sleep 0.5
echo -e "XXX\n50\nyum remove package_2... \nXXX"
sleep 2
echo -e "XXX\n75\nyum remove package_2... Done.\nXXX"
sleep 0.5
echo -e "XXX\n75\nyum remove package_3... \nXXX"
sleep 2
echo -e "XXX\n100\nyum remove package_3... Done.\nXXX"
sleep 1
} |whiptail --title "Yum Removal" --gauge "Please wait while installing" 6 60 0
这里,关键部分是echo -n "XXX\n<new percent>\n<new_gauge_text>\nXXX"
。Whiptail 使用该XXX
字符串来指示对显示的修改。