# 询问 ask() { read -p "$1(y/n) >>> :" res if [ "$res" == "y" ]; then return 0 else return 1 fi } ask "是否同意" && pwd
[command1] && [command2]&&运算符会在命令command1为真时,执行命令command2,当两个命令都为真时,才会有结果输出