我可以修改选择菜单项的方式吗?



当我显示带有select的菜单时,tt显示如下内容

1) Sample
2) Sample

我想把它变成

[01] Sample
[02] Sample

这可能吗?


(可能背景的原始问题)

此代码是开源的,我的朋友允许他的存储库中的任何代码都可以自由复制或编辑。

我在编辑这部分时遇到了麻烦

source /usr/local/sbin/back
_title ()
{
clear
printf "nCUSTOMIZE WS STATUSnn"
}
_msg ()
{
_title
printf "n"
read -p "Your message : " message
}
_color ()
{
_title
printf "nChoose color:nn"
select option in blue red green;
do
if [[ -n ${REPLY//[0-9]/} ]] || [[ $REPLY -lt 1 ]] || [[ $REPLY -gt 13 ]]; then
printf "nTry Again.n" && sleep 2
else
color=$option && printf "nSelected Color: %snn" "$color"
break
fi
done
}

_edit ()
{
_msg
_color
_title
cd /usr/local/bin/
for wspy in ws-ssh.py ws-stunnel.py ws-ovpn.py
do
sed -i "s|^RESPONSE =.*|RESPONSE = 'HTTP/1.1 101 <font color="${color}">${message}</font>XXXXContent-Length: 1048576000000YYYY'|" $wspy
sed -i 's|XXXX|\r\n|' $wspy
sed -i 's|YYYY|\r\n\r\n|' $wspy
done
cd ~
printf "nDone, Please restart services via MENU to take effect.nn"
return
}

_title
PS3="
Choose the number from options: "
select option in Edit Exit;
do
case $option in
Edit)
_edit
break
;;
Exit)
exit
break
;;
*)
printf "Try Again." && sleep 2
edit_ws
break
;;
esac
done

我可以修改如何选择数字的菜单项吗?

。这是不可能改变的。硬编码为)。来自https://github.com/bminor/bash/blob/master/execute_cmd.c#L3134:

#define RP_SPACE ") "

最新更新