Skip to content

ask before editing shell profiles in install.sh and uninstall.sh - #11

Merged
gentbot merged 2 commits into
mainfrom
fix/low-priority-items
Sep 26, 2026
Merged

gentbot merged 2 commits into
mainfrom
fix/low-priority-items

Conversation

@gentbot

@gentbot gentbot commented Sep 26, 2026

Copy link
Copy Markdown
Owner

install.sh appended a source line to the user's shell profile, and uninstall.sh rewrote profiles, without asking. Neither should change a user's shell configuration without express permission.

  • install.sh: ask before adding the source line when run in a terminal. When stdin is not a terminal, leave the profile untouched and print the line to add. New flags: --yes adds the line without asking, --no-profile never touches the profile. Unknown options are rejected.
  • uninstall.sh: ask per profile before removing the source line, and list the profiles without changing them when not run in a terminal. --yes removes the line without asking.
  • uninstall.sh: rewrite profiles in place instead of replacing them with mv. A symlinked profile (common with dotfile managers) stays a symlink and keeps its permissions. Also stop aborting under set -e when the source line was the only line in the file (grep -v exits 1).
  • update.sh: pass its arguments through to install.sh.

Tests: add tests/installers.bats (12 tests), run with HOME pointed at a temporary directory so nothing outside it is touched. Covers the non-interactive default, --yes, --no-profile, interactive y/n answers, symlinked profiles, file modes and the single-line profile case.

What and why

Changes

Checklist

All PRs

  • bats tests/ passes locally
  • shellcheck worktree-functions.sh passes locally
  • CHANGELOG.md updated (add entry under [Unreleased])

New public functions

  • Docblock above function follows the project format
  • [ "$1" = "--help" ] && { wrktr_help <name>; return 0; } guard present
  • wrktr_validate || return 1 at top (for session-dependent functions)
  • Dry-run support: _wrktr_run wraps mutations; _wrktr_is_dryrun gates conditional logic
  • Error messages use _wrktr_breaker red "..." (writes to stderr)
  • Help entry added to wrktr_help case statement
  • Documentation added to docs/wrktr.md function reference
  • Row added to Quick reference table in docs/wrktr.md
  • Tab completion registered if function takes branch or session names
  • Tests added to tests/wrktr.bats (at least one success, one failure)

Behavior changes to existing functions

  • Describe whether the change is backwards-compatible
  • Existing tests updated to reflect new behavior
  • docs/wrktr.md updated if command usage or behavior description changed

install.sh appended a source line to the user's shell profile, and
uninstall.sh rewrote profiles, without asking. Neither should change a
user's shell configuration without express permission.

- install.sh: ask before adding the source line when run in a terminal.
  When stdin is not a terminal, leave the profile untouched and print
  the line to add. New flags: --yes adds the line without asking,
  --no-profile never touches the profile. Unknown options are rejected.
- uninstall.sh: ask per profile before removing the source line, and
  list the profiles without changing them when not run in a terminal.
  --yes removes the line without asking.
- uninstall.sh: rewrite profiles in place instead of replacing them with
  mv. A symlinked profile (common with dotfile managers) stays a symlink
  and keeps its permissions. Also stop aborting under set -e when the
  source line was the only line in the file (grep -v exits 1).
- update.sh: pass its arguments through to install.sh.

Tests: add tests/installers.bats (12 tests), run with HOME pointed at a
temporary directory so nothing outside it is touched. Covers the
non-interactive default, --yes, --no-profile, interactive y/n answers,
symlinked profiles, file modes and the single-line profile case.
The uninstall.sh symlink test read the file mode with
`stat -f %Lp ... || stat -c %a ...`. On GNU/Linux, `stat -f` is the
filesystem-status form: it exits 0 with unrelated output, so the
fallback never ran and the assertion failed on the Ubuntu CI job.

Compare `ls -l` permissions instead, which is the same on macOS and
Linux. No production code changes.
@gentbot
gentbot merged commit f9daff0 into main Sep 26, 2026
5 checks passed
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