Difference between revisions of "Bash, cómo hacer una pregunta y responder acorde en un script"

From Wiki de Caballero
Jump to navigation Jump to search
(Created page with "<source lang="bash> echo 'Pregunta? (s/N)' read runCommandQuestion # Next line sets default value to 'N' to avoid warnings in the if [ -z $runCommandQuestion ] && runCommandQu...")
 
(No difference)

Latest revision as of 11:40, 7 November 2019

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