Skip to content
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

Open
mcandre opened this issue Nov 9, 2024 · 5 comments
Open

readme: recommend double rather than single quotes in YAML files #513

mcandre opened this issue Nov 9, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@mcandre
Copy link

mcandre commented Nov 9, 2024

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/

@mcandre mcandre added bug Something isn't working needs triage labels Nov 9, 2024
@gowridurgad
Copy link

Hello @mcandre ,
Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.

@priyagupta108 priyagupta108 self-assigned this Nov 14, 2024
@priyagupta108
Copy link
Contributor

Hi @mcandre 👋,
The YAML specification doesn't seem to specifically encourage using double quotes.
In YAML, both single quotes ' and double quotes " can be used to denote string values, but they have different behaviors:

  • Single quotes allow almost any character in your string and won't parse escape codes. For example, '\n' would be interpreted literally as the string \n.
  • Double quotes parse escape codes, so "\n" would be interpreted as a line feed character.

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.

@mcandre
Copy link
Author

mcandre commented Nov 20, 2024

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.

@priyagupta108
Copy link
Contributor

priyagupta108 commented Nov 22, 2024

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.

@mcandre
Copy link
Author

mcandre commented Nov 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants