Skip to content

Commit

Permalink
Small install script update for bash (#657)
Browse files Browse the repository at this point in the history
Small script update to make it easier for users that use `/bin/bash`. 


- It fixes the user input that was not prompted for some unknown reason.
It's probably better to update the PATH by default as it removes one
user step.
- I have also made overwriting the current bin with downloaded version
to avoid having conflicting version.
  • Loading branch information
haixuanTao authored Sep 19, 2024
2 parents af05fe1 + bbe6649 commit f53263b
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,43 +185,41 @@ fi
echo "Placing dora-rs cli in $dest"

if [ -e "$dest/$bin" ] && [ "$force" = false ]; then
echo "\`$dest/$bin\` already exists"
echo " Replacing \`$dest/$bin\` with downloaded version"
cp "$td/$bin" "$dest/$bin"
chmod 755 "$dest/$bin"
else
mkdir -p "$dest"
cp "$td/$bin" "$dest/$bin"
chmod 755 "$dest/$bin"
echo ""
fi

read -p "Do you want to add $dest to your PATH automatically? (y/n): " response

if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
if [ "$SHELL" = "/bin/bash" ]; then
if ! grep -q "$dest" ~/.bashrc; then
echo "Adding $dest to PATH in ~/.bashrc"
echo "export PATH=\$PATH:$dest" >> ~/.bashrc
source ~/.bashrc
echo "Path added to ~/.bashrc and reloaded."
else
echo "$dest is already in the PATH in ~/.bashrc"
fi
elif [ "$SHELL" = "/bin/zsh" ]; then
if ! grep -q "$dest" ~/.zshrc; then
echo "Adding $dest to PATH in ~/.zshrc"
echo "export PATH=\$PATH:$dest" >> ~/.zshrc
source ~/.zshrc
echo "Path added to ~/.zshrc and reloaded."
else
echo "$dest is already in the PATH in ~/.zshrc"
fi
if [ "$SHELL" = "/bin/bash" ]; then
if ! grep -q "$dest" ~/.bashrc; then
echo "Adding $dest to PATH in ~/.bashrc"
echo "export PATH=\$PATH:$dest" >> ~/.bashrc
echo "Path added to ~/.bashrc."
echo "Please reload with:"
echo " source ~/.bashrc"
else
echo "Unsupported shell: $SHELL"
echo "Please add the following to your shell's configuration file manually:"
echo " export PATH=\$PATH:$dest"
echo "$dest is already in the PATH in ~/.bashrc"
fi
elif [ "$SHELL" = "/bin/zsh" ]; then
if ! grep -q "$dest" ~/.zshrc; then
echo "Adding $dest to PATH in ~/.zshrc"
echo "export PATH=\$PATH:$dest" >> ~/.zshrc
echo "Path added to ~/.zshrc."
echo "Please reload with:"
echo " source ~/.zshrc"
else
echo "$dest is already in the PATH in ~/.zshrc"
fi
else
echo "You chose not to add $dest to your PATH."
echo "To run dora CLI without adding to PATH, use: '~/.dora/bin/dora'"
echo "Unsupported shell: $SHELL"
echo "Please add the following to your shell's configuration file manually:"
echo " export PATH=\$PATH:$dest"
fi


rm -rf "$td"

0 comments on commit f53263b

Please sign in to comment.