Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/
Date: Fri, 02 Mar 2018 18:35:57
Message-Id: 1520015709.41d0608e51e5fe3b5034de9ae3700c2490380e2e.williamh@gentoo
1 commit: 41d0608e51e5fe3b5034de9ae3700c2490380e2e
2 Author: William Hubbs <williamh <AT> gentoo <DOT> org>
3 AuthorDate: Fri Mar 2 18:33:51 2018 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Fri Mar 2 18:35:09 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=41d0608e
7
8 Remove OpenRC completions since they are provided upstream
9
10 completions/rc | 21 ----------
11 completions/rc-service | 111 -------------------------------------------------
12 completions/rc-status | 28 -------------
13 completions/rc-update | 40 ------------------
14 4 files changed, 200 deletions(-)
15
16 diff --git a/completions/rc b/completions/rc
17 deleted file mode 100644
18 index 7453ed4..0000000
19 --- a/completions/rc
20 +++ /dev/null
21 @@ -1,21 +0,0 @@
22 -# Gentoo Linux Bash Shell Command Completion
23 -#
24 -# Copyright 1999-2013 Gentoo Foundation
25 -# Distributed under the terms of the GNU General Public License, v2 or later
26 -
27 -#
28 -# rc completion command
29 -#
30 -_rc()
31 -{
32 - local cur
33 - COMPREPLY=()
34 - cur="${COMP_WORDS[COMP_CWORD]}"
35 - if [[ ${#COMP_WORDS[*]} -le 2 ]]; then
36 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
37 - fi
38 - return 0
39 -} &&
40 -complete -F _rc rc
41 -
42 -# vim: ft=sh:et:ts=4:sw=4:tw=80
43
44 diff --git a/completions/rc-service b/completions/rc-service
45 deleted file mode 100644
46 index 9ad2ce1..0000000
47 --- a/completions/rc-service
48 +++ /dev/null
49 @@ -1,111 +0,0 @@
50 -# Gentoo Linux Bash Shell Command Completion
51 -#
52 -# Copyright 1999-2013 Gentoo Foundation
53 -# Distributed under the terms of the GNU General Public License, v2 or later
54 -
55 -source "@helpersdir@/gentoo-common.sh"
56 -
57 -_rc_service() {
58 - local cur prev numwords opts
59 - local words i x filename
60 - local action actionpos
61 - COMPREPLY=()
62 - cur="${COMP_WORDS[COMP_CWORD]}"
63 - prev="${COMP_WORDS[COMP_CWORD-1]}"
64 - numwords=${#COMP_WORDS[*]}
65 -
66 - if [[ ${prev} == '>' || ${prev} == '<' ]] ; then
67 - COMPREPLY=($(compgen -f -- ${cur}))
68 - return 0
69 - fi
70 -
71 - # find action
72 - for x in ${COMP_LINE} ; do
73 - if [[ ${x} =~ --(list|exists|resolve) ]] || \
74 - [[ ${x} =~ -(l|e|r) ]]
75 - then
76 - action=${x}
77 - break
78 - fi
79 - done
80 - if [[ -n ${action} ]]; then
81 - for ((i = 0; i < ${numwords}; i++ )); do
82 - if [[ ${COMP_WORDS[${i}]} == "${action}" ]]; then
83 - actionpos=${i}
84 - break
85 - fi
86 - done
87 -
88 - for ((i = 1; i < ${numwords}; i++ )); do
89 - if [[ ! ${COMP_WORDS[$i]} == -* ]]; then
90 - break
91 - fi
92 - done
93 - fi
94 -
95 - if [[ ${COMP_CWORD} -eq 3 ]]; then
96 - return 1
97 - fi
98 -
99 - # check if an option was typed
100 - if [[ ${cur} == -* ]]; then
101 - if [[ ${cur} == --* ]]; then
102 - opts="--list --exists --resolve"
103 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
104 - return 0
105 - elif [[ ${cur} == -* ]]; then
106 - opts="-l -e -r"
107 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
108 - return 0
109 - fi
110 -
111 -
112 - # NOTE: This slows things down!
113 - # (Adapted from bash_completion by Ian Macdonald <ian@×××××××.org>)
114 - # This removes any options from the list of completions that have
115 - # already been specified on the command line.
116 - COMPREPLY=($(echo "${COMP_WORDS[@]}" | \
117 - (while read -d ' ' i; do
118 - [[ -z ${i} ]] && continue
119 - # flatten array with spaces on either side,
120 - # otherwise we cannot grep on word boundaries of
121 - # first and last word
122 - COMPREPLY=" ${COMPREPLY[@]} "
123 - # remove word from list of completions
124 - COMPREPLY=(${COMPREPLY/ ${i%% *} / })
125 - done
126 - echo ${COMPREPLY[@]})))
127 -
128 - return 0
129 - # if no option typed
130 - else
131 - if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed
132 - words="`rc-service -l | grep ^${cur}`" # complete for init scripts
133 - COMPREPLY=($(for i in ${words} ; do \
134 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
135 - done))
136 - return 0
137 - elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
138 - filename=`rc-service -r ${prev}`
139 - opts=`cat ${filename} | grep "^\w*()" | sed "s/().*$//"` # Greps the functions included in the init script
140 - if [[ "x${opts}" == "x" ]] ; then # if no options found loosen the grep algorhythm
141 - opts=`cat ${filename} | grep "\w*()" | sed "s/().*$//"`
142 - fi
143 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
144 - return 0
145 - fi
146 - fi
147 - if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
148 - [[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then
149 - words="`rc-service -l | grep ^${cur}`"
150 - COMPREPLY=($(for i in ${words} ; do \
151 - [[ ${i} == ${cur}* ]] && echo ${i} ; \
152 - done))
153 - return 0
154 - fi
155 -
156 - return 0
157 -} &&
158 -complete -F _rc_service rc-service
159 -
160 -# vim: ft=sh:et:ts=4:sw=4:tw=80
161
162 diff --git a/completions/rc-status b/completions/rc-status
163 deleted file mode 100644
164 index 794067f..0000000
165 --- a/completions/rc-status
166 +++ /dev/null
167 @@ -1,28 +0,0 @@
168 -# Gentoo Linux Bash Shell Command Completion
169 -#
170 -# Copyright 1999-2013 Gentoo Foundation
171 -# Distributed under the terms of the GNU General Public License, v2 or later
172 -
173 -#
174 -# rc-status completion command
175 -#
176 -_rcstatus()
177 -{
178 - local cur
179 - cur="${COMP_WORDS[COMP_CWORD]}"
180 - if [[ $COMP_CWORD -eq 1 ]]; then
181 - if [[ "${cur}" == --* ]]; then
182 - COMPREPLY=($(compgen -W '--all --list --unused' -- ${cur}))
183 - elif [[ "${cur}" == -* ]]; then
184 - COMPREPLY=($(compgen -W '-a -l -u' -- ${cur}))
185 - else
186 - COMPREPLY=($(compgen -W "$(rc-status --list)" -- ${cur}))
187 - fi
188 - else
189 - unset COMPREPLY
190 - fi
191 - return 0
192 -} &&
193 -complete -F _rcstatus rc-status
194 -
195 -# vim: ft=sh:et:ts=4:sw=4:tw=80
196
197 diff --git a/completions/rc-update b/completions/rc-update
198 deleted file mode 100644
199 index ae45744..0000000
200 --- a/completions/rc-update
201 +++ /dev/null
202 @@ -1,40 +0,0 @@
203 -# Gentoo Linux Bash Shell Command Completion
204 -#
205 -# Copyright 1999-2013 Gentoo Foundation
206 -# Distributed under the terms of the GNU General Public License, v2 or later
207 -
208 -#
209 -# rc-update completion command
210 -#
211 -_rcupdate()
212 -{
213 - local cur show
214 - COMPREPLY=()
215 - cur="${COMP_WORDS[COMP_CWORD]}"
216 - if [[ $COMP_CWORD -eq 1 ]]; then
217 - if [[ "${cur}" == -* ]]; then
218 - COMPREPLY=($(compgen -W '-a -d -s' -- ${cur}))
219 - else
220 - COMPREPLY=($(compgen -W 'add del show' ${cur}))
221 - fi
222 - else
223 - if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then
224 - show="TRUE"
225 - fi
226 - if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \
227 - ([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]])
228 - then
229 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
230 - elif [[ $COMP_CWORD -eq 2 ]]; then
231 - COMPREPLY=($(compgen -X "*.@(c|sh|test)" -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/init.d/*; do echo ${i##*/}; done)" $cur))
232 - elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then
233 - COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur))
234 - else
235 - unset COMPREPLY
236 - fi
237 - fi
238 - return 0
239 -} &&
240 -complete -F _rcupdate rc-update
241 -
242 -# vim: ft=sh:et:ts=4:sw=4:tw=80