You are absolutely right!
The quoting within double square brackets makes no sense at all, at least in this case.
But since I use double quotes daily -- especially for single square bracket expressions, passing arguments to functions and scripts, as well as variable assignment sometimes (which is completely useless for simple delcarations) -- I guess some people, at least I do, write double quotes around variable expansions instinctively.
Double quoting can give you a sense of savety. It is like coming home
where double quotes are. - D. Kummer
A benefit of doing double quotes consequently and comprehensibly -- but only as it makes sense -- is that coworkers who are new to bash can learn how to write more stable scripts.
It also accentuates the fact that the art of data processing with bash is more about separating data streams (including variables) by field separators and pipe them through filters. As soon as you got your data chunks separated from the stream, hold them together with double quotes!
Another benefit could be the better readability of bash scripts with double quoted strings within a code highlighting editor.
5
and3
, is maintainability. The values may change later, and the resulting errors may not be obvious. – Peter - Reinstate Monica Feb 15 '19 at 13:15[[ ]]
, only for[ ]
. – Benjamin W. Feb 15 '19 at 20:25[[ ]]
they also coerce the operands of-eq
to integers. – ilkkachu Feb 15 '19 at 23:01