我正在寻找foo
可能包含的内容:
$ echo blah && foo && echo the sequel
blah
Do you want to continue? [y/n]: n
$ echo blah && foo && echo the sequel
blah
Do you want to continue? [y/n]: y
blah
$
答案1
标准吗? 不是。
你可以做
foo() {
local answer
while true; do
read -p "Do you wish to continue? [y/n]: " answer
case $answer in
[yY]*) return 0 ;;
[nN]*) return 1 ;;
esac
done
}