diff options
author | Rory Dudley | 2024-03-30 23:20:03 -0600 |
---|---|---|
committer | Rory Dudley | 2024-03-30 23:20:03 -0600 |
commit | 2534e480bf4de2101f390beded67493565913238 (patch) | |
tree | afbd0f998114e22f4f65868ef895bf4d31b9f212 /src/poem | |
parent | 90b4e0226d49f4f61300f91b6a9b1e7978bd2f9b (diff) | |
download | dwarvish-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')
-rw-r--r-- | src/poem/anthology/cd.rs | 9 |
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) { |