We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YAML is not always readable. Here is an example of build config from Travis that failed, because of YAML parsing.
script: - echo "default shell: $SHELL"
To see what's wrong, let's use https://yaml-online-parser.appspot.com/ to convert it to Python.
>>> a = {'script': [{'echo "default shell': '$SHELL"'}]}
The logical way to get the first command to be executed it to get the first element from the script: array.
script:
>>> a['script'][0] {'echo "default shell': '$SHELL"'}
But wait, it is a dict. Should it be the string?
dict
>>> b['script'][0] 'echo "default shell: $SHELL"'
The correct YAML for b needs the whole line to be quoted.
b
script: - 'echo "default shell: $SHELL"'
Otherwise YAML splits the command on the first found colon :. It doesn't understand internal " quoting.
:
"
"Better" YAML should not allow any spaces in dict keys and spaces between the key and the colon.
echo: hello
then will still be equal to
{'echo': 'hello'}
But these will be just plain strings.
echo : hello
echo "say: hello"
Maybe HashiCorp HCL was born to be the Better YAML because of this gotcha.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
YAML is not always readable. Here is an example of build config from Travis that failed, because of YAML parsing.
To see what's wrong, let's use https://yaml-online-parser.appspot.com/ to convert it to Python.
The logical way to get the first command to be executed it to get the first element from the
script:
array.But wait, it is a
dict
. Should it be the string?The correct YAML for
b
needs the whole line to be quoted.Otherwise YAML splits the command on the first found colon
:
. It doesn't understand internal"
quoting.Solution
"Better" YAML should not allow any spaces in dict keys and spaces between the key and the colon.
then will still be equal to
But these will be just plain strings.
Maybe HashiCorp HCL was born to be the Better YAML because of this gotcha.
The text was updated successfully, but these errors were encountered: