Wednesday, 16 July 2025

.env file when are quotes required

 https://stackoverflow.com/questions/71538752/when-are-quotes-needed-in-env-file



Use the quotation marks when the string contains spaces or certain special character and certain syntaxes. These include:

  • space and other whitespace,

  • backslash (escapes a space and newline – \  gives space even in unquoted string),

  • quotation marks (but you can combine multiple quotation mark\ 'styles like'"this"),

  • pound sign (#) that marks start of comment (if it is not in quotes string or $(…)),

  • dollar sign (that is used to expand a variable – see below),

  • parentheses (( and )) – depending on context,

  • shell redirection chars (><2>| etc.),

  • asterisk (*) and question mark (?), since it is used in globs,

  • square brackets (because they list characters),

  • comma-separated text in {…} (because it provides multiple variants of text – {foo,bar}baz expands to foobaz barbaz),

  • maybe others,

  • and of course, the newline.

No comments:

Post a Comment