Add specific colors for debug messages

This commit is contained in:
Jeremy Gardais 2020-01-07 16:10:01 +01:00
parent a7ce5f7b42
commit 71b1392dce
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 8 additions and 2 deletions

View File

@ -11,6 +11,12 @@
## Enable (0) or disable (1) debug
debug=0
## Colors {{{
c_redb='\033[1;31m'
c_magentab='\033[1;35m'
c_reset='\033[0m'
## }}}
## Manage files of year
date_year="2019"
@ -31,14 +37,14 @@ tar_file_name="${date_year}.${current_dir}${xz_compression_lvl}.tar.xz"
# }}}
[ "${debug}" -eq "0" ] && printf '%b\n' "Create an archive for ${current_dir} files between ${date_start} and ${date_end} using XZ's compression level: ${xz_compression_lvl}."
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "Create an archive for ${current_dir} files between ${date_start} and ${date_end} using XZ's compression level: ${xz_compression_lvl}."
## Get the list of files between the 2 dates and ignore tar files
find . -type f -newermt "${date_start}" -not -newermt "${date_end}" -not -iname "*.tar*" -print0 | tar cJf "${tar_file_name}" --null -T -
## Check previous return code and if the archive exists with size > 0
if [ "${?}" -eq "0" ] && [ -s "${tar_file_name}" ]; then
[ "${debug}" -eq "0" ] && printf '%b\n' "${tar_file_name} successfully created, the files can be deleted."
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "${tar_file_name} successfully created, the files can be deleted."
find . -type f -newermt "${date_start}" -not -newermt "${date_end}" -not -iname "*.tar*" -delete
fi