Debian Codegraph @

ex6.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # Check some of the system's environmental variables.
4 # This is good preventative maintenance.
5 # If, for example, $USER, the name of the person at the console, is not set,
6 #+ the machine will not recognize you.
7
8 : ${HOSTNAME?} ${USER?} ${HOME?} ${MAIL?}
9 echoscip-shell system . . echo.
10 echoscip-shell system . . echo. "Name of the machine is $HOSTNAME."
11 echoscip-shell system . . echo. "You are $USER."
12 echoscip-shell system . . echo. "Your home directory is $HOME."
13 echoscip-shell system . . echo. "Your mail INBOX is located in $MAIL."
14 echoscip-shell system . . echo.
15 echoscip-shell system . . echo. "If you are reading this message,"
16 echoscip-shell system . . echo. "critical environmental variables have been set."
17 echoscip-shell system . . echo.
18 echoscip-shell system . . echo.
19
20 # ------------------------------------------------------
21
22 # The ${variablename?} construction can also check
23 #+ for variables set within the script.
24
25 ThisVariable=Value-of-ThisVariable
26 # Note, by the way, that string variables may be set
27 #+ to characters disallowed in their names.
28 : ${ThisVariable?}
29 echoscip-shell system . . echo. "Value of ThisVariable is $ThisVariable".
30
31 echoscip-shell system . . echo.; echoscip-shell system . . echo.
32
33
34 : ${ZZXy23AB?"ZZXy23AB has not been set."}
35 # Since ZZXy23AB has not been set,
36 #+ then the script terminates with an error message.
37
38 # You can specify the error message.
39 # : ${variablename?"ERROR MESSAGE"}
40
41
42 # Same result with: dummy_variable=${ZZXy23AB?}
43 # dummy_variable=${ZZXy23AB?"ZXy23AB has not been set."}
44 #
45 # echo ${ZZXy23AB?} >/dev/null
46
47 # Compare these methods of checking whether a variable has been set
48 #+ with "set -u" . . .
49
50
51
52 echoscip-shell system . . echo. "You will not see this message, because script already terminated."
53
54 HERE=0
55 exit $HERE # Will NOT exit here.
56
57 # In fact, this script will return an exit status (echo $?) of 1.