Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env nix-shell
- #! nix-shell -i zsh -p zsh gzip bzip2 lz4 xz zstd unzip pax --pure
- file="${1}"
- function expand
- {
- ${2} -dc ${1} 2>/dev/null
- }
- function expand_archive
- {
- ${2} -dc ${1} 2>/dev/null | pax -v 2>/dev/null
- }
- case "${1}" in
- *.tar.Z) uncompress -c ${1} 2>/dev/null | pax -v 2>/dev/null ;;
- *.tar.gz) expand_archive "${file}" gzip ;;
- *.tgz) expand_archive "${file}" gzip ;;
- *.tar.bz2) expand_archive "${file}" bzip2 ;;
- *.tar.lz4) expand_archive "${file}" lz4 ;;
- *.tar.xz) expand_archive "${file}" xz ;;
- *.tar.zst) expand_archive "${file}" zstd ;;
- *.tar) pax -v -f "${file}" 2>/dev/null ;;
- *.cpio.Z) uncompress -c ${1} 2>/dev/null | pax -v 2>/dev/null ;;
- *.cpio.gz) expand_archive "${file}" gzip ;;
- *.tgz) expand_archive "${file}" gzip ;;
- *.cpio.bz2) expand_archive "${file}" bzip2 ;;
- *.cpio.lz4) expand_archive "${file}" lz4 ;;
- *.cpio.xz) expand_archive "${file}" xz ;;
- *.cpio.zst) expand_archive "${file}" zstd ;;
- *.cpio) pax -v -f "${file}" 2>/dev/null ;;
- *.Z) uncompress -c "${file}" 2>/dev/null ;;
- *.gz) expand "${file}" gzip ;;
- *.bz2) expand "${file}" bzip2 ;;
- *.lz4) expand "${file}" lz4 ;;
- *.xz) expand "${file}" xz ;;
- *.zst) expand "${file}" zstd ;;
- *.zip) unzip -l "${file}" 2>/dev/null ;;
- *.ZIP) unzip -l "${file}" 2>/dev/null ;;
- *) exit 1 ;;
- esac
- exit $?
- # local variables:
- # mode: shell-script
- # sh-shell: zsh
- # coding: utf-8
- # end:
Advertisement
Add Comment
Please, Sign In to add comment