author | ddmitriev |
Wed, 21 Sep 2016 16:46:13 +0300 | |
changeset 41292 | 08bd6740b8e3 |
parent 38492 | 5b094876c96a |
permissions | -rw-r--r-- |
34731
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
1 |
/* |
35323 | 2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
34731
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
4 |
* |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
8 |
* |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
13 |
* accompanied this code). |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
14 |
* |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
18 |
* |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
21 |
* questions. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
22 |
*/ |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
23 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
24 |
/** |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
25 |
* Test that shebang handling works properly. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
26 |
* |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
27 |
* @test |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
28 |
* @option -scripting |
36689 | 29 |
* @runif os.not.windows.cmd |
34731
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
30 |
*/ |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
31 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
32 |
// The test generates three different JavaScript source files. The first two |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
33 |
// are generated at the beginning of the test and do not change. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
34 |
// * a.js |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
35 |
// print("A: " + arguments) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
36 |
// * b.js |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
37 |
// #!<path_to_jjs> -lalelu -- ignore |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
38 |
// print("B: " + arguments) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
39 |
// |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
40 |
// The third file, shebang.js, is generated differently for each particular |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
41 |
// test case, containing different shebang lines and one statement: |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
42 |
// * shebang.js |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
43 |
// #!<path_to_jjs> <shebang_line> |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
44 |
// print("S: " + arguments) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
45 |
// |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
46 |
// The path_to_jjs is extracted from the environment based on JAVA_HOME, so the |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
47 |
// latter must be set properly. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
48 |
// |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
49 |
// Each shebang.js is run four times, in all possible combinations of values |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
50 |
// from the following two axes: |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
51 |
// * without passing any arguments, and passing the arguments 'a.js' and |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
52 |
// '"hello world"' (the latter being a quoted string); |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
53 |
// * run via jjs, and via direct shell execution (using shebang). |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
54 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
55 |
var pseudosheb = "#!${jjs} -lalelu -- ignore", |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
56 |
System = Java.type('java.lang.System'), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
57 |
Paths = Java.type('java.nio.file.Paths'), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
58 |
Files = Java.type('java.nio.file.Files'), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
59 |
Opt = Java.type('java.nio.file.StandardOpenOption'), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
60 |
Arrays = Java.type('java.util.Arrays') |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
61 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
62 |
var sep = Java.type('java.io.File').separator, |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
63 |
win = System.getProperty("os.name").startsWith("Windows"), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
64 |
jjsName = "jjs" + (win ? ".exe" : ""), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
65 |
javaHome = System.getProperty("java.home") |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
66 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
67 |
var jjs = javaHome + "/../bin/".replace(/\//g, sep) + jjsName |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
68 |
if (!Files.exists(Paths.get(jjs))) { |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
69 |
jjs = javaHome + "/bin/".replace(/\//g, sep) + jjsName |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
70 |
} |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
71 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
72 |
// Create and cwd to a temporary directory. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
73 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
74 |
var tmpdir = Files.createTempDirectory(null), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
75 |
tmp = tmpdir.toAbsolutePath().toString(), |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
76 |
curpwd = $ENV.PWD |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
77 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
78 |
$ENV.PWD = tmp |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
79 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
80 |
// Test cases. Each case is documented with the expected output for the four |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
81 |
// different executions. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
82 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
83 |
var shebs = [ |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
84 |
// No arguments on the shebang line. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
85 |
// noargs jjs/shebang -> no output but "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
86 |
// args jjs/shebang -> output the arguments with "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
87 |
"", |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
88 |
// One interpreter argument. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
89 |
// noargs jjs/shebang -> no output but "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
90 |
// args jjs/shebang -> output the arguments with "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
91 |
"--language=es6", |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
92 |
// Two interpreter arguments. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
93 |
// noargs jjs/shebang -> no output but "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
94 |
// args jjs/shebang -> output the arguments with "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
95 |
"--language=es6 -scripting", |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
96 |
// One interpreter argument and a JavaScript file without shebang. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
97 |
// (For shebang execution, this is a pathological example, as the |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
98 |
// JavaScript file passed as a shebang argument will be analyzed and |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
99 |
// shebang mode will not be entered.) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
100 |
// noargs jjs -> no output but "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
101 |
// args jjs -> output the arguments with "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
102 |
// noargs shebang -> no output but "A" and "S" prefixes |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
103 |
// args shebang -> output "A", "S", and "A" prefixes, then the error |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
104 |
// message: |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
105 |
// "java.io.IOException: hello world is not a file" |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
106 |
"-scripting a.js", |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
107 |
// One interpreter argument and a JavaScript file with shebang. (This |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
108 |
// is another pathological example, as it will force shebang mode, |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
109 |
// leading to all subsequent arguments, including shebang.js, being |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
110 |
// treated as arguments to the script b.js.) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
111 |
// noargs jjs -> no output but the "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
112 |
// args jjs -> output the arguments with "S" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
113 |
// noargs shebang -> output shebang.js with "B" prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
114 |
// args shebang -> output shebang.js and the arguments with "B" |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
115 |
// prefix |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
116 |
"-scripting b.js" |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
117 |
] |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
118 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
119 |
function write(file, lines) { |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
120 |
Files.write(Paths.get(tmp, file), Arrays.asList(lines), Opt.CREATE, Opt.WRITE) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
121 |
} |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
122 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
123 |
function insn(name) { |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
124 |
return "print('${name}:' + arguments)" |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
125 |
} |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
126 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
127 |
function run(viajjs, name, arg1, arg2) { |
35323 | 128 |
var prefix = viajjs ? "${jjs} -scripting " : win ? 'sh -c "' : '', |
129 |
suffix = viajjs ? '' : win ? '"' : '' |
|
130 |
$EXEC("${prefix}./shebang.js ${arg1} ${arg2}${suffix}") |
|
34731
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
131 |
print("* ${name} via ${viajjs ? 'jjs' : 'shebang'}") |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
132 |
print($OUT.trim()) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
133 |
print($ERR.trim()) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
134 |
} |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
135 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
136 |
write('a.js', insn('A')) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
137 |
write('b.js', [pseudosheb, insn('B')]) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
138 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
139 |
shebs.forEach(function(sheb) { |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
140 |
var shebang = "#!${jjs} ${sheb}" |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
141 |
print("<<< ${sheb} >>>") |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
142 |
write('shebang.js', [shebang, insn('S')]) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
143 |
$EXEC('chmod +x shebang.js') |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
144 |
run(false, 'noargs', '', '') |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
145 |
run(true, 'noargs', '', '') |
35323 | 146 |
run(false, 'withargs', 'a.js', "'hello world'") |
147 |
run(true, 'withargs', 'a.js', "'hello world'") |
|
34731
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
148 |
$EXEC('rm shebang.js') |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
149 |
}) |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
150 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
151 |
// Cleanup. |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
152 |
|
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
153 |
$EXEC('rm a.js b.js') |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
154 |
$ENV.PWD = curpwd |
585a112b3719
8144221: fix Nashorn shebang argument handling on Mac/Linux
mhaupt
parents:
diff
changeset
|
155 |
Files.delete(tmpdir) |