Args returns args except "ssh" itself combined with optional additional command and args to be executed on the remote host. It attempts to quote the given arguments to account for ssh executing the remote command in a shell. It returns nil when unable to quote the remote command.
(remoteCommandAndArgs ...string)
| 83 | // the given arguments to account for ssh executing the remote command in a |
| 84 | // shell. It returns nil when unable to quote the remote command. |
| 85 | func (sp *Spec) Args(remoteCommandAndArgs ...string) []string { |
| 86 | // Format the remote command to run using the ssh connection, quoting |
| 87 | // values where needed because ssh executes these in a POSIX shell. |
| 88 | remoteCommand, err := quoteCommand(remoteCommandAndArgs...) |
| 89 | if err != nil { |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | sshArgs, err := sp.args() |
| 94 | if err != nil { |
| 95 | return nil |
| 96 | } |
| 97 | if remoteCommand != "" { |
| 98 | sshArgs = append(sshArgs, remoteCommand) |
| 99 | } |
| 100 | return sshArgs |
| 101 | } |
| 102 | |
| 103 | func (sp *Spec) args(sshFlags ...string) ([]string, error) { |
| 104 | var args []string |