わたなべです.

Yukihiro Matsumoto <matz / netlab.co.jp> writes:

:  (1) installは使わない,全部rubyでインストールする

のつもりでいたんだけど, すっかり忘れてました.

インストール時にだいたい必要なものを集めてこんなのを作ってました.
#まだ中途.

一年前に作った command.rb です.
#と思ったけど ftools.rb もいじったんだ.
#どこへやったんだっけかな? たぶん家にあるのでこれは後程.

require 'ftools' =begin command - utilities to replace common UNIX commands in Makefiles etc. =synopsis ruby -r command -e cat files... >destination ruby -r command -e mv sources... destination ruby -r command -e cp sources... destination ruby -r command -e touch files... ruby -r command -e rm_f files... ruby -r command -e rm_rf directories... ruby -r command -e mkdir_p directories... ruby -r command -e chmod mode files... ruby -r command -e test_f file ruby -r command -e install files... destination ruby -r command -e glob files... ruby -r command -e csh_glob files... =description The module is used in Win32 port to replace common UNIX commands. Most commands are wrapers on generic modules ftools.rb. =end raise "ruby 1.1b9_11 required" if VERSION < "1.1b9_11" def expand_wildcards ARGV.each_with_index do |f,i| ARGV[i] = /[*?[]/ =~ f ? Dir[f] : f end ARGV.flatten! || ARGV end def glob puts expand_wildcards.join " " end def csh_glob print expand_wildcards.join "\0" end def chmod mode = ARGV.shift.oct File.chmod mode, *expand_wildcards end def cat for src in expand_wildcards File.copy src, $stdout end end def cp dst = ARGV.pop expand_wildcards raise "Too many argument" if ARGV.size > 1 and not FileTest.directory? dst for src in ARGV File.copy src, dst end end def rm_f File.safe_unlink *expand_wildcards end def rm_rf File.safe_unlink_tree *expand_wildcards end def mv dst = ARGV.pop expand_wildcards raise "Too many argument" if ARGV.size > 1 and not FileTest.directory? dst for src in ARGV File.move src, dst end end def mkdir_p File.makedirs(*ARGV) end def touch for file in expand_wildcards if FileTest.exist? file and not FileTest.zero? file f = open(file, "r+") c = f.sysread(1) f.seek(0, 0) f.syswrite(c) f.close else open(file, "w").close end end end def test_f exit FileTest.file? ARGV[0] end def install dst = ARGV.pop expand_wildcards raise "Too many argument" if ARGV.size > 1 and not FileTest.directory? dst for src in ARGV File.install src, dst, File.stat(src).mode & 0777, false end end # vi: set sw=2: