February 2001
Beginner to intermediate
448 pages
9h 2m
English
The ultimate bulletproofing of a script comes by combining many of the thoughts presented in this chapter. The goal is to make the script impervious to any kind of input the user might throw at it (or that it might read from a file). This special-case “what-if” code can be so detailed and cumbersome to write that it takes up more lines in your script than the main production logic flow. Therefore, I suggest that you implement these ideas in your nonpersonal scripts.
The following example shows an example of bulletproofing.
$ cat gcdksh #! /bin/ksh function gcd { # Function to generate gcd between two numbers integer u v r u=$1 v=$2 while ((v)) # Key gcd loop do r=u%v u=v v=r done print $u # Returns value to caller of function ...Read now
Unlock full access