fix: commands on SSH hosts run under sh -c, so hosts whose login shell is csh or tcsh list, zip and send files too
This commit is contained in:
1 parent
458d826de6
commit
6d8f39f2a5
3 files changed
+29
-6
No files matched your search
+10
-2
@@ -562,6 +562,14 @@ func (u *unpacker) own(p string) {
|
||||
// shq quotes s for a POSIX shell.
|
||||
func shq(s string) string { return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'" }
|
||||
|
||||
// posix wraps a command for the host's sh: the user's login shell gets one
|
||||
// word to hand on, so fish or csh there does not matter.
|
||||
func posix(cmd string) string {
|
||||
// csh reads "!" as history even inside single quotes; '\!' is a plain
|
||||
// "!" for it and for sh alike.
|
||||
return "sh -c " + strings.ReplaceAll(shq(cmd), "!", `'\!'`)
|
||||
}
|
||||
|
||||
// shipSSH writes the tar stream into tar on the SSH host, in Dir.
|
||||
func (a *Agent) shipSSH(ctx context.Context, args proto.FSShipArgs, src string, m *shipMeter) error {
|
||||
client, _, err := a.sshConnect(ctx, *args.SSH, func(_, note string) { m.note.Store(note) })
|
||||
@@ -615,7 +623,7 @@ func (a *Agent) shipSSH(ctx context.Context, args proto.FSShipArgs, src string,
|
||||
return err
|
||||
}
|
||||
cmd := "mkdir -p -- " + shq(dir) + " && cd -- " + shq(dir) + " && tar -xf -" + flags
|
||||
if err := sess.Start(cmd); err != nil {
|
||||
if err := sess.Start(posix(cmd)); err != nil {
|
||||
return err
|
||||
}
|
||||
m.note.Store("")
|
||||
@@ -646,7 +654,7 @@ func sshRun(c *ssh.Client, cmd string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
defer s.Close()
|
||||
out, err := s.Output(cmd)
|
||||
out, err := s.Output(posix(cmd))
|
||||
var ee *ssh.ExitError
|
||||
if errors.As(err, &ee) {
|
||||
err = nil // the checks may exit non-zero; what they print is the answer
|
||||
|
||||
Reference in new issue
Block a user