Add system(command; args) operator with --enable-system-operator flag

Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/8a11e9a0-10d2-4f2a-ae29-4e9d0bfc266f

Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-27 10:14:40 +00:00
committed by GitHub
co-authored by mikefarah
parent d181cf87d1
commit 9a72c0f780
8 changed files with 292 additions and 4 deletions
@@ -0,0 +1,23 @@
# System Operators
The `system` operator allows you to run an external command and use its output as a value in your expression.
**Security warning**: The system operator is disabled by default. You must explicitly pass `--enable-system-operator` to use it.
## Usage
```bash
yq --enable-system-operator '.field = system("command"; "arg1")'
```
The operator takes:
- A command string (required)
- An argument or array of arguments separated by `;` (optional)
The current matched node's value is serialised and piped to the command via stdin. The command's stdout (with trailing newline stripped) is returned as a string.
## Disabling the system operator
The system operator is disabled by default. When disabled, a warning is logged and `null` is returned instead of running the command.
Use `--enable-system-operator` flag to enable it.