bash : pack & archive fix exports.

This commit is contained in:
Dmitry Voronin 2023-11-03 00:15:40 +03:00
parent 1ca04a7c16
commit a39b8c86c4
2 changed files with 12 additions and 5 deletions

View file

@ -1,5 +1,8 @@
_ARCHIVE_PATTERN="_[0-9]{12}-[[:alnum:]]{40}.t[xg]z"
alias _ARCHIVE_DATE="date +%Y%m%d%H%M"
_ARCHIVE_DATE()
{
date +%Y%m%d%H%M
}
# archive file with maximum compression and checksum.
# usage: archive [FILES]
@ -277,7 +280,8 @@ archive_convert()
}
# export everything, primarily for use with parallel..
export -f archive archive_fast archive_check unarchive archive_name
export -f archive archive_fast archive_check unarchive archive_name _ARCHIVE_DATE
export _ARCHIVE_PATTERN
# autocomplete.
_archive_name()

View file

@ -106,13 +106,13 @@ unpack()
# actions on error.
if [[ $? != 0 ]]; then
_error "${target}"
_pack_error "${target}"
((failed++))
fi
done
# print report.
if [[ ${count} -gt 1 ]]; then
if [[ ${count} -gt 1 ]] || [[ "${*}" = "" ]]; then
if [[ ${failed} -gt 0 ]]; then
echo -e "${color_bred}Items failed to unpack: ${failed}.${color_default}"
else
@ -122,7 +122,7 @@ unpack()
}
# show error.
_error()
_pack_error()
{
echo -e "${color_bred}${1}: failed.${color_default}"
}
@ -180,3 +180,6 @@ _unpack_tar()
{
pv "${1}" | tar -xf -
}
# export functions.
export -f pack unpack _pack_tgz _pack_txz _pack_tar _pack_zip _unpack_zip _unpack_7z _unpack_tgz _unpack_txz _unpack_tar _pack_error