From ea4a7bba3e48c3e2bddca9aec1eb3bbb1e810cec Mon Sep 17 00:00:00 2001 From: desktop Date: Fri, 3 Nov 2023 21:28:11 +0300 Subject: [PATCH] bash : pack : add support for iso unpacking. --- .linux/bash/module/pack.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.linux/bash/module/pack.sh b/.linux/bash/module/pack.sh index 927e57e..e6fd83f 100644 --- a/.linux/bash/module/pack.sh +++ b/.linux/bash/module/pack.sh @@ -1,4 +1,4 @@ -_PACK_SUPPORTED=".tar$|.zip$" +_UNPACK_SUPPORTED=".tar$|.tgz$|.txz$|.zip$|.iso$" # Pack files into desired format. # Usage: pack @@ -63,7 +63,7 @@ unpack() # show error if no target specified. if [[ "${targets}" = "" ]]; then - targets=($(ls | grep -E ${_PACK_SUPPORTED})) + targets=($(ls | grep -E ${_UNPACK_SUPPORTED})) total=${#targets[@]} fi @@ -98,6 +98,9 @@ unpack() "tar") _unpack_tar "${target}" ;; + "iso") + _unpack_iso "${target}" + ;; *) echo "${target}: format not supported." return 2 @@ -154,32 +157,38 @@ _pack_tar() # unpack zip archive. _unpack_zip() { - unzip "${1}" + unzip "${@}" } # unpack 7z archive. _unpack_7z() { - 7z x "${1}" + 7z x "${@}" } # unpack tgz archive. _unpack_tgz() { - pv "${1}" | gzip -d | tar -xf - + pv "${@}" | gzip -d | tar -xf - } # unpack txz archive. _unpack_txz() { - pv "${1}" | xz -d | tar -xf - + pv "${@}" | xz -d | tar -xf - } # unpack tar archive. _unpack_tar() { - pv "${1}" | tar -xf - + pv "${@}" | tar -xf - +} + +# unpack iso image. +_unpack_iso() +{ + 7z x "${@}" } # 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 +export -f pack unpack _pack_tgz _pack_txz _pack_tar _pack_zip _unpack_zip _unpack_7z _unpack_tgz _unpack_txz _unpack_tar _pack_error _unpack_iso