xref: /freebsd/contrib/libarchive/unzip/bsdunzip.1 (revision 64884e0d4ce7ed57c970e1b34f93e3754c656900)
1.\"-
2.\" Copyright (c) 2007-2008 Dag-Erling Smørgrav
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd June 27, 2023
29.Dt BSDUNZIP 1
30.Os
31.Sh NAME
32.Nm bsdunzip
33.Nd extract files from a ZIP archive
34.Sh SYNOPSIS
35.Nm
36.Op Fl aCcfjLlnopqtuvy
37.Op { Fl O | Fl I No } Ar encoding
38.Op Fl d Ar dir
39.Op Fl x Ar pattern
40.Op Fl P Ar password
41.Ar zipfile
42.Op Ar member ...
43.Sh DESCRIPTION
44.\" ...
45The following options are available:
46.Bl -tag -width Fl
47.It Fl a
48When extracting a text file, convert DOS-style line endings to
49Unix-style line endings.
50.It Fl C
51Match file names case-insensitively.
52.It Fl c
53Extract to stdout/screen.
54When extracting files from the zipfile, they are written to stdout.
55This is similar to
56.Fl p ,
57but does not suppress normal output.
58.It Fl d Ar dir
59Extract files into the specified directory rather than the current
60directory.
61.It Fl f
62Update existing.
63Extract only files from the zipfile if a file with the same name
64already exists on disk and is older than the former.
65Otherwise, the file is silently skipped.
66.It Fl I Ar encoding
67.It Fl O Ar encoding
68Convert filenames from the specified encoding.
69.It Fl j
70Ignore directories stored in the zipfile; instead, extract all files
71directly into the extraction directory.
72.It Fl L
73Convert the names of the extracted files and directories to lowercase.
74.It Fl l
75List, rather than extract, the contents of the zipfile.
76.It Fl n
77No overwrite.
78When extracting a file from the zipfile, if a file with the same name
79already exists on disk, the file is silently skipped.
80.It Fl o
81Overwrite.
82When extracting a file from the zipfile, if a file with the same name
83already exists on disk, the existing file is replaced with the file
84from the zipfile.
85.It Fl p
86Extract to stdout.
87When extracting files from the zipfile, they are written to stdout.
88The normal output is suppressed as if
89.Fl q
90was specified.
91.It Fl P Ar password
92Extract encrypted files using a password.
93Putting a password on the command line using this option can be
94insecure.
95.It Fl q
96Quiet: print less information while extracting.
97.It Fl t
98Test: do not extract anything, but verify the checksum of every file
99in the archive.
100.It Fl u
101Update.
102When extracting a file from the zipfile, if a file with the same name
103already exists on disk, the existing file is replaced with the file
104from the zipfile if and only if the latter is newer than the former.
105Otherwise, the file is silently skipped.
106.It Fl v
107List verbosely, rather than extract, the contents of the zipfile.
108This differs from
109.Fl l
110by using the long listing.
111Note that most of the data is currently fake and does not reflect the
112content of the archive.
113.It Fl x Ar pattern
114Exclude files matching the pattern
115.Ar pattern .
116.It Fl y
117Print four digit years in listings instead of two.
118.It Fl Z Ar mode
119Emulate
120.Xr zipinfo 1L
121mode.
122Enabling
123.Xr zipinfo 1L
124mode changes the way in which additional arguments are parsed.
125Currently only
126.Xr zipinfo 1L
127mode 1 is supported, which lists the file names one per line.
128.It Ar [member ...]
129Optional list of members to extract from the zipfile.
130Can include patterns, e.g.,
131.Ar 'memberdir/*'
132will extract all files and dirs below memberdir.
133.El
134.Pp
135Note that only one of
136.Fl n ,
137.Fl o ,
138and
139.Fl u
140may be specified.
141If specified filename is
142.Qq - ,
143then data is read from
144.Va stdin .
145.Sh ENVIRONMENT
146If the
147.Ev UNZIP_DEBUG
148environment variable is defined, the
149.Fl q
150command-line option has no effect, and additional debugging
151information will be printed to
152.Va stderr .
153.Sh COMPATIBILITY
154The
155.Nm
156utility aims to be sufficiently compatible with other implementations
157to serve as a drop-in replacement in the context of the
158.Xr ports 7
159system.
160No attempt has been made to replicate functionality which is not
161required for that purpose.
162.Pp
163For compatibility reasons, command-line options will be recognized if
164they are listed not only before but also after the name of the
165zipfile.
166.Pp
167Normally, the
168.Fl a
169option should only affect files which are marked as text files in the
170zipfile's central directory.
171Since the
172.Xr archive 3
173library does not provide access to that information, it is not available
174to the
175.Nm
176utility.
177Instead, the
178.Nm
179utility will assume that a file is a text file if no non-ASCII
180characters are present within the first block of data decompressed for
181that file.
182If non-ASCII characters appear in subsequent blocks of data, a warning
183will be issued.
184.Pp
185The
186.Nm
187utility is only able to process ZIP archives handled by
188.Xr libarchive 3 .
189Depending on the installed version of
190.Xr libarchive 3 ,
191this may or may not include self-extracting or ZIPX archives.
192.Sh SEE ALSO
193.Xr libarchive 3
194.Sh HISTORY
195The
196.Nm
197utility appeared in
198.Fx 8.0 .
199.Sh AUTHORS
200The
201.Nm
202utility and this manual page were written by
203.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
204It uses the
205.Xr archive 3
206library developed by
207.An Tim Kientzle Aq Mt kientzle@FreeBSD.org .
208.Sh CAVEATS
209The
210.Nm
211utility performs two scans of the command-line for arguments before
212and after the archive name, so as to maintain compatibility with
213Info-ZIP unzip.
214As a result, the POSIX
215.Ql --
216double-dash string used to separate options from arguments will need to
217be repeated.
218For example, to extract a "-a.jpg" from "-b.zip" with overwrite, one
219would need to invoke
220.Dl bsdunzip -o -- -a.jpg -- -b.zip
221