Skip to content

Commit

Permalink
try to make echo usage as posix compliant as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
cartercanedy committed Sep 11, 2024
1 parent bc2ac3f commit e4c34ac
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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}"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e4c34ac

Please sign in to comment.