Description
Tokenize a restricted unquoted dotenv assignment with portable ASCII name and comments beginning at start or after whitespace; rejects quoting, interpolation and multiline syntax.
Environment assignments pair names with literal string values. Repeated names need an explicit first/last policy, and missing values differ from present empty strings. A dotenv file and a shell program can use different quoting and expansion rules; these tools implement their stated literal subsets using supplied data.
Tokenize a restricted unquoted dotenv assignment with portable ASCII name and comments beginning at start or after whitespace; rejects quoting, interpolation and multiline syntax.
When to use this tool
Use this tool to tokenize a restricted unquoted dotenv assignment with portable ASCII name and comments beginning at start or after whitespace; rejects quoting, interpolation and multiline syntax.
How to use the tool and how it works
- Enter line using the input definitions below.
- Run the operation. Resolve malformed-input errors before interpreting the result.
- Read result.name, result.value, result.comment. Interpret signs, units, ordering and null values using the rules below.
Parse a single unquoted NAME=value line with optional surrounding assignment whitespace. In the raw value, start a comment at a hash at position zero or after space/tab; trim trailing value whitespace and return the comment or null.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| line | One literal dotenv-subset line, without CR or LF. | Text, at most 8,192 UTF-16 code units; the stated grammar and narrower limits also apply. |
| Output field | Interpretation |
|---|---|
| result | Object containing the fields below. |
| result.name | Parsed portable ASCII assignment name. |
| result.value | Literal decoded or parsed value string. |
| result.comment | Comment text beginning with hash, or null when none is recognized. |
{
"input": {
"line": " A=hello # note"
},
"output": {
"result": {
"name": "A",
"value": "hello",
"comment": "# note"
}
}
} Limitations and assumptions
- Quotes, dollar signs, backslashes, CR/LF and NUL are rejected; this is a restricted dotenv dialect, not a general dotenv or shell parser.
- Portable assignment records require names matching [A-Za-z_][A-Za-z0-9_]* and NUL-free values. Name matching is case-sensitive. Reference scanners and quoted-value helpers follow only their own stated grammar and do not read the process environment.
- Every declared top-level input is required and unknown fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
- Numeric outputs must be finite and within the absolute safe-integer magnitude; exact larger integers use decimal text. Source positions are zero-based UTF-16 offsets and span ends are exclusive unless a different convention is explicitly stated.
Alternative or Complementary methods
Select the consuming application’s dotenv dialect explicitly. Keep literal substitution separate from recursive expansion and shell execution, and retain occurrence provenance when resolving duplicate assignments.
References
Similar or alternative tools
- Restricted Dotenv Assignment Line Formatter
Format one portable environment assignment using the documented literal JSON-double dotenv subset; never expands dollar references or emits a shell command.
- Restricted Dotenv Comment Source Spans
Locate an unquoted whitespace-introduced dotenv comment in one balanced single/double-quoted line; literal hash inside quotes is not a comment.