-
-
Notifications
You must be signed in to change notification settings - Fork 2
Description
In our current local WIP state, the dotfiles-search-commits helper has evolved well beyond its original form as a simple alias for grepping commit logs. It now supports multiple modes (log, log-recent, code) with aliases, regex options (basic/extended/perl), structured help/error handling, implicit fallbacks for common cases, and clearer usage examples.
While this expansion significantly improves usability, it also introduces complexity around return vs exit behavior when defined as a shell function inside aliases.zsh. Sourcing functions that use exit can inadvertently terminate the entire interactive shell session. At this stage, it’s more sustainable to promote this into a proper bin/ script so that it behaves like a standalone CLI tool without these caveats.
- https://gist.github.com/0xdevalias/063ed7edafd735fd141b94c04ef38ed5#zsh-script-patterns-handling-nested-function-exits-and-returns-without-killing-your-shell
-
Zsh Script Patterns: Handling Nested Function Exits and Returns Without Killing Your Shell
-
Remaining TODOs / Known Issues:
- Migrate implementation from
zsh/aliases.zshintobin/dotfiles-search-commits(orbin/dotfiles-history? which should be the name and which the alias?) for safer execution.- Update aliases to correctly point to the new
bin/script (if they are still needed)
- Update aliases to correctly point to the new
- Cleanup:
- Remove temporary debug scaffolding (
inner_function_test). - Remove
return_or_exitand similar hacks once promoted to a proper script.
- Remove temporary debug scaffolding (
- Broader testing before committing/pushing:
- Verify consistent handling of exit codes across environments (zsh, bash).
- Review error handling and edge cases (missing patterns, invalid regex mode).