e$B$O$8$a$^$7$F!"HxED$H$$$$$^$9!#e(B
shell.rb
e$B$r;H$C$?$A$g$C$H$7$?%9%/%j%W%H$r=q$$$FBgNL$N%U%!%$%ke(B(3000e$B%U%!%$%k!(e(B
11GB)e$B$re(B
e$B=hM}$7$F$$$?$iESCf$G;_$^$C$F$7$^$$$^$7$?!#e(B
e$B%9%/%j%W%H<+BN$KLdBj$O$J$$$H;W$&$N$G!“0l1~Js9p$^$G!#e(B
e$B0J2<!”%9%?%C%/%H%l!<%9$HDd;_$7$?%9%/%j%W%H$G$9!#e(B
require ‘pathname’
require ‘shell’
require ‘optparse’
def main(from, to, debug, commands)
files = []
from.find do |path|
files << path if path.file?
end
if debug > 0
STDERR.puts “from_dir = #{from.to_s}”
STDERR.puts “to_dir = #{to.to_s}”
end
files.sort.each do |file|
dest = to + file.relative_path_from(from)
dest.parent.mkpath
if debug > 0
STDERR.puts "input = #{file.to_s}"
STDERR.puts "output = #{dest.to_s}"
end
Shell.new.transact do
cat(file.to_s) | system(*commands) > dest.to_s
end
end
end
if $0 == FILE
from = nil
to = nil
debug = 0
opt = OptionParser.new
opt.on(’-t’, ‘–to TO’, String) {|v| to = Pathname.new v}
opt.on(’-f’, ‘–from FROM’, String) {|v| from = Pathname.new v}
opt.on(’-d’, ‘–debug’) { debug += 1 }
opt.parse!(ARGV)
unless from and to and ARGV.length > 0
puts opt.help
exit
end
main(from, to, debug, ARGV)
end
/home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:203:in
stop': stopping only thread (ThreadError) note: use sleep to stop forever from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:203:in
wait’
from
/home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:155:in
exclusive_unlock' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:33:in
exclusive’
from
/home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:147:in
exclusive_unlock' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:201:in
wait’
from
/home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/process-controller.rb:185:in
wait_all_jobs_execution' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/thread.rb:135:in
synchronize’
from
/home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/process-controller.rb:182:in
wait_all_jobs_execution' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:246:in
check_point’
from
/home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:254:in
transact' from /home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:519:in
send’
from
/home/oda/opt/stow/ruby-1.8.5-p12/lib/ruby/1.8/shell/command-processor.rb:519:in
transact' from ./bin/dir_filter.rb:27:in
main’
from ./bin/dir_filter.rb:18:in each' from ./bin/dir_filter.rb:18:in
main’