如何为 bash whiptail 输入框设置默认文本?

How to set default text for bash whiptail input boxes?

我正在制作一个简单的安装程序,它使用 whiptail 提示进行用户输入。我希望能够设置默认文本。不幸的是 --default-item 不起作用,似乎只适用于菜单项。

MYLARUSER=$(whiptail --inputbox "Enter the user to run Mylar as (usually pi)" 8 78 $MYLARUSER --title "$SECTION" 3>&1 1>&2 2>&3)
exitstatus=$?; if [ $exitstatus = 1 ]; then exit 1; fi

我试过使用 echo "default" | whiptail...但它似乎没有做任何事情。

所以我的问题是我正在重用我定义的变量。这要归功于 this reddit user.

MYLARUSER=$(whiptail --inputbox "Enter the user to run Mylar as (usually pi)" 8 78 "defaulttext" --title "$SECTION" 3>&1 1>&2 2>&3)
exitstatus=$?; if [ $exitstatus = 1 ]; then exit 1; fi