diff --git a/setup.sh b/setup.sh index ffd1ebf..9461eee 100755 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,14 @@ #!/bin/sh -e +# Make sure that echo is posix compliant +echo() { + if [ ! "$BASH_VERSION" = "" ]; then + /usr/bin/env echo -e "$@" + else + /usr/bin/env echo "$@" + fi +} + RC='\033[0m' RED='\033[31m' YELLOW='\033[33m' @@ -14,11 +23,13 @@ if [ ! -d "$LINUXTOOLBOXDIR" ]; then echo "${GREEN}linuxtoolbox directory created: $LINUXTOOLBOXDIR${RC}" fi -if [ -d "$LINUXTOOLBOXDIR/mybash" ]; then rm -rf "$LINUXTOOLBOXDIR/mybash"; fi +if [ -d "$LINUXTOOLBOXDIR/mybash" ]; then + rm -rf "$LINUXTOOLBOXDIR/mybash" +fi echo "${YELLOW}Cloning mybash repository into: $LINUXTOOLBOXDIR/mybash${RC}" -git clone https://github.com/ChrisTitusTech/mybash "$LINUXTOOLBOXDIR/mybash" -if [ $? -eq 0 ]; then + +if git clone https://github.com/ChrisTitusTech/mybash "$LINUXTOOLBOXDIR/mybash"; then echo "${GREEN}Successfully cloned mybash repository${RC}" else echo "${RED}Failed to clone mybash repository${RC}" @@ -255,11 +266,11 @@ linkConfig() { touch "$CURRENT_BASHRC" fi - if cat "$CURRENT_BASHRC" | grep -q ". $GITPATH/.bashrc"; then + if grep -q ". $GITPATH/.bashrc" < "$CURRENT_BASHRC" ; then echo "Bash config is already being sourced${RC}" else echo "Appending to current bash config" - cat >> $CURRENT_BASHRC << EOF + cat >> "$CURRENT_BASHRC" << EOF ## ChrisTitusTech's bash config . $GITPATH/.bashrc