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

From Wiki de Caballero
Revision as of 11:40, 7 November 2019 by Felipe (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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