Last active
November 17, 2020 05:41
-
-
Save aemonair/4ba1f83a5bf95e2c4785437eed7e283c to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
CC=gcc | |
GPP=g++ | |
PRONAME=$0 | |
if [ -z $1 ];then | |
echo -e "\033[0;31mUsage : $PRONAME < C-Programs File's name >\033[0m" | |
exit 1 | |
fi | |
FLAGS="$* -g -lpthread" | |
FILN=$1 | |
FILO=$(echo "$1"|sed 's/\.[Cc]\|\.cpp$//g') | |
#FILO=$(echo "$1"|sed 's/\.[Cc]$//g') | |
#filename=$(basename "$FILN") | |
#echo $filename | |
#extension="${filename##*.}" | |
# C/CPP | |
extension="${FILN##*.}" | |
#echo $extension | |
if [ ${extension} = "cpp" ];then | |
CC=g++ | |
elif [ ${extension} = "c" ];then | |
CC=gcc | |
fi | |
#echo -e ${CC} | |
#echo $FILN | |
#echo $FILO | |
#echo $FLAGS | |
if [ ${FILN} = ${FILO} ];then | |
echo -e "\033[0;31m Input filename is not a C/CPP-Program file !\033[0m" | |
exit 1 | |
fi | |
echo "Compiling ..." | |
echo -e "CC \033[0;35m${FLAGS}\033[0m" | |
${CC} -o ${FILO} ${FLAGS} | |
#echo $CC | |
#echo ${FILO} | |
#echo ${FLAGS} | |
if [ 0 -ne $? ];then | |
echo -e "\033[43;33mERROR ${CC} -o ${FILO} ${FILN} ${FLAGS}\033[0m" | |
echo -e "\033[0;31m $(date)\033[0m" | |
exit 1 | |
else | |
# echo "${FILO} is OK." | |
echo -e "\033[0;36m Completed .\033[0m" | |
echo -e "\033[0;31m $(date)\033[0m" | |
./$FILO | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cc.sh *.c
to compiler the c language programs to binary file.