小编Amr*_*Amr的帖子

关于引用 ("A"B"C") 的 ShellCheck 警告

我正在编写简单的 shell 脚本,当我在https://www.shellcheck.net检查我的脚本时,它在第 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"?
Run Code Online (Sandbox Code Playgroud)

https://github.com/koalaman/shellcheck/wiki/SC2140

事实上我不明白如何纠正它

#!/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 …
Run Code Online (Sandbox Code Playgroud)

shell-script quoting shellcheck

4
推荐指数
1
解决办法
410
查看次数

标签 统计

quoting ×1

shell-script ×1

shellcheck ×1