CHAPTER 6Testing Variables and AssigningDefaults

Many scripts require a minimum set of input parameters or defined variables in order to run correctly. For example, they may contain customizable values used for configuration purposes, which are initially set to default values. In this chapter we'll look at various methods of testing variables and setting default values. The differences between many of these syntactical variants are subtle, but each is useful for working with undefined variables, setting variable defaults, and debugging.

All of the methods in this chapter check the state of a given variable and assign or substitute a value based on that assessment. The point here is to provide a variety of ways to perform these types of tasks. ...

Get Expert Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.