Using bash, in the case
esac
structure, are double quotes necessary in $expression
:
case "$expression" in
...
esac
or not:
case $expression in
...
esac
?
Using bash, in the case
esac
structure, are double quotes necessary in $expression
:
case "$expression" in
...
esac
or not:
case $expression in
...
esac
?
Share Improve this question edited Mar 4 at 14:08 Mario Palumbo asked Mar 4 at 14:00 Mario PalumboMario Palumbo 1,0351 gold badge16 silver badges37 bronze badges 3 |1 Answer
Reset to default 5No, quotes are generally not necessary.
According to the manual (see Conditional Constructs):
The word undergoes tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal (see Shell Parameter Expansion) before matching is attempted.
Since pathname expansion and word splitting are not applied to word, the typical function of quotes to suppress those behaviors is redundant. The only potential benefit of quotes is to suppress tilde expansion.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745039683a4607736.html
$expression
contains spaces or special characters. In general, they are recommended because future changes to$expression
will still make the statement work. – Wiimm Commented Mar 4 at 20:16