util/bash-completion: Load scripts on demand
PATCH 1/1 util/bash-completion: Load scripts on demand
There are two system directories for bash-completion scripts. One is /usr/share/bash-completion/completions and the other is /etc/bash_completion.d/. The 'etc' scripts are loaded in advance and for backward compatibility while the 'usr' scripts are loaded on demand. To load scripts on demand, it requires the corresponding script to every command, so the main bash-completion script is split into several subscripts for different grub commands. To share the code, the real completion functions are still implemented in 'grub', and each subscript sources 'grub' and invokes the corresponding function.
--- util/bash-completion.d/Makefile.am | 114 +++++++++++++++++- .../bash-completion.d/grub-bios-setup.bash.in | 30 +++++ .../bash-completion.d/grub-completion.bash.in | 89 ++------------ util/bash-completion.d/grub-editenv.bash.in | 30 +++++ util/bash-completion.d/grub-install.bash.in | 30 +++++ util/bash-completion.d/grub-mkconfig.bash.in | 30 +++++ util/bash-completion.d/grub-mkfont.bash.in | 30 +++++ util/bash-completion.d/grub-mkimage.bash.in | 30 +++++ .../grub-mkpasswd-pbkdf2.bash.in | 30 +++++ util/bash-completion.d/grub-mkrescue.bash.in | 30 +++++ util/bash-completion.d/grub-probe.bash.in | 30 +++++ util/bash-completion.d/grub-reboot.bash.in | 30 +++++ .../grub-script-check.bash.in | 30 +++++ .../grub-set-default.bash.in | 30 +++++ .../grub-sparc64-setup.bash.in | 30 +++++ 15 files changed, 510 insertions(+), 83 deletions(-) create mode 100644 util/bash-completion.d/grub-bios-setup.bash.in create mode 100644 util/bash-completion.d/grub-editenv.bash.in create mode 100644 util/bash-completion.d/grub-install.bash.in create mode 100644 util/bash-completion.d/grub-mkconfig.bash.in create mode 100644 util/bash-completion.d/grub-mkfont.bash.in create mode 100644 util/bash-completion.d/grub-mkimage.bash.in create mode 100644 util/bash-completion.d/grub-mkpasswd-pbkdf2.bash.in create mode 100644 util/bash-completion.d/grub-mkrescue.bash.in create mode 100644 util/bash-completion.d/grub-probe.bash.in create mode 100644 util/bash-completion.d/grub-reboot.bash.in create mode 100644 util/bash-completion.d/grub-script-check.bash.in create mode 100644 util/bash-completion.d/grub-set-default.bash.in create mode 100644 util/bash-completion.d/grub-sparc64-setup.bash.in
util/bash-completion.d/Makefile.am +109 -5
@@ -1,13 +1,117 @@ - bash_completion_source = grub-completion.bash.in bash_completion_script = grub +grub_bios_setup_source = grub-bios-setup.bash.in +grub_bios_setup_script = @grub_bios_setup@ +grub_editenv_source = grub-editenv.bash.in +grub_editenv_script = @grub_editenv@ +grub_install_source = grub-install.bash.in +grub_install_script = @grub_install@ +grub_mkconfig_source = grub-mkconfig.bash.in +grub_mkconfig_script = @grub_mkconfig@ +grub_mkfont_source = grub-mkfont.bash.in +grub_mkfont_script = @grub_mkfont@ +grub_mkimage_source = grub-mkimage.bash.in +grub_mkimage_script = @grub_mkimage@ +grub_mkpasswd_pbkdf2_source = grub-mkpasswd-pbkdf2.bash.in +grub_mkpasswd_pbkdf2_script = @grub_mkpasswd_pbkdf2@ +grub_mkrescue_source = grub-mkrescue.bash.in +grub_mkrescue_script = @grub_mkrescue@ +grub_probe_source = grub-probe.bash.in +grub_probe_script = @grub_probe@ +grub_reboot_source = grub-reboot.bash.in +grub_reboot_script = @grub_reboot@ +grub_script_check_source = grub-script-check.bash.in +grub_script_check_script = @grub_script_check@ +grub_set_default_source = grub-set-default.bash.in +grub_set_default_script = @grub_set_default@ +grub_sparc64_setup_source = grub-sparc64-setup.bash.in +grub_sparc64_setup_script = @grub_sparc64_setup@ -EXTRA_DIST = $(bash_completion_source) +EXTRA_DIST = $(bash_completion_source) \ + $(grub_bios_setup_source) \ + $(grub_editenv_source) \ + $(grub_install_source) \ + $(grub_mkconfig_source) \ + $(grub_mkfont_source) \ + $(grub_mkimage_source) \ + $(grub_mkpasswd_pbkdf2_source) \ + $(grub_mkrescue_source) \ + $(grub_probe_source) \ + $(grub_reboot_source) \ + $(grub_script_check_source) \ + $(grub_set_default_source) \ + $(grub_sparc64_setup_source) -CLEANFILES = $(bash_completion_script) config.log +CLEANFILES = $(bash_completion_script) \ + $(grub_bios_setup_script) \ + $(grub_editenv_script) \ + $(grub_install_script) \ + $(grub_mkconfig_script) \ + $(grub_mkfont_script) \ + $(grub_mkimage_script) \ + $(grub_mkpasswd_pbkdf2_script) \ + $(grub_mkrescure_script) \ + $(grub_probe_script) \ + $(grub_reboot_script) \ + $(grub_script_check_script) \ + $(grub_set_default_script) \ + $(grub_sparc64_setup_script) \ + config.log -bashcompletiondir = $(sysconfdir)/bash_completion.d -bashcompletion_DATA = $(bash_completion_script) +bashcompletiondir = $(datarootdir)/bash-completion/completions +bashcompletion_DATA = $(bash_completion_script) \ + $(grub_bios_setup_script) \ + $(grub_editenv_script) \ + $(grub_install_script) \ + $(grub_mkconfig_script) \ + $(grub_mkfont_script) \ + $(grub_mkimage_script) \ + $(grub_mkpasswd_pbkdf2_script) \ + $(grub_mkrescure_script) \ + $(grub_probe_script) \ + $(grub_reboot_script) \ + $(grub_script_check_script) \ + $(grub_set_default_script) \ + $(grub_sparc64_setup_script) $(bash_completion_script): $(bash_completion_source) $(top_builddir)/config.status $(top_builddir)/config.status --file=$@:$< + +$(grub_bios_setup_script): $(grub_bios_setup_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_editenv_script): $(grub_editenv_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_install_script): $(grub_install_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_mkconfig_script): $(grub_mkconfig_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_mkfont_script): $(grub_mkfont_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_mkimage_script): $(grub_mkimage_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_mkpasswd_pbkdf2_script): $(grub_mkpasswd_pbkdf2_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_mkrescue_script): $(grub_mkrescue_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_probe_script): $(grub_probe_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_reboot_script): $(grub_reboot_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_script_check_script): $(grub_script_check_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_set_default_script): $(grub_set_default_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$< + +$(grub_sparc64_setup_script): $(grub_sparc64_setup_source) $(top_builddir)/config.status + $(top_builddir)/config.status --file=$@:$<
util/bash-completion.d/grub-bios-setup.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-bios-setup@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_bios_setup () { + . @datarootdir@/bash-completion/completions/grub && __grub_setup +} +complete -F _grub_bios_setup -o filenames @grub_bios_setup@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-completion.bash.in +11 -78
198 lines not on this page · raw message
util/bash-completion.d/grub-editenv.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-editenv@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_editenv () { + . @datarootdir@/bash-completion/completions/grub && __grub_editenv +} +complete -F _grub_editenv -o filenames @grub_editenv@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-install.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-install@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_install () { + . @datarootdir@/bash-completion/completions/grub && __grub_install +} +complete -F _grub_install -o filenames @grub_install@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-mkconfig.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-mkconfig@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_mkconfig () { + . @datarootdir@/bash-completion/completions/grub && __grub_mkconfig +} +complete -F _grub_mkconfig -o filenames @grub_mkconfig@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-mkfont.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-mkfont@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_mkfont () { + . @datarootdir@/bash-completion/completions/grub && __grub_mkfont +} +complete -F _grub_mkfont -o filenames @grub_mkfont@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-mkimage.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-mkimage@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_mkimage () { + . @datarootdir@/bash-completion/completions/grub && __grub_mkimage +} +complete -F _grub_mkimage -o filenames @grub_mkimage@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-mkpasswd-pbkdf2.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-mkpasswd-pbkdf2@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_mkpasswd_pbkdf2 () { + . @datarootdir@/bash-completion/completions/grub && __grub_mkpasswd_pbkdf2 +} +complete -F _grub_mkpasswd_pbkdf2 -o filenames @grub_mkpasswd_pbkdf2@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-mkrescue.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-mkresue@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_mkrescue () { + . @datarootdir@/bash-completion/completions/grub && __grub_mkrescue +} +complete -F _grub_mkrescue -o filenames @grub_mkrescue@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-probe.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-probe@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_probe () { + . @datarootdir@/bash-completion/completions/grub && __grub_probe +} +complete -F _grub_probe -o filenames @grub_probe@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-reboot.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-reboot@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_reboot () { + . @datarootdir@/bash-completion/completions/grub && __grub_set_entry +} +complete -F _grub_reboot -o filenames @grub_reboot@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-script-check.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-script-check@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_script_check () { + . @datarootdir@/bash-completion/completions/grub && __grub_script_check +} +complete -F _grub_script_check -o filenames @grub_script_check@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-set-default.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-set-default@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_set_default () { + . @datarootdir@/bash-completion/completions/grub && __grub_set_entry +} +complete -F _grub_set_default -o filenames @grub_set_default@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
util/bash-completion.d/grub-sparc64-setup.bash.in new file +30 -0
@@ -0,0 +1,30 @@ +# +# Bash completion for @grub-sparc64-setup@ +# +# Copyright (C) 2024 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see <http://www.gnu.org/licenses/>. + +_grub_sparc64_setup () { + . @datarootdir@/bash-completion/completions/grub && __grub_setup +} +complete -F _grub_sparc64_setup -o filenames @grub_sparc64_setup@ + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
Signature · 7 lines
2.35.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 11 lines · Gary Lin via Grub-devel
There are two system directories for bash-completion scripts. One is
/usr/share/bash-completion/completionsand the other is/etc/bash_completion.d/. The 'etc' scripts are loaded in advance and for backward compatibility while the 'usr' scripts are loaded on demand. To load scripts on demand, it requires the corresponding script to every command, so the main bash-completion script is split into several subscripts for different grub commands. To share the code, the real completion functions are still implemented in 'grub', and each subscript sources 'grub' and invokes the corresponding function.Signed-off-by Gary Lin <[email protected]>
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel