From: nobu.nokada@... Date: 2002-04-19T14:46:51+09:00 Subject: Re: recursive require warning... Hi, At Fri, 19 Apr 2002 12:28:10 +0900, Phil Tomson wrote: > >> Is it possible that we could have some sort of warning message when this > >> happens, something like: "Warning: recursive require slave.rb line 3" > > > >It's easy, but really desirable in common? > > It would have made it much easier to find the problem on Windows in this > case. I didn't realize that the file was requireing itself (slave.rb) > instead of the Slave.rb in the other directory. Sometimes recursive require is used intently. Actually, once it was prohibited, complained as expected. You can check conflicts with a tool instead. #! /usr/bin/ruby require 'getopts' getopts("id") icase = $OPT_i default = $OPT_d paths = ARGV paths.concat($:) if default dirs = {} files = {} paths.each do |path| path = "." if path.empty? ipath = icase ? path.downcase : path next if dirs[ipath] dirs[ipath] = true Dir.glob(path+"/**/*.rb") do |rb| f = rb[(path.length+1)..-1] f.downcase! if icase (files[f] ||= []) << path end end files.reject! {|f, path| path.size == 1} w = files.keys.collect {|f| f.length}.max files.sort.each {|f, path| printf("%-*s %s\n", w, f, path.join(" "))} -- Nobu Nakada