From 5902c51fe5b81ec6e8651eb2d29255ec6b9659fa Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sat, 5 May 2018 04:22:05 +0300 Subject: Refactor bash completion building --- completion/make.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'completion/make.sh') diff --git a/completion/make.sh b/completion/make.sh index dd00d05..51b0730 100755 --- a/completion/make.sh +++ b/completion/make.sh @@ -2,11 +2,20 @@ pacman_bash_completion='/usr/share/bash-completion/completions/pacman' -(IFS=; while read -r line; do - [ "${line:0:12}" = 'make_import ' ] && { - grep -Poz '(?<=\n)'"${line:12}"'\(\) \{\n(.*\n)*?\}' "$pacman_bash_completion" | - xargs -0 - } || { - echo "$line" - } -done) < 'bash.in' > 'bash' +function delete-shell-fn() { + perl -0777 -pe 's/\n'"$1"'\(\) *\{\n([^}].*\n)*\}\n*/\n\n/g;s/\n{3,}/\n\n/g' +} + +cat "$pacman_bash_completion" | +delete-shell-fn '_pacman_keyids' | +delete-shell-fn '_pacman_key' | +delete-shell-fn '_makepkg' | +sed 's/^_pacman() {$/_pakku() {/' \ +> 'bash' || { + rm 'bash' + exit 1 +} +patch -sNp1 -r - --no-backup-if-mismatch -i 'bash.patch' || { + rm 'bash' + exit 1 +} -- cgit v1.2.3-70-g09d2