xref: /freebsd/contrib/libarchive/unzip/bsdunzip.1 (revision e64fe029e9d3ce476e77a478318e0c3cd201ff08)
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 January 2, 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 d Ar dir
38.Op Fl x Ar pattern
39.Op Fl P Ar password
40.Ar zipfile
41.Op Ar member ...
42.Sh DESCRIPTION
43.\" ...
44The following options are available:
45.Bl -tag -width Fl
46.It Fl a
47When extracting a text file, convert DOS-style line endings to
48Unix-style line endings.
49.It Fl C
50Match file names case-insensitively.
51.It Fl c
52Extract to stdout/screen.
53When extracting files from the zipfile, they are written to stdout.
54This is similar to
55.Fl p ,
56but does not suppress normal output.
57.It Fl d Ar dir
58Extract files into the specified directory rather than the current
59directory.
60.It Fl f
61Update existing.
62Extract only files from the zipfile if a file with the same name
63already exists on disk and is older than the former.
64Otherwise, the file is silently skipped.
65.It Fl j
66Ignore directories stored in the zipfile; instead, extract all files
67directly into the extraction directory.
68.It Fl L
69Convert the names of the extracted files and directories to lowercase.
70.It Fl l
71List, rather than extract, the contents of the zipfile.
72.It Fl n
73No overwrite.
74When extracting a file from the zipfile, if a file with the same name
75already exists on disk, the file is silently skipped.
76.It Fl o
77Overwrite.
78When extracting a file from the zipfile, if a file with the same name
79already exists on disk, the existing file is replaced with the file
80from the zipfile.
81.It Fl p
82Extract to stdout.
83When extracting files from the zipfile, they are written to stdout.
84The normal output is suppressed as if
85.Fl q
86was specified.
87.It Fl P Ar password
88Extract encrypted files using a password.
89Putting a password on the command line using this option can be
90insecure.
91.It Fl q
92Quiet: print less information while extracting.
93.It Fl t
94Test: do not extract anything, but verify the checksum of every file
95in the archive.
96.It Fl u
97Update.
98When extracting a file from the zipfile, if a file with the same name
99already exists on disk, the existing file is replaced with the file
100from the zipfile if and only if the latter is newer than the former.
101Otherwise, the file is silently skipped.
102.It Fl v
103List verbosely, rather than extract, the contents of the zipfile.
104This differs from
105.Fl l
106by using the long listing.
107Note that most of the data is currently fake and does not reflect the
108content of the archive.
109.It Fl x Ar pattern
110Exclude files matching the pattern
111.Ar pattern .
112.It Fl y
113Print four digit years in listings instead of two.
114.It Fl Z Ar mode
115Emulate
116.Xr zipinfo 1L
117mode.
118Enabling
119.Xr zipinfo 1L
120mode changes the way in which additional arguments are parsed.
121Currently only
122.Xr zipinfo 1L
123mode 1 is supported, which lists the file names one per line.
124.It Ar [member ...]
125Optional list of members to extract from the zipfile.
126Can include patterns, e.g.
127.Ar 'memberdir/*'
128will extract all files and dirs below memberdir.
129.El
130.Pp
131Note that only one of
132.Fl n ,
133.Fl o ,
134and
135.Fl u
136may be specified.
137If specified filename is
138.Qq - ,
139then data is read from
140.Va stdin .
141.Sh ENVIRONMENT
142If the
143.Ev UNZIP_DEBUG
144environment variable is defined, the
145.Fl q
146command-line option has no effect, and additional debugging
147information will be printed to
148.Va stderr .
149.Sh COMPATIBILITY
150The
151.Nm
152utility aims to be sufficiently compatible with other implementations
153to serve as a drop-in replacement in the context of the
154.Xr ports 7
155system.
156No attempt has been made to replicate functionality which is not
157required for that purpose.
158.Pp
159For compatibility reasons, command-line options will be recognized if
160they are listed not only before but also after the name of the
161zipfile.
162.Pp
163Normally, the
164.Fl a
165option should only affect files which are marked as text files in the
166zipfile's central directory.
167Since the
168.Xr archive 3
169library does not provide access to that information, it is not available
170to the
171.Nm
172utility.
173Instead, the
174.Nm
175utility will assume that a file is a text file if no non-ASCII
176characters are present within the first block of data decompressed for
177that file.
178If non-ASCII characters appear in subsequent blocks of data, a warning
179will be issued.
180.Pp
181The
182.Nm
183utility is only able to process ZIP archives handled by
184.Xr libarchive 3 .
185Depending on the installed version of
186.Xr libarchive 3 ,
187this may or may not include self-extracting or ZIPX archives.
188.Sh SEE ALSO
189.Xr libarchive 3
190.Sh HISTORY
191The
192.Nm
193utility appeared in
194.Fx 8.0 .
195.Sh AUTHORS
196The
197.Nm
198utility and this manual page were written by
199.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
200It uses the
201.Xr archive 3
202library developed by
203.An Tim Kientzle Aq Mt kientzle@FreeBSD.org .
204.Sh CAVEATS
205The
206.Nm
207utility performs two scans of the command-line for arguments before
208and after the archive name, so as to maintain compatibility with
209Info-ZIP unzip.
210As a result, the POSIX
211.Ql --
212double-dash string used to separate options from arguments will need to
213be repeated.
214For example, to extract a "-a.jpg" from "-b.zip" with overwrite, one
215would need to invoke
216.Dl bsdunzip -o -- -a.jpg -- -b.zip
217