You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Line 4:
foo --bang=$bar
^-- SC2086: Double quote to prevent globbing and word splitting.
Here's what I wanted or expected to see:
Line 5 should similarly trigger, as it is also subject to word splitting. By contrast line 6 (correctly) does not trigger because the inner expansion is properly quoted. This has the effect of only passing an argument to foo if $bar is set, and otherwise no arguments are passed.
As @eatnumber1 notes below, line 7 is also safe because the entire expansion is quoted, but will result in an empty-string argument being passed to foo, which isn't necessarily desirable.
The text was updated successfully, but these errors were encountered:
Worth noting that ShellCheck does the right thing (no warnings) if the entire expansion is quoted. E.g. the following produce no warnings and each printf correctly prints foo bar with no line breaks.
For bugs
shellcheck --version
or "online"):Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
Here's what I wanted or expected to see:
Line 5 should similarly trigger, as it is also subject to word splitting. By contrast line 6 (correctly) does not trigger because the inner expansion is properly quoted. This has the effect of only passing an argument to
foo
if$bar
is set, and otherwise no arguments are passed.As @eatnumber1 notes below, line 7 is also safe because the entire expansion is quoted, but will result in an empty-string argument being passed to
foo
, which isn't necessarily desirable.The text was updated successfully, but these errors were encountered: