Czasami muszę poprosić użytkownika o potwierdzenie „tak / nie”.
Zwykle używam czegoś takiego:
# 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] )
echo "Aborting..."
exit 1;;
* )
echo "Please answer y or n for yes or no.";;
esac
done;
}
Czy jest na to lepszy sposób? Czy to narzędzie może już jest w moim /binfolderze?
select, ale poza tym nie widzę prostszego sposobu.