about summary refs log tree commit diff
path: root/library/std/src/sys/pal
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2025-05-31 21:51:33 +0000
committerChris Denton <chris@chrisdenton.dev>2025-05-31 21:55:26 +0000
commit921b6c02aa01b40b9dfea318f4ae7ec1a9811499 (patch)
tree337e38b1c671cf5a6ed8520f895954456a32e78c /library/std/src/sys/pal
parent4d08223c054cf5a56d9761ca925fd46ffebe7115 (diff)
If HOME is empty, use the fallback instead
Diffstat (limited to 'library/std/src/sys/pal')
-rw-r--r--library/std/src/sys/pal/unix/os.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs
index 48609030aed..633cb299736 100644
--- a/library/std/src/sys/pal/unix/os.rs
+++ b/library/std/src/sys/pal/unix/os.rs
@@ -633,7 +633,10 @@ pub fn temp_dir() -> PathBuf {
 }
 
 pub fn home_dir() -> Option<PathBuf> {
-    return crate::env::var_os("HOME").or_else(|| unsafe { fallback() }).map(PathBuf::from);
+    return crate::env::var_os("HOME")
+        .filter(|s| !s.is_empty())
+        .or_else(|| unsafe { fallback() })
+        .map(PathBuf::from);
 
     #[cfg(any(
         target_os = "android",