commit f1261b57d9bd38f7d8b488753e712aad258bd118
parent 542f645bc226bca275a852afa24dc48f73074ca0
Author: sin <sin@2f30.org>
Date: Tue, 21 Apr 2015 14:30:11 +0100
Add support to tar multiple files in a single run
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tar.c b/tar.c
@@ -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
@@ -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':
@@ -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':