docs: public static String[] processOptions(String args[])
      {
          String usageError;
          goodUsage: for (int i = 0; ; ++i) {
              if (i == args.length) {
                  return new String[0];
              }
              String arg = args[i];
              if (!arg.startsWith("-")) {
                  processStdin = false;
                  fileList.add(arg);
                  mainModule = arg;
                  String[] result = new String[args.length - i - 1];
                  System.arraycopy(args, i+1, result, 0, args.length - i - 1);
                  return result;
              }
              if (arg.equals("-version")) {
                  if (++i == args.length) {
                      usageError = arg;
                      break goodUsage;
                  }
                  int version;
                  try {
                      version = Integer.parseInt(args[i]);
                  } catch (NumberFormatException ex) {
                      usageError = args[i];
                      break goodUsage;
                  }
                  if (!Context.isValidLanguageVersion(version)) {
                      usageError = args[i];
                      break goodUsage;
                  }
                  shellContextFactory.setLanguageVersion(version);
                  continue;
              }
              if (arg.equals("-opt") || arg.equals("-O")) {
                  if (++i == args.length) {
                      usageError = arg;
                      break goodUsage;
                  }
                  int opt;
                  try {
                      opt = Integer.parseInt(args[i]);
                  } catch (NumberFormatException ex) {
                      usageError = args[i];
                      break goodUsage;
                  }
                  if (opt == -2) {
                      // Compatibility with Cocoon Rhino fork
                      opt = -1;
                  } else if (!Context.isValidOptimizationLevel(opt)) {
                      usageError = args[i];
                      break goodUsage;
                  }
                  shellContextFactory.setOptimizationLevel(opt);
                  continue;
              }
              if (arg.equals("-encoding")) {
                  if (++i == args.length) {
                      usageError = arg;
                      break goodUsage;
                  }
                  String enc = args[i];
                  shellContextFactory.setCharacterEncoding(enc);
                  continue;
              }
              if (arg.equals("-strict")) {
                  shellContextFactory.setStrictMode(true);
                  shellContextFactory.setAllowReservedKeywords(false);
                  errorReporter.setIsReportingWarnings(true);
                  continue;
              }
              if (arg.equals("-fatal-warnings")) {
                  shellContextFactory.setWarningAsError(true);
                  continue;
              }
              if (arg.equals("-e")) {
                  processStdin = false;
                  if (++i == args.length) {
                      usageError = arg;
                      break goodUsage;
                  }
                  if (!global.initialized) {
                      global.init(shellContextFactory);
                  }
                  IProxy iproxy = new IProxy(IProxy.EVAL_INLINE_SCRIPT);
                  iproxy.scriptText = args[i];
                  shellContextFactory.call(iproxy);
                  continue;
              }
              if (arg.equals("-require")) {
                  useRequire = true;
                  continue;
              }
              if (arg.equals("-sandbox")) {
                  sandboxed = true;
                  useRequire = true;
                  continue;
              }
              if (arg.equals("-modules")) {
                  if (++i == args.length) {
                      usageError = arg;
                      break goodUsage;
                  }
                  if (modulePath == null) {
                      modulePath = new ArrayList<String>();
                  }
                  modulePath.add(args[i]);
                  useRequire = true;
                  continue;
              }
              if (arg.equals("-w")) {
                  errorReporter.setIsReportingWarnings(true);
                  continue;
              }
              if (arg.equals("-f")) {
                  processStdin = false;
                  if (++i == args.length) {
                      usageError = arg;
                      break goodUsage;
                  }
                  if (args[i].equals("-")) {
                      fileList.add(null);
                  } else {
                      fileList.add(args[i]);
                      mainModule = args[i];
                  }
                  continue;
              }
              if (arg.equals("-sealedlib")) {
                  global.setSealedStdLib(true);
                  continue;
              }
              if (arg.equals("-debug")) {
                  shellContextFactory.setGeneratingDebug(true);
                  continue;
              }
              if (arg.equals("-?") ||
                  arg.equals("-help")) {
                  // print usage message
                  global.getOut().println(
                      ToolErrorReporter.getMessage("msg.shell.usage", Main.class.getName()));
                  exitCode = 1;
                  return null;
              }
              usageError = arg;
              break goodUsage;
          }
          // print error and usage message
          global.getOut().println(
              ToolErrorReporter.getMessage("msg.shell.invalid", usageError));
          global.getOut().println(
              ToolErrorReporter.getMessage("msg.shell.usage", Main.class.getName()));
          exitCode = 1;
          return null;
      }