[devel] [SCM] packages/control: heads/sisyphus
Dmitry V. Levin
ldv на altlinux.org
Чт Янв 27 16:59:11 MSK 2022
On Thu, Jan 27, 2022 at 01:17:01PM +0000, Andrey Limachko wrote:
> Update of /people/liannnix/packages/control.git
[...]
> diff --git a/control/control.bash_completion b/control/control.bash_completion
> new file mode 100644
> index 0000000..6f35d9c
> --- /dev/null
> +++ b/control/control.bash_completion
> @@ -0,0 +1,17 @@
> +#!/bin/bash
> +
> +_control_completions()
> +{
> + local facilities_fullpath=($(compgen -A file /etc/control.d/facilities/))
> + local facilities=(${facilities_fullpath[@]##*/})
> + facilities=(${facilities[@]##.*})
Непонятно, зачем понадобилась последняя строка.
> + if [[ ${#COMP_WORDS[@]} -le 3 && ${COMP_CWORD} -eq 1 ]]; then
> + COMPREPLY=($(compgen -W "${facilities[*]}" "${COMP_WORDS[1]}"))
> + elif [[ ${#COMP_WORDS[@]} -eq 3 && ${COMP_CWORD} -eq 2 && " ${facilities[*]} " == *" ${COMP_WORDS[1]} "* ]]; then
Эта строка длинновата, надо сделать перенос.
> + local current_facility=${COMP_WORDS[1]}
> + local actions=($(${COMP_WORDS[0]} ${current_facility} list))
> + COMPREPLY=($(compgen -W "${actions[*]}" "${COMP_WORDS[2]}"))
А не проще ли написать "${COMP_WORDS[0]} ${COMP_WORDS[1]} list"
чем две строки присваиваний с последующим "${actions[*]}"?
--
ldv
Подробная информация о списке рассылки Devel