Project

General

Profile

Actions

Bug #854

closed

Rake::FileList#egrep が動かない

Added by okkez (okkez _) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
ruby -v:
Backport:

Description

=begin
以下のような Rakefile を作って Ruby1.9.1 preview2 で動かすと動きません。

Rakefile

coding: utf-8

desc 'aaa'
task :a do
p FileList['*.rb'].egrep(/require/)
end

カレントディレクトリに SJIS で書かれたファイルが存在する場合にこけました。
=end

Actions #1

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Target version set to 1.9.1 Release Candidate

=begin

=end

Actions #2

Updated by yugui (Yuki Sonoda) over 15 years ago

=begin
Yuguiです。

okkez _ さんは書きました:

以下のような Rakefile を作って Ruby1.9.1 preview2 で動かすと動きません。

Rakefile

coding: utf-8

desc 'aaa'
task :a do
p FileList['*.rb'].egrep(/require/)
end

カレントディレクトリに SJIS で書かれたファイルが存在する場合にこけました。

これ、
 *.rbをexternal_encoding指定無しで開いてeach_lineして、
 各行に対して/require/.match(line) して、
 マッチしたらその行を出力、ということをやっていて、
途中でdefault_externalとして壊れている行(cp932文字列リテラル)に出会って

それでArgumentError(invalid byte sequence in UTF-8)になってます。

壊れている文字列とのマッチで例外というのはそれなりにreasonableだと思って
いたんですが、このケースは確かに何か困りそうです。.rbならまだしもmagic
commentを読めとも言えますが、
.txtの場合だってあるわけです。

これの対応策としてはエンコーディングが不明ならASCII-8BITで開け、というこ
とになりますでしょうか。

--
Yugui
http://yugui.jp
私は私をDumpする

=end

Actions #3

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Due date set to 12/22/2008
  • Category set to core
  • Assignee set to matz (Yukihiro Matsumoto)

=begin

=end

Actions #4

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Priority changed from Normal to 5

=begin

=end

Actions #5

Updated by yugui (Yuki Sonoda) over 15 years ago

  • Due date changed from 12/22/2008 to 12/24/2008
  • Assignee deleted (matz (Yukihiro Matsumoto))

=begin

=end

Actions #6

Updated by matz (Yukihiro Matsumoto) over 15 years ago

  • Status changed from Open to Closed

=begin
fixed by r20908.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0