1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Scripts: Add lzop (.lzo) support to xzdiff and xzgrep.

This commit is contained in:
Lasse Collin 2011-03-19 13:08:22 +02:00
parent 923b22483b
commit 4eb83e3204
4 changed files with 28 additions and 16 deletions

View file

@ -6,7 +6,7 @@
.\" .\"
.\" License: GNU GPLv2+ .\" License: GNU GPLv2+
.\" .\"
.TH XZDIFF 1 "2010-09-27" "Tukaani" "XZ Utils" .TH XZDIFF 1 "2011-03-19" "Tukaani" "XZ Utils"
.SH NAME .SH NAME
xzcmp, xzdiff, lzcmp, lzdiff \- compare compressed files xzcmp, xzdiff, lzcmp, lzdiff \- compare compressed files
.SH SYNOPSIS .SH SYNOPSIS
@ -33,8 +33,9 @@ on files compressed with
.BR xz (1), .BR xz (1),
.BR lzma (1), .BR lzma (1),
.BR gzip (1), .BR gzip (1),
.BR bzip2 (1),
or or
.BR bzip2 (1). .BR lzop (1).
All options specified are passed directly to All options specified are passed directly to
.BR cmp (1) .BR cmp (1)
or or
@ -66,6 +67,7 @@ are provided for backward compatibility with LZMA Utils.
.BR xz (1), .BR xz (1),
.BR gzip (1), .BR gzip (1),
.BR bzip2 (1), .BR bzip2 (1),
.BR lzop (1),
.BR zdiff (1) .BR zdiff (1)
.SH BUGS .SH BUGS
Messages from the Messages from the

View file

