From 58be47dc9af1bf54eaccacc5e8fd7936d4e7d1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Wed, 29 Jan 2025 16:31:17 -0700 Subject: [PATCH] Filename fixes The previous PR wasn't rebased, so it failed to compile, this PR fixes it. --- crates/shell/src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/shell/src/main.rs b/crates/shell/src/main.rs index c981d11..565c812 100644 --- a/crates/shell/src/main.rs +++ b/crates/shell/src/main.rs @@ -186,10 +186,13 @@ async fn main() -> miette::Result<()> { if options.file.is_some() || options.command.is_some() { let script_text; + let filename: Option; if options.file.is_some() { - script_text = std::fs::read_to_string(options.file.unwrap()).unwrap(); + script_text = std::fs::read_to_string(options.file.clone().unwrap()).unwrap(); + filename = Some(options.file.unwrap().display().to_string()); } else if options.command.is_some() { script_text = options.command.unwrap(); + filename = None; } else { panic!(); } @@ -198,7 +201,7 @@ async fn main() -> miette::Result<()> { debug_parse(&script_text); return Ok(()); } - let exit_code = execute(&script_text, Some(file.display().to_string()), &mut state).await?; + let exit_code = execute(&script_text, filename, &mut state).await?; if options.interact { interactive(Some(state), options.norc).await?; }