Skip to contentSkip to conversation

bash-completion: Remove obsolete usage of 'have' function

PATCH In review Mike Gilbert 4 participants 6 messages Dec 6, 2014 – Dec 7, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bash-completion: Remove obsolete usage of 'have' function

Recent versions of bash-completion do not provide the 'have' function. To keep things simple, this patch just removes it completely.

---
 ChangeLog                                      |  4 ++
 util/bash-completion.d/grub-completion.bash.in | 66 +++++---------------------
 2 files changed, 17 insertions(+), 53 deletions(-)
ChangeLog +4 -0
index a9ed5aa..3554467 100644
@@ -1,3 +1,7 @@
+2014-12-05  Mike Gilbert  <[email protected]>
+	* util/bash-completion.d/grub-completion.bash.in: Remove references to
+	'have' function.
+
 2014-12-05  Andrei Borzenkov  <[email protected]>
 
 	* tests/util/grub-shell.in: Support --files also for netboot.
util/bash-completion.d/grub-completion.bash.in +13 -53

132 lines not on this page · raw message

Signature · 1 line
2.2.0
#1 lore raw

В Fri, 5 Dec 2014 22:22:23 -0500
Mike Gilbert <[email protected]> пишет:

Quoted 1 line

Recent versions of bash-completion do not provide the 'have' function.

It still does as of today GIT.

Quoted 1 line

To keep things simple, this patch just removes it completely.

No, that is not what was intended when 'have' was deprecated. You should put completion for each command in separate function which is then autoloaded on demand.

Quoted 164 lines
---
 ChangeLog                                      |  4 ++
 util/bash-completion.d/grub-completion.bash.in | 66 +++++---------------------
 2 files changed, 17 insertions(+), 53 deletions(-)
ChangeLog +4 -0
index a9ed5aa..3554467 100644
@@ -1,3 +1,7 @@
+2014-12-05  Mike Gilbert  <[email protected]>
+	* util/bash-completion.d/grub-completion.bash.in: Remove references to
+	'have' function.
+
 2014-12-05  Andrei Borzenkov  <[email protected]>
 
 	* tests/util/grub-shell.in: Support --files also for netboot.
util/bash-completion.d/grub-completion.bash.in +13 -53
index 44bf135..2b98004 100644
@@ -165,15 +165,8 @@ _grub_set_entry () {
     fi
 }
 
-__grub_set_default_program="@grub_set_default@"
-have ${__grub_set_default_program} && \
-    complete -F _grub_set_entry -o filenames ${__grub_set_default_program}
-unset __grub_set_default_program
-
-__grub_reboot_program="@grub_reboot@"
-have ${__grub_reboot_program} && \
- complete -F _grub_set_entry -o filenames ${__grub_reboot_program}
-unset __grub_reboot_program
+complete -F _grub_set_entry -o filenames @grub_set_default@
+complete -F _grub_set_entry -o filenames @grub_reboot@
 
 
 #
@@ -197,10 +190,7 @@ _grub_editenv () {
                 create list set unset"
 }
 
-__grub_editenv_program="@grub_editenv@"
-have ${__grub_editenv_program} && \
- complete -F _grub_editenv -o filenames ${__grub_editenv_program}
-unset __grub_editenv_program
+complete -F _grub_editenv -o filenames @grub_editenv@
 
 
 #
@@ -218,10 +208,7 @@ _grub_mkconfig () {
         _filedir
     fi
 }
-__grub_mkconfig_program="@grub_mkconfig@"
-have ${__grub_mkconfig_program} && \
- complete -F _grub_mkconfig -o filenames ${__grub_mkconfig_program}
-unset __grub_mkconfig_program
+complete -F _grub_mkconfig -o filenames @grub_mkconfig@
 
 
 #
@@ -253,15 +240,8 @@ _grub_setup () {
     fi
 }
 
-__grub_bios_setup_program="@grub_bios_setup@"
-have ${__grub_bios_setup_program} && \
- complete -F _grub_setup -o filenames ${__grub_bios_setup_program}
-unset __grub_bios_setup_program
-
-__grub_sparc64_setup_program="@grub_sparc64_setup@"
-have ${__grub_sparc64_setup_program} && \
- complete -F _grub_setup -o filenames ${__grub_sparc64_setup_program}
-unset __grub_sparc64_setup_program
+complete -F _grub_setup -o filenames @grub_bios_setup@
+complete -F _grub_setup -o filenames @grub_sparc64_setup@
 
 
 #
