blob: 9606209b82f6605327316eac627932a86109ebd0 [file] [log] [blame]
Michael Walsh7d68d002017-05-05 16:36:54 -05001#!/bin/bash
2
3# Template to start a simple bash program. This is designed only for the
Gunnar Mills28e403b2017-10-25 16:16:38 -05004# simplest of programs where all program parameters are positional, there is no
Michael Walsh7d68d002017-05-05 16:36:54 -05005# help text, etc.
6
7# Description of argument(s):
8# parm1 Bla, bla, bla (e.g. "example data").
9
10
Michael Walsh7d68d002017-05-05 16:36:54 -050011function get_parms {
12
13 # Get program parms.
14
15 parm1="${1}" ; shift
16
17 return 0
18
19}
Michael Walsh7d68d002017-05-05 16:36:54 -050020
21
Michael Walsh7beadb22017-10-26 17:45:12 -050022function exit_function {
23
24 return
25
26}
27
Michael Walsh7d68d002017-05-05 16:36:54 -050028function validate_parms {
29
30 # Validate program parameters.
31
32 # Your validation code here.
33
34 if [ -z "${parm1}" ] ; then
35 echo "**ERROR** You must provide..." >&2
36 return 1
37 fi
38
Michael Walsh7beadb22017-10-26 17:45:12 -050039 trap "exit_function $signal \$?" EXIT
40
Michael Walsh7d68d002017-05-05 16:36:54 -050041 return 0
42
43}
Michael Walsh7d68d002017-05-05 16:36:54 -050044
45
Michael Walsh7d68d002017-05-05 16:36:54 -050046function mainf {
47
Michael Walsh7d68d002017-05-05 16:36:54 -050048 get_parms "$@" || return 1
49
50 validate_parms || return 1
51
52 # Your code here...
53
54 return 0
55
56}
Michael Walsh7d68d002017-05-05 16:36:54 -050057
58
Michael Walsh7d68d002017-05-05 16:36:54 -050059# Main
60
61 mainf "${@}"
62 rc="${?}"
63 exit "${rc}"