aboutsummaryrefslogtreecommitdiff
path: root/completion/make.sh
diff options
context:
space:
mode:
authorkitsunyan2018-05-05 01:22:05 +0000
committerkitsunyan2018-05-05 01:22:05 +0000
commit5902c51fe5b81ec6e8651eb2d29255ec6b9659fa (patch)
treeba10340034ddb96a70df9e8991f7b5a2f1dbe1d7 /completion/make.sh
parent451cc4aca13cb6637b55c527d1e0647d6fffad5b (diff)
Refactor bash completion building
Diffstat (limited to 'completion/make.sh')
-rwxr-xr-xcompletion/make.sh25
1 files changed, 17 insertions, 8 deletions
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
+}