Serious Shell Programming
There are many shells in the world, some sold by a seashore, but in Serious Shell Programming you will learn about the Linux/UNIX shell used by programmers, system administrators, and scripters the world-over to harness the power of the command-line.
The command-line is the primary interface, presented to Linux/UNIX administrators when they log into the console, that displays a prompt and takes typed commands to execute. Commonly abbreviated as CLI, the command-line interface is implemented as a program to take orders from the human operator. The name given to any program implementing a CLI is the shell.
Some shells can be scripted to avoid repetition by the human controller. However, not all shells speak the same dialect and not all shells are available on all Linux/UNIX systems. For example, writing a script that uses the Z shell (zsh) may not be compatible with your friends system which lacks zsh. These are known as portability issues and choosing your shell carefully can improve portability to multiple Operating Systems.
All currently-maintained UNIX/Linux Operating Systems provide a shell at
/bin/sh. Despite the amalgam of different versions out there, every shell found at
/bin/sh must implement at-minimum the POSIX standard. The implementation of which strictly defines the base functionality that must be present for programmers. While shell maintainers are free to add features that go above and beyond the POSIX standard, targeting the core POSIX functionality allows maintainers to present you with a common interface, portable to many similar environments.
/bin/sh is often a version of the Bourne Again Shell (bash) while on FreeBSD and many versions of UNIX
/bin/sh does not support the higher-level features of bash.
Writing code that targets the baseline POSIX features of
/bin/sh maximizes portability and usually is done with a specific purpose in-mind. Code that runs in a restricted environment with few dependencies, for example, can benefit from using strict POSIX
/bin/sh code in the event more capable languages such as Python or Perl may not be available.
The techniques in this book will help you create shell scripts that are compatible with FreeBSD, NetBSD, Solaris, and Linux including RedHat, CentOS, Ubuntu, and many more. Specifically avoided are unportable techniques, especially those that only work on systems that use bash installed to