--split-exp should have an option to refuse overwriting existing files.
stouset opened this issue · comments
❯ cat -p foo.yaml
---
a: 1
---
b: 2
❯ yq -s '"bar.yaml"' < foo.yaml
❯ cat -p bar.yaml
---
b: 2
It would be nice if there was an additional flag you could pass with --split-exp
to error out when overwriting an existing file. This would catch situations where a --split-exp
expression resolves to the same document twice.
Note that this feature should not simply check that two such expressions resolve to the same string, but actually refuse to overwrite existing files. This ensures it works well with more complicated scenarios like find … -exec yq --split-exp '...' {} \;
where you might use the same expression across multiple documents.
Makes sense - just need the time to add it. I'd also accept a PR :)