ShellCheck warning regarding quoting ("A"B"C")

The single string

ifconfig_"${Bridge}"="addm ${NIC}"

is the same as

"ifconfig_$Bridge=addm $NIC"

(the curly braces aren't needed and the whole string can be quoted by a single set of double quotes)

Since you used double quotes to quote two separate parts of the same string, ShellCheck wondered whether you possibly meant for the "inner pair" of quotes to be literal and actually part of the string, i.e. whether you meant to write fconfig_"${Bridge}\"=\"addm ${NIC}".

Since you didn't, it would be better to rewrite the string as I showed before, just to make it clear that it's one single string with no embedded quotes.

Note that you have made no error in your code with regard to the quoting here, and that ShellCheck is simply inquiring about your intention because this is (arguably) a common error when you do want literal double quotes inside a string.

If you feel strongly about your way of quoting the string, then you may disable the ShellCheck warning with a directive in a comment before the affected line:

# shellcheck disable=SC2140
sysrc ifconfig_"${Bridge}"="addm ${NIC}"

This basically means "I know what I'm doing and rule SC2140 does not apply here, thank you very much."


If you follow the suggested explanation link for SC2140, you get this text,

Problematic code:

echo "<img src="foo.png" />" > file.html

or

export "var"="42"

Correct code:

echo "<img src=\"foo.png\" />" > file.html

or

export "var=42"

Look at the second example - it's almost identical structure to your code

sysrc ifconfig_"${Bridge}"="addm ${NIC}"

What you're being told is to check whether the double quotes are supposed to be part of the string, or if you've simply got extra ones you don't need. In your case it's the second option, and this line should probably be better written as

sysrc "ifconfig_${Bridge}=addm ${NIC}"