@@ -505,7 +505,7 @@ protected void launch(Builder contextBuilder) {
505
505
506
506
if (commandString != null || inputFile != null ) {
507
507
try {
508
- evalNonInteractive (context );
508
+ evalNonInteractive (context , consoleHandler );
509
509
rc = 0 ;
510
510
} catch (PolyglotException e ) {
511
511
if (!e .isExit ()) {
@@ -590,7 +590,11 @@ private static void printPythonLikeStackTrace(PolyglotException e) {
590
590
System .err .println (e .getMessage ());
591
591
}
592
592
593
- private void evalNonInteractive (Context context ) throws IOException {
593
+ private void evalNonInteractive (Context context , ConsoleHandler consoleHandler ) throws IOException {
594
+ // We need to setup the terminal even when not running the REPL because code may request
595
+ // input from the terminal.
596
+ setupTerminal (consoleHandler );
597
+
594
598
Source src ;
595
599
if (commandString != null ) {
596
600
src = Source .newBuilder (getLanguageId (), commandString , "<string>" ).build ();
@@ -855,6 +859,14 @@ private void setupREPL(Context context, ConsoleHandler consoleHandler) {
855
859
856
860
}
857
861
862
+ private void setupTerminal (ConsoleHandler consoleHandler ) {
863
+ consoleHandler .setupReader (() -> false , () -> 0 , (item ) -> {
864
+ }, (pos ) -> null , (pos , item ) -> {
865
+ }, (pos ) -> {
866
+ }, () -> {
867
+ }, null );
868
+ }
869
+
858
870
/**
859
871
* Some system properties have already been read at this point, so to change them, we just
860
872
* re-execute the process with the additional options.
0 commit comments