Quote variables for well defined behavior #527
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By quoting variables we can improve stability of this script. $HOME and $password are both user supplied variables, that may contain spaces.
We need to quote them, or they may be expanded into extra arguments. This means this scripit will no longer break, if a space is supplied inside the password.
What
In tests it was discovered that setup sometime fails. This turned out due to passwords that contain spaces, breaking the setup script.
This PR tries to fix this problem, and mitigates a couple of other potential issues.
Currently the problem still persists. I suspect that the same problem also happens inside the container entrypoint, and needs to be quoted there as well. Until then this PR will remain a draft.
Why
Variables should be quoted if they may contain spaces (
$password
,$DOWNLOAD_DIR
).read
treats backslashes differently, which can be annoying when entering a random password. with the-r
flag we can disable this behavior.$@
will return an array of all arguments, which will then be translated into a string. When using$*
we will get a sting which is safe to use, as its behavior is defined.References
DEVOPS-1304
Test run failing in test-community-containers
Checklist