| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <HTML |
| 3 | ><HEAD |
| 4 | ><TITLE |
| 5 | >Testing Your Knowledge of Tests</TITLE |
| 6 | ><META |
| 7 | NAME="GENERATOR" |
| 8 | CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ |
| 9 | "><LINK |
| 10 | REL="HOME" |
| 11 | TITLE="Advanced Bash-Scripting Guide" |
| 12 | HREF="index.html"><LINK |
| 13 | REL="UP" |
| 14 | TITLE="Tests" |
| 15 | HREF="tests.html"><LINK |
| 16 | REL="PREVIOUS" |
| 17 | TITLE="Nested if/then Condition Tests" |
| 18 | HREF="nestedifthen.html"><LINK |
| 19 | REL="NEXT" |
| 20 | TITLE="Operations and Related Topics" |
| 21 | HREF="operations.html"><META |
| 22 | HTTP-EQUIV="Content-Style-Type" |
| 23 | CONTENT="text/css"><LINK |
| 24 | REL="stylesheet" |
| 25 | HREF="common/kde-common.css" |
| 26 | TYPE="text/css"><META |
| 27 | HTTP-EQUIV="Content-Type" |
| 28 | CONTENT="text/html; charset=iso-8859-1"><META |
| 29 | HTTP-EQUIV="Content-Language" |
| 30 | CONTENT="en"><LINK |
| 31 | REL="stylesheet" |
| 32 | HREF="common/kde-localised.css" |
| 33 | TYPE="text/css" |
| 34 | TITLE="KDE-English"><LINK |
| 35 | REL="stylesheet" |
| 36 | HREF="common/kde-default.css" |
| 37 | TYPE="text/css" |
| 38 | TITLE="KDE-Default"></HEAD |
| 39 | ><BODY |
| 40 | CLASS="SECT1" |
| 41 | BGCOLOR="#FFFFFF" |
| 42 | TEXT="#000000" |
| 43 | LINK="#AA0000" |
| 44 | VLINK="#AA0055" |
| 45 | ALINK="#AA0000" |
| 46 | STYLE="font-family: sans-serif;" |
| 47 | ><DIV |
| 48 | CLASS="NAVHEADER" |
| 49 | ><TABLE |
| 50 | SUMMARY="Header navigation table" |
| 51 | WIDTH="100%" |
| 52 | BORDER="0" |
| 53 | CELLPADDING="0" |
| 54 | CELLSPACING="0" |
| 55 | ><TR |
| 56 | ><TH |
| 57 | COLSPAN="3" |
| 58 | ALIGN="center" |
| 59 | >Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting</TH |
| 60 | ></TR |
| 61 | ><TR |
| 62 | ><TD |
| 63 | WIDTH="10%" |
| 64 | ALIGN="left" |
| 65 | VALIGN="bottom" |
| 66 | ><A |
| 67 | HREF="nestedifthen.html" |
| 68 | ACCESSKEY="P" |
| 69 | >Prev</A |
| 70 | ></TD |
| 71 | ><TD |
| 72 | WIDTH="80%" |
| 73 | ALIGN="center" |
| 74 | VALIGN="bottom" |
| 75 | >Chapter 7. Tests</TD |
| 76 | ><TD |
| 77 | WIDTH="10%" |
| 78 | ALIGN="right" |
| 79 | VALIGN="bottom" |
| 80 | ><A |
| 81 | HREF="operations.html" |
| 82 | ACCESSKEY="N" |
| 83 | >Next</A |
| 84 | ></TD |
| 85 | ></TR |
| 86 | ></TABLE |
| 87 | ><HR |
| 88 | ALIGN="LEFT" |
| 89 | WIDTH="100%"></DIV |
| 90 | ><DIV |
| 91 | CLASS="SECT1" |
| 92 | ><H1 |
| 93 | CLASS="SECT1" |
| 94 | ><A |
| 95 | NAME="TESTTEST" |
| 96 | ></A |
| 97 | >7.5. Testing Your Knowledge of Tests</H1 |
| 98 | ><P |
| 99 | >The systemwide <TT |
| 100 | CLASS="FILENAME" |
| 101 | >xinitrc</TT |
| 102 | > file can be used |
| 103 | to launch the X server. This file contains quite a number |
| 104 | of <I |
| 105 | CLASS="FIRSTTERM" |
| 106 | >if/then</I |
| 107 | > tests. The following |
| 108 | is excerpted from an <SPAN |
| 109 | CLASS="QUOTE" |
| 110 | >"ancient"</SPAN |
| 111 | > version of |
| 112 | <TT |
| 113 | CLASS="FILENAME" |
| 114 | >xinitrc</TT |
| 115 | > (<I |
| 116 | CLASS="FIRSTTERM" |
| 117 | >Red Hat 7.1</I |
| 118 | >, |
| 119 | or thereabouts).</P |
| 120 | ><P |
| 121 | ><TABLE |
| 122 | BORDER="0" |
| 123 | BGCOLOR="#E0E0E0" |
| 124 | WIDTH="100%" |
| 125 | ><TR |
| 126 | ><TD |
| 127 | ><PRE |
| 128 | CLASS="PROGRAMLISTING" |
| 129 | > 1 if [ -f $HOME/.Xclients ]; then |
| 130 | 2 exec $HOME/.Xclients |
| 131 | 3 elif [ -f /etc/X11/xinit/Xclients ]; then |
| 132 | 4 exec /etc/X11/xinit/Xclients |
| 133 | 5 else |
| 134 | 6 # failsafe settings. Although we should never get here |
| 135 | 7 # (we provide fallbacks in Xclients as well) it can't hurt. |
| 136 | 8 xclock -geometry 100x100-5+5 & |
| 137 | 9 xterm -geometry 80x50-50+150 & |
| 138 | 10 if [ -f /usr/bin/netscape -a -f /usr/share/doc/HTML/index.html ]; then |
| 139 | 11 netscape /usr/share/doc/HTML/index.html & |
| 140 | 12 fi |
| 141 | 13 fi</PRE |
| 142 | ></TD |
| 143 | ></TR |
| 144 | ></TABLE |
| 145 | ></P |
| 146 | ><P |
| 147 | >Explain the <I |
| 148 | CLASS="FIRSTTERM" |
| 149 | >test</I |
| 150 | > constructs in the |
| 151 | above snippet, then examine an updated version of the |
| 152 | file, <TT |
| 153 | CLASS="FILENAME" |
| 154 | >/etc/X11/xinit/xinitrc</TT |
| 155 | >, and |
| 156 | analyze the <I |
| 157 | CLASS="FIRSTTERM" |
| 158 | >if/then</I |
| 159 | > test constructs |
| 160 | there. You may need to refer ahead to the discussions of <A |
| 161 | HREF="textproc.html#GREPREF" |
| 162 | >grep</A |
| 163 | >, <A |
| 164 | HREF="sedawk.html#SEDREF" |
| 165 | >sed</A |
| 166 | >, |
| 167 | and <A |
| 168 | HREF="regexp.html#REGEXREF" |
| 169 | >regular expressions</A |
| 170 | >.</P |
| 171 | ></DIV |
| 172 | ><DIV |
| 173 | CLASS="NAVFOOTER" |
| 174 | ><HR |
| 175 | ALIGN="LEFT" |
| 176 | WIDTH="100%"><TABLE |
| 177 | SUMMARY="Footer navigation table" |
| 178 | WIDTH="100%" |
| 179 | BORDER="0" |
| 180 | CELLPADDING="0" |
| 181 | CELLSPACING="0" |
| 182 | ><TR |
| 183 | ><TD |
| 184 | WIDTH="33%" |
| 185 | ALIGN="left" |
| 186 | VALIGN="top" |
| 187 | ><A |
| 188 | HREF="nestedifthen.html" |
| 189 | ACCESSKEY="P" |
| 190 | >Prev</A |
| 191 | ></TD |
| 192 | ><TD |
| 193 | WIDTH="34%" |
| 194 | ALIGN="center" |
| 195 | VALIGN="top" |
| 196 | ><A |
| 197 | HREF="index.html" |
| 198 | ACCESSKEY="H" |
| 199 | >Home</A |
| 200 | ></TD |
| 201 | ><TD |
| 202 | WIDTH="33%" |
| 203 | ALIGN="right" |
| 204 | VALIGN="top" |
| 205 | ><A |
| 206 | HREF="operations.html" |
| 207 | ACCESSKEY="N" |
| 208 | >Next</A |
| 209 | ></TD |
| 210 | ></TR |
| 211 | ><TR |
| 212 | ><TD |
| 213 | WIDTH="33%" |
| 214 | ALIGN="left" |
| 215 | VALIGN="top" |
| 216 | >Nested <TT |
| 217 | CLASS="REPLACEABLE" |
| 218 | ><I |
| 219 | >if/then</I |
| 220 | ></TT |
| 221 | > Condition Tests</TD |
| 222 | ><TD |
| 223 | WIDTH="34%" |
| 224 | ALIGN="center" |
| 225 | VALIGN="top" |
| 226 | ><A |
| 227 | HREF="tests.html" |
| 228 | ACCESSKEY="U" |
| 229 | >Up</A |
| 230 | ></TD |
| 231 | ><TD |
| 232 | WIDTH="33%" |
| 233 | ALIGN="right" |
| 234 | VALIGN="top" |
| 235 | >Operations and Related Topics</TD |
| 236 | ></TR |
| 237 | ></TABLE |
| 238 | ></DIV |
| 239 | ></BODY |
| 240 | ></HTML |
| 241 | > |