There seem to be only three rules about parsing the .env files: (1) they need to be encoded in UTF-8, (2) comment lines start with #, and (3) the format is VAR=VAL. But how quotation marks are parsed? Bash has it's specific rules for them, but .env are not Bash. I also found that Docker takes the quotation marks as-is. On another hand, I saw .env files using quotation marks.
Are there any formal rules? Should quotation marks be avoided in .env files, or when shouldn't they?
Related
I have my Path environment variable with a subset of the paths enclosed with quotation marks (see Figure). This gives me problems in launching some applications which need the Path variable. I opened the Control Panel and I can see that there are no quotation marks there. I also don't understand why the string with quotation marks compares twice, but the first time without quotation marks.
Any suggestion on how to modify it?
Im trying to copy a file in docker with below format
database-20.2.1.zip
I have tried using something like below, but it does not seems to work
COPY databse-+([0-9]).+([0-9]).+([0-9]).zip /docker-entrypoint-initdb.d/database.zip
Is this something that can be done in docker copy ?
Dockerfile COPY uses shell globs, not regular expressions. The actual implementation uses the Go filepath.Match syntax. That syntax doesn't allow some of the combinations that regular expressions do: you can match any single digit [0-9], or any number of characters *, but not any number of digits.
Depending on how strict you want to be about what files you'll accept and how consistent the filename format is, any of the following will work:
COPY database-[0-9][0-9].[0-9].[0-9].zip ./database.zip
COPY database-*.*.*.zip ./database.zip
COPY database-*.zip ./database.zip
In all cases note that the pattern can match multiple files in the build context. If the right-hand side of COPY is a single file name (not ending with /) but the glob matches multiple files you will get a build error. In this case that's probably what you want.
The Erlang official user's guide (http://erlang.org/doc/reference_manual/data_types.html#id67942) says:
An atom is to be enclosed in single quotes (') if it does not begin with a lower-case letter or if it contains other characters than alphanumeric characters, underscore (_), or #.
Why Erlang allows an atom to include bare # signs? Does it have a practical usage, or any historical meaning?
Does it have a practical usage
Yes it does. Node names in Erlang are represented as atoms and they contain an # separating the name and host. Allowing # in atoms without single quotes makes it convenient to type them (unless they contain other special characters like . or -).
$ erl
1> foo#bar.
foo#bar
I'm working on a translation project and I'm moving all of the English strings out of the views and into a YAML file. Some of the very well written strings employ special characters such as ampersands and N-dashes.
Is there any way to include those?
In the meantime I've turned "&" to "and" and "–" to "--"
but, at least in the English version, I feel like the copy starts to loose it's flavor. I doubt the Chinese version will miss these, but maybe they will want different special characters that I don't know about.
You can have special characters in YAML file values as long as they're not at the beginning of a string.
In the case of &, for example, if it is the first character of your string, then your YAML parser will think it's an anchor, when it tries to read the string (if it's not, like key: this & that, then it will be read as a string, as you would expect).
For more information about what you can and can't have in your YAML strings (and what are considered special characters), see:
YAML Ruby Cookbook
The question and accepted answer for Do I need quotes for strings in Yaml?
Every to_yaml output have three leading dashes:
---
a:
b:
c: soemthing
How convert object to yaml without leading dashes?
From the YAML specification:
YAML uses three dashes (“---”) to separate directives from document content. This also serves to signal the start of a document if no directives are present.
That means: Your example starts as a valid YAML document should start. Nothing wrong with it.
Under the hood, to_yaml uses Psych to parse and emit your data.
Though there are optional parameters you can specify (listed here), none suppress the leading dashes.
The simplest approach would be to gsub away the dashes.
object.to_yaml.gsub(/^---$/, "")