[hackers] [sbase] Add support to tar multiple files in a single run || sin

From: <git_AT_suckless.org>
Date: Tue, 21 Apr 2015 16:43:58 +0200 (CEST)

commit f1261b57d9bd38f7d8b488753e712aad258bd118
Author: sin <sin_AT_2f30.org>
Date: Tue Apr 21 14:30:11 2015 +0100

    Add support to tar multiple files in a single run

diff --git a/tar.c b/tar.c
index 573dbdb..0f82f15 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -341,7 +341,7 @@ static void
 usage(void)
 {
         eprintf("usage: %s [-C dir] [-j | -z] -x [-m | -t] [-f file]\n"
- " %s [-C dir] [-h] -c dir [-f file]\n", argv0, argv0);
+ " %s [-C dir] [-h] -c dir ... [-f file]\n", argv0, argv0);
 }
 
 int
_AT_@ -379,10 +379,11 @@ main(int argc, char *argv[])
                 usage();
         } ARGEND;
 
- if (!mode || argc != (mode == 'c'))
- usage();
- if (mode == 'c' && filtermode)
+ if (!mode)
                 usage();
+ if (mode == 'c')
+ if (!argc || filtermode)
+ usage();
 
         switch (mode) {
         case 'c':
_AT_@ -401,7 +402,8 @@ main(int argc, char *argv[])
                 }
                 if (chdir(dir) < 0)
                         eprintf("chdir %s:", dir);
- recurse(argv[0], NULL, &r);
+ for (; *argv; argc--, argv++)
+ recurse(*argv, NULL, &r);
                 break;
         case 't':
         case 'x':
Received on Tue Apr 21 2015 - 16:43:58 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 21 2015 - 16:48:19 CEST