diff --git a/CHANGELOG b/CHANGELOG index 2a2b778..3318056 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ next - Support re-entry into previously-unpacked archive directory - Support direct entry into directory with archive-like name + - Improved .7z support (use 7z/7zr/7za archiver as available) - Fix minor no-recreate bug - Fix .jar archive type recognition diff --git a/README.md b/README.md index cace8b1..76e16ec 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Currently, it supports handling these file types: (requires tar with built-in support for these compression formats, i.e. the -zjJ options) * 7-zip - (requires **7zr** binary) + (requires **7z**/**7za**/**7zr** binary) * zip, jar (requires **zip** and **unzip** binaries) * rar diff --git a/man/walk.1 b/man/walk.1 index 228e105..de18d2e 100644 --- a/man/walk.1 +++ b/man/walk.1 @@ -38,7 +38,7 @@ tar, compressed with gzip/bzip2/xz i.e. the -zjJ options) .IP - 2 7-zip -(requires \fB7zr\fR binary) +(requires \fB7z\fR/\fB7za\fR/\fB7zr\fR binary) .IP - 2 zip, jar (requires \fBzip\fR and \fBunzip\fR binaries) diff --git a/src/walk.sh b/src/walk.sh index 2ae9c97..3752eb7 100755 --- a/src/walk.sh +++ b/src/walk.sh @@ -117,7 +117,7 @@ help () { echo "" echo "Recognized archive types:" echo " - tar, tar.gz, tar.bz2, tar.xz (requires tar with built-in compression support)" - echo " - 7-zip (requires 7zr)" + echo " - 7-zip (requires 7z/7za/7zr)" echo " - zip, jar (requires zip/unzip)" echo " - rar (requires rar)" echo " - cpio, ar" @@ -320,8 +320,8 @@ archvtype () { ;; "7-zip archive"*|"X-"*".7z") z7opt="-bd -ms=on" - fn_unpack () { 7zr x $z7opt "$1" ; } - fn_pack () { 7zr a $z7opt "$1" . ; } + fn_unpack () { _7z x $z7opt "$1" ; } + fn_pack () { _7z a $z7opt "$1" . ; } ;; *"rar archive"*|"X-"*".rar") raropt="-o+ -ol -ow -r0 -tl" @@ -396,6 +396,24 @@ test_reentry () { false } +findbin () { + # findbin BINARY... + # Returns the path of the first BINARY that which(1) could find. + local list="$*" + while [ $# -gt 0 ]; do + which "$1" && return + shift + done + err "binary not found: $list" +} + +_7z () { + local bin + bin=$(findbin 7z 7za 7zr) || return + "$bin" "$@" +} + + #####################################################################