From 126f41e003ee47e06fa10bc39b4db187f3a16a5e Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Sun, 22 Mar 2020 17:06:08 -0500 Subject: [PATCH] Make `rustpython -i script.py` work like it does in CPython --- src/main.rs | 9 ++++++++- src/shell.rs | 5 ----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index da94fb26c..c4ac3b38e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -368,8 +368,15 @@ fn run_rustpython(vm: &VirtualMachine, matches: &ArgMatches) -> PyResult<()> { } else if let Some(module) = matches.value_of("m") { run_module(&vm, module)?; } else if let Some(filename) = matches.value_of("script") { - run_script(&vm, scope, filename)? + run_script(&vm, scope.clone(), filename)?; + if matches.is_present("inspect") { + shell::run_shell(&vm, scope)?; + } } else { + println!( + "Welcome to the magnificent Rust Python {} interpreter \u{1f631} \u{1f596}", + crate_version!() + ); shell::run_shell(&vm, scope)?; } diff --git a/src/shell.rs b/src/shell.rs index 7371c34ef..e3922ee88 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -41,11 +41,6 @@ fn shell_exec(vm: &VirtualMachine, source: &str, scope: Scope) -> ShellExecResul } pub fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> { - println!( - "Welcome to the magnificent Rust Python {} interpreter \u{1f631} \u{1f596}", - crate_version!() - ); - let mut repl = Readline::new(helper::ShellHelper::new(vm, scope.clone())); let mut full_input = String::new();