Improve text_executable heuristic
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 <43386ce32af96f5c56f2a88e458cb94cebee3751@gmail.com>

sjackman/homebrew,DomT4/brew,muellermartin/dist,muellermartin/dist,JCount/brew,EricFromCanada/brew,mahori/brew,JCount/brew,DomT4/brew,gordonmcshane/homebrew,hanxue/linuxbrew,amar-laksh/brew_sudo,alyssais/brew,Linuxbrew/brew,Homebrew/brew,tonyg/homebrew,amar-laksh/brew_sudo,Linuxbrew/brew,mistydemeo/homebrew,claui/brew,maxim-belkin/brew,mahori/brew,toonetown/homebrew,MikeMcQuaid/brew,pseudocody/brew,DomT4/brew,mistydemeo/homebrew,toonetown/homebrew,MikeMcQuaid/brew,AnastasiaSulyagina/brew,nandub/brew,staticfloat/brew,amar-laksh/brew_sudo,nandub/brew,reelsense/brew,muellermartin/dist,mistydemeo/homebrew,nandub/brew,gordonmcshane/homebrew,Linuxbrew/brew,bfontaine/brew,hanxue/linuxbrew,EricFromCanada/brew,gregory-nisbet/brew,MikeMcQuaid/brew,konqui/brew,maxim-belkin/brew,reitermarkus/brew,ilovezfs/brew,rwhogg/brew,vitorgalvao/brew,bfontaine/brew,gordonmcshane/homebrew,AnastasiaSulyagina/brew,EricFromCanada/brew,MikeMcQuaid/brew,zmwangx/brew,alyssais/brew,pseudocody/brew,mahori/brew,Linuxbrew/brew,mgrimes/brew,reitermarkus/brew,palxex/brew,reitermarkus/brew,jmsundar/brew,AnastasiaSulyagina/brew,tonyg/homebrew,vitorgalvao/brew,jmsundar/brew,rwhogg/brew,palxex/brew,gregory-nisbet/brew,konqui/brew,DomT4/brew,aw1621107/brew,EricFromCanada/brew,claui/brew,pseudocody/brew,claui/brew,alyssais/brew,hanxue/linuxbrew,zmwangx/brew,reelsense/brew,mahori/brew,konqui/brew,vitorgalvao/brew,Homebrew/brew,reitermarkus/brew,JCount/brew,gregory-nisbet/brew,nandub/brew,ilovezfs/brew,palxex/brew,JCount/brew,sjackman/homebrew,Homebrew/brew,rwhogg/brew,mgrimes/brew,maxim-belkin/brew,sjackman/homebrew,toonetown/homebrew,sjackman/homebrew,staticfloat/brew,tonyg/homebrew,reelsense/brew,bfontaine/brew,vitorgalvao/brew,aw1621107/brew,jmsundar/brew,staticfloat/brew,konqui/brew,aw1621107/brew,Homebrew/brew,zmwangx/brew,ilovezfs/brew,claui/brew,mgrimes/brew