mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
whoami: Run tests on Windows
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
|
||||
#[cfg(unix)]
|
||||
use crate::common::util::*;
|
||||
|
||||
#[test]
|
||||
@@ -34,7 +33,6 @@ fn test_normal_compare_id() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_normal_compare_env() {
|
||||
let whoami = whoami();
|
||||
if whoami == "nobody" {
|
||||
|
||||
@@ -1069,10 +1069,12 @@ pub fn whoami() -> String {
|
||||
|
||||
// Use environment variable to get current user instead of
|
||||
// invoking `whoami` and fall back to user "nobody" on error.
|
||||
std::env::var("USER").unwrap_or_else(|e| {
|
||||
println!("{}: {}, using \"nobody\" instead", UUTILS_WARNING, e);
|
||||
"nobody".to_string()
|
||||
})
|
||||
std::env::var("USER")
|
||||
.or_else(|_| std::env::var("USERNAME"))
|
||||
.unwrap_or_else(|e| {
|
||||
println!("{}: {}, using \"nobody\" instead", UUTILS_WARNING, e);
|
||||
"nobody".to_string()
|
||||
})
|
||||
}
|
||||
|
||||
/// Add prefix 'g' for `util_name` if not on linux
|
||||
|
||||
Reference in New Issue
Block a user