feat(functions): port key-crypt to a fish function #158

Merged
rootiest merged 1 commits from feat/key-crypt-fish-function into main 2026-09-21 05:52:16 +00:00
Owner

Summary

  • Bring key-crypt in from ~/scripts as functions/key-crypt.fish instead of a standalone --no-config script.
  • Converts exit-based control flow to return; drops the fish_exit/signal traps (they'd hijack the whole interactive shell's Ctrl-C once loaded) in favor of an outer wrapper that cleans up the temp file and scratch globals after every call.
  • Routes rm/mv/mkdir through command so config-level wrapper functions can't intercept them, and switches the gpg/tar presence checks to type -q to match the repo's dependency-guard convention (also required for docs/verify-manual.py's DEPENDENCIES check to resolve).
  • --install now writes a small standalone wrapper script (source this function file, call key-crypt) to ~/.local/bin/key-crypt instead of copying the file itself, since a fish function can't be exec'd directly by the .desktop Open With entries. --uninstall is unchanged aside from the command-prefixed rm.

Test plan

  • fish -n functions/key-crypt.fish (syntax)
  • python3 docs/verify-manual.py (84/84, including DEPENDENCIES resolution)
  • --help, no-args (exit 2), missing-input (exit 1) in an isolated --no-config fish
  • Real encrypt round-trip against a live smartcard-backed key: encrypt, re-run without --force (exit 1, output exists), re-run with --force, --remove refusing when output would land inside input
  • __kc_is_encrypted correctly distinguishes the produced .gpg file from a plain file
  • --install/--uninstall in an isolated $HOME: wrapper written, executable, and actually runs standalone (--help, missing-input) outside of fish's function context; desktop entries written and removed
  • No leaked global variables after a call (tmp, input, c_head, etc. all erased)
## Summary - Bring `key-crypt` in from `~/scripts` as `functions/key-crypt.fish` instead of a standalone `--no-config` script. - Converts `exit`-based control flow to `return`; drops the `fish_exit`/signal traps (they'd hijack the whole interactive shell's Ctrl-C once loaded) in favor of an outer wrapper that cleans up the temp file and scratch globals after every call. - Routes `rm`/`mv`/`mkdir` through `command` so config-level wrapper functions can't intercept them, and switches the `gpg`/`tar` presence checks to `type -q` to match the repo's dependency-guard convention (also required for `docs/verify-manual.py`'s DEPENDENCIES check to resolve). - `--install` now writes a small standalone wrapper script (source this function file, call `key-crypt`) to `~/.local/bin/key-crypt` instead of copying the file itself, since a fish function can't be exec'd directly by the `.desktop` Open With entries. `--uninstall` is unchanged aside from the command-prefixed `rm`. ## Test plan - [x] `fish -n functions/key-crypt.fish` (syntax) - [x] `python3 docs/verify-manual.py` (84/84, including DEPENDENCIES resolution) - [x] `--help`, no-args (exit 2), missing-input (exit 1) in an isolated `--no-config` fish - [x] Real encrypt round-trip against a live smartcard-backed key: encrypt, re-run without `--force` (exit 1, output exists), re-run with `--force`, `--remove` refusing when output would land inside input - [x] `__kc_is_encrypted` correctly distinguishes the produced `.gpg` file from a plain file - [x] `--install`/`--uninstall` in an isolated `$HOME`: wrapper written, executable, and actually runs standalone (`--help`, missing-input) outside of fish's function context; desktop entries written and removed - [x] No leaked global variables after a call (`tmp`, `input`, `c_head`, etc. all erased)
rootiest added the Kind/FeatureArea/Functions labels 2026-09-21 05:08:42 +00:00
rootiest added 1 commit 2026-09-21 05:08:50 +00:00
Bring key-crypt in from ~/scripts as functions/key-crypt.fish instead of a
standalone --no-config script. Converts exit-based control flow to return,
drops the fish_exit/signal traps (global-scope hijack risk in a shared
shell) in favor of an outer wrapper that cleans up the temp file and all
scratch globals after every call, and routes rm/mv/mkdir through `command`
so config-level wrapper functions can't intercept them.

--install now writes a small standalone wrapper script (source this
function file, call key-crypt) to ~/.local/bin/key-crypt instead of
copying the file itself, since a fish function can't be exec'd directly by
the .desktop Open With entries. --uninstall is unchanged aside from the
command-prefixed rm.
rootiest force-pushed feat/key-crypt-fish-function from 8735e1b871 to fc68486aaf 2026-09-21 05:08:50 +00:00 Compare
rootiest merged commit 1608b9b527 into main 2026-09-21 05:52:16 +00:00
rootiest deleted branch feat/key-crypt-fish-function 2026-09-21 05:52:16 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rootiest/fish-config#158