In one of my Bash scripts, there's a point where I have a variable SCRIPT
which contains the /path/to/an/exe
, and what the script ultimately needs to do, is executing that executable. Therefore the last line of the script is
$($SCRIPT)
so that $SCRIPT
is expanded to /path/to/an/exe
, and $(/path/to/an/exe)
executes the executable.
However, running shellcheck
on the script generates this error:
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...
Is there a way I can rewrite that $($SCRIPT)
in a more appropriate way? eval
does not seem to be of much help here.