Chapter 33. Scripting With Style

Get into the habit of writing shell scripts in a structured and systematic manner. Even "on-the-fly" and "written on the back of an envelope" scripts will benefit if you take a few minutes to plan and organize your thoughts before sitting down and coding.

Herewith are a few stylistic guidelines. This is not intended as an Official Shell Scripting Stylesheet.

33.1. Unofficial Shell Scripting Stylesheet

 

... reading the UNIX source code to the Bourne shell (/bin/sh). I was shocked at how much simple algorithms could be made cryptic, and therefore useless, by a poor choice of code style. I asked myself, "Could someone be proud of this code?"

 Landon Noll

Notes

[1]

In this context, " magic numbers" have an entirely different meaning than the magic numbers used to designate file types.