@ -19,10 +19,10 @@
# Instead of unsetting XZ_OPT, just make sure that xz will use file format # Instead of unsetting XZ_OPT, just make sure that xz will use file format
# autodetection. This way memory usage limit and thread limit can be # autodetection. This way memory usage limit and thread limit can be
# specified via XZ_OPT. With gzip and bzip2 it's OK to just unset the # specified via XZ_OPT. With gzip, bzip2, and lzop it's OK to just unset the
# environment variables. # environment variables.
xz='@xz@ --format=auto' xz='@xz@ --format=auto'
unset GZIP BZIP BZIP2 unset GZIP BZIP BZIP2 LZOP
case ${0##*/} in case ${0##*/} in
*cmp*) prog=xzcmp; cmp=${CMP:-cmp};; *cmp*) prog=xzcmp; cmp=${CMP:-cmp};;
@ -77,17 +77,21 @@ if test $# -eq 1; then
xz1=bzip2;; xz1=bzip2;;
*[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z)
xz1=gzip;; xz1=gzip;;
*[-.]lzo | *.tzo)
xz1=lzop;;
*) *)
echo >&2 "$0: $1: Unknown compressed file name suffix" echo >&2 "$0: $1: Unknown compressed file name suffix"
exit 2;; exit 2;;
esac esac
case $1 in case $1 in
*[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma) *[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *[-.]lzo)
FILE=`expr "X$1" : 'X\(.*\)[-.][abglmxzZ2]*$'`;; FILE=`expr "X$1" : 'X\(.*\)[-.][abglmoxzZ2]*$'`;;
*.t[abglx]z) *.t[abglx]z)
FILE=`expr "X$1" : 'X\(.*[-.]t\)[abglx]z$'`ar;; FILE=`expr "X$1" : 'X\(.*[-.]t\)[abglx]z$'`ar;;
*.tbz2) *.tbz2)
FILE=`expr "X$1" : 'X\(.*[-.]t\)bz2$'`ar;; FILE=`expr "X$1" : 'X\(.*[-.]t\)bz2$'`ar;;
*.tzo)
FILE=`expr "X$1" : 'X\(.*[-.]t\)zo$'`ar;;
esac esac
xz_status=$( xz_status=$(
exec 4>&1 exec 4>&1
@ -97,15 +101,17 @@ elif test $# -eq 2; then
case $1 in case $1 in
*[-.]bz2 | *.tbz | *.tbz2) xz1=bzip2;; *[-.]bz2 | *.tbz | *.tbz2) xz1=bzip2;;
*[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz1=gzip;; *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz1=gzip;;
*[-.]lzo | *.tzo) xz1=lzop;;
esac esac
case $2 in case $2 in
*[-.]bz2 | *.tbz | *.tbz2) xz2=bzip2;; *[-.]bz2 | *.tbz | *.tbz2) xz2=bzip2;;
*[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz2=gzip;; *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) xz2=gzip;;
*[-.]lzo | *.tzo) xz2=lzop;;
esac esac
case $1 in case $1 in
*[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *.t[abglx]z | *.tbz2 | -) *[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *.t[abglx]z | *.tbz2 | *[-.]lzo | *.tzo | -)
case "$2" in case "$2" in
*[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *.t[abglx]z | *.tbz2 | -) *[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *.t[abglx]z | *.tbz2 | *[-.]lzo | *.tzo | -)
if test "$1$2" = --; then if test "$1$2" = --; then
xz_status=$( xz_status=$(
exec 4>&1 exec 4>&1
@ -125,7 +131,7 @@ elif test $# -eq 2; then
*) xz_status=0;; *) xz_status=0;;
esac esac
else else
F=`expr "/$2" : '.*/\(.*\)[-.][ablmtxz2]*$'` || F=$prog F=`expr "/$2" : '.*/\(.*\)[-.][ablmotxz2]*$'` || F=$prog
tmp= tmp=
trap ' trap '
test -n "$tmp" && rm -f "$tmp" test -n "$tmp" && rm -f "$tmp"
@ -152,7 +158,7 @@ elif test $# -eq 2; then
esac;; esac;;
*) *)
case "$2" in case "$2" in
*[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *.t[abglx]z | *.tbz2 | -) *[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *.t[abglx]z | *.tbz2 | *[-.]lzo | *.tzo | -)
xz_status=$( xz_status=$(
exec 4>&1 exec 4>&1
($xz2 -cdfq -- "$2" 4>&-; echo $? >&4) 3>&- | ($xz2 -cdfq -- "$2" 4>&-; echo $? >&4) 3>&- |

View file

@ -6,7 +6,7 @@
.\" .\"
.\" License: GNU GPLv2+ .\" License: GNU GPLv2+
.\" .\"
.TH XZGREP 1 "2010-09-27" "Tukaani" "XZ Utils" .TH XZGREP 1 "2011-03-19" "Tukaani" "XZ Utils"
.SH NAME .SH NAME
xzgrep \- search compressed files for a regular expression xzgrep \- search compressed files for a regular expression
.SH SYNOPSIS .SH SYNOPSIS
@ -40,8 +40,9 @@ which may be either uncompressed or compressed with
.BR xz (1), .BR xz (1),
.BR lzma (1), .BR lzma (1),
.BR gzip (1), .BR gzip (1),
.BR bzip2 (1),
or or
.BR bzip2 (1). .BR lzop (1).
All options specified are passed directly to All options specified are passed directly to
.BR grep (1). .BR grep (1).
.PP .PP
@ -51,9 +52,10 @@ is specified, then standard input is decompressed if necessary
and fed to and fed to
.BR grep (1). .BR grep (1).
When reading from standard input, When reading from standard input,
.BR gzip (1) .BR gzip (1),
.BR bzip2 (1),
and and
.BR bzip2 (1) .BR lzop (1)
compressed files are not supported. compressed files are not supported.
.PP .PP
If If
@ -92,4 +94,5 @@ or
.BR xz (1), .BR xz (1),
.BR gzip (1), .BR gzip (1),
.BR bzip2 (1), .BR bzip2 (1),
.BR lzop (1),
.BR zgrep (1) .BR zgrep (1)

View file

@ -22,10 +22,10 @@
# Instead of unsetting XZ_OPT, just make sure that xz will use file format # Instead of unsetting XZ_OPT, just make sure that xz will use file format
# autodetection. This way memory usage limit and thread limit can be # autodetection. This way memory usage limit and thread limit can be
# specified via XZ_OPT. With gzip and bzip2 it's OK to just unset the # specified via XZ_OPT. With gzip, bzip2, and lzop it's OK to just unset the
# environment variables. # environment variables.
xz='@xz@ --format=auto' xz='@xz@ --format=auto'
unset GZIP BZIP BZIP2 unset GZIP BZIP BZIP2 LZOP
case ${0##/*} in case ${0##/*} in
*egrep*) prog=xzegrep; grep=${GREP:-egrep};; *egrep*) prog=xzegrep; grep=${GREP:-egrep};;
@ -149,6 +149,7 @@ for i; do
case $i in case $i in
*[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) uncompress="gzip -cdfq";; *[-.][zZ] | *_z | *[-.]gz | *.t[ag]z) uncompress="gzip -cdfq";;
*[-.]bz2 | *[-.]tbz | *.tbz2) uncompress="bzip2 -cdfq";; *[-.]bz2 | *[-.]tbz | *.tbz2) uncompress="bzip2 -cdfq";;
*[-.]lzo | *[-.]tzo) uncompress="lzop -cdfq";;
*) uncompress="$xz -cdfq";; *) uncompress="$xz -cdfq";;
esac esac
# Fail if xz or grep (or sed) fails. # Fail if xz or grep (or sed) fails.