From 5f4008459c53efb06802806c614ac68f5859d6e1 Mon Sep 17 00:00:00 2001 From: G2-Games Date: Mon, 19 Sep 2022 17:04:28 -0500 Subject: [PATCH] Fixed installer for older versions --- install.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 62cee45..0340175 100755 --- a/install.sh +++ b/install.sh @@ -5,7 +5,7 @@ originaldir=$PWD environment=$(ps -o args= -p $$ | egrep -m 1 -o '\w{0,5}sh' | head -1) if [ "$environment" = "bash" ] || [ "$environment" = "zsh" ]; then - if ! grep -q 'bash ~/.welcome/welcome.sh' $bashrc && ! grep -q 'zsh ~/.welcome/welcome.sh' $zshrc && ! grep -q 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -q 'zsh /home/$USER/.welcome/welcome.sh' $zshrc; + if ! grep -qs 'bash ~/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh ~/.welcome/welcome.sh' $zshrc && ! grep -qs 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh /home/$USER/.welcome/welcome.sh' $zshrc; then echo "Welcome! Installing in $environment..." tput sc @@ -76,16 +76,16 @@ then exit 1 fi # Check for older versions and replace bashrc lines # - if grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc ; + if grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc ; then - line=$(grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc) + line=$(grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc) line=${line%:*} sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc echo 'bash ~/.welcome/welcome.sh' >> $bashrc fi - if grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ; + if grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ; then - line=$(grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc) + line=$(grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc) line=${line%:*} sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc echo 'zsh ~/.welcome/welcome.sh' >> $zshrc @@ -117,30 +117,30 @@ then rm ~/.welcome/welcome.sh rm ~/.welcome/config.cfg rmdir ~/.welcome - if grep -n 'bash ~/.welcome/welcome.sh' $bashrc ; + if grep -sn 'bash ~/.welcome/welcome.sh' $bashrc ; then - line=$(grep -n 'bash ~/.welcome/welcome.sh' $bashrc) + line=$(grep -sn 'bash ~/.welcome/welcome.sh' $bashrc) line=${line%:*} sed -i "${line}d" $bashrc sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc fi - if grep -n 'zsh ~/.welcome/welcome.sh' $zshrc ; + if grep -sn 'zsh ~/.welcome/welcome.sh' $zshrc ; then - line=$(grep -n 'zsh ~/.welcome/welcome.sh' $zshrc) + line=$(grep -sn 'zsh ~/.welcome/welcome.sh' $zshrc) line=${line%:*} sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc fi # Check for older versions # - if grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc ; + if grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc ; then - line=$(grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc) + line=$(grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc) line=${line%:*} sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc fi - if grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ; + if grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ; then - line=$(grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc) + line=$(grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc) line=${line%:*} sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc fi