Support empty username and password for docker login.#12
Conversation
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.
|
Ah, I should have searched for that in shell documentation. Now I found this: First, And then you have either
So with the
And So in our case BTW, if we use |
For background, see issue #11, but that has a bigger picture than you need to review this PR.
In my testing, the check for an empty USERNAME by doing
-z "${USERNAME+x}"always fails: it is never empty. The+xseems wrong to me. A trick like that can be needed when comparing two strings, but not when checking if a single string is empty.I have tested in a shell. First without the
USERNAMEvariable existing at all:Fine.
Now with
USERNAMEvariable defined, and not empty:Also fine.
Now with
USERNAMEvariable defined, but empty:The check with
+xis wrong here.I have tested my fix on a different branch, where I did some extra changes so I could make my own docker image available. Usage is then like this: