From f4ed00f77f453b0b6db93872c4e7d35d663f8c0c Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 19 Jul 2017 21:13:34 -0400 Subject: [PATCH] updated tide-fetch to use find command instead of Dir.glob for performance. Also expands tilde now --- tide-fetch.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tide-fetch.rb b/tide-fetch.rb index 5fcfc6d..d2f864f 100755 --- a/tide-fetch.rb +++ b/tide-fetch.rb @@ -42,18 +42,13 @@ def open_with(app) spawn("#{app} #{$item}") end -def find_files(file) - if file.match(/^\.?\//) - files = [file] - else - files = Dir.glob("**/#{file}").sort_by(&:length) - end - raise RuleError.new() if files.length == 0 - files -end - def find_file(file) - find_files(file).first + file = file.gsub(/^~/, ENV["HOME"]) + if not file.match(/^\.?\//) + file = `find . -path '*#{file}' -print -quit`.chomp + end + raise RuleError.new() if (file.length == 0 || (not File.exist?(file))) + file end def mimetype(regex) -- 2.49.0