From 2c5e7c02ea015f3d5eb439c8d43466b36cbdde92 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Tue, 6 Nov 2018 14:05:12 -0500 Subject: [PATCH] [archive] Add missing bzip2 extensions We already had .tar.bz2, .tbz, .tbz2 and .bz2 We were missing .tar.bz and .bz Noticed this in the pull request #308 by @Konfekt. --- modules/archive/README.md | 8 ++++---- modules/archive/functions/archive | 6 +++--- modules/archive/functions/unarchive | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/archive/README.md b/modules/archive/README.md index 87e8943..d5ebaff 100644 --- a/modules/archive/README.md +++ b/modules/archive/README.md @@ -1,4 +1,4 @@ -Archive +archive ======= Provides `archive` and `unarchive` functions for easy archive manipulation. @@ -11,18 +11,18 @@ Functions * `archive` generates an archive based on file extension. Syntax is `archive myarchive.tar.gz /path/to/archive` * `unarchive` unarchives a file based on the extension. Syntax is `unarchive myarchive.7z` -Archive Formats +Archive formats --------------- | Format | Requirements | | ------ | ------------ | | .tar | `tar` | | .tar.gz, .tgz | `tar` or `pigz` | -| .tar.bz2, .tbz | `tar` or `pbzip2` | +| .tar.bz, .tar.bz2, .tbz, .tbz2 | `tar` or `pbzip2` | | .tar.xz, .txz | `tar` with xz support | | .tar.zma, .tlz | `tar` with lzma support | | .gz | `gunzip` or `pigz` | -| .bz2 | `bunzip2` or `pbzip2` | +| .bz, .bz2 | `bunzip2` or `pbzip2` | | .xz | `unxz` | | .lzma | `unzlma` | | .Z | `uncompress` | diff --git a/modules/archive/functions/archive b/modules/archive/functions/archive index 7200cb0..1a79cd5 100644 --- a/modules/archive/functions/archive +++ b/modules/archive/functions/archive @@ -25,8 +25,8 @@ fi # near-liner decrease in compression time based on on the number of available cores. case "${archive_name}" in - (*.tar.gz|*.tgz) tar -cvf "${archive_name}" --use-compress-program="gzip" "${dir_to_archive}" ;; - (*.tar.bz2|*.tbz|*.tbz2) tar -cvf "${archive_name}" --use-compress-program="bzip2" "${dir_to_archive}" ;; + (*.tar.gz|*.tgz) tar -cvf "${archive_name}" --use-compress-program=gzip "${dir_to_archive}" ;; + (*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar -cvf "${archive_name}" --use-compress-program=bzip2 "${dir_to_archive}" ;; (*.tar.xz|*.txz) tar --xz --help &>/dev/null && tar -cvJf "${archive_name}" "${dir_to_archive}" ;; (*.tar.lzma|*.tlz) tar --lzma --help &>/dev/null && tar -cvf "${archive_name}" --lzma "${dir_to_archive}" ;; (*.tar) tar -cvf "${archive_name}" "${dir_to_archive}" ;; @@ -34,7 +34,7 @@ case "${archive_name}" in (*.rar) rar a "${archive_name}" "${dir_to_archive}" ;; (*.7z) 7za a "${archive_name}" "${dir_to_archive}" ;; (*.gz) print "${0}: .gz is only useful for single files, and does not capture permissions. Use .tar.gz" ;; - (*.bz2) print "${0}: .bzip2 is only useful for single files, and does not capture permissions. Use .tar.bz2" ;; + (*.bz|*.bz2) print "${0}: .bzip2 is only useful for single files, and does not capture permissions. Use .tar.bz2" ;; (*.xz) print "${0}: .xz is only useful for single files, and does not capture permissions. Use .tar.xz" ;; (*.lzma) print "${0}: .lzma is only useful for single files, and does not capture permissions. Use .tar.lzma" ;; (*) print "${0}: unknown archive type: ${archive_name}" ;; diff --git a/modules/archive/functions/unarchive b/modules/archive/functions/unarchive index a25af9f..1d175d0 100644 --- a/modules/archive/functions/unarchive +++ b/modules/archive/functions/unarchive @@ -20,14 +20,14 @@ local archive_name="${1:t}" case "${archive_name}" in (*.tar.gz|*.tgz) tar -xvzf "${archive_name}" ;; - (*.tar.bz2|*.tbz|*.tbz2) tar -xvjf "${archive_name}" ;; + (*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar -xvjf "${archive_name}" ;; (*.tar.xz|*.txz) tar --xz --help &>/dev/null && tar --xz -xvf "${archive_name}" \ || xzcat "${archive_name}" | tar xvf - ;; (*.tar.lzma|*.tlz) tar --lzma --help &>/dev/null && tar --lzma -xvf "${archive_name}" \ || lzcat "${archive_name}" | tar xvf - ;; (*.tar) tar xvf "${archive_name}" ;; (*.gz) gunzip "${archive_name}" ;; - (*.bz2) bunzip2 "${archive_name}" ;; + (*.bz|*.bz2) bunzip2 "${archive_name}" ;; (*.xz) unxz "${archive_name}" ;; (*.lzma) unlzma "${archive_name}" ;; (*.Z) uncompress "${archive_name}" ;;