From e3668227c0df3aa741ac22063d5d7e7e29f2ff43 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 14 Jul 2021 18:32:22 +0800 Subject: [PATCH] Remove absolute path for files in the current directory. --- src/bin/rhai-repl.rs | 7 ++++++- src/bin/rhai-run.rs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bin/rhai-repl.rs b/src/bin/rhai-repl.rs index af322021..62dc3869 100644 --- a/src/bin/rhai-repl.rs +++ b/src/bin/rhai-repl.rs @@ -78,7 +78,12 @@ fn main() { eprintln!("Error script file path: {}\n{}", filename, err); exit(1); } - Ok(f) => f, + Ok(f) => { + match f.strip_prefix(std::env::current_dir().unwrap().canonicalize().unwrap()) { + Ok(f) => f.into(), + _ => f, + } + } }; contents.clear(); diff --git a/src/bin/rhai-run.rs b/src/bin/rhai-run.rs index e2867515..4d1749df 100644 --- a/src/bin/rhai-run.rs +++ b/src/bin/rhai-run.rs @@ -43,7 +43,11 @@ fn main() { eprintln!("Error script file path: {}\n{}", filename, err); exit(1); } - Ok(f) => f, + Ok(f) => match f.strip_prefix(std::env::current_dir().unwrap().canonicalize().unwrap()) + { + Ok(f) => f.into(), + _ => f, + }, }; let mut engine = Engine::new();