homebrew-core/Formula/bash-completion.rb
2015-09-22 15:36:19 +01:00

65 lines
2.5 KiB
Ruby

# NOTE: version 2.0 is out, but it requires Bash 4, and OS X ships
# with 3.2.48. See homebrew-versions for a 2.0 formula.
class BashCompletion < Formula
desc "Programmable bash completion"
homepage "https://bash-completion.alioth.debian.org/"
url "https://bash-completion.alioth.debian.org/files/bash-completion-1.3.tar.bz2"
mirror "http://pkgs.fedoraproject.org/repo/pkgs/bash-completion/bash-completion-1.3.tar.bz2/a1262659b4bbf44dc9e59d034de505ec/bash-completion-1.3.tar.bz2"
sha256 "8ebe30579f0f3e1a521013bcdd183193605dab353d7a244ff2582fb3a36f7bec"
bottle do
cellar :any_skip_relocation
revision 1
sha256 "5f7f9f96ebf1a31d08a8bf429f47c83a8a44ac2b98f6556888e9e1f5b2f1bb35" => :el_capitan
sha256 "a31fe5655a5f0298e69da7b858be6af05a47faeabb635e445ea3d481b48e5a6c" => :yosemite
sha256 "5b5d5c9d802c4d77b5eb7db2179ed595ab464a387639b0829cd65e282509b9aa" => :mavericks
end
# Backports the following upstream patch from 2.x:
# https://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=commitdiff_plain;h=50ae57927365a16c830899cc1714be73237bdcb2
patch :DATA
def compdir
etc/"bash_completion.d"
end
def install
inreplace "bash_completion" do |s|
s.gsub! "/etc/bash_completion", etc/"bash_completion"
s.gsub! "readlink -f", "readlink"
end
system "./configure", "--prefix=#{prefix}"
system "make", "install"
unless (compdir/"brew_bash_completion.sh").exist?
compdir.install_symlink HOMEBREW_CONTRIB/"brew_bash_completion.sh"
end
end
def caveats; <<-EOS.undent
Add the following lines to your ~/.bash_profile:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Homebrew's own bash completion script has been installed to
#{compdir}
EOS
end
end
__END__
diff --git a/bash_completion b/bash_completion
index 6601937..5184767 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1334,7 +1334,7 @@ _known_hosts_real()
# append any available aliases from config files
if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
- local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
+ local hosts=$( sed -ne 's/^['"$'\t '"']*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -P "$prefix$user" \
-S "$suffix" -W "$hosts" -- "$cur" ) )
fi