samedi 17 janvier 2015

Is it possible to add a function within a function?



function update_profile
{
echo "1. Update Name"
echo "2. Update Age"
echo "3. Update Gender"
echo "Enter option: "
read option

case $option in
1) update_name ;;
2) update_age ;;
3) update_gender ;;
esac

function update_name
{
echo "Enter new name: "
read name
}
}


My code, but incomplete, just want to make sure if it's possible to do this way. I do know that i can throw all the codes into the case, but it will be messy, so I was thinking to create a stand alone function, within a function, and to be called when needed to perform it's commands.



Aucun commentaire:

Enregistrer un commentaire