fix: improve exit codes for agent/agentssh and cli/ssh (#10850)

This commit is contained in:
Mathias Fredriksson
2023-11-24 14:35:56 +02:00
committed by GitHub
parent dbdcad0d09
commit 61be4dfe5a
4 changed files with 78 additions and 8 deletions
+6 -1
View File
@@ -379,11 +379,16 @@ func (r *RootCmd) ssh() *clibase.Cmd {
err = sshSession.Wait()
if err != nil {
if exitErr := (&gossh.ExitError{}); errors.As(err, &exitErr) {
// Clear the error since it's not useful beyond
// reporting status.
return ExitError(exitErr.ExitStatus(), nil)
}
// If the connection drops unexpectedly, we get an
// ExitMissingError but no other error details, so try to at
// least give the user a better message
if errors.Is(err, &gossh.ExitMissingError{}) {
return xerrors.New("SSH connection ended unexpectedly")
return ExitError(255, xerrors.New("SSH connection ended unexpectedly"))
}
return xerrors.Errorf("session ended: %w", err)
}