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/poem/anthology/cd.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/poem/anthology/cd.rs') 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) { -- cgit v1.2.3