Add support to tar multiple files in a single run

This commit is contained in:
sin 2015-04-21 14:30:11 +01:00
parent 542f645bc2
commit f1261b57d9

10
tar.c
View File

@ -341,7 +341,7 @@ static void
usage(void) usage(void)
{ {
eprintf("usage: %s [-C dir] [-j | -z] -x [-m | -t] [-f file]\n" 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 int
@ -379,9 +379,10 @@ main(int argc, char *argv[])
usage(); usage();
} ARGEND; } ARGEND;
if (!mode || argc != (mode == 'c')) if (!mode)
usage(); usage();
if (mode == 'c' && filtermode) if (mode == 'c')
if (!argc || filtermode)
usage(); usage();
switch (mode) { switch (mode) {
@ -401,7 +402,8 @@ main(int argc, char *argv[])
} }
if (chdir(dir) < 0) if (chdir(dir) < 0)
eprintf("chdir %s:", dir); eprintf("chdir %s:", dir);
recurse(argv[0], NULL, &r); for (; *argv; argc--, argv++)
recurse(*argv, NULL, &r);
break; break;
case 't': case 't':
case 'x': case 'x':