stdin parameter of $EXEC

Anthony Vanelverdinghe anthony.vanelverdinghe at
Thu Jun 25 18:41:29 UTC 2015


Looking at the fix for JDK-8080490 ("add $EXECV command to Nashorn 
scripting mode") raised a few questions concerning the stdin parameter 
of $EXEC:

- sample exec.js [1] uses the empty string to denote "no stdin". Why 
wasn't undefined used instead?
- $EXEC("someCmd", null) actually sends "null" to the process. In my 
opinion, null should be treated the same as undefined & not send any 
input to the process.
- the implementation of $EXEC [2] always opens an OutputStreamWriter, 
even when there's no stdin. I think it would be better to move the 
if-statement out of the try-catch, like:

if (input != UNDEFINED && input != NULL) {
     try (OutputStreamWriter outputStream = new 
OutputStreamWriter(process.getOutputStream())) {
     } catch (final IOException ex) {}

What do you think?


Kind regards,

More information about the nashorn-dev mailing list