ShellCheck warning: "Remove surrounding $() to avoid executing output. [SC2091]"

1.3k Views Asked by At

I have the following set of commands in my script:

message="Secure copying file $remoteHost"
backupLogOutput "Info $message"
$(scp  "$file" "$remoteUser"@"$remoteHost":"$remotePath")  >> "$BACKUPLOG"
backupErrorHandler "$?" "$message"

ShellCheck is giving me the warning on the scp line (3):

Remove surrounding $() to avoid executing output. [SC2091]

The script works. I do want to execute the output. Shall I ignore this warning or should the scp line be written in a different way?

1

There are 1 best solutions below

0
On BEST ANSWER

I don't think you actually do want to execute what scp outputs - it looks more like you simply want to copy a file:

scp  "$file" "$remoteUser"@"$remoteHost":"$remotePath"  >> "$BACKUPLOG"