Skip to content

Commit 8f07d84

Browse files
committed
Don't attempt to read a token from stdin if a cmdline token is provided
1 parent 020651c commit 8f07d84

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/cargo/ops/registry/login.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ pub fn registry_login(
3535
};
3636

3737
let mut token_from_stdin = None;
38-
if !std::io::stdin().is_terminal() {
39-
let token = std::io::read_to_string(std::io::stdin()).unwrap_or_default();
40-
if !token.is_empty() {
41-
token_from_stdin = Some(token);
38+
let token = token_from_cmdline.or_else(|| {
39+
if !std::io::stdin().is_terminal() {
40+
let token = std::io::read_to_string(std::io::stdin()).unwrap_or_default();
41+
if !token.is_empty() {
42+
token_from_stdin = Some(token);
43+
}
4244
}
43-
}
44-
let token = token_from_cmdline.or_else(|| token_from_stdin.as_deref().map(Secret::from));
45+
token_from_stdin.as_deref().map(Secret::from)
46+
});
4547

4648
let options = LoginOptions {
4749
token,

0 commit comments

Comments
 (0)