From 2534e480bf4de2101f390beded67493565913238 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Sat, 30 Mar 2024 23:20:03 -0600 Subject: Replace env!("HOME") with env::var("HOME") Replaced all (non-test) instances of env!("HOME") with env::var("HOME"). The env! macro should only be used in instances where the environment variable should be resolved during compile time. --- src/compose.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/compose.rs') diff --git a/src/compose.rs b/src/compose.rs index 3d2a2db..c90f470 100644 --- a/src/compose.rs +++ b/src/compose.rs @@ -1,6 +1,7 @@ use crate::poem::{read::Readable, recite::Reciteable, Poem}; pub mod environment; pub use environment::Environment; +use std::env; use std::fs; use std::path::PathBuf; @@ -18,8 +19,17 @@ pub fn env() -> Environment { }; // User defined rc file in ~ - let mut local_rc = PathBuf::from(env!("HOME")); - local_rc.push(".dwvshrc"); + let local_rc = match env::var("HOME") { + Ok(val) => { + let mut rc = PathBuf::from(val); + rc.push(".dwvshrc"); + rc + } + Err(_) => { + eprintln!("dwvsh: unknown home, falling back to /etc"); + PathBuf::from(&global_rc) + } + }; // Read, read, and recite rrr(global_rc, &mut env); -- cgit v1.2.3