Pack : Create a dir for each unpack.

This commit is contained in:
Dmitry Voronin 2024-06-04 15:14:50 +03:00
parent 5b39eb3ab8
commit 0ba52987e7
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -66,13 +66,21 @@
[[ "''${targets}" = "" ]] && targets=($(_ls_files | grep -E ''${_unpack_supported}))
process() {
# unpack file type.
# Use full path to file.
target=''$(realpath "''${target}")
# Unpack file type.
local type="''${target##*.}"
[[ "''${target}" =~ .tar.gz$ ]] && type="tar.gz"
[[ "''${target}" =~ .tar.xz$ ]] && type="tar.xz"
# unpack content.
# Make a dir for files.
local dir="''${target%.$type}"; dir="''${dir##*/}"
mkdir "''${dir}" > /dev/null
pushd "''${dir}" > /dev/null
# Unpack content.
case "''${type,,}" in
"zip")
_unpack_zip "''${target}"
@ -106,6 +114,9 @@
return 2
;;
esac
# Cd back.
popd > /dev/null
}
_iterate_targets process ''${targets[@]}