Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--split-exp should have an option to refuse overwriting existing files. #2028

Open
stouset opened this issue May 3, 2024 · 1 comment
Open

Comments

@stouset
Copy link

stouset commented May 3, 2024

❯ 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.

@mikefarah
Copy link
Owner

Makes sense - just need the time to add it. I'd also accept a PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants