【发布时间】:2020-12-18 21:00:36
【问题描述】:
在我的一个 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 在这里似乎没有太大帮助。
【问题讨论】:
标签: bash command-substitution indirection shellcheck multiple-indirection