1
0
Fork 0
mirror of synced 2024-12-25 23:43:20 -05:00

[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.
This commit is contained in:
Eric Nielsen 2018-11-06 14:05:12 -05:00
parent 60b0910f6d
commit 2c5e7c02ea
3 changed files with 9 additions and 9 deletions

View file

@ -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` |

View file

@ -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}" ;;

View file

@ -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}" ;;