Book Image

Linux Essentials - Second Edition

By : Christine Bresnahan, Richard Blum
Book Image

Linux Essentials - Second Edition

By: Christine Bresnahan, Richard Blum

Overview of this book

Linux Essentials, Second Edition provides a solid foundation of knowledge for anyone considering a career in information technology, for anyone new to the Linux operating system, and for anyone who is preparing to sit for the Linux Essentials Exam. Through this engaging resource, you can access key information in a learning-by-doing style. Hands-on tutorials and end-of-chapter exercises and review questions lead you in both learning and applying new information—information that will help you achieve your goals! With the experience provided in this compelling reference, you can sit down for the Linux Essentials Exam with confidence. An open-source operating system, Linux is a UNIX-based platform that is freely updated by developers. The nature of its development means that Linux is a low-cost and secure alternative to other operating systems, and is used in many different IT environments. Passing the Linux Essentials Exam prepares you to apply your knowledge regarding this operating system within the workforce.
Table of Contents (19 chapters)
17
EULA

Setting the Script’s Exit Value

images

Ordinarily, a script’s return value is the same as the last command the script called; that is, the script returns $?. You can control the exit value, however, or exit from the script at any point, by using the exit command. Used without any options, exit causes immediate termination of the script, with the usual exit value of $?. This can be useful in error handling or in aborting an ongoing operation for any reason—if the script detects an error or if the user selects an option to terminate, you can call exit to quit.

If you pass a numeric value between 0 and 255 to exit, the script terminates and returns the specified value as the script’s own exit value. You can use this feature to signal errors to other scripts that might call your own script. You may have to include extra code to keep track of the causes of abnormal termination, though. For instance, you might set aside a variable (say, $termcause) to hold the cause of...