|Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting|
|Prev||Chapter 7. Tests||Next|
The systemwide xinitrc file can be used to launch the X server. This file contains quite a number of if/then tests, as the following excerpt shows.
1 if [ -f $HOME/.Xclients ]; then 2 exec $HOME/.Xclients 3 elif [ -f /etc/X11/xinit/Xclients ]; then 4 exec /etc/X11/xinit/Xclients 5 else 6 # failsafe settings. Although we should never get here 7 # (we provide fallbacks in Xclients as well) it can't hurt. 8 xclock -geometry 100x100-5+5 & 9 xterm -geometry 80x50-50+150 & 10 if [ -f /usr/bin/netscape -a -f /usr/share/doc/HTML/index.html ]; then 11 netscape /usr/share/doc/HTML/index.html & 12 fi 13 fi
Explain the "test" constructs in the above excerpt, then examine the entire file, /etc/X11/xinit/xinitrc, and analyze the if/then test constructs there. You may need to refer ahead to the discussions of grep, sed, and regular expressions.