diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-14 21:34:00 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-14 21:34:00 +0200 |
commit | cca4c9f4c0878b08fac6dfe014148ddcd5aa7678 (patch) | |
tree | b66ee21e9057492fdd4a9599d75c489468585978 | |
parent | afc766fc12d54670aaed9bbb228efc7a5be561db (diff) | |
download | busybox-w32-cca4c9f4c0878b08fac6dfe014148ddcd5aa7678.tar.gz busybox-w32-cca4c9f4c0878b08fac6dfe014148ddcd5aa7678.tar.bz2 busybox-w32-cca4c9f4c0878b08fac6dfe014148ddcd5aa7678.zip |
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>
-rw-r--r-- | archival/unzip.c | 12 |
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 @@ | |||
64 | //usage: "\n -o Overwrite" | 64 | //usage: "\n -o Overwrite" |
65 | //usage: "\n -j Do not restore paths" | 65 | //usage: "\n -j Do not restore paths" |
66 | //usage: "\n -p Print to stdout" | 66 | //usage: "\n -p Print to stdout" |
67 | //usage: "\n -t Test" | ||
67 | //usage: "\n -q Quiet" | 68 | //usage: "\n -q Quiet" |
68 | //usage: "\n -x FILE Exclude FILEs" | 69 | //usage: "\n -x FILE Exclude FILEs" |
69 | //usage: "\n -d DIR Extract into DIR" | 70 | //usage: "\n -d DIR Extract into DIR" |
@@ -556,7 +557,7 @@ int unzip_main(int argc, char **argv) | |||
556 | 557 | ||
557 | opts = 0; | 558 | opts = 0; |
558 | /* '-' makes getopt return 1 for non-options */ | 559 | /* '-' makes getopt return 1 for non-options */ |
559 | while ((i = getopt(argc, argv, "-d:lnopqxjv")) != -1) { | 560 | while ((i = getopt(argc, argv, "-d:lnotpqxjv")) != -1) { |
560 | switch (i) { | 561 | switch (i) { |
561 | case 'd': /* Extract to base directory */ | 562 | case 'd': /* Extract to base directory */ |
562 | base_dir = optarg; | 563 | base_dir = optarg; |
@@ -574,8 +575,13 @@ int unzip_main(int argc, char **argv) | |||
574 | overwrite = O_ALWAYS; | 575 | overwrite = O_ALWAYS; |
575 | break; | 576 | break; |
576 | 577 | ||
577 | case 'p': /* Extract files to stdout and fall through to set verbosity */ | 578 | case 't': /* Extract files to /dev/null */ |
579 | xmove_fd(xopen("/dev/null", O_WRONLY), STDOUT_FILENO); | ||
580 | /*fallthrough*/ | ||
581 | |||
582 | case 'p': /* Extract files to stdout */ | ||
578 | dst_fd = STDOUT_FILENO; | 583 | dst_fd = STDOUT_FILENO; |
584 | /*fallthrough*/ | ||
579 | 585 | ||
580 | case 'q': /* Be quiet */ | 586 | case 'q': /* Be quiet */ |
581 | quiet++; | 587 | quiet++; |
@@ -984,7 +990,6 @@ int unzip_main(int argc, char **argv) | |||
984 | /* O_NOFOLLOW defends against symlink attacks */ | 990 | /* O_NOFOLLOW defends against symlink attacks */ |
985 | dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW); | 991 | dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW); |
986 | #endif | 992 | #endif |
987 | do_extract: | ||
988 | if (!quiet) { | 993 | if (!quiet) { |
989 | printf(/* zip.fmt.method == 0 | 994 | printf(/* zip.fmt.method == 0 |
990 | ? " extracting: %s\n" | 995 | ? " extracting: %s\n" |
@@ -992,6 +997,7 @@ int unzip_main(int argc, char **argv) | |||
992 | printable_string(dst_fn) | 997 | printable_string(dst_fn) |
993 | ); | 998 | ); |
994 | } | 999 | } |
1000 | do_extract: | ||
995 | #if ENABLE_FEATURE_UNZIP_CDF | 1001 | #if ENABLE_FEATURE_UNZIP_CDF |
996 | if (S_ISLNK(file_mode)) { | 1002 | if (S_ISLNK(file_mode)) { |
997 | if (dst_fd != STDOUT_FILENO) /* not -p? */ | 1003 | if (dst_fd != STDOUT_FILENO) /* not -p? */ |