q = q ? ();
(
q.grep = {|pattern="JITLib", where = "Help", includes(["rtf", "html", "scd"])|
var p, l;
var str;
var includesList;
var resultList = List();
includes.isString.if({
includes = [includes]
});
includesList = includes.collect{|name| " --include=*.% ".format(name)}.join;
str = "cd %; grep -r % \"%\" -l *"
.format(where, includesList, pattern);
p = Pipe.new(str, "r"); // list directory contents in long format
l = p.getLine; // get the first line
while({l.notNil}, {resultList.add(l); l = p.getLine; }); // post until l = nil
p.close; // close the pipe to avoid that nasty buildup
resultList
}
)
// grep for "spawn" in quarks directory
q[\grep].("spawn", "~/Library/Application\\ Support/SuperCollider/quarks".standardizePath, "html").printAll; ""
// grep for "spawn" in all helpfiles
q[\grep].("spawn", "Help").printAll; ""
contributions:
- LFSaw.de
- AdC
in early spring '07