Getting ready

This recipe might be introducing some readers to a concept they would like to avoid: software engineering. It's true, you are probably writing scripts to quickly get a task completed, but if your script is to be used by other people (or for a long time), its great to catch errors early when they occur and prevent program misbehaviour.

Even without formal computer science or engineering training, the idea of use cases is based on having any particular piece of functionality, with X input, and seeing whether Y does as expected. Sometimes, limits or ranges can be imposed, an action may complete or fail, and any results compared can conclude whether the "use case" passes or fails.

Let's look at a step by step example using a program ...

Get Bash Cookbook 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.