@@ -394,10 +394,15 @@ protected void launch(Builder contextBuilder) {
394
394
unbufferedIO = unbufferedIO || System .getenv ("PYTHONUNBUFFERED" ) != null ;
395
395
}
396
396
397
- // The unlikely separator is used because options need to be strings. See
398
- // PythonOptions.getExecutableList()
399
- contextBuilder .option ("python.ExecutableList" , String .join ("🏆" , getExecutableList ()));
400
- setContextOptionIfUnset (contextBuilder , "python.Executable" , getExecutable ());
397
+ String executable = getContextOptionIfSetViaCommandLine ("python.Executable" );
398
+ if (executable != null ) {
399
+ contextBuilder .option ("python.ExecutableList" , executable );
400
+ } else {
401
+ contextBuilder .option ("python.Executable" , getExecutable ());
402
+ // The unlikely separator is used because options need to be
403
+ // strings. See PythonOptions.getExecutableList()
404
+ contextBuilder .option ("python.ExecutableList" , String .join ("🏆" , getExecutableList ()));
405
+ }
401
406
402
407
// setting this to make sure our TopLevelExceptionHandler calls the excepthook
403
408
// to print Python exceptions
@@ -471,16 +476,21 @@ protected void launch(Builder contextBuilder) {
471
476
System .exit (rc );
472
477
}
473
478
474
- private void setContextOptionIfUnset ( Builder contextBuilder , String key , String value ) {
479
+ private String getContextOptionIfSetViaCommandLine ( String key ) {
475
480
if (System .getProperty ("polyglot." + key ) != null ) {
476
- return ;
481
+ return System . getProperty ( "polyglot." + key ) ;
477
482
}
478
483
for (String f : givenArguments ) {
479
484
if (f .startsWith ("--" + key )) {
480
- return ;
485
+ String [] splits = f .split ("=" , 2 );
486
+ if (splits .length > 1 ) {
487
+ return splits [1 ];
488
+ } else {
489
+ return "true" ;
490
+ }
481
491
}
482
492
}
483
- contextBuilder . option ( key , value ) ;
493
+ return null ;
484
494
}
485
495
486
496
private static void printFileNotFoundException (NoSuchFileException e ) {
0 commit comments