Pack : Create a dir for each unpack.
This commit is contained in:
parent
5b39eb3ab8
commit
0ba52987e7
|
@ -66,13 +66,21 @@
|
||||||
[[ "''${targets}" = "" ]] && targets=($(_ls_files | grep -E ''${_unpack_supported}))
|
[[ "''${targets}" = "" ]] && targets=($(_ls_files | grep -E ''${_unpack_supported}))
|
||||||
|
|
||||||
process() {
|
process() {
|
||||||
# unpack file type.
|
# Use full path to file.
|
||||||
|
target=''$(realpath "''${target}")
|
||||||
|
|
||||||
|
# Unpack file type.
|
||||||
local type="''${target##*.}"
|
local type="''${target##*.}"
|
||||||
|
|
||||||
[[ "''${target}" =~ .tar.gz$ ]] && type="tar.gz"
|
[[ "''${target}" =~ .tar.gz$ ]] && type="tar.gz"
|
||||||
[[ "''${target}" =~ .tar.xz$ ]] && type="tar.xz"
|
[[ "''${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
|
case "''${type,,}" in
|
||||||
"zip")
|
"zip")
|
||||||
_unpack_zip "''${target}"
|
_unpack_zip "''${target}"
|
||||||
|
@ -106,6 +114,9 @@
|
||||||
return 2
|
return 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Cd back.
|
||||||
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
_iterate_targets process ''${targets[@]}
|
_iterate_targets process ''${targets[@]}
|
||||||
|
|
Loading…
Reference in a new issue