mirror of
https://github.com/starship/starship.git
synced 2024-11-22 00:04:05 +01:00
fix(username): avoid using whoami
on android
Closes #6340 Co-Authored-By: AminurAlam <64137875+aminuralam@users.noreply.github.com>
This commit is contained in:
parent
eaccc512f2
commit
abad5e3de2
@ -19,13 +19,13 @@ const USERNAME_ENV_VAR: &str = "USERNAME";
|
||||
/// Does not display the username:
|
||||
/// - If the option `username.detect_env_vars` is set with a negated environment variable [A]
|
||||
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
#[cfg(not(test))]
|
||||
#[cfg(not(any(test, target_os = "android")))]
|
||||
let mut username = whoami::fallible::username()
|
||||
.inspect_err(|e| log::debug!("Failed to get username {e:?}"))
|
||||
.ok()
|
||||
.or_else(|| context.get_env(USERNAME_ENV_VAR))?;
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(any(test, target_os = "android"))]
|
||||
let mut username = context.get_env(USERNAME_ENV_VAR)?;
|
||||
|
||||
let mut module = context.new_module("username");
|
||||
|
Loading…
Reference in New Issue
Block a user