@@ -642,13 +642,17 @@ public int readEvalPrint(Context context, ConsoleHandler consoleHandler) {
642642 continuePrompt = doEcho ? sys .getMember ("ps2" ).asString () : null ;
643643 }
644644 if (e .isIncompleteSource ()) {
645- // read another line of input
645+ // read more input until we get an empty line
646646 consoleHandler .setPrompt (continuePrompt );
647647 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+ }
648653 if (additionalInput == null ) {
649654 throw new EOFException ();
650655 }
651- sb .append (additionalInput ).append ('\n' );
652656 // The only continuation in the while loop
653657 continue ;
654658 } else if (e .isExit ()) {
@@ -666,16 +670,18 @@ public int readEvalPrint(Context context, ConsoleHandler consoleHandler) {
666670 break ;
667671 }
668672 } 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 );
677684 }
678- throw new RuntimeException ("error while calling exit" , e );
679685 }
680686 System .out .println ();
681687 return lastStatus ;
0 commit comments