This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.
Last Updated: 2024-11-21
Imagine you have a shell script as follows:
pattern=$1
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.