How to upgrade zsh if it failed previously?

I am on a mac system. I assume this would be the same for a linux system too, but a mac system is my assumption.

I upgraded on login prompt, and then it failed. Gave a bunch of parse errors, mainly full with ^M characters. The fix is in theory universal, not specific to this problem.

The cause of that is git's autocrlf rule. If you type git config --list, and you see this line: core.autocrlf=true, then we know that is the reason it went wrong.

Since zsh is giving you a parse error, you can't run upgrade_oh_my_zsh as is from the command prompt. You'd get a command not found for it.

To fix it

These should be good for all fixes, not just for the specific one I encountered.

  1. $ git config --global core.autocrlf false to turn off the offending rule. Yes, I know if you work with Windows based line ending things this could cause trouble, but there are other ways of solving it (ignore white space, ignore EOL char, etc)
  2. $ cd ~/.oh-my-zsh/tools/ to get into the directory. Technically you can issue the important command from ~, but this way is easier.
  3. Try $ sh ./ One of two things can happen: it's either successfull, or git will complain that you have unstaged changes. If the latter happens, carry on.
  4. $ git status (we're still in the ~/.oh-my-zsh/tools folder!). It should give you a list of files that have been changed.
  5. $ git reset --hard HEAD. This will restore sanity for git. Once done, run point 3 again, and you should win at that point.