5
是否有任何默认功能/实用程序在Bash脚本中提示用户输入是/否?
有时我需要问用户是/否来确认某些内容。 通常我使用这样的东西: # Yes/no dialog. The first argument is the message that the user will see. # If the user enters n/N, send exit 1. check_yes_no(){ while true; do read -p "$1" yn if [ "$yn" = "" ]; then yn='Y' fi case "$yn" in [Yy] ) break;; [Nn] ) …
14
command-line
bash