Skip to content

Commit c0d1fac

Browse files
committed
Better echo
1 parent 62dad0b commit c0d1fac

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

install_libchdb.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,24 @@ curl -L -o libchdb.tar.gz $DOWNLOAD_URL
4141
# Untar the file
4242
tar -xzf libchdb.tar.gz
4343

44+
# Check if console supports colors, if that define REDECHO and ENDECHO
45+
if [[ -t 1 ]]; then
46+
RED='\033[0;31m'
47+
NC='\033[0m'
48+
REDECHO() { echo -e "${RED}$@${NC}"; }
49+
ENDECHO() { echo -ne "${NC}"; }
50+
else
51+
REDECHO() { echo "$@"; }
52+
ENDECHO() { :; }
53+
fi
54+
4455
# If current uid is 0, SUDO is not required
4556
SUDO=''
4657
if [[ $EUID -ne 0 ]]; then
4758
SUDO='sudo'
59+
REDECHO "\nYou may be asked for your sudo password to install:"; ENDECHO
60+
echo " libchdb.so to /usr/local/lib/"
61+
echo " chdb.h to /usr/local/include/"
4862
fi
4963

5064
# Install the library and header file
@@ -62,6 +76,6 @@ fi
6276
# Clean up
6377
rm -f libchdb.tar.gz libchdb.so chdb.h
6478

65-
echo "Installation completed successfully."
66-
echo "If any error occurred, please report it to:"
67-
echo " https://github.com/chdb-io/chdb/issues/new/choose"
79+
REDECHO "Installation completed successfully." ; ENDECHO
80+
REDECHO "If any error occurred, please report it to:" ; ENDECHO
81+
REDECHO " https://github.com/chdb-io/chdb/issues/new/choose" ; ENDECHO

0 commit comments

Comments
 (0)