Skip to content

fix: make try init re-source safe through the shell wrapper - #140

Open
rohaquinlop wants to merge 1 commit into
tobi:mainfrom
rohaquinlop:fix/init-re-source
Open

fix: make try init re-source safe through the shell wrapper#140
rohaquinlop wants to merge 1 commit into
tobi:mainfrom
rohaquinlop:fix/init-re-source

Conversation

@rohaquinlop

@rohaquinlop rohaquinlop commented Aug 23, 2026

Copy link
Copy Markdown

What

Route try exec init to the init logic so re-running try init from a sourced shell re-emits the wrapper instead of opening the interactive selector.

Why

The shell wrapper generated by try init shadows the try binary. When a shell config is sourced again (source ~/.zshrc), the try init line now resolves to the wrapper, which calls try exec — and exec had no init case, falling through to the interactive selector with init <path> as the search query.

Changes

  • try.rb: dispatch init in the exec subcommand path, mirroring plain try init behavior.
  • spec/tests/test_36_shell_eval.sh: regression tests for bash and zsh asserting try exec init PATH re-emits the wrapper with the new path.
  • spec/init_spec.md: document re-sourcing safety.

Note: #105 (zzzhizhia) covers the same exec init dispatch and has been open since March 2026. This PR is an independent implementation with additional bash/zsh regression coverage in test_36_shell_eval.sh and init_spec.md documentation. Happy to close this one if #105 is preferred.

The shell wrapper shadows the binary, so `try init` inside a sourced
shell (e.g. `source ~/.zshrc` twice) fell through to the interactive
selector instead of re-emitting the wrapper. Dispatch `init` in the
`exec` path so re-init behaves like a plain `try init`.

Adds shell-eval regression tests for bash and zsh covering
`try exec init PATH` re-emitting the wrapper with the new path.
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