Read the POSIX standard
Thursday, February 16th, 2012
Stop reading your local manual pages when programming/scripting stuff, and use the POSIX standard instead:
There are four main parts:
- The Base Definitions (XBD): The basics of a POSIX-compliant system.
- The System Interfaces (XSH): What POSIX-compliant systems offer to programs. I.e. programming in C (stdlib)
- The Shell & Utilities (XCU): How a POSIX-compliant shell and system utilities behave.
- The Rationale (XRAT): Why they decided to do things the way they did.
Some Do's and Dont's:
- Read the Shell Command Language section so you know how the shell actually works. Surprisingly many shell scripters apparently have no idea how the shell really works, and get results through trial and error (which inevitably leads to buggy shell scripts.)
- Write POSIX Basic Regular Expressions
- Write POSIX Extended Regular Expressions if you really must
- Don't use or overwrite POSIX Environment reserved words when using variables.
- Use Shell & Utilities → Utilities as a reference guide on what will work on just about every Unix system.
Finally, read Bash Pitfalls to learn why your shell scripting sucks.