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

Uses zsh only if zsh is installed #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hunterclarke
Copy link

@hunterclarke hunterclarke commented Jun 30, 2023

Currently, the install script creates a .zshrc file, then uses the presence of that file as the indication that the system uses zsh. Instead, test that zsh is installed before taking steps to use zsh.

Why

The install script is broken if zsh is not installed.

What is changing

Check for zsh before configuring zsh in the install script.

How to test

  1. Run install.sh in master on a machine that doesn't have zsh installed. Install should fail with /bin/bash: line 72: zsh: command not found
  2. Run the updated install.sh on a machine that doesn't have zsh installed. Install should succeed and the running shell should remain in place.
  3. Install zsh and run the updated install.sh. Install should succeed and the running shell should switch to zsh.

Currently, the install script creates a .zshrc file, then uses the presence of that file as the indication that the system uses zsh. Instead, test that zsh is installed before taking steps to use zsh.
@aquib-sh
Copy link

Hi, I think you are still creating the .bashrc again and then again checking if .bashrc exists and then adding PATH into it. I think this part is not needed if the person is using zsh. I think maybe you should modify it to first check whether the user has zsh or bash and then add code to update only those configuration files.

if [ ! -f "$HOME/.bashrc" ]; then
	touch "$HOME/.bashrc"
fi

if [ -x "$(command -v zsh)" ] && [ ! -f "$HOME/.zshrc" ]; then
	touch "$HOME/.zshrc"
fi

if [ -x "$(command -v zsh)" ]; then
	echo "" >> "$HOME/.zshrc"
	echo "export PATH=\"$BINARY_PATH:\$PATH\"" >> "$HOME/.zshrc"
fi
if [ -f "$HOME/.bashrc" ]; then
	echo "" >> "$HOME/.bashrc"
	echo "export PATH=\"$BINARY_PATH:\$PATH\"" >> "$HOME/.bashrc"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants