Add --no-clobber for explicit output files
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
DennisGaida raised accidental overwrites in Discussion #1976. I'd suggest an opt-in --no-clobber instead of changing the default or adding prompts.
With --output, the flag would fail without changing an existing destination, including symlinks, or exclusively create a new file. It would reject use without --output or with --in-place. Without the flag, behavior stays unchanged; shell redirection is outside this feature.
The explicit-output branches in cmd/sops/main.go currently use os.Create. Exclusive creation would avoid the race in a separate existence check.
I'd implement this across commands supporting --output, including legacy syntax, with tests for unchanged existing bytes and invalid combinations. Does this approach fit SOPS?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the explicit-output branches of cmd/sops/main.go, where os.Create is currently used, and trace the commands that support --output, including legacy syntax. Add coverage for unchanged existing bytes, symlink destinations, exclusive creation, and invalid use without --output or with --in-place. Done means --no-clobber works across those commands while existing behavior and shell redirection remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100