Description
Resolve explicit case-sensitive portable environment assignment occurrences under first-wins policy with source indexes; no shell execution or expansion.
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.
Resolve explicit case-sensitive portable environment assignment occurrences under first-wins policy with source indexes; no shell execution or expansion.
When to use this tool
Use this tool to resolve explicit case-sensitive portable environment assignment occurrences under first-wins policy with source indexes; no shell execution or expansion.
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.assignments. Interpret signs, units, ordering and null values using the rules below.
Group exact assignment names in first-appearance order and retain each first occurrence with its original source index. Empty strings remain explicit values.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.assignments | Selected assignment records with source indexes or overlay/shadow provenance as stated above. |
{
"input": {
"assignmentsJson": "[{\"name\":\"A\",\"value\":\"1\"},{\"name\":\"A\",\"value\":\"2\"},{\"name\":\"B\",\"value\":\"\"}]"
},
"output": {
"result": {
"assignments": [
{
"name": "A",
"value": "1",
"index": 0
},
{
"name": "B",
"value": "",
"index": 2
}
]
}
}
} Limitations and assumptions
- No shell execution, reference expansion or operating-system name folding is performed.
- 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 Last Wins
Resolve explicit case-sensitive portable environment assignment occurrences under last-wins policy with source indexes; no shell execution or expansion.
- Environment Empty Value Audit
Distinguish empty from nonempty whitespace-only portable environment values, retaining source occurrences; does not conflate missing variables with present empty values.