yq/cmd
Tony 249efaee46 feat: add --split-exp-no-overwrite flag to refuse overwriting existing files
When using --split-exp to split documents into per-file outputs, yq
silently overwrites any pre-existing files at the target paths because
os.Create truncates. For workflows that generate filenames from input
data (e.g. '.metadata.name + ".yml"'), this can clobber unrelated files
when two documents map to the same name, or when a target path collides
with something already on disk.

This change adds an opt-in --split-exp-no-overwrite flag (and a
matching yqlib constructor NewMultiPrinterWriterWithOptions) that uses
O_WRONLY|O_CREATE|O_EXCL so existing files are left untouched and yq
exits with a clear error message instead.

The default behaviour (overwrite) is unchanged; the original
NewMultiPrinterWriter constructor still exists and now delegates to the
new options-aware constructor with noOverwrite=false.

Fixes #2028
2026-05-22 05:41:48 +08:00
..
completion.go Fix: shell-completion (#2006) 2024-04-22 14:15:36 +10:00
constant.go feat: add --split-exp-no-overwrite flag to refuse overwriting existing files 2026-05-22 05:41:48 +08:00
evaluate_all_command_test.go Fixing tests with latest linting rules 2026-03-26 09:29:51 +11:00
evaluate_all_command.go fix: preserve original filename when using --front-matter (#2613) 2026-03-26 09:06:20 +11:00
evaluate_sequence_command_test.go Fixing tests with latest linting rules 2026-03-26 09:29:51 +11:00
evaluate_sequence_command.go fix: preserve original filename when using --front-matter (#2613) 2026-03-26 09:06:20 +11:00
root_test.go Fixing tests with latest linting rules 2026-03-26 09:29:51 +11:00
root.go feat: add --split-exp-no-overwrite flag to refuse overwriting existing files 2026-05-22 05:41:48 +08:00
unwrap_flag.go Spellig with cspell 2023-09-19 10:43:11 +10:00
utils_test.go Bumping golint 2026-03-21 09:25:31 +11:00
utils.go feat: add --split-exp-no-overwrite flag to refuse overwriting existing files 2026-05-22 05:41:48 +08:00
version_test.go More tests 2026-02-01 10:27:18 +11:00
version.go Bumping version 2026-04-17 16:03:30 +10:00