mirror of
https://github.com/starship/starship.git
synced 2024-11-07 08:54:50 +01:00
feat(sudo): use sudo -N option if available
This commit is contained in:
parent
888afbed35
commit
7ea32bdf23
@ -18,7 +18,15 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let is_sudo_cached = context.exec_cmd("sudo", &["-n", "true"]).is_some();
|
||||
let mut sudo_option = "-nv";
|
||||
|
||||
/* let's check if -N option is supported */
|
||||
let is_sudo_nocreds_update = context.exec_cmd("sudo", &["-NV"]).is_some();
|
||||
if is_sudo_nocreds_update {
|
||||
sudo_option = "-Nnv"
|
||||
}
|
||||
|
||||
let is_sudo_cached = context.exec_cmd("sudo", &[sudo_option]).is_some();
|
||||
|
||||
if !is_sudo_cached {
|
||||
return None;
|
||||
|
Loading…
Reference in New Issue
Block a user