File tree 1 file changed +12
-4
lines changed 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -591,8 +591,17 @@ fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
591
591
let stdout = io:: stdout ( ) ;
592
592
let mut stdout = stdout. lock ( ) ;
593
593
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 ( ) ;
596
605
for line in stdin. lock ( ) . lines ( ) {
597
606
let mut line = line. expect ( "line failed" ) ;
598
607
line. push ( '\n' ) ;
@@ -601,8 +610,7 @@ fn run_shell(vm: &VirtualMachine, scope: Scope) -> PyResult<()> {
601
610
ShellExecResult :: Continue => println ! ( "Unexpected EOF" ) ,
602
611
ShellExecResult :: PyErr ( exc) => print_exception ( vm, & exc) ,
603
612
}
604
- print ! ( "{}" , get_prompt( vm, "ps1" ) ) ;
605
- stdout. flush ( ) . expect ( "flush failed" ) ;
613
+ print_prompt ( ) ;
606
614
}
607
615
608
616
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments