Skip to content

Commit 163fbd8

Browse files
author
Ian Campbell
committed
boot.sh: Correct use of "Alternate Value" expansion
Using `${var:+alt}` expands to the alternative value for variables which set _and_ non-empty, while `${var+alt}` expands to the alternative value for variables which are set, even if they are empty. $ ( foo="abc" ; bar="" ; echo "FOO: \"${foo+set}\" \"${foo:+set}\""; echo "BAR: \"${bar+set}\" \"${bar:+set}\""; echo "BAZ: \"${baz+set}\" \"${baz:+set}\"" ) FOO: "set" "set" BAR: "set" "" BAZ: "" "" The `${var:+alt}` semantics is what is needed here, it only really matters if the variable (`${kubeadm_data}` in this case) is ever set to `""`, which it never is here, but correct it anyway to avoid a potential future pitfall. Signed-off-by: Ian Campbell <ijc@docker.com>
1 parent 0d844b0 commit 163fbd8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

boot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ if [ $# -eq 0 ] ; then
2828
# then we configure for auto init. If it is completely unset then
2929
# we do not.
3030
if [ -n "${KUBE_MASTER_AUTOINIT+x}" ] ; then
31-
kubeadm_data="${kubeadm_data+$kubeadm_data, }\"init\": { \"content\": \"${KUBE_MASTER_AUTOINIT}\" }"
31+
kubeadm_data="${kubeadm_data:+$kubeadm_data, }\"init\": { \"content\": \"${KUBE_MASTER_AUTOINIT}\" }"
3232
fi
3333
if [ "${KUBE_MASTER_UNTAINT}" = "y" ] ; then
34-
kubeadm_data="${kubeadm_data+$kubeadm_data, }\"untaint-master\": { \"content\": \"\" }"
34+
kubeadm_data="${kubeadm_data:+$kubeadm_data, }\"untaint-master\": { \"content\": \"\" }"
3535
fi
3636

3737
state="kube-master-state"

0 commit comments

Comments
 (0)