mhaupt@1819: /* mhaupt@1819: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. mhaupt@1819: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. mhaupt@1819: * mhaupt@1819: * This code is free software; you can redistribute it and/or modify it mhaupt@1819: * under the terms of the GNU General Public License version 2 only, as mhaupt@1819: * published by the Free Software Foundation. mhaupt@1819: * mhaupt@1819: * This code is distributed in the hope that it will be useful, but WITHOUT mhaupt@1819: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or mhaupt@1819: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License mhaupt@1819: * version 2 for more details (a copy is included in the LICENSE file that mhaupt@1819: * accompanied this code). mhaupt@1819: * mhaupt@1819: * You should have received a copy of the GNU General Public License version mhaupt@1819: * 2 along with this work; if not, write to the Free Software Foundation, mhaupt@1819: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. mhaupt@1819: * mhaupt@1819: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA mhaupt@1819: * or visit www.oracle.com if you need additional information or have any mhaupt@1819: * questions. mhaupt@1819: */ mhaupt@1819: mhaupt@1819: /** mhaupt@1819: * JDK-8130127: streamline input parameter of Nashorn scripting $EXEC function mhaupt@1819: * mhaupt@1819: * Test different variants of stdin passing to $EXEC. mhaupt@1819: * mhaupt@1819: * @test mhaupt@1819: * @option -scripting mhaupt@1819: * @run mhaupt@1819: */ mhaupt@1819: mhaupt@1819: var File = java.io.File, mhaupt@1819: sep = File.separator, mhaupt@1819: System = java.lang.System, mhaupt@1819: os = System.getProperty("os.name"), mhaupt@1819: win = os.startsWith("Windows"), mhaupt@1819: jjsName = "jjs" + (win ? ".exe" : ""), mhaupt@1819: javaHome = System.getProperty("java.home") mhaupt@1819: mhaupt@1819: var jjs = javaHome + "/../bin/".replace(/\//g, sep) + jjsName mhaupt@1819: if (!new File(jjs).isFile()) { mhaupt@1819: jjs = javaHome + "/bin/".replace(/\//g, sep) + jjsName mhaupt@1819: } mhaupt@1819: mhaupt@1819: var jjsCmd = jjs + " readprint.js" mhaupt@1819: mhaupt@1819: print($EXEC(jjsCmd)) mhaupt@1819: print($EXEC(jjsCmd, null)) mhaupt@1819: print($EXEC(jjsCmd, undefined)) mhaupt@1819: print($EXEC(jjsCmd, "")) mhaupt@1819: mhaupt@1819: print($EXEC(jjs, "print('hello')")) mhaupt@1819: