@@ -642,13 +642,17 @@ public int readEvalPrint(Context context, ConsoleHandler consoleHandler) {
642
642
continuePrompt = doEcho ? sys .getMember ("ps2" ).asString () : null ;
643
643
}
644
644
if (e .isIncompleteSource ()) {
645
- // read another line of input
645
+ // read more input until we get an empty line
646
646
consoleHandler .setPrompt (continuePrompt );
647
647
String additionalInput = consoleHandler .readLine ();
648
+ while (additionalInput != null && !additionalInput .isEmpty ()) {
649
+ sb .append (additionalInput ).append ('\n' );
650
+ consoleHandler .setPrompt (continuePrompt );
651
+ additionalInput = consoleHandler .readLine ();
652
+ }
648
653
if (additionalInput == null ) {
649
654
throw new EOFException ();
650
655
}
651
- sb .append (additionalInput ).append ('\n' );
652
656
// The only continuation in the while loop
653
657
continue ;
654
658
} else if (e .isExit ()) {
@@ -666,16 +670,18 @@ public int readEvalPrint(Context context, ConsoleHandler consoleHandler) {
666
670
break ;
667
671
}
668
672
} catch (EOFException e ) {
669
- try {
670
- evalInternal (context , "import site; exit()\n " );
671
- } catch (PolyglotException e2 ) {
672
- if (e2 .isExit ()) {
673
- // don't use the exit code from the PolyglotException
674
- return lastStatus ;
675
- } else if (e2 .isCancelled ()) {
676
- continue ;
673
+ if (!noSite ) {
674
+ try {
675
+ evalInternal (context , "import site; exit()\n " );
676
+ } catch (PolyglotException e2 ) {
677
+ if (e2 .isExit ()) {
678
+ // don't use the exit code from the PolyglotException
679
+ return lastStatus ;
680
+ } else if (e2 .isCancelled ()) {
681
+ continue ;
682
+ }
683
+ throw new RuntimeException ("error while calling exit" , e );
677
684
}
678
- throw new RuntimeException ("error while calling exit" , e );
679
685
}
680
686
System .out .println ();
681
687
return lastStatus ;
0 commit comments