Suppose in a Bash script, the function foo is defined as follows:

function foo {
    echo ">> $1 ..."
    echo ">> $2 ..."
}

Calling foo:

foo "" "test"

That is, foo is called with an empty string and “test” as the argument value, resulting in

> > >... >>> test ...

Now suppose I have a function, bar, which is defined as follows

function bar {
    foo $1 $2
}

And then I call bar,

bar "" "test"

Results output

>>> test ... > > >...

The reason is that the first parameter value bar accepts is an empty string, but when it passes the parameter value to foo, Bash no longer considers the parameter value to be an empty string, but instead treats it as $IFS — the field separator, So foo gets only one parameter value from bar, “test”, and treats that as its first parameter value.

In fact, not only are empty strings often troublesome, but the presence of Spaces in parameter values also makes bar behave unpredictably.

The correct definition of BAR is as follows:

function bar {
    foo "$1" "$2"
}

Therefore, when writing a Bash script, you should not hesitate to enclose it in double quotation marks if you are unsure whether the parameter values of a function are empty strings or contain Spaces. Single quotes are not possible, because Bash variables cannot be expanded inside single quotes.