The eval part of the script is unnecessarily versatile. I think a much simpler (and easier to understand) step is to ask user to relaunch their Terminal.
Then the instruction becomes an easy 1 step task.
Then the instruction becomes an easy 1 step task.
> For brew to be available as command, brew needs to update your path and [bash/zsh/etc] profile. Please select how you wish to continue:
> 1. Please do this for me
> 2. Explain what you're about to do first, then ask me again.
> 3. No thanks. I'll do this myself.
And then you also make sure there's a runtime flag or even env var that can be used to override this, for admins who need to install brew as part of mass deploys.
FWIW, some variation on:
$ exec bash
ought to work, since what you care about is restarting the shell (.bashrc,PATH,etc), rather than the terminal per se.$ source ~/.zshrc
Startup scripts often aren’t idempotent, and it takes work to make sure they are. Please don’t source your startup script unless you know what you’re doing.