Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eac9f2e

Browse files
committed
Minor bash completion cleanup
The -n and --networking options were removed because they are unsupported. Bash completion should not reveal the existence of otherwise undocumented unsupported options. Signed-off-by: Harald Albers <[email protected]>
1 parent 2e863e8 commit eac9f2e

1 file changed

Lines changed: 8 additions & 44 deletions

File tree

contrib/completion/bash/docker

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!bash
1+
#!/bin/bash
22
#
33
# bash completion file for core docker commands
44
#
5-
# This script provides supports completion of:
5+
# This script provides completion of:
66
# - commands and their options
77
# - container ids and names
88
# - image repos and tags
@@ -11,9 +11,9 @@
1111
# To enable the completions either:
1212
# - place this file in /etc/bash_completion.d
1313
# or
14-
# - copy this file and add the line below to your .bashrc after
15-
# bash completion features are loaded
16-
# . docker.bash
14+
# - copy this file to e.g. ~/.docker-completion.sh and add the line
15+
# below to your .bashrc after bash completion features are loaded
16+
# . ~/.docker-completion.sh
1717
#
1818
# Note:
1919
# Currently, the completions will not work if the docker daemon is not
@@ -153,8 +153,6 @@ _docker_docker() {
153153
-H)
154154
return
155155
;;
156-
*)
157-
;;
158156
esac
159157

160158
case "$cur" in
@@ -187,8 +185,6 @@ _docker_build() {
187185
__docker_image_repos_and_tags
188186
return
189187
;;
190-
*)
191-
;;
192188
esac
193189

194190
case "$cur" in
@@ -209,8 +205,6 @@ _docker_commit() {
209205
-m|--message|-a|--author|--run)
210206
return
211207
;;
212-
*)
213-
;;
214208
esac
215209

216210
case "$cur" in
@@ -362,13 +356,11 @@ _docker_create() {
362356
--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-p|--publish|--expose|--dns|--lxc-conf|--dns-search)
363357
return
364358
;;
365-
*)
366-
;;
367359
esac
368360

369361
case "$cur" in
370362
-*)
371-
COMPREPLY=( $( compgen -W "-n --networking --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir --cpuset -c --cpu-shares --name -a --attach -v --volume --link -e --env --env-file -p --publish --expose --dns --volumes-from --lxc-conf --security-opt --add-host --cap-add --cap-drop --device --dns-search --net --restart" -- "$cur" ) )
363+
COMPREPLY=( $( compgen -W "--privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir --cpuset -c --cpu-shares --name -a --attach -v --volume --link -e --env --env-file -p --publish --expose --dns --volumes-from --lxc-conf --security-opt --add-host --cap-add --cap-drop --device --dns-search --net --restart" -- "$cur" ) )
372364
;;
373365
*)
374366
local counter=$(__docker_pos_first_nonflag '--cidfile|--volumes-from|-v|--volume|-e|--env|--env-file|--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-a|--attach|--link|-p|--publish|--expose|--dns|--lxc-conf|--security-opt|--add-host|--cap-add|--cap-drop|--device|--dns-search|--net|--restart')
@@ -392,16 +384,12 @@ _docker_events() {
392384
--since)
393385
return
394386
;;
395-
*)
396-
;;
397387
esac
398388

399389
case "$cur" in
400390
-*)
401391
COMPREPLY=( $( compgen -W "--since" -- "$cur" ) )
402392
;;
403-
*)
404-
;;
405393
esac
406394
}
407395

@@ -480,8 +468,6 @@ _docker_inspect() {
480468
-f|--format)
481469
return
482470
;;
483-
*)
484-
;;
485471
esac
486472

487473
case "$cur" in
@@ -507,16 +493,12 @@ _docker_login() {
507493
-u|--username|-p|--password|-e|--email)
508494
return
509495
;;
510-
*)
511-
;;
512496
esac
513497

