1 Star 0 Fork 0

jevonryan / shell脚本学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
holdon.sh 570 Bytes
一键复制 编辑 原始数据 按行查看 历史
yunweinote@126.com 提交于 2019-10-25 14:33 . 添加了holdon.sh
#!/bin/bash
# 本脚本用于测试:询问等待,超时后设置为默认值
# 采用函数调用自己的方式,会存在多次输入的情况.bug
# 采用while循环的方式,能够正确使用
echo "从[1,2,3]选择"
function holdon(){
read -p "请输入你的值:" youranswer
if [ -d ${youranswer} ];then
youranswer=1
else
while [ "${youranswer}" != "1" ] && [ "${youranswer}" != "2" ] && [ "${youranswer}" != "3" ]
do
echo "请重新输入:"
read -p "请输入你的值:" youranswer
done
fi
echo "你的输入是:${youranswer}"
}
holdon
Shell
1
https://gitee.com/jevonryan/shell_scripting_learning.git
git@gitee.com:jevonryan/shell_scripting_learning.git
jevonryan
shell_scripting_learning
shell脚本学习
master

搜索帮助