diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-27 07:48:11 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-02-27 07:48:11 +0000 |
commit | 7425d4f6ef047dd274cbea8115955462d5449330 (patch) | |
tree | 575dcd5c8f6df0908e4198376441d4257dcde75d /sample/from.rb | |
parent | fd1d8cdc09ed86e4a0812120a17ff0d7b04adcaf (diff) |
This commit was manufactured by cvs2svn to create tag 'r1_1b9'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/r1_1b9@100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/from.rb')
-rw-r--r-- | sample/from.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/sample/from.rb b/sample/from.rb index d39bb70084..0a83f081f1 100644 --- a/sample/from.rb +++ b/sample/from.rb @@ -9,8 +9,6 @@ include Kconv class String - public :kconv - def kconv(code = Kconv::EUC) Kconv.kconv(self, code, Kconv::AUTO) end @@ -34,11 +32,15 @@ end if ARGV.length == 0 user = ENV['USER'] else - user = ARGV[0] + file = user = ARGV[0] + ARGV.clear end [ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m| - break if File.exist? ARGV[0] = "#{m}/mail/#{user}" + if File.exist? f = "#{m}/mail/#{user}" + file = f + break + end end $outcount = 0; @@ -63,18 +65,23 @@ def fromout(date, from, subj) end from = from.kconv(lang).kjust(28) subj = subj.kconv(lang).kjust(40) - printf "%02d/%02d/%02d [%s] %s\n",y,m,d,from,subj + printf "%02d/%02d/%02d [%s] %s\n",y%100,m,d,from,subj $outcount += 1 end -for file in ARGV - next if !File.exist?(file) +if File.exist?(file) + atime = File.atime(file) + mtime = File.mtime(file) f = open(file, "r") - while !f.eof? - mail = Mail.new(f) - fromout mail.header['Date'], mail.header['From'], mail.header['Subject'] + begin + until f.eof? + mail = Mail.new(f) + fromout mail.header['Date'],mail.header['From'],mail.header['Subject'] + end + ensure + f.close + File.utime(atime, mtime, file) end - f.close end if $outcount == 0 |