From 8f07d84404dae405f6bca96dc5645e65057e2989 Mon Sep 17 00:00:00 2001 From: Arlo Siemsen Date: Wed, 2 Aug 2023 18:37:40 -0500 Subject: [PATCH] Don't attempt to read a token from stdin if a cmdline token is provided --- src/cargo/ops/registry/login.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/registry/login.rs b/src/cargo/ops/registry/login.rs index 3128ef98520..49f65da7855 100644 --- a/src/cargo/ops/registry/login.rs +++ b/src/cargo/ops/registry/login.rs @@ -35,13 +35,15 @@ pub fn registry_login( }; let mut token_from_stdin = None; - if !std::io::stdin().is_terminal() { - let token = std::io::read_to_string(std::io::stdin()).unwrap_or_default(); - if !token.is_empty() { - token_from_stdin = Some(token); + let token = token_from_cmdline.or_else(|| { + if !std::io::stdin().is_terminal() { + let token = std::io::read_to_string(std::io::stdin()).unwrap_or_default(); + if !token.is_empty() { + token_from_stdin = Some(token); + } } - } - let token = token_from_cmdline.or_else(|| token_from_stdin.as_deref().map(Secret::from)); + token_from_stdin.as_deref().map(Secret::from) + }); let options = LoginOptions { token,