docs: public void cmdProc(Interp interp, TclObject argv[])
      throws TclException {
          int currentObjIndex, len, i;
          int objc = argv.length - 1;
          boolean doBackslashes = true;
          boolean doCmds = true;
          boolean doVars = true;
          StringBuffer result = new StringBuffer();
          String s;
          char c;
  
          for (currentObjIndex = 1; currentObjIndex < objc; currentObjIndex++) {
              if (!argv[currentObjIndex].toString().startsWith("-")) {
                  break;
              }
              int opt = TclIndex.get(interp, argv[currentObjIndex],
                              validCmds, "switch", 0);
              switch (opt) {
                  case OPT_NOBACKSLASHES:
                      doBackslashes = false;
                      break;
                  case OPT_NOCOMMANDS:
                      doCmds = false;
                      break;
                  case OPT_NOVARS:
                      doVars = false;
                      break;
                  default:
                      throw new TclException(interp,
                                      "SubstCrCmd.cmdProc: bad option " + opt
                                      + " index to cmds");
              }
          }
          if (currentObjIndex != objc) {
              throw new TclNumArgsException(interp, currentObjIndex, argv,
                              "?-nobackslashes? ?-nocommands? ?-novariables? string");
          }
  
          /*
           * Scan through the string one character at a time, performing
           * command, variable, and backslash substitutions.
           */
  
          s = argv[currentObjIndex].toString();
          len = s.length();
          i = 0;
          while (i < len) {
              c = s.charAt(i);
  
              if ((c == '[') && doCmds) {
                  ParseResult res;
                  try {
                      interp.evalFlags = Parser.TCL_BRACKET_TERM;
                      interp.eval(s.substring(i + 1, len));
                      TclObject interp_result = interp.getResult();
                      interp_result.preserve();
                      res = new ParseResult(interp_result,
                                      i + interp.termOffset);
                  } catch (TclException e) {
                      i = e.errIndex + 1;
                      throw e;
                  }
                  i = res.nextIndex + 2;
                  result.append( res.value.toString() );
                  res.release();
                  /**
                   * Removed
                   (ToDo) may not be portable on Mac
                  } else if (c == '\r') {
                     i++;
                   */
              } else if ((c == '$') && doVars) {
                  ParseResult vres = Parser.parseVar(interp,
                                  s.substring(i, len));
                  i += vres.nextIndex;
                  result.append( vres.value.toString() );
                  vres.release();
              } else if ((c == '\\') && doBackslashes) {
                  BackSlashResult bs = Interp.backslash(s, i, len);
                  i = bs.nextIndex;
                  if (bs.isWordSep) {
                      break;
                  } else {
                      result.append( bs.c );
                  }
              } else {
                  result.append( c );
                  i++;
              }
          }
  
          interp.setResult(result.toString());
      }