homebrew-core/Formula/checkbashisms.rb
2018-12-11 09:17:59 +13:00

32 lines
931 B
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.18.11.tar.xz"
sha256 "d5738c616914f5b78ff57a142b4055c560c71910eed23f2fc8ef93386ac6ad7d"
bottle :unneeded
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