@@ -304,10 +284,7 @@ _grub_install () {
         _filedir
     fi
 }
-__grub_install_program="@grub_install@"
-have ${__grub_install_program} && \
- complete -F _grub_install -o filenames ${__grub_install_program}
-unset __grub_install_program
+complete -F _grub_install -o filenames @grub_install@
 
 
 #
@@ -326,10 +303,7 @@ _grub_mkfont () {
         _filedir
     fi
 }
-__grub_mkfont_program="@grub_mkfont@"
-have ${__grub_mkfont_program} && \
- complete -F _grub_mkfont -o filenames ${__grub_mkfont_program}
-unset __grub_mkfont_program
+complete -F _grub_mkfont -o filenames @grub_mkfont@
 
 
 #
@@ -357,10 +331,7 @@ _grub_mkrescue () {
         _filedir
     fi
 }
-__grub_mkrescue_program="@grub_mkrescue@"
-have ${__grub_mkrescue_program} && \
- complete -F _grub_mkrescue -o filenames ${__grub_mkrescue_program}
-unset __grub_mkrescue_program
+complete -F _grub_mkrescue -o filenames @grub_mkrescue@
 
 
 #
@@ -399,10 +370,7 @@ _grub_mkimage () {
         _filedir
     fi
 }
-__grub_mkimage_program="@grub_mkimage@"
-have ${__grub_mkimage_program} && \
- complete -F _grub_mkimage -o filenames ${__grub_mkimage_program}
-unset __grub_mkimage_program
+complete -F _grub_mkimage -o filenames @grub_mkimage@
 
 
 #
@@ -421,10 +389,7 @@ _grub_mkpasswd_pbkdf2 () {
         _filedir
     fi
 }
-__grub_mkpasswd_pbkdf2_program="@grub_mkpasswd_pbkdf2@"
-have ${__grub_mkpasswd_pbkdf2_program} && \
- complete -F _grub_mkpasswd_pbkdf2 -o filenames ${__grub_mkpasswd_pbkdf2_program}
-unset __grub_mkpasswd_pbkdf2_program
+complete -F _grub_mkpasswd_pbkdf2 -o filenames @grub_mkpasswd_pbkdf2@
 
 
 #
@@ -459,10 +424,7 @@ _grub_probe () {
         _filedir
     fi
 }
-__grub_probe_program="@grub_probe@"
-have ${__grub_probe_program} && \
- complete -F _grub_probe -o filenames ${__grub_probe_program}
-unset __grub_probe_program
+complete -F _grub_probe -o filenames @grub_probe@
 
 
 #
@@ -481,9 +443,7 @@ _grub_script_check () {
         _filedir
     fi
 }
-__grub_script_check_program="@grub_script_check@"
-have ${__grub_script_check_program} && \
- complete -F _grub_script_check -o filenames ${__grub_script_check_program}
+complete -F _grub_script_check -o filenames @grub_script_check@
 
 
 # Local variables:
#2 lore raw
Quoted 6 lines · Andrei Borzenkov

В Fri, 5 Dec 2014 22:22:23 -0500
Mike Gilbert <[email protected]> пишет:

Quoted 1 line

Recent versions of bash-completion do not provide the 'have' function.

It still does as of today GIT.

Right, sorry. I should have said it is marked as deprecated.

#3 lore raw
In reply to Andrei Borzenkov
Quoted 8 lines · Andrei Borzenkov <arvidjaar <at> gmail.com> writes:

В Fri, 5 Dec 2014 22:22:23 -0500
Mike Gilbert <floppym <at> gentoo.org> пишет:

Quoted 1 line

Recent versions of bash-completion do not provide the 'have' function.

It still does as of today GIT.

# Backwards compatibility for compat completions that use have(). # @deprecated should no longer be used; generally not needed with dynamically
# loaded completions, and _have is suitable for runtime use.
have()
{
unset -v have
_have && have=yes
}

All major Linux distributions are using bash-completion version which support dynamically loaded completions. Therefor we should cleanup shipped bash-completions.

