# HG changeset patch # User sundar # Date 1376912814 -19800 # Node ID 8b2ee6bf9c628e07ad05fc412c20d544e006dc77 # Parent 9476460521b30601257e5f1f22b9a6c0b574ca27 8023210: jjs tools should support a mode where it will load few command line scripts and then entering into interactive shell Reviewed-by: hannesw, attila, lagergren, jlaskey diff -r 9476460521b3 -r 8b2ee6bf9c62 nashorn/src/jdk/nashorn/internal/runtime/options/Options.java --- a/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java Fri Aug 16 18:51:53 2013 +0200 +++ b/nashorn/src/jdk/nashorn/internal/runtime/options/Options.java Mon Aug 19 17:16:54 2013 +0530 @@ -408,13 +408,13 @@ final LinkedList argList = new LinkedList<>(); Collections.addAll(argList, args); - final String extra = getStringProperty(NASHORN_ARGS_PROPERTY, null); - if (extra != null) { - final StringTokenizer st = new StringTokenizer(extra); - while (st.hasMoreTokens()) { - argList.add(st.nextToken()); + final String extra = getStringProperty(NASHORN_ARGS_PROPERTY, null); + if (extra != null) { + final StringTokenizer st = new StringTokenizer(extra); + while (st.hasMoreTokens()) { + argList.add(st.nextToken()); + } } - } while (!argList.isEmpty()) { final String arg = argList.remove(0); @@ -431,8 +431,9 @@ continue; } - // if it doesn't start with -, it's a file - if (!arg.startsWith("-")) { + // If it doesn't start with -, it's a file. But, if it is just "-", + // then it is a file representing standard input. + if (!arg.startsWith("-") || arg.length() == 1) { files.add(arg); continue; } diff -r 9476460521b3 -r 8b2ee6bf9c62 nashorn/src/jdk/nashorn/tools/Shell.java --- a/nashorn/src/jdk/nashorn/tools/Shell.java Fri Aug 16 18:51:53 2013 +0200 +++ b/nashorn/src/jdk/nashorn/tools/Shell.java Mon Aug 19 17:16:54 2013 +0530 @@ -292,6 +292,14 @@ // For each file on the command line. for (final String fileName : files) { + if ("-".equals(fileName)) { + final int res = readEvalPrint(context, global); + if (res != SUCCESS) { + return res; + } + continue; + } + final File file = new File(fileName); final ScriptFunction script = context.compileScript(new Source(fileName, file.toURI().toURL()), global); if (script == null || errors.getNumberOfErrors() != 0) {