summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/ar.c6
-rw-r--r--archival/tar.c4
2 files changed, 7 insertions, 3 deletions
diff --git a/archival/ar.c b/archival/ar.c
index 2886d15..46c10aa 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -240,10 +240,12 @@ int ar_main(int argc UNUSED_PARAM, char **argv)
archive_handle = init_handle();
- /* --: prepend '-' to the first argument if required */
+ /* prepend '-' to the first argument if required */
+ if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0')
+ argv[1] = xasprintf("-%s", argv[1]);
/* -1: at least one param is reqd */
/* one of p,t,x[,r] is required */
- opt_complementary = "--:-1:p:t:x"IF_FEATURE_AR_CREATE(":r");
+ opt_complementary = "-1:p:t:x"IF_FEATURE_AR_CREATE(":r");
opt = getopt32(argv, "voc""ptx"IF_FEATURE_AR_CREATE("r"));
argv += optind;
diff --git a/archival/tar.c b/archival/tar.c
index 280ded4..f62b330 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -966,7 +966,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM;
/* Prepend '-' to the first argument if required */
- opt_complementary = "--:" // first arg is options
+ if (argv[1] && argv[1][0] != '-' && argv[1][0] != '\0')
+ argv[1] = xasprintf("-%s", argv[1]);
+ opt_complementary =
"tt:vv:" // count -t,-v
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
"\xff::" // --exclude=PATTERN is a list