From 71017f1d4f9504cef50bd87ad33c958e766dd3ad Mon Sep 17 00:00:00 2001 From: Malcolm Fell Date: Tue, 28 Jul 2026 09:55:07 +1200 Subject: [PATCH] install: skip zsh integration when binary lacks --init A binary that predates the shell integration (e.g. the v0.1.0-beta.1 release) treats `--init zsh` as a plain-English task and asks the model, which returns something like `zsh -i`. `eval "$(maic --init zsh)"` then launches a nested interactive shell that hangs every new shell forever. Probe the installed binary for the integration's sentinel line before wiring the `eval` into ~/.zshrc; skip with an upgrade hint otherwise, so a version mismatch can never poison the user's shell. --- install.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 83c9e7e..d5bd3a2 100755 --- a/install.sh +++ b/install.sh @@ -86,7 +86,23 @@ case ":$PATH:" in *) path_line="export PATH=\"$PREFIX:\$PATH\"" ;; esac -if [ -n "${MAIC_NO_SHELL_INIT:-}" ]; then +# Only wire in the `eval` if THIS binary actually understands `--init zsh`. +# A binary that predates the integration treats `--init zsh` as a plain-English +# task and asks the model, which happily returns something like `zsh -i` — and +# `eval "$(...)"` would then launch a nested interactive shell that hangs every +# new shell forever. Probing for the integration's sentinel line makes a +# version mismatch impossible to poison ~/.zshrc with. +init_sentinel="# maic shell integration (zsh)" +supports_init="" +if "$PREFIX/maic" --init zsh 2>/dev/null | grep -qF "$init_sentinel"; then + supports_init=1 +fi + +if [ -z "$supports_init" ]; then + echo "This maic ($tag) predates the zsh integration; not touching $rc." >&2 + echo "Upgrade to a release that supports 'maic --init zsh' to enable it." >&2 + [ -n "$path_line" ] && echo "Make sure this is on your PATH: $path_line" >&2 +elif [ -n "${MAIC_NO_SHELL_INIT:-}" ]; then echo "Skipping shell integration (MAIC_NO_SHELL_INIT set). To enable it, add to $rc:" >&2 [ -n "$path_line" ] && echo " $path_line" >&2 echo ' eval "$(maic --init zsh)"' >&2