514498
case "$cur" in
515499
-*)
516500
COMPREPLY=( $( compgen -W "-u --username -p --password -e --email" -- "$cur" ) )
517501
;;
518-
*)
519-
;;
520502
esac
521503
}
522504

@@ -556,16 +538,12 @@ _docker_ps() {
556538
-n)
557539
return
558540
;;
559-
*)
560-
;;
561541
esac
562542

563543
case "$cur" in
564544
-*)
565545
COMPREPLY=( $( compgen -W "-q --quiet -s --size -a --all --no-trunc -l --latest --since --before -n" -- "$cur" ) )
566546
;;
567-
*)
568-
;;
569547
esac
570548
}
571549

@@ -574,8 +552,6 @@ _docker_pull() {
574552
-t|--tag)
575553
return
576554
;;
577-
*)
578-
;;
579555
esac
580556

581557
case "$cur" in
@@ -603,8 +579,6 @@ _docker_restart() {
603579
-t|--time)
604580
return
605581
;;
606-
*)
607-
;;
608582
esac
609583

610584
case "$cur" in
@@ -624,7 +598,6 @@ _docker_rm() {
624598
return
625599
;;
626600
*)
627-
local force=
628601
for arg in "${COMP_WORDS[@]}"; do
629602
case "$arg" in
630603
-f|--force)
@@ -748,16 +721,13 @@ _docker_run() {
748721
--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-p|--publish|--expose|--dns|--lxc-conf|--dns-search)
749722
return
750723
;;
751-
*)
752-
;;
753724
esac
754725

755726
case "$cur" in
756727
-*)
757-
COMPREPLY=( $( compgen -W "--rm -d --detach -n --networking --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir --cpuset -c --cpu-shares --sig-proxy --name -a --attach -v --volume --link -e --env --env-file -p --publish --expose --dns --volumes-from --lxc-conf --security-opt --add-host --cap-add --cap-drop --device --dns-search --net --restart" -- "$cur" ) )
728+
COMPREPLY=( $( compgen -W "--rm -d --detach --privileged -P --publish-all -i --interactive -t --tty --cidfile --entrypoint -h --hostname -m --memory -u --user -w --workdir --cpuset -c --cpu-shares --sig-proxy --name -a --attach -v --volume --link -e --env --env-file -p --publish --expose --dns --volumes-from --lxc-conf --security-opt --add-host --cap-add --cap-drop --device --dns-search --net --restart" -- "$cur" ) )
758729
;;
759730
*)
760-
761731
local counter=$(__docker_pos_first_nonflag '--cidfile|--volumes-from|-v|--volume|-e|--env|--env-file|--entrypoint|-h|--hostname|-m|--memory|-u|--user|-w|--workdir|--cpuset|-c|--cpu-shares|-n|--name|-a|--attach|--link|-p|--publish|--expose|--dns|--lxc-conf|--security-opt|--add-host|--cap-add|--cap-drop|--device|--dns-search|--net|--restart')
762732

763733
if [ $cword -eq $counter ]; then
@@ -779,16 +749,12 @@ _docker_search() {
779749
-s|--stars)
780750
return
781751
;;
782-
*)
783-
;;
784752
esac
785753

786754
case "$cur" in
787755
-*)
788756
COMPREPLY=( $( compgen -W "--no-trunc --automated -s --stars" -- "$cur" ) )
789757
;;
790-
*)
791-
;;
792758
esac
793759
}
794760

@@ -808,8 +774,6 @@ _docker_stop() {
808774
-t|--time)
809775
return
810776
;;
811-
*)
812-
;;
813777
esac
814778

815779
case "$cur" in
@@ -911,7 +875,7 @@ _docker() {
911875
local cur prev words cword
912876
_get_comp_words_by_ref -n : cur prev words cword
913877

914-
local command='docker'
878+
local command='docker' cpos=0
915879
local counter=1
916880
while [ $counter -lt $cword ]; do
917881
case "${words[$counter]}" in

0 commit comments

Comments
 (0)