ruby-changes:28904
From: nobu <ko1@a...>
Date: Mon, 27 May 2013 17:33:58 +0900 (JST)
Subject: [ruby-changes:28904] nobu:r40956 (trunk): rbinstall.rb: reject empty files
nobu 2013-05-27 17:33:47 +0900 (Mon, 27 May 2013) New Revision: 40956 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40956 Log: rbinstall.rb: reject empty files * tool/rbinstall.rb (install_recursive): add maxdepth option. * tool/rbinstall.rb (bin-comm): limit depth of bindir and reject empty files. [ruby-core:55101] [Bug #8432] Modified files: trunk/ChangeLog trunk/tool/rbinstall.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 40955) +++ ChangeLog (revision 40956) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon May 27 17:33:28 2013 Nobuyoshi Nakada <nobu@r...> + + * tool/rbinstall.rb (install_recursive): add maxdepth option. + + * tool/rbinstall.rb (bin-comm): limit depth of bindir and reject empty + files. [ruby-core:55101] [Bug #8432] + Mon May 27 16:16:18 2013 Koichi Sasada <ko1@a...> * vm_trace.c (rb_postponed_job_flush, rb_postponed_job_register): use Index: tool/rbinstall.rb =================================================================== --- tool/rbinstall.rb (revision 40955) +++ tool/rbinstall.rb (revision 40956) @@ -198,6 +198,7 @@ def install_recursive(srcdir, dest, opti https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L198 opts = options.clone noinst = opts.delete(:no_install) glob = opts.delete(:glob) || "*" + maxdepth = opts.delete(:maxdepth) subpath = (srcdir.size+1)..-1 prune = [] skip = [] @@ -217,19 +218,21 @@ def install_recursive(srcdir, dest, opti https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L218 prune = path_matcher(prune) skip = path_matcher(skip) File.directory?(srcdir) or return rescue return - paths = [[srcdir, dest, true]] + paths = [[srcdir, dest, 0]] found = [] while file = paths.shift found << file file, d, dir = *file if dir + depth = dir + 1 + next if maxdepth and maxdepth < depth files = [] Dir.foreach(file) do |f| src = File.join(file, f) d = File.join(dest, dir = src[subpath]) stat = File.lstat(src) rescue next if stat.directory? - files << [src, d, true] if /\A\./ !~ f and !prune[dir] + files << [src, d, depth] if maxdepth != depth and /\A\./ !~ f and !prune[dir] elsif stat.symlink? # skip else @@ -453,7 +456,7 @@ install?(:local, :comm, :bin, :'bin-comm https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L456 else trans = proc {|base| base} end - install_recursive(File.join(srcdir, "bin"), bindir) do |src, cmd| + install_recursive(File.join(srcdir, "bin"), bindir, :maxdepth => 1) do |src, cmd| cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])} shebang = '' @@ -462,6 +465,7 @@ install?(:local, :comm, :bin, :'bin-comm https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L465 shebang = f.gets body = f.read end + shebang or raise "empty file - #{src}" if PROLOG_SCRIPT shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")} else -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/