summaryrefslogtreecommitdiffstats
path: root/src/poem
diff options
context:
space:
mode:
Diffstat (limited to 'src/poem')
-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) {