Jack Nagel dd4302ae9b Improve text_executable heuristic
Previously we detected this by reading the first line of the file.
However, "first line" is meaningless when dealing with binary files, but
IO#readline will happily keep reading until it finds a newline
character, which can result in some unnecessarily large buffers.

Aside from the performance issue, this causes an additional problem
under Ruby 1.9: trying to match the binary string against a pattern will
raise ArgumentError (unless the binary string just happens to also be
valid UTF-8, heh).

Fix both issues: only read the first 1024 bytes, as no sane shebang will
ever be that long, and use a plain read(), which returns an ASCII
encoded string even on 1.9.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-09-27 17:26:26 -05:00
..
2012-09-27 17:26:26 -05:00
2012-09-19 21:27:59 -05:00
2012-09-27 16:24:04 -05:00
2011-11-13 19:23:00 -08:00
2012-09-25 14:35:05 -05:00
2012-07-04 22:47:33 -05:00
2012-07-16 16:26:47 -05:00
2012-08-17 13:38:26 -05:00
2012-09-25 11:31:56 -04:00
2012-09-27 16:21:39 -05:00