Fixes#13156
- Enhanced uninstall script to automatically restore .zshrc from uninstall backup
when no original backup (.zshrc.pre-oh-my-zsh) exists
- Improved install script to create backup even when KEEP_ZSHRC=yes
- Added better user feedback and error handling
- Prevents data loss for users who installed with --keep-zshrc option
The issue occurred when users installed oh-my-zsh with KEEP_ZSHRC=yes
(keeping their existing .zshrc), which didn't create a backup. During
uninstall, their .zshrc would be deleted with no backup to restore.
Now the uninstall process:
1. Creates a timestamped backup of current .zshrc
2. Looks for original backup (.zshrc.pre-oh-my-zsh)
3. If found, restores the original
4. If not found, automatically restores from the uninstall backup
5. Provides clear feedback to the user
This ensures users never lose their .zshrc configuration during uninstall.
If there's no `~/.shell.pre-oh-my-zsh`, don't assume the default choice
is Bash. In fact Zsh is the default shell for macOS since Catalina
(10.15) [1], yet users of other OSes have likely to have Bash as their
default.
This commit fix issue #8252
[1] https://support.apple.com/en-us/HT208050
* Balk at incompatible Windows/MSYS git
* Test for chsh presence before trying to use it
* Replace non-portable `[[ ... ]]` and `[ x = *pattern* ]` constructs