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