Avoid Most Bash Errors Pretty Much By Quoting Everything, And More Best Practices

This page shows common errors that Bash programmers make. These examples are all flawed in some way.

You will save yourself from many of these pitfalls if you simply always use quotes and never use WordSplitting for any reason! Word splitting is a broken legacy misfeature inherited from the Bourne shell that’s stuck on by default if you don’t quote expansions. The vast majority of pitfalls are in some way related to unquoted expansions, and the ensuing word splitting and globbing that result.

All of us have fallen into one of these pits.

Why not use Python instead? 🙂

Oh yea, non-interactive shells 😠.

More on Quotes and Word Splitting.

Leave a Reply

Your email address will not be published. Required fields are marked *