termmode.go: Added nil check in term.Restore() for nonexistent cp filename

Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
Russ Magee 2019-04-05 19:10:38 -07:00
parent 306ea64299
commit a53ec4ac2d
2 changed files with 8 additions and 3 deletions

View File

@ -298,7 +298,7 @@ func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *hkexsh.S
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
exitStatus = uint32(status.ExitStatus()) exitStatus = uint32(status.ExitStatus())
fmt.Print(stdErrBuffer) fmt.Print(stdErrBuffer)
fmt.Printf("Exit Status: %d\n", exitStatus) //# //fmt.Printf("Exit Status: %d\n", exitStatus) //#
} }
} }
} }
@ -367,7 +367,7 @@ func doCopyMode(conn *hkexnet.Conn, remoteDest bool, files string, rec *hkexsh.S
// an ExitStatus() method with the same signature. // an ExitStatus() method with the same signature.
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok { if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
exitStatus = uint32(status.ExitStatus()) exitStatus = uint32(status.ExitStatus())
log.Printf("Exit Status: %d", exitStatus) //log.Printf("Exit Status: %d", exitStatus)
} }
} }
} }

View File

@ -3,6 +3,7 @@
package hkexsh package hkexsh
import ( import (
"errors"
"io" "io"
unix "golang.org/x/sys/unix" unix "golang.org/x/sys/unix"
@ -67,7 +68,11 @@ func GetState(fd int) (*State, error) {
// Restore restores the terminal connected to the given file descriptor to a // Restore restores the terminal connected to the given file descriptor to a
// previous state. // previous state.
func Restore(fd int, state *State) error { func Restore(fd int, state *State) error {
if state != nil {
return unix.IoctlSetTermios(fd, ioctlWriteTermios, &state.termios) return unix.IoctlSetTermios(fd, ioctlWriteTermios, &state.termios)
} else {
return errors.New("nil State")
}
} }
// ReadPassword reads a line of input from a terminal without local echo. This // ReadPassword reads a line of input from a terminal without local echo. This