diff options
| author | Jack Nagel | 2012-09-27 17:03:43 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-09-27 17:26:26 -0500 |
| commit | dd4302ae9bd75f05be2b9a1a3b44f8925d1ea700 (patch) | |
| tree | e64340bbe335c7bb204bcacb552ab2e9919537a1 /Library/Homebrew/cmd | |
| parent | 1b2e19d4259bd0b9eb7551bc8006227de89afec1 (diff) | |
| download | brew-dd4302ae9bd75f05be2b9a1a3b44f8925d1ea700.tar.bz2 | |
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>
Diffstat (limited to 'Library/Homebrew/cmd')
0 files changed, 0 insertions, 0 deletions
