mirror of
https://github.com/containers/skopeo.git
synced 2025-08-11 19:32:04 +00:00
bash completion: use read -r instead of disabling SC2207
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
parent
b31f0da5c6
commit
1d8f5f29a5
@ -1,7 +1,4 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
# shellcheck shell=bash disable=SC2207
|
|
||||||
|
|
||||||
PROG="skopeo"
|
|
||||||
|
|
||||||
_complete_() {
|
_complete_() {
|
||||||
local options_with_args=$1
|
local options_with_args=$1
|
||||||
@ -19,13 +16,13 @@ _complete_() {
|
|||||||
|
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$boolean_options $options_with_args" -- "$cur")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [ -n "$transports" ]
|
if [ -n "$transports" ]
|
||||||
then
|
then
|
||||||
compopt -o nospace
|
compopt -o nospace
|
||||||
COMPREPLY=( $( compgen -W "$transports" -- "$cur" ) )
|
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$transports" -- "$cur")
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -34,7 +31,7 @@ _complete_() {
|
|||||||
_skopeo_supported_transports() {
|
_skopeo_supported_transports() {
|
||||||
local subcommand=$1
|
local subcommand=$1
|
||||||
|
|
||||||
${PROG} "$subcommand" --help | grep "Supported transports" -A 1 | tail -n 1 | sed -e 's/,/:/g' -e 's/$/:/'
|
skopeo "$subcommand" --help | grep "Supported transports" -A 1 | tail -n 1 | sed -e 's/,/:/g' -e 's/$/:/'
|
||||||
}
|
}
|
||||||
|
|
||||||
_skopeo_copy() {
|
_skopeo_copy() {
|
||||||
@ -168,11 +165,12 @@ _skopeo_skopeo() {
|
|||||||
|
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
|
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$boolean_options $options_with_args" -- "$cur")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
commands=$( "${COMP_WORDS[@]:0:$COMP_CWORD}" --generate-bash-completion )
|
commands=$( "${COMP_WORDS[@]:0:$COMP_CWORD}" --generate-bash-completion )
|
||||||
COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
|
|
||||||
|
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${commands[*]} help" -- "$cur")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@ -187,7 +185,7 @@ _cli_bash_autocomplete() {
|
|||||||
|
|
||||||
_get_comp_words_by_ref -n : cur prev words cword
|
_get_comp_words_by_ref -n : cur prev words cword
|
||||||
|
|
||||||
local command=${PROG} cpos=0
|
local command="skopeo" cpos=0
|
||||||
local counter=1
|
local counter=1
|
||||||
while [ $counter -lt "$cword" ]; do
|
while [ $counter -lt "$cword" ]; do
|
||||||
case "${words[$counter]}" in
|
case "${words[$counter]}" in
|
||||||
@ -207,4 +205,4 @@ _cli_bash_autocomplete() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F _cli_bash_autocomplete $PROG
|
complete -F _cli_bash_autocomplete skopeo
|
||||||
|
Loading…
Reference in New Issue
Block a user