File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,3 +201,16 @@ It uses the
201201.Xr archive 3
202202library developed by
203203.An Tim Kientzle Aq Mt kientzle@FreeBSD.org .
204+ .Sh CAVEATS
205+ The
206+ .Nm
207+ utility performs two scans of the command-line for arguments before
208+ and after the archive name, so as to maintain compatibility with
209+ Info-ZIP unzip.
210+ As a result, the POSIX
211+ .Ql --
212+ double-dash string used to separate options from arguments will need to
213+ be repeated.
214+ For example, to extract a "-a.jpg" from "-b.zip" with overwrite, one
215+ would need to invoke
216+ .Dl bsdunzip -o -- -a.jpg -- -b.zip
Original file line number Diff line number Diff line change @@ -1114,6 +1114,10 @@ main(int argc, char *argv[])
11141114 for (int i = 0 ; i < argc ; ++ i )
11151115 debug ("%s%c" , argv [i ], (i < argc - 1 ) ? ' ' : '\n' );
11161116
1117+ #ifdef __GLIBC__
1118+ /* Prevent GNU getopt(3) from rearranging options. */
1119+ setenv ("POSIXLY_CORRECT" , "" );
1120+ #endif
11171121 /*
11181122 * Info-ZIP's unzip(1) expects certain options to come before the
11191123 * zipfile name, and others to come after - though it does not
@@ -1144,6 +1148,10 @@ main(int argc, char *argv[])
11441148 nopts -- ; /* fake argv[0] */
11451149 nopts += getopts (argc - nopts , argv + nopts );
11461150
1151+ /* There may be residual arguments if we encountered -- */
1152+ while (nopts < argc )
1153+ add_pattern (& include , argv [nopts ++ ]);
1154+
11471155 if (n_opt + o_opt + u_opt > 1 )
11481156 errorx ("-n, -o and -u are contradictory" );
11491157
You can’t perform that action at this time.
0 commit comments