我是编写代码/脚本的新手,如果这是一个简单的问题,请原谅我。我搜索了网站,但找不到解决问题的答案。我正在尝试在脚本的其余部分中使用{}
,但它会回来shellcheck
。当我对其进行In Output_Test.sh line 12:
SerialOutput="$SerialOutput\n v$version $serial"
^-- SC2030: Modification of SerialOutput is local (to subshell caused by pipeline).
In Output_Test.sh line 14:
echo "{$SerialOutput}"
^-- SC2031: SerialOutput was modified in a subshell. That change might be lost.
时,它会说明以下内容
#!/bin/sh
if [ -d "/Library/Preferences/VMware Fusion/" ] ; then
result=$(grep -iH Serial /Library/Preferences/VMware\ Fusion/license* | awk '{print $2 $4}' | sed 's/"//g')
echo "$result" | while read -r a;
do
version=$(echo "$a" | cut -d "-" -f 3)
serial=$(echo "$a" | cut -d ":" -f 2 | sed 's/Serial//g')
SerialOutput="$SerialOutput\n v$version $serial"
done
else
echo "{NA}"
fi
echo "{$SerialOutput}"
任何人都可以帮助澄清我做错了什么吗?以下是相关脚本。
shift