summaryrefslogtreecommitdiffstats
path: root/src/poem/anthology
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/poem/anthology
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/poem/anthology')
-rw-r--r--src/poem/anthology/cd.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/poem/anthology/cd.rs b/src/poem/anthology/cd.rs
index 3b48f60..d3a1998 100644
--- a/src/poem/anthology/cd.rs
+++ b/src/poem/anthology/cd.rs
@@ -1,9 +1,16 @@
use crate::poem::Verse;
+use std::env;
pub fn incant(verse: &Verse) -> i32 {
let path = match verse.clause() {
Some(path) => path[0].to_string(),
- None => env!("HOME").to_string(),
+ None => match env::var("HOME") {
+ Ok(val) => val,
+ Err(_) => {
+ eprintln!("cd: unknown home, staying in pwd");
+ return 1;
+ }
+ },
};
match std::env::set_current_dir(&path) {