Consider the effect on your argument numbers when a variable may not be set

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2023-03-28

Imagine you have a shell script as follows:

grep $pattern 

If $pattern is not set, grep will act oddly, the same as if it is called with no arguments.

Compare to this:

grep "$pattern" 

Now grep is called with a blank string even if $pattern was never set, and the line and will work as a pass-through, returning every line.