summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author"Vladimir N. Oleynik"2005-10-12 08:17:29 +0000
committer"Vladimir N. Oleynik"2005-10-12 08:17:29 +0000
commitf5888696967416075ba52434ed6059e3a7f4957b (patch)
tree00140a4d803dd893fb87305e8aa25ee40d0d0d44
parent161aae727399e97c1c532fb6877de0d34d821bb5 (diff)
downloadbusybox-f5888696967416075ba52434ed6059e3a7f4957b.zip
busybox-f5888696967416075ba52434ed6059e3a7f4957b.tar.gz
new featured bb_opt_complementally, correct argc checking
-rw-r--r--archival/tar.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/archival/tar.c b/archival/tar.c
index d984267..32e9cba 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -603,7 +603,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
# define TAR_OPT_STR_CREATE "ch"
# define TAR_OPT_FLAG_CREATE 2
#else
-//# define CTX_CREATE 0
+# define CTX_CREATE 0
# define TAR_OPT_STR_CREATE ""
# define TAR_OPT_FLAG_CREATE 0
#endif
@@ -690,10 +690,6 @@ int tar_main(int argc, char **argv)
unsigned long opt;
unsigned long ctx_flag = 0;
- if (argc < 2) {
- bb_show_usage();
- }
-
/* Prepend '-' to the first argument if required */
if (argv[1][0] != '-')
argv[1] = bb_xasprintf("-%s", argv[1]);
@@ -702,11 +698,14 @@ int tar_main(int argc, char **argv)
tar_handle = init_handle();
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
- bb_opt_complementally = "?c~tx:t~cx:x~ct:X*:T*";
+#ifdef CONFIG_FEATURE_TAR_CREATE
+ bb_opt_complementally = "?:c?c:t?t:x?x:c~tx:t~cx:x~ct:X*:T*";
+#else
+ bb_opt_complementally = "?:t?t:x?x:t~x:x~t:X*:T*";
+#endif
#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS
bb_applet_long_options = tar_long_options;
#endif
-
opt = bb_getopt_ulflags(argc, argv, tar_options,
&base_dir, /* Change to dir <optarg> */
&tar_filename /* archive filename */
@@ -716,14 +715,7 @@ int tar_main(int argc, char **argv)
#endif
);
-#ifdef CONFIG_FEATURE_TAR_CREATE
ctx_flag = opt & (CTX_CREATE | CTX_TEST | CTX_EXTRACT);
-#else
- ctx_flag = opt & (CTX_TEST | CTX_EXTRACT);
-#endif
- if (ctx_flag == 0) {
- bb_show_usage();
- }
if(ctx_flag & CTX_TEST) {
if ((tar_handle->action_header == header_list) ||
(tar_handle->action_header == header_verbose_list)) {