Software Development Degree BTB520 Lecture Notes - Lecture 12: Teleprinter, Terminal Capabilities, Computer Terminal
Document Summary
Lecture 12 - advanced scripting - trap; functions; Terminal handling trap trap specifies action to take when a signal is detected trap "rm -f /tmp/*32417*; exit" int - action for -c trap - int. Functions function definition: function_name() { statements invoked by using name, can pass arguments. Must be defined before use, usually at the beginning of the script. Arguments replace the , , variables during function execution. return statement can be used to return a numeric value, same as exit from a script to return strings, either place in a variable, or use command substitution when invoking the function. An example, the function placing the result into a variable; notice that all variables are global: ==> cat functions. example1 add() { sum=0 for num do sum=0 done add 23 45 -17 echo . A similar example, using the return statement: