#COLORS
CDEF=" \033[0m" # default color
CCIN=" \033[0;36m" # info color
CGSC=" \033[0;32m" # success color
CRER=" \033[0;31m" # error color
CWAR=" \033[0;33m" # waring color
b_CDEF=" \033[1;37m" # bold default color
b_CCIN=" \033[1;36m" # bold info color
b_CGSC=" \033[1;32m" # bold success color
b_CRER=" \033[1;31m" # bold error color
b_CWAR=" \033[1;33m" # bold warning color
# echo like ... with flag type and display message colors
log () {
case ${1} in
"-s")
echo -e "${b_CGSC}${@/-s/}${CDEF}";; # print success message
"-e")
echo -e "${b_CRER}${@/-e/}${CDEF}";; # print error message
"-w")
echo -e "${b_CWAR}${@/-w/}${CDEF}";; # print warning message
"-i")
echo -e "${b_CCIN}${@/-i/}${CDEF}";; # print info message
*)
echo -e "$@"
;;
esac
}
log -s "success"
log -e "error"
log -w "warning"
log -i "info"
shell|自定义一个调试信息输出
最新推荐文章于 2024-11-03 12:02:27 发布