Skip to content

Commit

Permalink
sunos grep/find
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud9 user committed Feb 23, 2011
1 parent f526849 commit a293e8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/DAV/plugins/codesearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ for (type in jsDAV_Codesearch_Plugin.IGNORE_DIRS) {
dirs = Util.makeUnique(dirs);
jsDAV_Codesearch_Plugin.PATTERN_DIR = Util.escapeRegExp(dirs.join("|"));
jsDAV_Codesearch_Plugin.PATTERN_EDIR = dirs.join(",");
jsDAV_Codesearch_Plugin.GREP_CMD = "grep";

(function() {
this.initialize = function() {
Expand Down Expand Up @@ -144,7 +145,7 @@ jsDAV_Codesearch_Plugin.PATTERN_EDIR = dirs.join(",");
};

this.doCodesearch = function(node, options, cbsearch) {
var cmd = "grep -P -s -r --color=never --binary-files=without-match -n",
var cmd = jsDAV_Codesearch_Plugin.GREP_CMD + " -P -s -r --color=never --binary-files=without-match -n",
file = this.handler.server.tmpDir + "/" + Util.uuid(),
_self = this;
if (!Util.isTrue(options.casesensitive))
Expand All @@ -165,6 +166,7 @@ jsDAV_Codesearch_Plugin.PATTERN_EDIR = dirs.join(",");
var out = "",
err = "",
grep = Spawn("/bin/bash", ["-c", cmd]);

grep.stdout.setEncoding("utf8");
grep.stderr.setEncoding("utf8");
grep.stdout.on("data", function(data) {
Expand Down
6 changes: 5 additions & 1 deletion lib/DAV/plugins/filesearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function jsDAV_Filesearch_Plugin(handler) {
this.initialize();
}

jsDAV_Filesearch_Plugin.FIND_CMD = "find";

(function() {
this.initialize = function() {
this.handler.addEventListener("report", this.httpReportHandler.bind(this));
Expand Down Expand Up @@ -64,12 +66,14 @@ function jsDAV_Filesearch_Plugin(handler) {
var args,
_self = this;
if (process.platform == "darwin") {
// BSD find
args = ["-L", "-E", node.path, "-type", "f", "(", "-iname",
options.query + "*", "-a", "!", "-regex",
".*(" + jsDAV_Codesearch_Plugin.PATTERN_DIR + ").*", ")",
"-print"];
}
else {
// GNU find
args = ["-L", node.path, "-type", "f", "-iname", options.query + "*",
"-a", "!", "-regex", ".*(" + jsDAV_Codesearch_Plugin.PATTERN_DIR + ").*",
"-regextype", "posix-extended", "-print"];
Expand All @@ -78,7 +82,7 @@ function jsDAV_Filesearch_Plugin(handler) {
console.log("search command: find " + args.join(" "));
var err = "",
out = "",
find = Spawn("find", args);
find = Spawn(jsDAV_Filesearch_Plugin.FIND_CMD, args);
find.stdout.on("data", function(data) {
if (!Util.empty(data))
out += data;
Expand Down

0 comments on commit a293e8b

Please sign in to comment.