Systemd .env parse
systemd-env-parse · version 1.0.0 · Structured formats · free, no key needed
Parse a systemd EnvironmentFile into assignments, a last-wins map, and duplicate keys.
Use when you need to: parse systemd environment file · read systemd EnvironmentFile assignments · systemd environmentfile quoting rules.
Decide before calling
Read the versioned contract and the supported scope below. Reuse systemd-env-parse@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use systemd-env-parse@1.0.0 for parse systemd environment file. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- parse systemd environment file
- read systemd EnvironmentFile assignments
- systemd environmentfile quoting rules
- find duplicate keys in a systemd environment file
- unescape a systemd environmentfile value
- systemd env file comment and continuation
- last assignment wins in a systemd environment file
Not supported
- join a later quoted piece onto an EnvironmentFile value
- expand dollar variables or percent specifiers in an EnvironmentFile
- open an EnvironmentFile path or honor a leading dash
Behavior
- One value mode is chosen from the first character after = that is not a space or tab. A quote selects that quote mode. Any other character, including a backslash, selects unquoted mode.
- In unquoted mode, quote characters stay quote characters. A backslash keeps the next character, so \\ is one backslash and \n is the letter n. A backslash and a following line break are both dropped and no space is inserted.
- After a closing quote, only spaces and tabs may remain before the line break. Other trailing text is invalid_input. This subset does not read another piece after the closer.
- CR, LF, and CRLF are physical line breaks. A break at the end of the text does not open another line. Inside quotes, the break characters stay in the value. assignments keeps source order. variables maps each key to its last value. duplicate_keys lists keys seen more than once, ordered by the first line.
- Empty lines, lines with no =, and lines whose first non-space character is # or ; are ignored. A comment does not swallow the next line. Invalid names reject the whole input. There is no specifier expansion.
Input
text(string, required): max length 4096; EnvironmentFile text. Maximum 4096 UTF-8 bytes, checked in run().
Output
assignments(array of object, required)variables(object, required)duplicate_keys(array of string, required)
Limits
- max input bytes: 4096
- max assignments: 128
- max physical lines: 256
- max value bytes: 4096
- max key chars: 128
- max continuations: 32
- max output bytes: 65536
Example
Request input:
{
"text": "NAME=Ada\nCITY=Tel Aviv\n"
}
Response:
{
"result": {
"assignments": [
{
"key": "NAME",
"value": "Ada",
"line": 1
},
{
"key": "CITY",
"value": "Tel Aviv",
"line": 2
}
],
"variables": {
"NAME": "Ada",
"CITY": "Tel Aviv"
},
"duplicate_keys": []
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "systemd-env-parse",
"version": "1.0.0",
"input": {
"text": "NAME=Ada\nCITY=Tel Aviv\n"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/systemd-env-parse/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"text":"NAME=Ada\nCITY=Tel Aviv\n"}'
The machine-readable contract is at /v1/tools/systemd-env-parse/versions/1.0.0.
CLI
node cli.mjs run systemd-env-parse 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Systemd directive list: List systemd unit directives as words using syntax quoting, continuation, and resets.
- Systemd .env format: Format assignments into canonical systemd EnvironmentFile text, one quoting mode per value.
- Gitconfig parse: Parse git config text into ordered sections, subsections, and multivar entries.
- Gitconfig key list: List git config keys in file order with qualified names and occurrences.
- Xpath10 evaluate: Evaluate an XPath 1.0 value expression and return its type with an exact string, number, or boolean token.
- Gitconfig format: Format git config sections as canonical text with escapes and subsections.