.Xr archive 3
library developed by
.An Tim Kientzle Aq Mt kientzle@FreeBSD.org .
+.Sh CAVEATS
+The
+.Nm
+utility performs two scans of the command-line for arguments before
+and after the archive name, so as to maintain compatibility with
+Info-ZIP unzip.
+As a result, the POSIX
+.Ql --
+double-dash string used to separate options from arguments will need to
+be repeated.
+For example, to extract a "-a.jpg" from "-b.zip" with overwrite, one
+would need to invoke
+.Dl bsdunzip -o -- -a.jpg -- -b.zip
for (int i = 0; i < argc; ++i)
debug("%s%c", argv[i], (i < argc - 1) ? ' ' : '\n');
+#ifdef __GLIBC__
+ /* Prevent GNU getopt(3) from rearranging options. */
+ setenv("POSIXLY_CORRECT", "");
+#endif
/*
* Info-ZIP's unzip(1) expects certain options to come before the
* zipfile name, and others to come after - though it does not
nopts--; /* fake argv[0] */
nopts += getopts(argc - nopts, argv + nopts);
+ /* There may be residual arguments if we encountered -- */
+ while (nopts < argc)
+ add_pattern(&include, argv[nopts++]);
+
if (n_opt + o_opt + u_opt > 1)
errorx("-n, -o and -u are contradictory");