# Systemd directive list

`systemd-directive-list` · version 1.0.0 · Structured formats · free, no key needed

List systemd unit directives as words using syntax quoting, continuation, and resets.

**Use when you need to: parse systemd unit directives · split a systemd unit setting into words · systemd unit file line continuation.**

## Decide before calling

Read the [versioned contract](/v1/tools/systemd-directive-list/versions/1.0.0) and the supported scope below. Reuse `systemd-directive-list@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-directive-list@1.0.0` for parse systemd unit directives. 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 unit directives
- split a systemd unit setting into words
- systemd unit file line continuation
- read repeatable systemd directives
- apply systemd syntax quoting to a unit value
- empty systemd directive resets the list
- list words in a systemd drop-in fragment

## Not supported

- split Environment= words into variable assignments
- expand percent specifiers in a unit file
- glue neighboring quoted fragments into one word

## Behavior

- A unit-file quote wraps one whole word. The opening quote is accepted only at the start of a word, and the closer must be followed by a space, a tab, or the end of the value. Text stuck to a closer is invalid_input. Quote marks are removed. This tool does not glue neighboring pieces into one word.
- A physical line continues only when the logical text so far ends in an odd number of backslashes. That final backslash is replaced by one space, and the next non-comment physical line is appended with its leading spaces. Comment lines in between are skipped. An even run of trailing backslashes does not continue.
- An empty value resets that key: words is empty and the effective list becomes empty. Key="" is one empty word, not a reset. Repeated section names continue the same section. lists keeps first-seen key order and the words that remain after resets.
- Escapes from systemd.syntax Table 1 apply in quoted and unquoted words. Unknown or truncated escapes are invalid_input. A plausible key outside [A-Za-z][A-Za-z0-9]* is unsupported_input. Specifiers are not expanded.

## Input

- `text` (string, required): max length 4096; Unit fragment. Maximum 4096 UTF-8 bytes, checked in run().

## Output

- `sections` (array of object, required)

## Limits

- max input bytes: 4096
- max sections: 32
- max directives: 64
- max words: 128
- max word bytes: 512
- max logical line bytes: 1024
- max physical lines: 256
- max continuations: 32
- max section chars: 128
- max output bytes: 65536

## Example

Request input:

```json
{
  "text": "[Service]\nEnvironment=\"VAR1=word1 word2\" VAR2=word3 \"VAR3=$word 5 6\"\n"
}
```

Response:

```json
{
  "result": {
    "sections": [
      {
        "name": "Service",
        "line": 1,
        "directives": [
          {
            "key": "Environment",
            "line": 2,
            "reset": false,
            "words": [
              "VAR1=word1 word2",
              "VAR2=word3",
              "VAR3=$word 5 6"
            ]
          }
        ],
        "lists": [
          {
            "key": "Environment",
            "words": [
              "VAR1=word1 word2",
              "VAR2=word3",
              "VAR3=$word 5 6"
            ]
          }
        ]
      }
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "systemd-directive-list",
  "version": "1.0.0",
  "input": {
    "text": "[Service]\nEnvironment=\"VAR1=word1 word2\" VAR2=word3 \"VAR3=$word 5 6\"\n"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/systemd-directive-list/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"[Service]\nEnvironment=\"VAR1=word1 word2\" VAR2=word3 \"VAR3=$word 5 6\"\n"}'
```

The machine-readable contract is at [/v1/tools/systemd-directive-list/versions/1.0.0](/v1/tools/systemd-directive-list/versions/1.0.0).

### CLI

```sh
node cli.mjs run systemd-directive-list 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Systemd .env parse](/tools/systemd-env-parse): Parse a systemd EnvironmentFile into assignments, a last-wins map, and duplicate keys.
- [Gitconfig parse](/tools/gitconfig-parse): Parse git config text into ordered sections, subsections, and multivar entries.
- [Systemd .env format](/tools/systemd-env-format): Format assignments into canonical systemd EnvironmentFile text, one quoting mode per value.
- [Xpath10 paths](/tools/xpath10-paths): List the canonical XPath 1.0 path of each node in a location-path node-set, in document order.
- [Gitconfig key list](/tools/gitconfig-key-list): List git config keys in file order with qualified names and occurrences.
- [XML exc c14n canonicalize](/tools/xml-exc-c14n-canonicalize): Exclusive XML Canonicalization 1.0 of a whole document, with an optional inclusive prefix list.
