How to Write Robust, Portable POSIX Shell Scripts
A complete walkthrough writing shell scripts that run correctly under any POSIX-compliant shell — not just whichever one happens to be installed on your own development machine.
tag
5 posts
A complete walkthrough writing shell scripts that run correctly under any POSIX-compliant shell — not just whichever one happens to be installed on your own development machine.
A command in the middle of a pipeline suddenly dies with a 'Broken pipe' error, sometimes only when piped into head or a similar early-exiting command. This is a specific, well-defined signal, not a random failure.
An unquoted variable works fine in testing, then silently breaks in production the first time it holds a value with a space in it. This is the single most common category of real-world shell scripting bug.
First previewed under the codename Monad in 2003, renamed Windows PowerShell in April 2006, and finally released to the web that November — replacing decades of cmd.exe-centric scripting with a genuine object-oriented shell.
A practical tour of FreeDOS batch scripting: variables, control flow, argument handling, and the quirks that differ from a modern shell.