Skip to content

Rewrite rcopy as a safe Go CLI#2

Draft
mrAibo wants to merge 13 commits into
mainfrom
agent/go-rewrite
Draft

Rewrite rcopy as a safe Go CLI#2
mrAibo wants to merge 13 commits into
mainfrom
agent/go-rewrite

Conversation

@mrAibo

@mrAibo mrAibo commented Jul 13, 2026

Copy link
Copy Markdown
Owner

What changed

  • replaced the sourced Bash implementation with a standard-library-only Go CLI
  • preserved the existing command-line flags and the 0/1 exit-status contract
  • kept rcopy.sh as a compatibility shim for existing shell setups
  • added Bash completion, Go regression tests, Bats CLI tests, contributor rules, and CI
  • added an offline vendor-mode build and a static Linux/amd64 artifact named rcopy-linux-amd64

Why

The previous script only defined functions when executed, changed caller-shell traps and file descriptors when sourced, built several remote shell commands from strings, passed the wrong lowercase port flag to scp, and could delete excluded files after an rsync move. The Go CLI constructs process arguments explicitly and uses safer transfer semantics.

User and developer impact

  • one static Linux binary with no Go runtime or third-party Go dependency
  • safer move behavior: rsync uses --remove-source-files; remote sync removes source files only after both copy stages succeed
  • correct scp -P handling
  • explicit rejection of rsync-only options in scp mode
  • preserved source rcopy.sh workflow through the compatibility shim
  • clearer dry-run summaries and NO_COLOR support

Validation performed locally

  • gofmt
  • go mod verify
  • go test ./...
  • go test -race ./...
  • go vet ./...
  • shell syntax checks
  • manual equivalents of all Bats scenarios
  • GOPROXY=off GOSUMDB=off go build -mod=vendor
  • static CGO_ENABLED=0 GOOS=linux GOARCH=amd64 build, verified as statically linked

Bats itself was not installed in the local environment; GitHub Actions runs the committed Bats suite.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant