simple_macros.sh (294B)
1 #!/bin/sh 2 3 tempdir="$(mktemp -d)" 4 trap 'rm -r $tempdir' INT TERM EXIT 5 6 7 # args: name 8 greeter() { 9 printf "Hello, %s!\n" "$1" 10 } 11 12 # args: numbers a,b to add 13 adder() { 14 a="$1" 15 b="$2" 16 echo $((a+b)) > "$tempdir"/the_answer 17 } 18 19 20 greeter there 21 adder 23 19 22 23 24 rm -r "$tempdir" 25 trap - INT TERM EXIT