homebrew-core/Formula/checkbashisms.rb

41 lines
1.2 KiB
Ruby

class Checkbashisms < Formula
desc "Checks for bashisms in shell scripts"
homepage "https://launchpad.net/ubuntu/+source/devscripts/"
url "https://deb.debian.org/debian/pool/main/d/devscripts/devscripts_2.22.1.tar.xz"
sha256 "35dd5e6029d27be35b96e8c6e38b8aa6fba791a21371dac2de0f8cdee5fe33d5"
license "GPL-2.0-or-later"
livecheck do
url "https://deb.debian.org/debian/pool/main/d/devscripts/"
regex(/href=.*?devscripts[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "26b4ede6116f7005fbca997faee7826acb3fb45b237934cbccf6731534a7e9b3"
end
def install
inreplace "scripts/checkbashisms.pl" do |s|
s.gsub! "###VERSION###", version
s.gsub! "#!/usr/bin/perl", "#!/usr/bin/perl -T"
end
bin.install "scripts/checkbashisms.pl" => "checkbashisms"
man1.install "scripts/checkbashisms.1"
end
test do
(testpath/"test.sh").write <<~EOS
#!/bin/sh
if [[ "home == brew" ]]; then
echo "dog"
fi
EOS
expected = <<~EOS
(alternative test command ([[ foo ]] should be [ foo ])):
EOS
assert_match expected, shell_output("#{bin}/checkbashisms #{testpath}/test.sh 2>&1", 1)
end
end