Created
April 16, 2019 22:59
-
-
Save arthurdapaz/af11b5cd1a1a7f18e18afcbbee3f7176 to your computer and use it in GitHub Desktop.
Script to install bash without brew or wget on MacOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Install Bash 5.0 (MacOS) | |
VERSION="5.0" | |
BASH_SHORT="bash-$VERSION" | |
BASH_SRC="$BASH_SHORT.tar.gz" | |
BASH_URL="https://ftp.gnu.org/gnu/bash" | |
BASH_PREFIX="/usr/local" | |
BASH_PATH="$BASH_PREFIX/bin/bash" | |
# initial setup | |
cd ~/ | |
curl -Ok $BASH_URL/$BASH_SRC | |
tar -zxvf $BASH_SRC | |
mv $BASH_SHORT .bash && cd .bash/ | |
./configure --prefix=$BASH_PREFIX && make && sudo make install | |
printf "\nInstalled bash'es:\n" | |
which -a bash | |
printf "\nWhitelisting the new bash...\n" | |
grep -q $BASH_PATH /private/etc/shells || echo $BASH_PATH | sudo tee -a /private/etc/shells | |
printf "\nSetting default shell:\n" | |
chsh -s $BASH_PATH | |
sudo chsh -s $BASH_PATH | |
printf "\nCreating uninstaller..." | |
touch bash_uninstall | |
cat > bash_uninstall <<EOF | |
#!/usr/bin/env bash | |
cd ~/.bash | |
sudo make uninstall clean | |
printf "\nCleaning whitelist...\n" | |
sed /$(sed 's:/:\\/:g' <<< $BASH_PATH)/d /private/etc/shells | |
printf "\nRemoving leftovers...\n" | |
rm -rf ~/.bash && cd ~/ | |
printf "\nSetting old bash back...\n" | |
chsh -s /bin/bash | |
sudo chsh -s /bin/bash | |
printf "\nInstalled bash'es:\n" | |
which -a bash | |
printf "\nOld bash is back!\n" | |
EOF | |
chmod +x bash_uninstall | |
printf "\nCleaning source: " | |
cd ~/ && rm -vf $BASH_SRC | |
printf "\n\nExit terminal and reopen to start using $BASH_SHORT\nTo uninstall it and revert to old:\n~/.bash/bash_uninstall\n" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like your post, your script & an uninstall option, Thank you.
May ask for little more?
Advice, I want to learn a new language, I thought I would start with a simple terminal Lang for my computer.
I have a mid 2010 imac.
I think I succeeded in updating to this a month or two ago here at github from what came installed?
Today as I read up on where to start, many say that version 3.2.57 is old from 2007 and to update for lots of reasons.
Any tips? perhaps I should practice more for a month so I can use your script correctly.
Do you have a place/book you refer beginners too?
(I'm a 54 yr old lay user, I plan to practice at least 1/2 hr day or I will get no where-obviously)