From 526a373fd77c52a63ef6584ad42c23b89f6c5432 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 7 Mar 2018 16:05:27 +0100 Subject: [PATCH] ssh/terminal: simplify defer Directly use unix.IoctlSetTermios and windows.SetConsoleMode instead of wrapping them with a closure. Change-Id: I6309253fbb6e59e029424273b48aaa608873ea17 Reviewed-on: https://go-review.googlesource.com/99455 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- ssh/terminal/util.go | 4 +--- ssh/terminal/util_windows.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ssh/terminal/util.go b/ssh/terminal/util.go index 02dad48..731c89a 100644 --- a/ssh/terminal/util.go +++ b/ssh/terminal/util.go @@ -108,9 +108,7 @@ func ReadPassword(fd int) ([]byte, error) { return nil, err } - defer func() { - unix.IoctlSetTermios(fd, ioctlWriteTermios, termios) - }() + defer unix.IoctlSetTermios(fd, ioctlWriteTermios, termios) return readPasswordLine(passwordReader(fd)) } diff --git a/ssh/terminal/util_windows.go b/ssh/terminal/util_windows.go index 4933ac3..8618955 100644 --- a/ssh/terminal/util_windows.go +++ b/ssh/terminal/util_windows.go @@ -89,9 +89,7 @@ func ReadPassword(fd int) ([]byte, error) { return nil, err } - defer func() { - windows.SetConsoleMode(windows.Handle(fd), old) - }() + defer windows.SetConsoleMode(windows.Handle(fd), old) var h windows.Handle p, _ := windows.GetCurrentProcess()