Bash, cómo hacer una pregunta y responder acorde en un script

From Wiki de Caballero
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
echo 'Pregunta? (s/N)'
read runCommandQuestion
# Next line sets default value to 'N' to avoid warnings in the if
[ -z $runCommandQuestion ] && runCommandQuestion=N
if [ $runCommandQuestion == "y" ] || [ $runCommandQuestion == "Y" ]
    then
        runCommand=y;
    else
        echo 'Doing nothing...'
        exit 1
fi