Quoted 5 lines
Quoted 1 line

To keep things simple, this patch just removes it completely.

No, that is not what was intended when 'have' was deprecated. You should put completion for each command in separate function which is then autoloaded on demand.

It was intended that you have one file (or a symlink) with the name of the command which will be completed. That means dropping all have and pointing symlinks with all support completions will fix it.

Or how would you update to recent bash-completion?

Justin

#4 lore raw

В Sun, 7 Dec 2014 18:23:13 +0000 (UTC)
Justin <[email protected]> пишет:

Quoted 27 lines
Quoted 8 lines · Andrei Borzenkov <arvidjaar <at> gmail.com> writes:

В Fri, 5 Dec 2014 22:22:23 -0500
Mike Gilbert <floppym <at> gentoo.org> пишет:

Quoted 1 line

Recent versions of bash-completion do not provide the 'have' function.

It still does as of today GIT.

# Backwards compatibility for compat completions that use have(). # @deprecated should no longer be used; generally not needed with dynamically
# loaded completions, and _have is suitable for runtime use.
have()
{
unset -v have
_have && have=yes
}

All major Linux distributions are using bash-completion version which support dynamically loaded completions. Therefor we should cleanup shipped bash-completions.

Quoted 2 lines
Quoted 1 line

To keep things simple, this patch just removes it completely.

Quoted 8 lines
Quoted 3 lines

No, that is not what was intended when 'have' was deprecated. You should put completion for each command in separate function which is then autoloaded on demand.

It was intended that you have one file (or a symlink) with the name of the command which will be completed. That means dropping all have and pointing symlinks with all support completions will fix it.

That was what I meant. Sorry, had to say "file" not "function".

Quoted 2 lines

Or how would you update to recent bash-completion?

bash-completion will process /etc/bash_completion.d and will source current grub completion just fine. But if you want to really adapt it, just removing calls to have() is not enough; you also need to fix install target and probably split it in separate files for each command.

#5 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Quoted 6 lines · Andrei Borzenkov

bash-completion will process /etc/bash_completion.d and will source current grub completion just fine. But if you want to really adapt it, just removing calls to have() is not enough; you also need to fix install target and probably split it in separate files for each command.

So you would accept a patch splitting the monolithic file into separate completion definition along with the necessary fixes in the buildsystem? If so, I will send the patch.

Justin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0

iQJ8BAEBCgBmBQJUhJ74XxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQyQ0JDQjFGMzBDQ0UxMjFGNENDNDgxMDdC OUQ0RjIzMUJEMTU1OEFCAAoJELnU8jG9FVirYeoP/AiuCQvtpZkPGGbc1pDQMQsM OndstG1iS8clMYTkeD+GAbi+eBfBMIYpocJsYcXOekfklMtCdOxIrxrJrhXQuhjI PndHIO8rEDODy2tNynHieNomOpfDgcOZ3cX615k/qa7WWCtKdEsg9xADwIvZPKHD KSREENfztA+ymm6asfIWMrXZVxrfrPsctcRwHwmr32WetSNdmQwx8kNa+P+xW5Vp 7Z+XlAgG+9mS6eWP7t30fmRBRMKZauJawPbnpUD7BUZ4Zd9ynsHIZ5SX47ewI4AM heHRg6Ik5xddnvdG2cjGSDwTtVREj7xkvtaL48o27UpgSCOemkOTHXnIVeCN5+G7 pomLWQIqvLic4vR/17o0z2JHjoeDJpSYp5sTeUHj9g7CUnZ/qaGN1DffEgh/DsLy GhmEaaeecNLuvk2J95a75t1GXv9a8qzgxSdqmcgock7kjoyR4GSjymI680GrtR1x 4ge01M5/J5CUd8UIrm7z6Wonb8CX6DJbf1FU9qygu43MZZbTV19a/Q/TH/RPDsRk 9Ovnsw2tQZaXWHpaR8XDd5XYsQCaYXegZaWJSSs0WBLmygDqbAKBYyj6pXLIhyKR oUjqz/cHEujWjOepLhnUeibDk+09ROULo22kNVGmmRt7FNBkUvNysasF+nrHc/7N VyECfb7DBPoI1efMSVtd
=Jl7m
-----END PGP SIGNATURE-----