1 /*
2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
105 String[] result = new String[numScriptArgs];
106 System.arraycopy(args, startScriptArg, result, 0, numScriptArgs);
107 return result;
108 }
109
110 if (arg.startsWith("-D")) {
111 String value = arg.substring(2);
112 int eq = value.indexOf('=');
113 if (eq != -1) {
114 System.setProperty(value.substring(0, eq),
115 value.substring(eq + 1));
116 } else {
117 if (!value.equals("")) {
118 System.setProperty(value, "");
119 } else {
120 // do not allow empty property name
121 usage(EXIT_CMD_NO_PROPNAME);
122 }
123 }
124 continue;
125 } else if (arg.equals("-?") || arg.equals("-help")) {
126 usage(EXIT_SUCCESS);
127 } else if (arg.equals("-e")) {
128 seenScript = true;
129 if (++i == args.length)
130 usage(EXIT_CMD_NO_SCRIPT);
131
132 ScriptEngine se = getScriptEngine(currentLanguage);
133 addStringSource(se, args[i]);
134 continue;
135 } else if (arg.equals("-encoding")) {
136 if (++i == args.length)
137 usage(EXIT_CMD_NO_ENCODING);
138 currentEncoding = args[i];
139 continue;
140 } else if (arg.equals("-f")) {
141 seenScript = true;
142 if (++i == args.length)
143 usage(EXIT_CMD_NO_FILE);
144 ScriptEngine se = getScriptEngine(currentLanguage);
145 if (args[i].equals("-")) {
|
1 /*
2 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
105 String[] result = new String[numScriptArgs];
106 System.arraycopy(args, startScriptArg, result, 0, numScriptArgs);
107 return result;
108 }
109
110 if (arg.startsWith("-D")) {
111 String value = arg.substring(2);
112 int eq = value.indexOf('=');
113 if (eq != -1) {
114 System.setProperty(value.substring(0, eq),
115 value.substring(eq + 1));
116 } else {
117 if (!value.equals("")) {
118 System.setProperty(value, "");
119 } else {
120 // do not allow empty property name
121 usage(EXIT_CMD_NO_PROPNAME);
122 }
123 }
124 continue;
125 } else if (arg.equals("-?") ||
126 arg.equals("-h") ||
127 arg.equals("--help") ||
128 // -help: legacy.
129 arg.equals("-help")) {
130 usage(EXIT_SUCCESS);
131 } else if (arg.equals("-e")) {
132 seenScript = true;
133 if (++i == args.length)
134 usage(EXIT_CMD_NO_SCRIPT);
135
136 ScriptEngine se = getScriptEngine(currentLanguage);
137 addStringSource(se, args[i]);
138 continue;
139 } else if (arg.equals("-encoding")) {
140 if (++i == args.length)
141 usage(EXIT_CMD_NO_ENCODING);
142 currentEncoding = args[i];
143 continue;
144 } else if (arg.equals("-f")) {
145 seenScript = true;
146 if (++i == args.length)
147 usage(EXIT_CMD_NO_FILE);
148 ScriptEngine se = getScriptEngine(currentLanguage);
149 if (args[i].equals("-")) {
|