I'm a bash newbie. Say I have this script:#!/bin/bashfunction cpp-lang {  yum install Development Tools  }function updatesys { yum -y update yum -y upgrade}     whiptail --checklist test 5 40 5\                Update Update the system on \                C++ Install C++ off 2>results while read choice do      case $choice in        Update )updatesys         ;;        C++)cpp-lang         ;;         *)         ;;         esac         done < resultsWhen I run it, it exits, should I return something from the function? Considering the script above as an example, should I run sudo every time I call yum install or is doing sudo ./script.shenough?
Questions about whiptail and bash functions
bash;shell script;centos;whiptail
Basically (the second question of course regarding the way sudo should be used most effectively), it's a matter of judgement:In the script there are three calls to yum.  If the script tested at the beginning whether it is running as root and sudo'd to run itself, that would make a simpler script.On the other hand, some people might comment that running exclusively as root makes it less safe to test the interactive part (in case you continued to develop and expand the script, including specifying the package names directly).  My own inclination would be to provide a command-line option to let the script be tested, and just show (or log) the corresponding commands that would be run.For instance:what happens if whiptail is not installed?if $choice is not a word, it might help to quote it in the case statement.what happens if yum reports an error (does the user see that, or is there another call to whiptail later)?