Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installer: fix, refactor and add installer arguments #5169

Closed
wants to merge 26 commits into from

Conversation

mcornella
Copy link
Member

@mcornella mcornella commented Jun 16, 2016

Ready for testing

This is an all-encompassing PR to fix once and for all all issues related to the OMZ installer, as well as adding features requested many times.


Fixes

zshrc file mangling

Fixes #2499. Fixes #4390. Fixes #4391.

Change of default shell issues

Fixes #4131. Fixes #4564. Fixes #4818. Fixes #5277. Fixes #6569. Fixes #7254.

Restore default shell

Fixes #3447. Fixes #6119. Fixes #6299. Fixes #6356. Fixes #6608.

$PATH management

Fixes #1359. Fixes #2586. Fixes #4925. Closes #2589. Closes #4317.

New features

Skip change of default shell

Fixes #4261. Fixes #7100. Fixes #7266. Fixes #7721. Fixes #7865.

The installer respects the environment variable CHSH. Set to no, it will skip the chsh step. It also reads the flag --skip-chsh which has the same effect. For instance, these two are equivalent:

CHSH=no sh install.sh
sh install.sh --skip-chsh

Don't run zsh after install

Fixes #4393. Fixes #5002. Fixes #5853. Fixes #5893. Fixes #6547. Fixes #7790.

As in the skip-chsh feature above, the installer respects the variable RUNZSH, which when set to no will skip the zsh call when the install is done. The flag --unattended also sets RUNZSH=no, as well as setting CHSH=no. So these two are equivalent:

RUNZSH=no CHSH=no sh install.sh
sh install.sh --unattended

Forks

Fixes #3648. Fixes #5628. Fixes #7496.

The installer respects the following environment variables, that can be set up when calling it with VAR=value sh install.sh.

  • REPO: value in the form of owner/project. Useful for forks in GitHub (defaults to `robbyrussell/oh-my-zsh).
  • BRANCH: default branch to check out once the clone has finished (defaults to master).
  • REMOTE: full remote URL (supersedes REPO if set). You could for example choose an ssh remote URL, like git@github.com:user/oh-my-zsh, or another fork from GitLab or Bitbucket.

Other

Fixes #5320. Fixes #7007.
Closes #5194.

@mcornella mcornella force-pushed the refactor-installer branch 4 times, most recently from a15d621 to cc44ad8 Compare June 20, 2016 23:23
@mcornella mcornella force-pushed the refactor-installer branch 5 times, most recently from c017808 to d9f18a5 Compare August 8, 2016 23:54
@mcornella mcornella added Status: testers needed Pull Requests that are waiting for testers to merge Area: installer Issue or PR related to the installer labels Aug 9, 2016
@mcornella mcornella force-pushed the refactor-installer branch 2 times, most recently from 53fa153 to 5cf6022 Compare August 9, 2016 00:34
tools/install.sh Outdated
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
# If this platform provides a "chsh" command (not Cygwin), do it, man!
if command_exists chsh; then
Copy link
Contributor

@fornwall fornwall Aug 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that /etc/shells exists if chsh exists, which is not the case on all systems (Android).

Could we also check for /etc/shells here before running grep /zsh$ /etc/shells | tail -1, and fall back to I can't change your shell automatically otherwise?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6398 should fix this

mcornella and others added 21 commits June 3, 2019 17:18
This replaces the currently running process with the new one using `exec`
instead of creating a new process. This way, when the user `exit`s out of
the new shell it will not pop them back into the shell from which ohmyzsh
was installed from.
Otherwise we risk a situation where a full path to `zsh` is commented, i.e.:

    #/usr/local/bin/zsh
Guard clauses are if constructs that return early if there is an error
that prevents continuing. This way there isn't a big nesting of if
expressions.
Co-authored-by: Fredrik Fornwall <fredrik@fornwall.net>
This changes the behavior to default to the binary found first in $PATH,
then checking it's actually in the shells file (/etc/shells).

If that fails go back to the previous behavior, but actually check that
the path obtained exists in the filesystem.

Co-authored-by: Joel Kuzmarski <leoj3n@gmail.com>
This facilitates testing of changes to the core installation code: you'll be
able to do a roundtrip test of install and uninstall using the working code on
your branch.

Controlled by passing $REPO and $BRANCH environment variables to install.sh.
Supposed to be POSIX-compatible. Proved to work in dash, yash and whatever
alpine uses. See https://unix.stackexchange.com/a/371873
Co-authored-by: Marshall Ford <inbox@marshallford.me>
Co-authored-by: Joel Kuzmarski <leoj3n@gmail.com>
Co-authored-by: Joel Kuzmarski <leoj3n@gmail.com>
Co-authored-by: Liquidsoul <liquidsoul@liquidsoul.fr>
Co-authored-by: Alexander Polynomdivision <digitalmail555@googlemail.com>
Co-authored-by: loket <loket@cruftlab.io>
Co-authored-by: Connor Demille <subtlepseudonym@gmail.com>
Co-authored-by: Antonio QUINTAVALLE <antonio.quintavalle@amadeus.com>
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
tput may throw errors on invalid $TERM values, for example.
This shorthand syntax allows for that as well as for if tput
doesn't exist.
installer: fix, refactor and add installer arguments
@mcornella mcornella closed this Jun 3, 2019
@mcornella mcornella deleted the refactor-installer branch June 3, 2019 15:21
@mcornella mcornella removed the Status: testers needed Pull Requests that are waiting for testers to merge label Oct 24, 2019
@mrk-han
Copy link

mrk-han commented Dec 2, 2019

For what it's worth: cat /etc/shells does not show /usr/local/bin/zsh but which zsh does show /usr/local/bin/zsh. Given this, will chsh -s $(which zsh) change the behavior for me?

stephen added a commit to stephen/dotfiles that referenced this pull request Jun 17, 2021
This lets installation run all the way through without running twice. Let's try it.

See ohmyzsh/ohmyzsh#5169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment