.\"
.\" $FreeBSD$
.\"
-.Dd January 2, 2023
+.Dd June 27, 2023
.Dt BSDUNZIP 1
.Os
.Sh NAME
.Sh SYNOPSIS
.Nm
.Op Fl aCcfjLlnopqtuvy
+.Op { Fl O | Fl I No } Ar encoding
.Op Fl d Ar dir
.Op Fl x Ar pattern
.Op Fl P Ar password
Extract only files from the zipfile if a file with the same name
already exists on disk and is older than the former.
Otherwise, the file is silently skipped.
+.It Fl I Ar encoding
+.It Fl O Ar encoding
+Convert filenames from the specified encoding.
.It Fl j
Ignore directories stored in the zipfile; instead, extract all files
directly into the extraction directory.
mode 1 is supported, which lists the file names one per line.
.It Ar [member ...]
Optional list of members to extract from the zipfile.
-Can include patterns, e.g.
+Can include patterns, e.g.,
.Ar 'memberdir/*'
will extract all files and dirs below memberdir.
.El
static int c_opt; /* extract to stdout */
static const char *d_arg; /* directory */
static int f_opt; /* update existing files only */
+static char *O_arg; /* encoding */
static int j_opt; /* junk directories */
static int L_opt; /* lowercase names */
static int n_opt; /* never overwrite */
ac(archive_read_support_format_zip(a));
+ if (O_arg)
+ ac(archive_read_set_format_option(a, "zip", "hdrcharset", O_arg));
+
if (P_arg)
archive_read_add_passphrase(a, P_arg);
else
{
fprintf(stderr,
-"Usage: unzip [-aCcfjLlnopqtuvyZ1] [-d dir] [-x pattern] [-P password] zipfile\n"
+"Usage: unzip [-aCcfjLlnopqtuvyZ1] [{-O|-I} encoding] [-d dir] [-x pattern] [-P password] zipfile\n"
" [member ...]\n");
exit(EXIT_FAILURE);
}
#ifdef HAVE_GETOPT_OPTRESET
optreset = 1;
#endif
- while ((opt = getopt(argc, argv, "aCcd:fjLlnopP:qtuvx:yZ1")) != -1)
+ while ((opt = getopt(argc, argv, "aCcd:fI:jLlnO:opP:qtuvx:yZ1")) != -1)
switch (opt) {
case '1':
Z1_opt = 1;
case 'f':
f_opt = 1;
break;
+ case 'I':
+ case 'O':
+ O_arg = optarg;
+ break;
case 'j':
j_opt = 1;
break;