diff options
| author | Jack Nagel | 2012-06-15 20:02:49 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-06-15 20:06:36 -0500 |
| commit | 7002359f7a39351a6e6805815d19aac301982a7c (patch) | |
| tree | 7b5deeae5e29751ceeeec677e977d8ce0eca01b5 /Library | |
| parent | 1b6f23c8a96fcb78163ba5a58a5e0e342d390663 (diff) | |
| download | brew-7002359f7a39351a6e6805815d19aac301982a7c.tar.bz2 | |
Improve Pathname#text_executable? regexp
file(1) does not allow leading whitespace on shebang lines, and there
appears to be no restrictions on what characters follow '#!', either.
While at it, fix an erroneous shebang test.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_mach.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index d171a6d6b..907679f99 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -272,7 +272,7 @@ class Pathname end def text_executable? - %r[#!\s*(/.+)+] === open('r') { |f| f.readline } + %r[^#!\s*.+] === open('r') { |f| f.readline } rescue EOFError false end diff --git a/Library/Homebrew/test/test_mach.rb b/Library/Homebrew/test/test_mach.rb index 9b9c3cd9b..a0efb6928 100644 --- a/Library/Homebrew/test/test_mach.rb +++ b/Library/Homebrew/test/test_mach.rb @@ -135,7 +135,7 @@ class TextExecutableTests < Test::Unit::TestCase def test_malformed_shebang pn = Pathname.new('baz') - pn.write '#! ' + pn.write ' #!' assert !pn.universal? assert !pn.i386? assert !pn.x86_64? @@ -146,7 +146,7 @@ class TextExecutableTests < Test::Unit::TestCase assert !pn.text_executable? assert_equal [], pn.archs assert pn.arch == :dunno - assert_match /text executable/, `/usr/bin/file -h '#{pn}'`.chomp + assert_no_match /text executable/, `/usr/bin/file -h '#{pn}'`.chomp end def teardown |
