summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-04-14 21:34:00 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-04-14 21:34:00 +0200
commitcca4c9f4c0878b08fac6dfe014148ddcd5aa7678 (patch)
treeb66ee21e9057492fdd4a9599d75c489468585978 /archival
parentafc766fc12d54670aaed9bbb228efc7a5be561db (diff)
downloadbusybox-cca4c9f4c0878b08fac6dfe014148ddcd5aa7678.tar.gz
unzip: add -t
function old new delta packed_usage 33584 33598 +14 .rodata 103218 103219 +1 unzip_main 2665 2656 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 15/-9) Total: 6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival')
-rw-r--r--archival/unzip.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index 12db4e579..66005a43e 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -64,6 +64,7 @@
//usage: "\n -o Overwrite"
//usage: "\n -j Do not restore paths"
//usage: "\n -p Print to stdout"
+//usage: "\n -t Test"
//usage: "\n -q Quiet"
//usage: "\n -x FILE Exclude FILEs"
//usage: "\n -d DIR Extract into DIR"
@@ -556,7 +557,7 @@ int unzip_main(int argc, char **argv)
opts = 0;
/* '-' makes getopt return 1 for non-options */
- while ((i = getopt(argc, argv, "-d:lnopqxjv")) != -1) {
+ while ((i = getopt(argc, argv, "-d:lnotpqxjv")) != -1) {
switch (i) {
case 'd': /* Extract to base directory */
base_dir = optarg;
@@ -574,8 +575,13 @@ int unzip_main(int argc, char **argv)
overwrite = O_ALWAYS;
break;
- case 'p': /* Extract files to stdout and fall through to set verbosity */
+ case 't': /* Extract files to /dev/null */
+ xmove_fd(xopen("/dev/null", O_WRONLY), STDOUT_FILENO);
+ /*fallthrough*/
+
+ case 'p': /* Extract files to stdout */
dst_fd = STDOUT_FILENO;
+ /*fallthrough*/
case 'q': /* Be quiet */
quiet++;
@@ -984,7 +990,6 @@ int unzip_main(int argc, char **argv)
/* O_NOFOLLOW defends against symlink attacks */
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW);
#endif
- do_extract:
if (!quiet) {
printf(/* zip.fmt.method == 0
? " extracting: %s\n"
@@ -992,6 +997,7 @@ int unzip_main(int argc, char **argv)
printable_string(dst_fn)
);
}
+ do_extract:
#if ENABLE_FEATURE_UNZIP_CDF
if (S_ISLNK(file_mode)) {
if (dst_fd != STDOUT_FILENO) /* not -p? */