作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试收集用户在鱼壳脚本中的输入,尤其是以下常见形式的用户输入:
This command will delete some files. Proceed (y/N)?
最佳答案
我所知道的最好方法是使用内置的read
。如果您在多个地方使用此功能,则可以创建此帮助程序功能:
function read_confirm
while true
read -l -P 'Do you want to continue? [y/N] ' confirm
switch $confirm
case Y y
return 0
case '' N n
return 1
end
end
end
if read_confirm
echo 'Do stuff'
end
关于user-input - 如何在 fish shell 中获得用户确认?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16407530/
我是一名优秀的程序员,十分优秀!