#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
#endif
- "[-f tarFile] [FILE] ...\n\n"
- "Create, extract, or list files from a tar file. Note that\n"
+ "[-f tarFile] [FILE] ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate, extract, or list files from a tar file. Note that\n"
"this version of tar treats hard links as separate files.\n\n"
"Main operation mode:\n"
#ifdef BB_FEATURE_TAR_CREATE
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
+#endif
;
/* Tar file constants */
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
#endif
- const char *tarName=NULL;
+ const char *tarName="-";
int listFlag = FALSE;
int extractFlag = FALSE;
int createFlag = FALSE;
usage(tar_usage);
/* Parse any options */
- while (--argc > 0 && (**(++argv) != '\0')) {
+ while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
stopIt=FALSE;
- while (stopIt==FALSE && *(++(*argv))) {
+ while (stopIt==FALSE && *argv && **argv) {
switch (**argv) {
case 'f':
if (--argc == 0) {
fatalError( "Option requires an argument: No file specified\n");
}
- if (tarName != NULL)
+ if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
fatalError( "Unknown tar flag '%c'\n"
"Try `tar --help' for more information\n", **argv);
}
+ ++(*argv);
}
}
#else
exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
#endif
- } else {
+ }
+ if (listFlag == TRUE || extractFlag == TRUE) {
exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
}