From 4253b883391e0fd4f485698894822c4a47f610a6 Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Tue, 10 Dec 2019 00:45:56 +0000 Subject: [PATCH] Don't print an error message on shell exit. If a shell has been successfully started, don't print an error message saying the shell failed to start if it exits with exit code other than 0. If an error occured during shell execution or the shell will print the message itself and exit with an error. --- lib/srv/exec.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/srv/exec.go b/lib/srv/exec.go index d088dfeb822a..48eb3e592d2d 100644 --- a/lib/srv/exec.go +++ b/lib/srv/exec.go @@ -409,9 +409,13 @@ func RunCommand() { errorAndExit(errorWriter, teleport.RemoteCommandFailure, err) } - // Wait for it to exit. + // Wait for the command to exit. It doesn't make sense to print an error + // message here because the shell has successfully started. If an error + // occured during shell execution or the shell exits with an error (like + // running exit 2), the shell will print an error if appropriate and return + // an exit code. err = cmd.Wait() - errorAndExit(errorWriter, exitCode(err), err) + os.Exit(exitCode(err)) } func (e *localExec) transformSecureCopy() error {