-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
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
readme: recommend double rather than single quotes in YAML files #513
Comments
Hello @mcandre , |
Hi @mcandre 👋,
The choice between single and double quotes depends on the specific use case. If you need to include escape sequences in your string, you should use double quotes. If you want your string to be interpreted exactly as it is, you should use single quotes. Single quoted strings work for all scenarios In general. Both quoting styles are widely accepted and used in YAML files. The choice between them often comes down to personal preference and the specific needs of your project. Therefore, there is nothing incorrect about the usage in the README file. |
Anything other than double quote syntax for YAML strings is hazardous and unintuitive. The spec should deprecate non-double quote syntax in the interest of safety. |
Thank you for sharing your perspective, but I’d like to clarify that the YAML specification does not deprecate single quote syntax, and both single and double quotes are valid for string values, depending on the use case. That said, I’m curious—is there a broader consensus or any official documentation suggesting that non-double quote syntax should be deprecated for safety reasons or that it’s generally hazardous? I’d really appreciate any resources or documentation you can provide on this. |
The YAML spec doesn't recommend any particular file extension, either. It's an important document but does not answer every question about ideal YAML usage. Just because the spec offers a jumpable bridge does not mean we should apply it. |
El El vie, 22 de nov de 2024 a la(s) 3:11 p.m., Andrew <
***@***.***> escribió:
… The YAML spec doesn't recommend any particular file extension, either.
It's an important document but does not answer every question about ideal
YAML usage. Just because the spec offers a jumpable bridge does not mean we
should apply it.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hi @mcandre , |
Most programming languages support C-style escape characters in (single quoted) strings. YAML does not. Such sequences are interpreted differently, and the user has to remember up to three different semantics. That's not simple. For this reason, it is hazardous to use non-double quoted strings for YAML content. Following a rule of using only double-quoted strings is safe and simple. |
Description:
YAML breaks conventions for escape characters in at least one of its three string syntaxes. For this reason, recommend using double quotes (
"test"
) for string values, rather than single quotes ('test'
) or bare, unquoted strings (test
).Action version:
N/A
Platform:
N/A
Runner type:
N/A
Tools version:
N/A
https://yaml.org/spec/
The text was updated successfully, but these errors were encountered: