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