Skip to content

Commit 13d7d63

Browse files
committed
Process prompt correctly on redox
1 parent 0c14b9b commit 13d7d63

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,17 @@ fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
591591
let stdout = io::stdout();
592592
let mut stdout = stdout.lock();
593593

594-
print!("{}", get_prompt(vm, "ps1"));
595-
stdout.flush().expect("flush failed");
594+
let mut print_prompt = || {
595+
let prompt = get_prompt(vm, "ps1");
596+
let prompt = match prompt {
597+
Some(ref s) => s.as_str(),
598+
None => "",
599+
};
600+
print!("{}", prompt);
601+
stdout.flush().expect("flush failed");
602+
};
603+
604+
print_prompt();
596605
for line in stdin.lock().lines() {
597606
let mut line = line.expect("line failed");
598607
line.push('\n');
@@ -601,8 +610,7 @@ fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
601610
ShellExecResult::Continue => println!("Unexpected EOF"),
602611
ShellExecResult::PyErr(exc) => print_exception(vm, &exc),
603612
}
604-
print!("{}", get_prompt(vm, "ps1"));
605-
stdout.flush().expect("flush failed");
613+
print_prompt();
606614
}
607615

608616
Ok(())

0 commit comments

Comments
 (0)