From e55c4802304eab76a956b4319283f28ba8cb95c6 Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Sun, 6 Oct 2019 17:02:12 -0500 Subject: Fix find for OSX --- nimterop/build.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nimterop/build.nim b/nimterop/build.nim index ce76914..c14bdaf 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -264,8 +264,10 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex = cmd = when defined(windows): "nimgrep --filenames --oneline --nocolor $1 $2 $3" - else: + elif defined(linux): "find $3 $1 -regextype egrep -regex $2" + elif defined(osx): + "find -E $3 $1 -regex $2" recursive = "" -- cgit v1.2.3 From 5f13dbe2026c5966d82f3222a1b925dc9573ed37 Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Sun, 6 Oct 2019 19:47:45 -0700 Subject: Fix windows findFile --- nimterop/build.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nimterop/build.nim b/nimterop/build.nim index c14bdaf..37fe932 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -263,7 +263,7 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex = var cmd = when defined(windows): - "nimgrep --filenames --oneline --nocolor $1 $2 $3" + "nimgrep --filenames --nocolor $1 $2 $3" elif defined(linux): "find $3 $1 -regextype egrep -regex $2" elif defined(osx): @@ -283,7 +283,7 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex = dir = dir / file.parentDir() file = file.extractFilename - cmd = cmd % [recursive, (".*[\\/]" & file & "$").quoteShell, dir.sanitizePath] + cmd = cmd % [recursive, (".*[\\\\/]" & file & "$").quoteShell, dir.sanitizePath] let (files, ret) = gorgeEx(cmd) @@ -291,14 +291,14 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex = for line in files.splitLines(): let f = when defined(windows): - if ":" in line: - line.split(":", maxsplit = 1)[0] + if line.len != 0 and line[0] != ' ' and line[^7 .. ^1] != "matches": + line else: "" else: line - if (f.len != 0 and result.len == 0 or result.len > f.len): + if (f.len != 0 and (result.len == 0 or result.len > f.len)): result = f if first: break -- cgit v1.2.3 From 3f8cfa32197bf1da41758fd8e303233c19ecc1e0 Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Sun, 6 Oct 2019 20:24:44 -0700 Subject: Fix findFile --- nimterop/build.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nimterop/build.nim b/nimterop/build.nim index 37fe932..bcbd96a 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -263,7 +263,7 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex = var cmd = when defined(windows): - "nimgrep --filenames --nocolor $1 $2 $3" + "nimgrep --filenames --oneline --nocolor $1 $2 $3" elif defined(linux): "find $3 $1 -regextype egrep -regex $2" elif defined(osx): @@ -291,8 +291,8 @@ proc findFile*(file: string, dir: string, recurse = true, first = false, regex = for line in files.splitLines(): let f = when defined(windows): - if line.len != 0 and line[0] != ' ' and line[^7 .. ^1] != "matches": - line + if ": " in line: + line.split(": ", maxsplit = 1)[1] else: "" else: -- cgit v1.2.3