Description
Distinguish empty from nonempty whitespace-only portable environment values, retaining source occurrences; does not conflate missing variables with present empty values.
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.
Distinguish empty from nonempty whitespace-only portable environment values, retaining source occurrences; does not conflate missing variables with present empty values.
When to use this tool
Use this tool to distinguish empty from nonempty whitespace-only portable environment values, retaining source occurrences; does not conflate missing variables with present empty values.
How to use the tool and how it works
- Enter assignmentsJson using the input definitions below. Serialize the JSON text fields in the decoded shape shown below.
- Run the operation. Resolve malformed-input errors before interpreting the result.
- Read result.empty, result.whitespaceOnly. Interpret signs, units, ordering and null values using the rules below.
Return separate source-indexed name records for values exactly equal to the empty string and for nonempty values whose JavaScript trim result is empty.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| assignmentsJson | JSON array of {name, value} strings using portable ASCII names and NUL-free literal values. Repeated names are retained until the stated policy is applied. | Text, at most 8,192 UTF-16 code units; the stated grammar and narrower limits also apply. |
These decoded examples show the structure of the JSON text fields. Supply each as its corresponding serialized JSON string.
{
"assignmentsJson": [
{
"name": "A",
"value": "1"
},
{
"name": "A",
"value": "2"
},
{
"name": "B",
"value": ""
}
]
} | Output field | Interpretation |
|---|---|
| result | Object containing the fields below. |
| result.empty | Source-indexed names whose value is exactly the empty string. |
| result.whitespaceOnly | Source-indexed names with nonempty values trimmed to empty. |
{
"input": {
"assignmentsJson": "[{\"name\":\"A\",\"value\":\"1\"},{\"name\":\"A\",\"value\":\"2\"},{\"name\":\"B\",\"value\":\"\"}]"
},
"output": {
"result": {
"empty": [
{
"name": "B",
"index": 2
}
],
"whitespaceOnly": []
}
}
} Limitations and assumptions
- The audit distinguishes present-empty, whitespace-only and absent variables; it does not establish application defaults or required-variable policy.
- 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
- Environment Assignment Value Byte Budget
Audit explicit environment values against a supplied UTF-8 byte budget, excluding variable names, equals, NUL terminators and OS argv/env aggregate limits.
- Environment Assignment First Wins
Resolve explicit case-sensitive portable environment assignment occurrences under first-wins policy with source indexes; no shell execution or expansion.