tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: [patch] tar: short option for xz (de)compression
On 2015-04-04 20:41, Joerg Sonnenberger wrote:
> On Sat, Apr 04, 2015 at 06:45:10PM +0200, Joachim Henke wrote:
> > I'm quite new to NetBSD. One small detail I'm missing, is a quick way
> > to extract *.tar.xz (or *.tar.lzma) archives. I got used to the option
> > '-J' present in GNU tar (FreeBSD tar has it, too):
>
> You know that you can just use -z? :)
>
> Joerg
Ok, I see '-z' works here because NetBSD gzip is able to automatically
detect and decompress xz archives. But compared to '-J', '-z' does _not_
work
- for the older .tar.lzma format: "gzip: unknown compression format"
- if base was build with MKPIGZGZIP != no
- for compression (of course)
Therefore I still suggest to enable the short option '-J' for tar.
Basically, the attached patch adds just two bytes to the binary (not
considering padding changes due to alignment). I think that's not too
much for working around the cases above, while at the same time
improving syntax compatibility towards FreeBSD and GNU tar.
Best regards,
Jo.
Index: bin/pax/options.c
===================================================================
RCS file: /cvsroot/src/bin/pax/options.c,v
retrieving revision 1.115
diff -u -r1.115 options.c
--- bin/pax/options.c 14 Nov 2013 04:00:48 -0000 1.115
+++ bin/pax/options.c 11 Apr 2015 14:13:53 -0000
@@ -773,6 +773,7 @@
{ "gunzip", no_argument, 0, 'z' },
{ "read-full-blocks", no_argument, 0, 'B' },
{ "directory", required_argument, 0, 'C' },
+ { "xz", no_argument, 0, 'J' },
{ "to-stdout", no_argument, 0, 'O' },
{ "absolute-paths", no_argument, 0, 'P' },
{ "sparse", no_argument, 0, 'S' },
@@ -798,8 +799,6 @@
OPT_EXCLUDE },
{ "no-recursion", no_argument, 0,
OPT_NORECURSE },
- { "xz", no_argument, 0,
- OPT_XZ },
#if !HAVE_NBTOOL_CONFIG_H
{ "chroot", no_argument, 0,
OPT_CHROOT },
@@ -877,7 +876,7 @@
* process option flags
*/
while ((c = getoldopt(argc, argv,
- "+b:cef:hjklmopqrs:tuvwxzBC:HI:OPST:X:Z014578",
+ "+b:cef:hjklmopqrs:tuvwxzBC:HI:JOPST:X:Z014578",
tar_longopts, NULL))
!= -1) {
switch(c) {
@@ -966,9 +965,6 @@
nopids = 1;
}
break;
- case 'O':
- Oflag = 1;
- break;
case 'p':
/*
* preserve user id, group id, file
@@ -1064,6 +1060,12 @@
incfiles[nincfiles - 1].file = optarg;
incfiles[nincfiles - 1].dir = chdname;
break;
+ case 'J':
+ gzip_program = XZ_CMD;
+ break;
+ case 'O':
+ Oflag = 1;
+ break;
case 'P':
/*
* do not remove leading '/' from pathnames
@@ -1142,9 +1144,6 @@
do_chroot = 1;
break;
#endif
- case OPT_XZ:
- gzip_program = XZ_CMD;
- break;
default:
tar_usage();
break;
@@ -2134,8 +2133,8 @@
static void
tar_usage(void)
{
- (void)fputs("usage: tar [-]{crtux}[-befhjklmopqvwzHOPSXZ014578] [archive] "
- "[blocksize]\n"
+ (void)fputs("usage: tar [-]{crtux}[-befhjklmopqvwzHJOPSXZ014578] "
+ "[archive] [blocksize]\n"
" [-C directory] [-T file] [-s replstr] "
"[file ...]\n", stderr);
exit(1);
Index: bin/pax/tar.1
===================================================================
RCS file: /cvsroot/src/bin/pax/tar.1,v
retrieving revision 1.33
diff -u -r1.33 tar.1
--- bin/pax/tar.1 22 Mar 2012 07:58:17 -0000 1.33
+++ bin/pax/tar.1 11 Apr 2015 14:13:53 -0000
@@ -25,7 +25,7 @@
.\"
.\" OpenBSD: tar.1,v 1.28 2000/11/09 23:58:56 aaron Exp
.\"
-.Dd June 18, 2011
+.Dd April 11, 2015
.Dt TAR 1
.Os
.Sh NAME
@@ -34,7 +34,7 @@
.Sh SYNOPSIS
.Nm tar
.Sm off
-.Oo \&- Oc {crtux} Op Fl 014578befHhjklmOoPpqSvwXZz
+.Oo \&- Oc {crtux} Op Fl 014578befHhJjklmOoPpqSvwXZz
.Sm on
.Op Ar archive
.Op Ar blocksize
@@ -107,6 +107,9 @@
.It Fl h , Fl Fl dereference
Follow symbolic links as if they were normal files
or directories.
+.It Fl J, Fl Fl xz
+Compress/decompress archive using
+.Xr xz 1 .
.It Fl j, Fl Fl bzip2, Fl Fl bunzip2
Use
.Xr bzip2 1
@@ -209,9 +212,6 @@
.Nm
to prompt the user for the filename to use when storing or
extracting files in an archive.
-.It Fl Fl xz
-Compress/decompress archive using
-.Xr xz 1 .
.It Fl z , Fl Fl gzip , Fl Fl gunzip
Compress/decompress archive using
.Xr gzip 1 .
Home |
Main Index |
Thread Index |
Old Index