From 747721bf11e5f7f6083e609e435db360f7cc729e Mon Sep 17 00:00:00 2001 From: VetheonGames Date: Tue, 11 Jun 2024 12:44:57 -0600 Subject: [PATCH] Update to handle when things are already installed --- other_software/install_rbenv_and_ruby.sh | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/other_software/install_rbenv_and_ruby.sh b/other_software/install_rbenv_and_ruby.sh index d19b1c7..feb2932 100644 --- a/other_software/install_rbenv_and_ruby.sh +++ b/other_software/install_rbenv_and_ruby.sh @@ -12,21 +12,29 @@ if ! command -v curl &> /dev/null; then exit 1 fi -git clone https://github.com/rbenv/rbenv.git ~/.rbenv -cd ~/.rbenv && src/configure && make -C src -echo "export PATH=\"\$HOME/.rbenv/bin:\$PATH\"" >> ~/.bashrc -echo "eval \"\$(rbenv init -)\"" >> ~/.bashrc -# shellcheck source=/dev/null -source ~/.bashrc +if [ ! -d "$HOME/.rbenv" ]; then + git clone https://github.com/rbenv/rbenv.git ~/.rbenv + cd ~/.rbenv && src/configure && make -C src + echo "export PATH=\"\$HOME/.rbenv/bin:\$PATH\"" >> ~/.bashrc + echo "eval \"\$(rbenv init -)\"" >> ~/.bashrc + # shellcheck source=/dev/null + source ~/.bashrc +else + echo "rbenv is already installed." +fi -git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build -echo "export PATH=\"\$HOME/.rbenv/plugins/ruby-build/bin:\$PATH\"" >> ~/.bashrc -# shellcheck source=/dev/null -source ~/.bashrc +if [ ! -d "$HOME/.rbenv/plugins/ruby-build" ]; then + git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build + echo "export PATH=\"\$HOME/.rbenv/plugins/ruby-build/bin:\$PATH\"" >> ~/.bashrc + # shellcheck source=/dev/null + source ~/.bashrc +else + echo "ruby-build is already installed." +fi # Get the latest 5 Ruby versions echo "Fetching latest Ruby versions..." -VERSIONS=$(rbenv install -l | grep -E "^\s*\d+\.\d+\.\d+$" | tail -n 5) +VERSIONS=$(rbenv install -l 2>/dev/null | grep -E "^\s*\d+\.\d+\.\d+$" | tail -n 5) # Present the user with options echo "Please select a Ruby version to install:"