Skip to content

Commit 0876fdf

Browse files
lcpDaniel Kiper
authored and
Daniel Kiper
committed
util/bash-completion: Fix for bash-completion 2.12
_split_longopt() was the bash-completion private API and removed since bash-completion 2.12. This commit initializes the bash-completion general variables with _init_completion() to avoid the potential "command not found" error. Although bash-completion 2.12 introduces _comp_initialize() to deprecate _init_completion(), _init_completion() is still chosen for the better backward compatibility. Signed-off-by: Gary Lin <[email protected]> Reviewed-by: Daniel Kiper <[email protected]>
1 parent 28c4405 commit 0876fdf

File tree

1 file changed

+22
-39
lines changed

1 file changed

+22
-39
lines changed

util/bash-completion.d/grub-completion.bash.in

+22-39
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,10 @@ __grub_list_modules () {
151151
# grub-set-default & grub-reboot
152152
#
153153
__grub_set_entry () {
154-
local cur prev split=false
154+
local cur prev words cword split
155+
_init_completion -s || return
155156

156157
COMPREPLY=()
157-
cur=`_get_cword`
158-
prev=${COMP_WORDS[COMP_CWORD-1]}
159-
160-
_split_longopt && split=true
161158

162159
case "$prev" in
163160
--boot-directory)
@@ -180,11 +177,10 @@ __grub_set_entry () {
180177
# grub-editenv
181178
#
182179
__grub_editenv () {
183-
local cur prev
180+
local cur prev words cword
181+
_init_completion || return
184182

185183
COMPREPLY=()
186-
cur=`_get_cword`
187-
prev=${COMP_WORDS[COMP_CWORD-1]}
188184

189185
case "$prev" in
190186
create|list|set|unset)
@@ -201,10 +197,10 @@ __grub_editenv () {
201197
# grub-mkconfig
202198
#
203199
__grub_mkconfig () {
204-
local cur prev
200+
local cur prev words cword
201+
_init_completion || return
205202

206203
COMPREPLY=()
207-
cur=`_get_cword`
208204

209205
if [[ "$cur" == -* ]]; then
210206
__grubcomp "$(__grub_get_options_from_help)"
@@ -217,13 +213,10 @@ __grub_mkconfig () {
217213
# grub-setup
218214
#
219215
__grub_setup () {
220-
local cur prev split=false
216+
local cur prev words cword split
217+
_init_completion -s || return
221218

222219
COMPREPLY=()
223-
cur=`_get_cword`
224-
prev=${COMP_WORDS[COMP_CWORD-1]}
225-
226-
_split_longopt && split=true
227220

228221
case "$prev" in
229222
-d|--directory)
@@ -246,15 +239,12 @@ __grub_setup () {
246239
# grub-install
247240
#
248241
__grub_install () {
249-
local cur prev last split=false
242+
local cur prev words cword split last
243+
_init_completion -s || return
250244

251245
COMPREPLY=()
252-
cur=`_get_cword`
253-
prev=${COMP_WORDS[COMP_CWORD-1]}
254246
last=$(__grub_get_last_option)
255247

256-
_split_longopt && split=true
257-
258248
case "$prev" in
259249
--boot-directory)
260250
_filedir -d
@@ -287,10 +277,10 @@ __grub_install () {
287277
# grub-mkfont
288278
#
289279
__grub_mkfont () {
290-
local cur
280+
local cur prev words cword
281+
_init_completion || return
291282

292283
COMPREPLY=()
293-
cur=`_get_cword`
294284

295285
if [[ "$cur" == -* ]]; then
296286
__grubcomp "$(__grub_get_options_from_help)"
@@ -304,11 +294,10 @@ __grub_mkfont () {
304294
# grub-mkrescue
305295
#
306296
__grub_mkrescue () {
307-
local cur prev last
297+
local cur prev words cword last
298+
_init_completion || return
308299

309300
COMPREPLY=()
310-
cur=`_get_cword`
311-
prev=${COMP_WORDS[COMP_CWORD-1]}
312301
last=$(__grub_get_last_option)
313302

314303
if [[ "$cur" == -* ]]; then
@@ -330,13 +319,10 @@ __grub_mkrescue () {
330319
# grub-mkimage
331320
#
332321
__grub_mkimage () {
333-
local cur prev split=false
322+
local cur prev words cword split
323+
_init_completion -s || return
334324

335325
COMPREPLY=()
336-
cur=`_get_cword`
337-
prev=${COMP_WORDS[COMP_CWORD-1]}
338-
339-
_split_longopt && split=true
340326

341327
case "$prev" in
342328
-d|--directory|-p|--prefix)
@@ -367,10 +353,10 @@ __grub_mkimage () {
367353
# grub-mkpasswd-pbkdf2
368354
#
369355
__grub_mkpasswd_pbkdf2 () {
370-
local cur
356+
local cur prev words cword
357+
_init_completion || return
371358

372359
COMPREPLY=()
373-
cur=`_get_cword`
374360

375361
if [[ "$cur" == -* ]]; then
376362
__grubcomp "$(__grub_get_options_from_help)"
@@ -384,13 +370,10 @@ __grub_mkpasswd_pbkdf2 () {
384370
# grub-probe
385371
#
386372
__grub_probe () {
387-
local cur prev split=false
373+
local cur prev words cword split
374+
_init_completion -s || return
388375

389376
COMPREPLY=()
390-
cur=`_get_cword`
391-
prev=${COMP_WORDS[COMP_CWORD-1]}
392-
393-
_split_longopt && split=true
394377

395378
case "$prev" in
396379
-t|--target)
@@ -417,10 +400,10 @@ __grub_probe () {
417400
# grub-script-check
418401
#
419402
__grub_script_check () {
420-
local cur
403+
local cur prev words cword
404+
_init_completion || return
421405

422406
COMPREPLY=()
423-
cur=`_get_cword`
424407

425408
if [[ "$cur" == -* ]]; then
426409
__grubcomp "$(__grub_get_options_from_help)"

0 commit comments

Comments
 (0)