Skip to content

refactor: move the embedded fzf script to a go:embed file #98

Description

@sorafujitani

Context

The default-run bash script lives as a Go string literal (defaultScriptTmpl in cmd/ccsession/main.go, near the bottom of the file at ~line 520-548). As a string literal it cannot be shellchecked, its shell-quoting hazards are documented in scattered Go comments, and it bloats the CLI wiring file.

Task

  1. Move the script body verbatim into cmd/ccsession/script.sh and load it with:
    //go:embed script.sh
    var defaultScriptTmpl string
  2. Keep the __CCS_BIND_*__ token-replacement mechanism in buildScript unchanged — the safety model (only config-validated key names are substituted; see internal/config) must not change.
  3. Move the shell-quoting/injection commentary to the top of script.sh as shell comments so it lives with the code it protects.
  4. Verify tests that assert on script content (grep -rn defaultScriptTmpl cmd/ and check main_test.go) still pass; adjust only import/whitespace-level breakage.
  5. Optional but preferred: run shellcheck on a rendered copy (tokens substituted with dummy values) locally and note the result in the PR. Do not add shellcheck to CI in this issue.

Acceptance criteria

  • go build ./cmd/ccsession produces a binary whose no-arg run behaves identically (manually smoke-test the picker launches and all three modes switch).
  • Script bytes are identical pre/post except for relocated comments (compare buildScript output in a test).
  • go test ./... passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: lowLower or indirect user-visible impactrefactorInternal restructuring with no behavior change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions