From 13b26eee62f143e1b0b154f6e240b6f6bdd60f90 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Fri, 3 Aug 2018 14:30:30 +0200 Subject: [PATCH 1/3] Add bash completion for `cp --archive` Signed-off-by: Harald Albers Upstream-commit: b9b3754ad3fc795942bc7388b8d143701bf19515 Component: cli --- components/cli/contrib/completion/bash/docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/cli/contrib/completion/bash/docker b/components/cli/contrib/completion/bash/docker index e31467077c..133eda71bb 100644 --- a/components/cli/contrib/completion/bash/docker +++ b/components/cli/contrib/completion/bash/docker @@ -1437,7 +1437,7 @@ _docker_container_commit() { _docker_container_cp() { case "$cur" in -*) - COMPREPLY=( $( compgen -W "--follow-link -L --help" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "--archive -a --follow-link -L --help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) From 1dfbd7519ac43664a0805f8da18ce8e92c7fa6e9 Mon Sep 17 00:00:00 2001 From: Ace-Tang Date: Fri, 3 Aug 2018 21:13:46 +0800 Subject: [PATCH 2/3] bash completion: fix uncorrect completion fix uncorrect completion for command docker docker Signed-off-by: Ace-Tang Upstream-commit: 7b4e2f3145433f94fcb2c3e78c480422cdb9ff6d Component: cli --- components/cli/contrib/completion/bash/docker | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/cli/contrib/completion/bash/docker b/components/cli/contrib/completion/bash/docker index e31467077c..c7645397ef 100644 --- a/components/cli/contrib/completion/bash/docker +++ b/components/cli/contrib/completion/bash/docker @@ -5117,6 +5117,9 @@ _docker() { local counter=1 while [ "$counter" -lt "$cword" ]; do case "${words[$counter]}" in + docker) + return 0 + ;; # save host so that completion can use custom daemon --host|-H) (( counter++ )) From 73443cfafe81f2f85815384050520284eadeb935 Mon Sep 17 00:00:00 2001 From: Harald Albers Date: Fri, 3 Aug 2018 15:06:09 +0200 Subject: [PATCH 3/3] Fix shellcheck warnings Signed-off-by: Harald Albers Upstream-commit: e587ec293bf154281215189487d7504cc1d70666 Component: cli --- components/cli/contrib/completion/bash/docker | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/components/cli/contrib/completion/bash/docker b/components/cli/contrib/completion/bash/docker index e31467077c..90396147ba 100644 --- a/components/cli/contrib/completion/bash/docker +++ b/components/cli/contrib/completion/bash/docker @@ -288,10 +288,9 @@ __docker_complete_networks() { COMPREPLY=( $(compgen -W "$(__docker_networks "$@")" -- "$current") ) } -# shellcheck disable=SC2128,SC2178 __docker_complete_containers_in_network() { - local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1") - COMPREPLY=( $(compgen -W "$containers" -- "$cur") ) + local containers=($(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1")) + COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) } # __docker_volumes returns a list of all volumes. Additional options to @@ -347,8 +346,7 @@ __docker_plugins_bundled() { for del in "${remove[@]}" ; do plugins=(${plugins[@]/$del/}) done - # shellcheck disable=SC2145 - echo "${plugins[@]} ${add[@]}" + echo "${plugins[@]}" "${add[@]}" } # __docker_complete_plugins_bundled applies completion of plugins based on the current @@ -1456,8 +1454,7 @@ _docker_container_cp() { local containers=( ${COMPREPLY[@]} ) COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) ) - # shellcheck disable=SC2128 - if [[ "$COMPREPLY" == *: ]]; then + if [[ "${COMPREPLY[*]}" = *: ]]; then __docker_nospace fi return @@ -1955,8 +1952,7 @@ _docker_container_run_and_create() { ;; *) COMPREPLY=( $( compgen -W 'none host private shareable container:' -- "$cur" ) ) - # shellcheck disable=SC2128 - if [ "$COMPREPLY" = "container:" ]; then + if [ "${COMPREPLY[*]}" = "container:" ]; then __docker_nospace fi ;; @@ -2010,8 +2006,7 @@ _docker_container_run_and_create() { ;; *) COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) - # shellcheck disable=SC2128 - if [ "$COMPREPLY" = "container:" ]; then + if [ "${COMPREPLY[*]}" = "container:" ]; then __docker_nospace fi ;; @@ -2074,15 +2069,14 @@ _docker_container_run_and_create() { _docker_container_start() { __docker_complete_detach_keys && return - # shellcheck disable=SC2078 case "$prev" in --checkpoint) - if [ __docker_daemon_is_experimental ] ; then + if __docker_daemon_is_experimental ; then return fi ;; --checkpoint-dir) - if [ __docker_daemon_is_experimental ] ; then + if __docker_daemon_is_experimental ; then _filedir -d return fi