robbyrussell/oh-my-zsh — pull request #3454 by sr-murthy (2014-12-30 16:14:04+00:00)
Title: Smoother way of changing default login shell back to bash on uninstall

The current uninstall script attempts to `chsh -s /bin/bash` to change the default login shell for the user back to `bash`. But `chsh -s /bin/bash` requires user login, and the script cannot deal with login failure or any disruption to the command. The main change, in general terms, is to check the exit code of `chsh -s /bin/bash` and to prompt the user more appropriately in case of success or failure of the login.

In the case of success `chsh -s /bin/bash` will reset the `UserShell` attribute of the user’s record in the OS X Directory Services database for their local domain node `.` back to `/bin/bash`, but this change is not immediately reflected in the working shell window (in which the uninstall script was executed). So the change here specifically involves asking the user whether they would like to do this, and dealing with the two different possibilities.

These changes are self-explanatory, but could be improved even further - for example, an assumption is made that the user wants to default back to `/bin/bash` but perhaps they do not, or perhaps they do not care because they have specified a specific shell type and path in their terminal app. For the moment thought these changes should make the uninstallation process less painful and the script easier to maintain and debug.

Note: the default login shell for a local domain user, from the point of OS X, is determined not by environment variables like `SHELL` or the shell preferences in Terminal.app but the value of the `UserShell` attribute of the user's record in the OS X Directory Services database for the their local domain node `.`. Moreover executing `chsh -s ` in the active shell window will in fact change this attribute directly but the change will not be visible immediately unless a new shell window is opened or the session restarted or with a command like `exec su - $USER`.