Sample Header Ad - 728x90

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

4 votes
2 answers
988 views
I am writing simple shell script and when I check my script at it give me error at line 14 Line 14: sysrc ifconfig_"${Bridge}"="addm ${NIC}" ^-- SC2140: Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? In fact I didn't understand how to correct it
#!/bin/sh

Setup() {
  # Determine interface automatically
  NIC="$(ifconfig -l | awk '{print $1}')"
  # Enabling the Bridge
  Bridge="$(ifconfig bridge create)"
  # Next, add the local interface as member of the bridge.
  # for the bridge to forward packets,
  # all member interfaces and the bridge need to be up:
  ifconfig "${Bridge}" addm "${NIC}" up
  # /etc/rc.conf
  sysrc cloned_interfaces="${Bridge}"
  sysrc ifconfig_"${Bridge}"="addm ${NIC}"

  # Create bhyve startup script
  touch /usr/local/etc/rc.d/bhyve
  chmod +x /usr/local/etc/rc.d/bhyve
  cat > /usr/local/etc/rc.d/bhyve
#!/bin/sh
# PROVIDE: bhyve
# REQUIRE: DAEMON
# KEYWORD: shutdown
. /etc/rc.subr
name=bhyve
start_cmd="${name}"_start
bhyve_start() {
}
load_rc_config "${name}"
run_rc_command "$1"
EOF
  sysrc bhyve_enable="YES"
}
Asked by Amr (61 rep)
Dec 26, 2020, 10:46 PM
Last activity: Dec 27, 2020, 05:09 PM