54 lines
1.6 KiB
Ruby
54 lines
1.6 KiB
Ruby
class Grep < Formula
|
|
desc "GNU grep, egrep and fgrep"
|
|
homepage "https://www.gnu.org/software/grep/"
|
|
url "https://ftp.gnu.org/gnu/grep/grep-3.1.tar.xz"
|
|
mirror "https://ftpmirror.gnu.org/grep/grep-3.1.tar.xz"
|
|
sha256 "db625c7ab3bb3ee757b3926a5cfa8d9e1c3991ad24707a83dde8a5ef2bf7a07e"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "75fd5efc0986b1771c3082e08b9dc2d8495546f81ad1a38a9a05f506c8046687" => :sierra
|
|
sha256 "867dffadb33d24d4a743df13c95ec08ff526f3be96b4965ae5e97ec08d46192d" => :el_capitan
|
|
sha256 "72ea449768eb5745712b40464b8eb1e7b9dc908ce26c8353e453681ee824ec89" => :yosemite
|
|
end
|
|
|
|
option "with-default-names", "Do not prepend 'g' to the binary"
|
|
deprecated_option "default-names" => "with-default-names"
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "pcre"
|
|
|
|
def install
|
|
args = %W[
|
|
--disable-dependency-tracking
|
|
--disable-nls
|
|
--prefix=#{prefix}
|
|
--infodir=#{info}
|
|
--mandir=#{man}
|
|
--with-packager=Homebrew
|
|
]
|
|
|
|
args << "--program-prefix=g" if build.without? "default-names"
|
|
|
|
system "./configure", *args
|
|
system "make"
|
|
system "make", "install"
|
|
end
|
|
|
|
def caveats
|
|
if build.without? "default-names" then <<-EOS.undent
|
|
The command has been installed with the prefix "g".
|
|
If you do not want the prefix, install using the "with-default-names"
|
|
option.
|
|
EOS
|
|
end
|
|
end
|
|
|
|
test do
|
|
text_file = testpath/"file.txt"
|
|
text_file.write "This line should be matched"
|
|
cmd = build.with?("default-names") ? "grep" : "ggrep"
|
|
grepped = shell_output("#{bin}/#{cmd} match #{text_file}")
|
|
assert_match "should be matched", grepped
|
|
end
|
|
end
|