Skip to content

Commit 3d8b495

Browse files
committed
cli/command: PromptUserForCredentials: print error on terminal restore fail
If restoring the terminal state fails, "echo" no longer works, which means that anything the user types is no longer shown. The login itself may already have succeeded, so we should not fail the command, but it's good to inform the user that this happened, which may give them a clue why things no longer work as they expect them to work. With this patch: docker login -u yourname Password: Error: failed to restore terminal state to echo input: something bad happened Login Succeeded We should consider printing instructions how to restore this manually (other than restarting the shell). e.g., 'run stty echo' when in a Linux or macOS shell, but PowerShell and CMD.exe may need different instructions. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent a21a5f4 commit 3d8b495

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cli/command/registry.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,15 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
161161
if err != nil {
162162
return registrytypes.AuthConfig{}, err
163163
}
164-
defer restoreInput()
164+
defer func() {
165+
if err := restoreInput(); err != nil {
166+
// TODO(thaJeztah): we should consider printing instructions how
167+
// to restore this manually (other than restarting the shell).
168+
// e.g., 'run stty echo' when in a Linux or macOS shell, but
169+
// PowerShell and CMD.exe may need different instructions.
170+
_, _ = fmt.Fprintln(cli.Err(), "Error: failed to restore terminal state to echo input:", err)
171+
}
172+
}()
165173

166174
argPassword, err = PromptForInput(ctx, cli.In(), cli.Out(), "Password: ")
167175
if err != nil {

0 commit comments

Comments
 (0)