wmiirc-rumai

git clone git://oldgit.suckless.org/wmiirc-rumai/
Log | Files | Refs | README | LICENSE

commit db940109449380c28cf17a66ab5921a7fa717635
parent fc13d7da0d4ea5d3d34e8b5137198be647a3249e
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Fri, 18 May 2007 15:04:17 -0700

import borior's impl of find_programs()

Diffstat:
wmiirc | 19+++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/wmiirc b/wmiirc @@ -84,20 +84,15 @@ begin end - require 'find' + require 'pathname' # Returns the names of programs present in the given directories. - def find_programs aDirs - aDirs = aDirs.map {|p| File.expand_path p} - names = [] - - Find.find(*aDirs) do |f| - if File.file? f and File.executable? f - names << File.basename(f) - end - end - - names.uniq.sort + def find_programs *aDirs + aDirs.flatten.map do |d| + Pathname.new(d).expand_path.children rescue [] + end.flatten.map do |f| + f.basename.to_s if f.file? and f.executable? + end.compact.uniq.sort end # terminate existing instances of this program