在我的一个 Bash 脚本中,有一点我有一个SCRIPT
包含 的变量/path/to/an/exe
,而脚本最终需要做的是执行该可执行文件。因此脚本的最后一行是
$($SCRIPT)
所以$SCRIPT
扩展为/path/to/an/exe
, 并$(/path/to/an/exe)
执行可执行文件。
但是,shellcheck
在脚本上运行会生成此错误:
In setscreens.sh line 7:
$($SCRIPT)
^--------^ SC2091: Remove surrounding $() to avoid executing output.
For more information:
https://www.shellcheck.net/wiki/SC2091 -- Remove surrounding $() to avoid e...
$($SCRIPT)
有没有办法以更合适的方式重写它?eval
在这里似乎没有太大帮助。