Encontré esta pregunta, buscando una forma de presentar algo como:
Something interesting happened. Proceed [Y/n/q]:
Usando los ejemplos anteriores deduje esto: -
echo -n "Something interesting happened. "
DEFAULT="y"
read -e -p "Proceed [Y/n/q]:" PROCEED
# adopt the default, if 'enter' given
PROCEED="${PROCEED:-${DEFAULT}}"
# change to lower case to simplify following if
PROCEED="${PROCEED,,}"
# condition for specific letter
if [ "${PROCEED}" == "q" ] ; then
echo "Quitting"
exit
# condition for non specific letter (ie anything other than q/y)
# if you want to have the active 'y' code in the last section
elif [ "${PROCEED}" != "y" ] ; then
echo "Not Proceeding"
else
echo "Proceeding"
# do proceeding code in here
fi
Espero que ayude a alguien a no tener que pensar la lógica, si encuentran el mismo problema
input
y luego usandoname=${input:-$name}
.