Skip to content

Commit c44423e

Browse files
Support empty username and password for docker login.
In my testing, the check for an empty USERNAME by doing `-z "${USERNAME+x}"` always fails: it is never empty. The `+x` seems wrong to me. A trick like that can be needed when comparing two strings, but not when checking if a single string is empty. Let's test. First without the `USERNAME` variable existing at all: ``` $ env | grep USERNAME $ if [ -z "${USERNAME+x}" ] ; then echo "empty"; fi empty $ if [ -z "${USERNAME}" ] ; then echo "empty"; fi empty ``` Fine. Now with `USERNAME` variable defined, and not empty: ``` $ export USERNAME=me $ if [ -z "${USERNAME+x}" ] ; then echo "empty"; fi $ if [ -z "${USERNAME}" ] ; then echo "empty"; fi ``` Also fine. Now with `USERNAME` variable defined, but empty: ``` $ export USERNAME= $ if [ -z "${USERNAME+x}" ] ; then echo "empty"; fi $ if [ -z "${USERNAME}" ] ; then echo "empty"; fi empty ``` The check with `=x` is wrong here.
1 parent 1cd6c45 commit c44423e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

scripts/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ else
9696
fi
9797

9898
# PROCEED WITH LOGIN
99-
if [ -z "${USERNAME+x}" ] || [ -z "${PASSWORD+x}" ]; then
99+
if [ -z "${USERNAME}" ] || [ -z "${PASSWORD}" ]; then
100100
echo "Container Registry: No authentication provided"
101101
else
102102
[ -z ${REGISTRY+x} ] && export REGISTRY=""

0 commit comments

Comments
 (0)