I'm using shfmt (a tool to tidy up bash scripts). It has a -s (simplify) option that rewrites a line like:
if [[ -n "$out" ]]
to unquoted version:
if [[ -n $out ]]
I'm actually curious if unquoting variables is safe for string-based comparisons/tests in [ and [[. In other words, is the tool rewriting the code to be any better?
I feel like there's no harm in the quoted version, it would definitely prevent splitting but I guess [ and [[ aren't really susceptible to splitting?