0ae1021bdf
It's not a universal solution but I think it'd work okay here, unless I'm missing something. Docs: * http://perldoc.perl.org/perlglossary.html#tainted * https://docstore.mik.ua/orelly/linux/cgi/ch08_04.htm Closes https://github.com/Homebrew/homebrew-core/pull/26290.
35 lines
1,008 B
Ruby
35 lines
1,008 B
Ruby
class Checkbashisms < Formula
|
|
desc "Checks for bashisms in shell scripts"
|
|
homepage "https://launchpad.net/ubuntu/+source/devscripts/"
|
|
url "https://launchpad.net/ubuntu/+archive/primary/+files/devscripts_2.17.9build1.tar.xz"
|
|
version "2.17.9build1"
|
|
sha256 "e0cb232c37eaf8a18584637b1170875b21a632bbd8a3aca2a83499e18beee0dd"
|
|
|
|
head "lp:ubuntu/devscripts", :using => :bzr
|
|
|
|
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
|