AndyM
AndyM

Reputation: 622

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

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?

Upvotes: 3

Views: 1464

Answers (1)

Toby Speight
Toby Speight

Reputation: 30831

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"

Upvotes: 5

Related Questions