- #5,216
sbrothy
Gold Member
- 677
- 524
Never really considered BASH simple. Or rather I consider it counterintuitive. I prefer C/C++ or even assembler! But sure, the power of the CLI! Pipe, man, apropos, less, find, regex,awk, sed... Once you feel just a little at home going back to that other OS becomes downright emasculating.
When I use BASH it ends up looking like this:
When I use BASH it ends up looking like this:
Code:
#!/bin/bash
#######################################################################
# Perform cleanup
#######################################################################
cleanup=0
echo
read -rsn1 -t 5 -p $'\e[93;5mAbout to perform cleanup. Press any key to skip in the next 3 seconds...\033[0m'
if [ ! $? -eq 0 ]
then
cleanup=1
else
echo
if [ -f ./pch.h.gch ]
then
read -rsn1 -t 5 -p $'\e[93;5mDo you want to keep the precompiled header (Y/n)...\033[0m' key
if [ $? -neq 0 ]
then
case $key in
n|N)
cleanup=1
;;
*)
;;
esac
fi
fi
fi
if [ ! $cleanup -eq 0 ]
then
echo
echo $'\e[33mPerforming cleanup...\e[0m'
echo
./clean.sh
echo
else
echo
echo $'\e[33mSkipping cleanup...\e[0m'
echo
fi
#######################################################################
# Precompiled header
#######################################################################
echo
read -rsn1 -t 5 -p $'\e[93;5mAbout to precompile header pch.h. Press any key to skip in the next 3 seconds...\033[0m'
if [ $? -eq 0 ]
then
echo
echo $'\e[33mSkipping building precompiled header...\e[0m'
echo
else
echo
echo $'\e[33mBuilding precompiled header...\e[0m'
echo
g++ -H -v -std=gnu++2b -Wall -Wextra -fmax-errors=3 -O0 -fdiagnostics-color=always -x c++-header -c pch.h -o pch.h.gch
echo
if [[ $? -ne 0 ]]
then
echo
echo $'\e[31mError creating precompiled header.\e[0m'
echo
exit 1
else
echo
echo $'\e[32mPrecompiled header successfully created.\e[0m'
echo
fi
fi
if ! [ -f ./pch.h.gch ]; then
echo
echo $'\e[31mPrecompiled header not found. Stop.\033[0m'
echo
exit 1;
fi
#######################################################################
# Build main executable
#######################################################################
echo
echo "Building main executable..."
echo
read -rsn1 -t 3 -p $'\e[93;5mAbout to build main executable. Press any key to skip in the next 3 seconds...\033[0m'
if [ $? -eq 0 ]
then
echo
echo $'\e[33mSkipping...\e[0m'
echo
else
echo
echo $'\e[33mBuilding main executable...\e[0m'
echo
g++ -H -v -std=gnu++2b -fdiagnostics-show-location=every-line -fdiagnostics-color=always -Wall -Wextra -fmax-errors=3 -O0 -o main -include pch.h main.cpp -L/usr/lib/x86_64-linux-gnu/cmake -lboost_filesystem -lboost_regex -lfmt
echo
if [[ $? -ne 0 ]]
then
echo
echo $'\e[31mError compiling main executable.\e[0m'
echo
exit 1
fi
echo
echo $'\e[32mSuccess.\e[0m'
echo
fi
if ! [ -f ./main ]; then
echo
echo $'\e[31mmain not created. Stop.\033[0m'
echo
exit 1;
fi
echo
echo "Done."
echo
exit 0
Last edited: