Archive : Update unarchive checks for simple format.

This commit is contained in:
Dmitry Voronin 2024-04-27 03:31:08 +03:00
parent 4ce33a429d
commit b44964a436
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -273,12 +273,12 @@
function unarchive() {
local IFS=$'\n'
local targets=(''${@})
[[ "''${targets}" = "" ]] && targets=$(_ls_archive)
[[ "''${targets}" = "" ]] && targets=$(_ls_archive_compressed)
process() {
# Validate.
# _archive_check "''${target}" || return 1
if ! _is_archive "''${target}"; then
if ! _is_compressed_archive "''${target}"; then
_iterate_skip "Not an archive."
return 0
fi
@ -404,6 +404,13 @@
[[ "''${out}" != "" ]]
}
# Check if file is a compressed archive.
function _is_compressed_archive() {
local out=$(echo "''${*}" | grep -E ''${_archive_pattern_compressed})
[[ "''${out}" != "" ]]
}
# List all archives.
function _ls_archive() {
ls | grep -E ''${_archive_pattern}
@ -414,6 +421,11 @@
ls | grep -E ''${_archive_pattern_fast}
}
# List fast archives.
function _ls_archive_compressed() {
ls | grep -E ''${_archive_pattern_compressed}
}
# Filter input for archives only.
function _filter_archive() {
grep -E ''${_archive_pattern}