Correctly interpret long form arguments that lack an equals symbol

This commit is contained in:
Adam Harrison authored and Paul Bellamy committed 2015-06-11 10:27:34 +01:00
1 parent 4f6ace8b10
commit a424bfe715
2 files changed
+20 -6

No files matched your search

+6 -2
View File
@@ -14,13 +14,17 @@ weave_on $HOST1 launch -iprange 10.2.0.0/24
start_container_with_dns $HOST1 --name=c1-name
start_container_with_dns $HOST1 --name=c2-name -h c2-hostname.weave.local.
start_container_with_dns $HOST1 --name=c3-name --hostname=c3-hostname.weave.local.
start_container_with_dns $HOST1 -h c4-hostname.weave.local. --name=c4-name
start_container_with_dns $HOST1 --hostname=c5-hostname.weave.local. --name=c5-name
start_container_with_dns $HOST1 --name=c4-name --hostname c4-hostname.weave.local.
start_container_with_dns $HOST1 -h c5-hostname.weave.local. --name=c5-name
start_container_with_dns $HOST1 --hostname=c6-hostname.weave.local. --name=c6-name
start_container_with_dns $HOST1 --hostname c7-hostname.weave.local. --name=c7-name
assert "docker_inspect_fqdn $HOST1 c1-name" "c1-name.weave.local."
assert "docker_inspect_fqdn $HOST1 c2-name" "c2-hostname.weave.local."
assert "docker_inspect_fqdn $HOST1 c3-name" "c3-hostname.weave.local."
assert "docker_inspect_fqdn $HOST1 c4-name" "c4-hostname.weave.local."
assert "docker_inspect_fqdn $HOST1 c5-name" "c5-hostname.weave.local."
assert "docker_inspect_fqdn $HOST1 c6-name" "c6-hostname.weave.local."
assert "docker_inspect_fqdn $HOST1 c7-name" "c7-hostname.weave.local."
end_suite
+14 -4
View File
@@ -650,16 +650,26 @@ dns_args() {
DNS_SEARCH_ARG="--dns-search=."
HOSTNAME_ARG=""
HOSTNAME_SPECIFIED=false
for arg in "$@" ; do
case $arg in
while [ $# -gt 0 ] ; do
case "$1" in
--dns-search=*)
DNS_SEARCH_ARG=""
shift
;;
--name)
HOSTNAME_ARG="--hostname=$2.$(dns_domain)"
shift 2
;;
--name=*)
HOSTNAME_ARG="--hostname=${arg#--name=}.$(dns_domain)"
HOSTNAME_ARG="--hostname=${1#*=}.$(dns_domain)"
shift
;;
-h|--hostname=*)
-h|--hostname|--hostname=*)
HOSTNAME_SPECIFIED=true
shift
;;
*)
shift
;;
esac
done