Program: 42387
Project: 42387
Buggy source:
List<XValue> expand(String arg){
  if (arg.startsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    r.add(new XValue(arg.substring(1,arg.length() - 1)));
    return r;
  }
  if (arg.startsWith("String_Node_Str") && arg.endsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    r.add(new XValue(parseXExpr(arg.substring(2,arg.length() - 2))));
    return r;
  }
  if (arg.startsWith("String_Node_Str") && arg.endsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    r.add(new XValue(parseXCmd(arg.substring(3,arg.length() - 1))));
    return r;
  }
  if (arg.startsWith("String_Node_Str") && arg.endsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    for (    String w : runCmd(arg.substring(2,arg.length() - 1)).split("String_Node_Str"))     r.add(new XValue(w));
    return r;
  }
  boolean bQuoted=false;
  if (arg.startsWith("String_Node_Str")) {
    bQuoted=true;
    arg=arg.substring(1,arg.length() - 1);
  }
  Result result=new Result(bQuoted);
  char c;
  int i;
  for (i=0; i < arg.length(); i++) {
    c=arg.charAt(i);
    if (c == '\\') {
      if (i < arg.length())       result.append(arg.charAt(++i));
      continue;
    }
    if (c == '$') {
      if (++i == arg.length())       break;
      StringBuffer sbv=new StringBuffer();
      if (arg.charAt(i) == '{') {
        i=readToMatching(arg,i,sbv,'}');
      }
 else {
        c=arg.charAt(i);
        if (c == '?' || c == '@' || c == '$' || c == '#' || c == '*' || Character.isDigit(c)) {
          boolean bKeepGoing;
          do {
            bKeepGoing=false;
            sbv.append(c);
            if (Character.isDigit(c)) {
              if (i < arg.length() - 1 && Character.isDigit(c=arg.charAt(i + 1))) {
                i++;
                bKeepGoing=true;
              }
            }
          }
 while (bKeepGoing);
        }
 else {
          for (; i < arg.length(); i++) {
            c=arg.charAt(i);
            if (Util.isIdentifier(c))             sbv.append(c);
 else {
              i--;
              break;
            }
          }
        }
      }
      String var=sbv.toString();
      if (!Util.isBlank(var)) {
        XValue value=null;
        if (var.equals("String_Node_Str")) {
          result.add(mArgs);
        }
 else         value=extractSingle(var);
        if (value != null)         result.append(value);
      }
    }
 else     result.append(c);
  }
  result.flush();
  if (bQuoted)   return result.getResult();
  ArrayList<XValue> result2=new ArrayList<XValue>();
  for (  XValue v : result.getResult()) {
    List<XValue> r=expandWild(v);
    if (r != null)     result2.addAll(r);
  }
  return result2;
}

Fixed version (ground truth):
List<XValue> expand(String arg) throws IOException {
  if (arg.startsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    r.add(new XValue(arg.substring(1,arg.length() - 1)));
    return r;
  }
  if (arg.startsWith("String_Node_Str") && arg.endsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    r.add(new XValue(parseXExpr(arg.substring(2,arg.length() - 2))));
    return r;
  }
  if (arg.startsWith("String_Node_Str") && arg.endsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    r.add(new XValue(parseXCmd(arg.substring(3,arg.length() - 1))));
    return r;
  }
  if (arg.startsWith("String_Node_Str") && arg.endsWith("String_Node_Str")) {
    List<XValue> r=new ArrayList<XValue>(1);
    for (    String w : runCmd(arg.substring(2,arg.length() - 1)).split("String_Node_Str"))     r.add(new XValue(w));
    return r;
  }
  boolean bQuoted=false;
  if (arg.startsWith("String_Node_Str")) {
    bQuoted=true;
    arg=arg.substring(1,arg.length() - 1);
  }
  Result result=new Result(bQuoted);
  char c;
  int i;
  for (i=0; i < arg.length(); i++) {
    c=arg.charAt(i);
    if (c == '\\') {
      if (i < arg.length())       result.append(arg.charAt(++i));
      continue;
    }
    if (c == '$') {
      if (++i == arg.length())       break;
      StringBuffer sbv=new StringBuffer();
      if (arg.charAt(i) == '{') {
        i=readToMatching(arg,i,sbv,'}');
      }
 else {
        c=arg.charAt(i);
        if (c == '?' || c == '@' || c == '$' || c == '#' || c == '*' || Character.isDigit(c)) {
          boolean bKeepGoing;
          do {
            bKeepGoing=false;
            sbv.append(c);
            if (Character.isDigit(c)) {
              if (i < arg.length() - 1 && Character.isDigit(c=arg.charAt(i + 1))) {
                i++;
                bKeepGoing=true;
              }
            }
          }
 while (bKeepGoing);
        }
 else {
          for (; i < arg.length(); i++) {
            c=arg.charAt(i);
            if (Util.isIdentifier(c))             sbv.append(c);
 else {
              i--;
              break;
            }
          }
        }
      }
      String var=sbv.toString();
      if (!Util.isBlank(var)) {
        XValue value=null;
        if (var.equals("String_Node_Str")) {
          result.add(mArgs);
        }
 else         value=extractSingle(var);
        if (value != null)         result.append(value);
      }
    }
 else     result.append(c);
  }
  result.flush();
  if (bQuoted)   return result.getResult();
  ArrayList<XValue> result2=new ArrayList<XValue>();
  for (  XValue v : result.getResult()) {
    List<XValue> r=expandWild(v);
    if (r != null)     result2.addAll(r);
  }
  return result2;
}