bash more commands in one function
hello
first year of learning linux and bash script Now i wrote a bash script with a function. Today i recieved a email from my teacher that 1 function only can have 1 command and no more then 1? thats a part of the script Code:
function tx_unreachable_msg() So what does this function? If the no ip service is unreachable then it's write to /etc/var/log/no-ip and after the sleep it's send a simpel mail to the adres in the variabele mail. i read here at the first line: Quote:
grts b |
It is possible to put more than one command in a function, but your teacher is trying to teach you how to write good programs. A function should have a single purpose. It should not be just a bunch of commands one after the other.
|
ok thx
so what i read in gnu.org is correct and it's possible to write more commands in one function. So saying that 1 function can only have no more than 1 functie is not correct even if he try to teach me the "good way". Before i have a class of java programming and we did this all the time to clean up or code. And it's not that i write my whole script in one function :-) i have more functions depend on the parameter that was given. The challenge was to write some functions,us a case statement and appand some parameters in the ./script.sh When i append the parameter -m for example it's only execute the mail function so writing a error to the log file and then mail the user is not so big. I will ask my teacher why he say that only one functie can be append to 1 function. grts b, |
All times are GMT -5. The time now is 01:46 AM. |