Repository navigation
Automation
--json
One JSON document on stdout. Every diagnostic (progress, warnings, errors)
goes to stderr, so sr replace ... --json | jq is always safe.
{ "version": "7.0.1", "dry_run": false, "root": "/home/me/project", "search": "old", "replacement": "new", "pattern_kind": "fixed", "duration_seconds": 0.412, "totals": { "scanned": 128, "changed": 7, "unchanged": 121, "skipped": 2, "failed": 0, "matches": 19, "replacements": 19, "renamed": 0, "bytes_read": 421887, "bytes_written": 20144 }, "session": { "id": "20260131T120530Z-9f3a1c", "directory": "...", ... }, "files": [ { "path": "...", "rel_path": "src/app.py", "status": "changed", "matches": 3, "replacements": 3, "encoding": "utf-8", "size_before": 4012, "size_after": 4015, "diff": { "added": 3, "removed": 3, "changed": 6 } } ], "errors": [], "warnings": [], "exit_code": 0 }
Add --diff to include the patch text of every file as "patch".
--porcelain
Stable path:line:col:kind:text records, one per line, designed to be cut
and piped:
sr find "old" --porcelain | cut -d: -f1 | sort -u
Exit codes (see sr help exit-codes)
0 success / at least one match 3 no match
1 runtime error 4 rollback failed
2 usage error 5 update failed
6 selftest failed
130 interrupted
set -euo pipefail sr replace "$OLD" "$NEW" -p '*.py' --yes --json --no-update-check > sr.json jq -e '.totals.failed == 0' sr.json jq -r '.files[].rel_path' sr.json
The --no-update-check flag keeps the network out of CI, and --yes avoids a
prompt that would otherwise hang the job (sr refuses to prompt when stdin is
not a terminal and exits non-zero instead).
Страница сгенерирована из встроенной справки sr 7.0.1 (sr help <topic>).
Первоисточник — sr/help_system.py; он же питает man sr и sr help --all.
Если страница и вывод sr help расходятся, верить нужно sr help: он всегда
соответствует установленной версии.