mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Auto merge of #12440 - arlosi:fix-token-read, r=weihanglo
Don't attempt to read a token from stdin if a cmdline token is provided Fixes #12438
This commit is contained in:
commit
336b4437a4
@ -35,13 +35,15 @@ pub fn registry_login(
|
||||
};
|
||||
|
||||
let mut token_from_stdin = None;
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user