zshgit-bisect

How to run 'git bisect run ' with a Zsh function


Previously in Bash I used git bisect run with script.sh param1 param2.

I use Zsh now and I converted scripts to functions in a single functions-file, for easier editing. Sourced functions-file.

How can I use git bisect run with Zsh function (not separate script file)?

I tried git bisect run zsh -c "sourced-function param1 param2 param3" but that gives "zsh:1: command not found: sourced-function", although in zsh I can run sourced-function.

I found `git bisect run` with a bash function, mentioning that in Git 2.40+ git bisect becomes a builtin - but did not understand if that affects my problem. Other suggested answer, exporting functions, seems impractical especially in Zsh.

I also found zsh and parallel: How to use functions. It says command not found which seems related but I don't know how to apply that in a feasible manner. It is not clear how to activate env_parallel and where.

It seems that the proper approach is to use zsh path for functions as separate files and autoload, not to source single file with functions. But I prefer this way, so the question remains.


Solution

  • Shells usually won't execute their function-loading startup scripts when run in non-interactive mode.

    For zsh you should be able to manually load those scripts/functions using the source built-in command:

    git bisect run zsh -c 'source "$HOME"/.zshrc; sourced-function param1 param2 param3'