Re: [PATCH] lib/mkmf.rb: have_bin()/find_bin()

From: Sean Chittenden <sean@...>
Date: 2002-08-14 18:11:06 UTC
List: ruby-core #323
> |Looks fine to me, but I wonder if both are necessary, have_bin
> |seems to work good enough even if it were an alias of find_bin.
> 
> I feel like "bin" in have_bin and find_bin (BTW, why both?) is better
> to be replaced by "executable".

executable works for me, I can update the patch.  The reason for both
was to keep inline with the style of having both find and have.  I
suppose you could alias them.  Anyway, I've included a slightly
updated patch that allows a user to specify a path.  If adding an
alias is important for API's sake, it's very possible to do.  :~) -sc

-- 
Sean Chittenden

Attachments (1)

patch (857 Bytes, text/x-diff)
Index: lib/mkmf.rb
===================================================================
RCS file: /src/ruby/lib/mkmf.rb,v
retrieving revision 1.87
diff -u -r1.87 mkmf.rb
--- lib/mkmf.rb	2002/06/28 14:42:46	1.87
+++ lib/mkmf.rb	2002/08/14 18:09:19
@@ -351,6 +351,30 @@
   return true
 end
 
+def find_executable(bin, path = nil)
+  printf "checking for %s... ", bin
+  STDOUT.flush
+
+  if path.nil?
+    path = ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR'])
+  else
+    path = path.split(Config::CONFIG['PATH_SEPARATOR'])
+  end
+ 
+  bin += Config::CONFIG['EXEEXT']
+  for dir in path
+    file = File.join(dir, bin)
+    if FileTest.executable?(file)
+      print "yes\n"
+      return file
+    else
+      next
+    end
+  end
+  print "no\n"
+  return nil
+end
+
 def arg_config(config, default=nil)
   $configure_args.fetch(config, default)
 end

In This Thread

Prev Next