Skip to content

Commit f849e0d

Browse files
committed
Improve code style
with the help of https://github.com/koalaman/shellcheck
1 parent 4fed06d commit f849e0d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

install.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
wait-to-continue(){
1919
echo
2020
echo 'Press Enter to continue or Ctrl-C to exit'
21-
read
21+
read -r
2222
}
2323

2424
install-xcode(){
@@ -74,13 +74,13 @@ setup-ssh-keys(){
7474
echo "used to keep track of different keys on different servers. The comment"
7575
echo "will be formatted as [your name]@codeup."
7676

77-
while [ -z $NAME ]; do
78-
read -p 'Enter your name: ' NAME
77+
while [ -z "$NAME" ]; do
78+
read -rp 'Enter your name: ' NAME
7979
done
8080

81-
ssh-keygen -trsa -b2048 -C "$NAME@codeup" -f $HOME/.ssh/id_rsa -N ''
81+
ssh-keygen -trsa -b2048 -C "$NAME@codeup" -f "$HOME/.ssh/id_rsa" -N ''
8282

83-
pbcopy < $HOME/.ssh/id_rsa.pub
83+
pbcopy < "$HOME/.ssh/id_rsa.pub"
8484

8585
echo "We've copied your ssh key to the clipboard for you. Now, we are going to take you"
8686
echo "to the GitHub website where you will add it as one of your keys by clicking the"
@@ -112,7 +112,7 @@ install-mysql(){
112112
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('codeup');
113113
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
114114
DELETE FROM mysql.user WHERE User='';
115-
DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';
115+
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
116116
FLUSH PRIVILEGES;
117117
EOF
118118
}
@@ -146,7 +146,7 @@ setup() {
146146
# if they do not exist
147147
xcode-select --print-path >/dev/null 2>&1 || install-xcode
148148
which brew >/dev/null 2>&1 || install-brew
149-
[ -d $HOME/.ssh ] && [ -f $HOME/.ssh/id_rsa ] || setup-ssh-keys
149+
[ -f "$HOME/.ssh/id_rsa" ] || setup-ssh-keys
150150

151151
# check if java was installed with brew cask if not install it
152152
brew cask list java >/dev/null 2>&1 || install-java
@@ -168,9 +168,11 @@ setup() {
168168
echo
169169
else
170170
echo 'Setting up global gitignore file...'
171-
echo '.DS_Store' >> ~/.gitignore_global
172-
echo '.idea' >> ~/.gitignore_global
173-
echo '*.iml' >> ~/.gitignore_global
171+
{
172+
echo '.DS_Store'
173+
echo '.idea'
174+
echo '*.iml'
175+
} >> ~/.gitignore_global
174176
git config --global core.excludesfile ~/.gitignore_global
175177
fi
176178
# set the default git editor to nano

0 commit comments

Comments
 (0)