summaryrefslogtreecommitdiffstats
path: root/src/compose.rs
diff options
context:
space:
mode:
authorRory Dudley2024-03-30 23:20:03 -0600
committerRory Dudley2024-03-30 23:20:03 -0600
commit2534e480bf4de2101f390beded67493565913238 (patch)
treeafbd0f998114e22f4f65868ef895bf4d31b9f212 /src/compose.rs
parent90b4e0226d49f4f61300f91b6a9b1e7978bd2f9b (diff)
downloaddwarvish-2534e480bf4de2101f390beded67493565913238.tar.gz
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.
Diffstat (limited to 'src/compose.rs')
-rw-r--r--src/compose.rs14
1 files changed, 12 insertions, 2 deletions
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);