fix(cli): quote the installer's temporary directory in the EXIT trap
What
The generated scripts/install.sh registered its cleanup as trap "rm -rf $tmp_dir" EXIT. The path was expanded when the trap was set and the resulting string was parsed again as shell code when the script exited. With a TMPDIR containing whitespace, rm -rf received several arguments and deleted paths that were not the temp directory, leaving the real one behind. With shell syntax such as $(...) in the path, that text ran on exit. Both cases exited 0.
Change
tmp_diris script-scoped rather thanlocal, so it still exists when the EXIT trap runs.- A failed
mktemp -daborts the install instead of continuing with an empty path. - The trap is
trap 'rm -rf -- "$tmp_dir"' EXIT, so the path is expanded only when the trap fires, quoted, and never treated as options.
Template: templates/templates/cli/release/install.sh.stmpl. Release snapshot and the review CLI fixture regenerated.
Verification
Ran the regenerated review installer with a stub curl and TMPDIR set to a directory whose name contains a space, and to one containing $(touch pwned):
- install completes and the binary is placed
- the temp directory is removed in both cases
- the sibling directory next to the "space" path is untouched
- no
pwnedfile appears in the working directory
bash -n passes on the generated script. UPDATE_SNAPS=1 go test ./pkg/generate/snapshots -run 'TestSnapCLIRelease|TestSnapCLIInstallDocs' updated and passes.
Summary by cubic
Fixes the generated install.sh cleanup trap so installing with a TMPDIR containing whitespace or shell syntax no longer deletes unrelated paths or executes path text on exit.
- The trap now expands the temporary directory path only when it fires, quoted and after a
--guard. tmp_diris script-scoped so it still exists when the trap runs, and a failedmktemp -daborts the install instead of continuing with an empty path.