format errors

This commit is contained in:
sawka 2022-09-15 00:37:17 -07:00
parent c600027d72
commit fcc1737fc4

View File

@ -520,7 +520,11 @@ func (msh *MShellProc) writeToPtyBuffer_nolock(strFmt string, args ...interface{
if !strings.HasSuffix(realStr, "\r\n") { if !strings.HasSuffix(realStr, "\r\n") {
realStr = realStr + "\r\n" realStr = realStr + "\r\n"
} }
realStr = "\033[0m\033[32m[scripthaus]\033[0m " + realStr if strings.HasPrefix(realStr, "*") {
realStr = "\033[0m\033[31m[scripthaus]\033[0m " + realStr[1:]
} else {
realStr = "\033[0m\033[32m[scripthaus]\033[0m " + realStr
}
barr := msh.PtyBuffer.Bytes() barr := msh.PtyBuffer.Bytes()
if len(barr) > 0 && barr[len(barr)-1] != '\n' { if len(barr) > 0 && barr[len(barr)-1] != '\n' {
realStr = "\r\n" + realStr realStr = "\r\n" + realStr
@ -552,14 +556,14 @@ func (msh *MShellProc) Launch() {
msh.WriteToPtyBuffer("cannot launch archived remote\n") msh.WriteToPtyBuffer("cannot launch archived remote\n")
return return
} }
msh.WriteToPtyBuffer("connecting to %s...\n", remoteCopy.GetName()) msh.WriteToPtyBuffer("connecting to %s...\n", remoteCopy.RemoteCanonicalName)
sshOpts := convertSSHOpts(remoteCopy.SSHOpts) sshOpts := convertSSHOpts(remoteCopy.SSHOpts)
sshOpts.SSHErrorsToTty = true sshOpts.SSHErrorsToTty = true
ecmd := sshOpts.MakeSSHExecCmd(MShellServerCommand) ecmd := sshOpts.MakeSSHExecCmd(MShellServerCommand)
cmdPty, err := msh.addControllingTty(ecmd) cmdPty, err := msh.addControllingTty(ecmd)
if err != nil { if err != nil {
statusErr := fmt.Errorf("cannot attach controlling tty to mshell command: %w", err) statusErr := fmt.Errorf("cannot attach controlling tty to mshell command: %w", err)
msh.WriteToPtyBuffer("error, %s\n", statusErr.Error()) msh.WriteToPtyBuffer("*error, %s\n", statusErr.Error())
msh.setErrorStatus(statusErr) msh.setErrorStatus(statusErr)
return return
} }
@ -576,7 +580,7 @@ func (msh *MShellProc) Launch() {
break break
} }
if readErr != nil { if readErr != nil {
msh.WriteToPtyBuffer("error reading from controlling-pty: %v\n", readErr) msh.WriteToPtyBuffer("*error reading from controlling-pty: %v\n", readErr)
break break
} }
msh.WithLock(func() { msh.WithLock(func() {
@ -600,7 +604,7 @@ func (msh *MShellProc) Launch() {
}) })
if err != nil { if err != nil {
msh.setErrorStatus(err) msh.setErrorStatus(err)
msh.WriteToPtyBuffer("error connecting to remote (uname=%q): %v\n", msh.UName, err) msh.WriteToPtyBuffer("*error connecting to remote (uname=%q): %v\n", msh.UName, err)
return return
} }
msh.WriteToPtyBuffer("connected\n") msh.WriteToPtyBuffer("connected\n")
@ -618,7 +622,7 @@ func (msh *MShellProc) Launch() {
go msh.NotifyRemoteUpdate() go msh.NotifyRemoteUpdate()
} }
}) })
msh.WriteToPtyBuffer("disconnected exitcode=%d\n", exitCode) msh.WriteToPtyBuffer("*disconnected exitcode=%d\n", exitCode)
}() }()
go msh.ProcessPackets() go msh.ProcessPackets()
return return