Is it possible to do this:
case $ans1_1 in
y)fedoraDeps;;
echo "something here";;
make -j 32;;
n)echo "Continuing"...;;
;;
*) echo "Answer 'y' or 'n'";;
esac
Where fedoraDeps
is a function with yum
commands.
I'm trying to replicate this with cases:
if [[ $ans1_1 = y ]]; then
fedoraDeps
echo "something here"
make -j 32
elif [[ $ans1_1 = n ]]; then
echo "Continuing..."
:
else
echo "Answer 'y' or 'n'"
fi
;
or line feed is used to end a command. ;;
is used to end the case branch. Just don't try to end the case branch after every command, and it's fine:
case $ans1_1 in
y)
fedoraDeps
echo "something here"
make -j 32 ;;
n)
echo "Continuing"... ;;
*)
echo "Answer 'y' or 'n'" ;;
esac
Due to variations in shell behaviors I suggest using spaces before semicolons... Single ';' allow for what you want. Double ';' 'end' the case 'match', i.e.
This should work:
case $ans1_1
in
y) fedoraDeps ;
echo "something here" ;
make -j 32 ;; ## last command for case 'match'
n) echo "Continuing"... ;;
## if you want a blank line then just use one
*) echo "Answer 'y' or 'n'" ;;
esac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With