1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

whoami: Run tests on Windows

This commit is contained in:
Jan Verbeek 2021-09-14 12:25:17 +02:00
parent 4555c85564
commit 0a3785bf84
2 changed files with 6 additions and 6 deletions

View file

@ -3,7 +3,6 @@
// * For the full copyright and license information, please view the LICENSE // * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code. // * file that was distributed with this source code.
#[cfg(unix)]
use crate::common::util::*; use crate::common::util::*;
#[test] #[test]
@ -34,7 +33,6 @@ fn test_normal_compare_id() {
} }
#[test] #[test]
#[cfg(unix)]
fn test_normal_compare_env() { fn test_normal_compare_env() {
let whoami = whoami(); let whoami = whoami();
if whoami == "nobody" { if whoami == "nobody" {

View file

@ -1069,7 +1069,9 @@ pub fn whoami() -> String {
// Use environment variable to get current user instead of // Use environment variable to get current user instead of
// invoking `whoami` and fall back to user "nobody" on error. // invoking `whoami` and fall back to user "nobody" on error.
std::env::var("USER").unwrap_or_else(|e| { std::env::var("USER")
.or_else(|_| std::env::var("USERNAME"))
.unwrap_or_else(|e| {
println!("{}: {}, using \"nobody\" instead", UUTILS_WARNING, e); println!("{}: {}, using \"nobody\" instead", UUTILS_WARNING, e);
"nobody".to_string() "nobody".to_string()
}) })