Skip to content

Commit

Permalink
7z: support different archiver binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
mle86 committed May 4, 2017
1 parent cf88b34 commit e445ff7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/walk.1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 21 additions & 3 deletions src/walk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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" "$@"
}


#####################################################################


Expand Down

0 comments on commit e445ff7

Please sign in to comment.