mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 16:31:24 +00:00
Patch to add in the -X option and fix the --exclude bug, originally by
Sebastien Huet, and now ported to the latest and greatest by both Arne Bernin <ab@netropol.de> and kent robotti <robotti@metconnect.com>.
This commit is contained in:
parent
f484e7e65c
commit
8cede00b9e
2
Config.h
2
Config.h
@ -222,7 +222,7 @@
|
|||||||
// Enable support for creation of tar files.
|
// Enable support for creation of tar files.
|
||||||
#define BB_FEATURE_TAR_CREATE
|
#define BB_FEATURE_TAR_CREATE
|
||||||
//
|
//
|
||||||
// Enable support for "--exclude" for excluding files
|
// Enable support for "--exclude" and "-X" for excluding files
|
||||||
#define BB_FEATURE_TAR_EXCLUDE
|
#define BB_FEATURE_TAR_EXCLUDE
|
||||||
//
|
//
|
||||||
//// Enable reverse sort
|
//// Enable reverse sort
|
||||||
|
@ -1218,6 +1218,7 @@ const char tar_usage[] =
|
|||||||
#endif
|
#endif
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
"[--exclude File] "
|
"[--exclude File] "
|
||||||
|
"[-X File]"
|
||||||
#endif
|
#endif
|
||||||
"[-f tarFile] [FILE(s)] ...\n"
|
"[-f tarFile] [FILE(s)] ...\n"
|
||||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||||
@ -1234,6 +1235,7 @@ const char tar_usage[] =
|
|||||||
"\tO\t\textract to stdout\n"
|
"\tO\t\textract to stdout\n"
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
"\texclude\t\tfile to exclude\n"
|
"\texclude\t\tfile to exclude\n"
|
||||||
|
"\tX\t\tfile with names to exclude\n"
|
||||||
#endif
|
#endif
|
||||||
"\nInformative output:\n"
|
"\nInformative output:\n"
|
||||||
"\tv\t\tverbosely list files processed\n"
|
"\tv\t\tverbosely list files processed\n"
|
||||||
|
@ -147,6 +147,9 @@ extern int tar_main(int argc, char **argv)
|
|||||||
char** extractList=NULL;
|
char** extractList=NULL;
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
int excludeListSize=0;
|
int excludeListSize=0;
|
||||||
|
char *excludeFileName ="-";
|
||||||
|
FILE *fileList;
|
||||||
|
char file[256];
|
||||||
#endif
|
#endif
|
||||||
const char *tarName="-";
|
const char *tarName="-";
|
||||||
int listFlag = FALSE;
|
int listFlag = FALSE;
|
||||||
@ -198,7 +201,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
case 'e':
|
case 'e':
|
||||||
if (strcmp(*argv, "exclude")==0) {
|
if (strcmp(*argv, "xclude")==0) {
|
||||||
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||||
excludeList[excludeListSize] = *(++argv);
|
excludeList[excludeListSize] = *(++argv);
|
||||||
if (excludeList[excludeListSize] == NULL)
|
if (excludeList[excludeListSize] == NULL)
|
||||||
@ -211,6 +214,30 @@ extern int tar_main(int argc, char **argv)
|
|||||||
stopIt=TRUE;
|
stopIt=TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'X':
|
||||||
|
if (*excludeFileName != '-')
|
||||||
|
fatalError("Only one 'X' option allowed\n");
|
||||||
|
excludeFileName = *(++argv);
|
||||||
|
if (excludeFileName == NULL)
|
||||||
|
fatalError("Option requires an argument: No file specified\n");
|
||||||
|
fileList = fopen (excludeFileName, "rt");
|
||||||
|
if (! fileList)
|
||||||
|
fatalError("Exclude file: file not found\n");
|
||||||
|
while (!feof(fileList)) {
|
||||||
|
fscanf(fileList, "%s", file);
|
||||||
|
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||||
|
excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
|
||||||
|
strcpy(excludeList[excludeListSize],file);
|
||||||
|
/* Remove leading "/"s */
|
||||||
|
if (*excludeList[excludeListSize] == '/')
|
||||||
|
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
|
||||||
|
/* Tack a NULL onto the end of the list */
|
||||||
|
excludeList[++excludeListSize] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fileList);
|
||||||
|
stopIt=TRUE;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
case '-':
|
case '-':
|
||||||
break;
|
break;
|
||||||
|
29
tar.c
29
tar.c
@ -147,6 +147,9 @@ extern int tar_main(int argc, char **argv)
|
|||||||
char** extractList=NULL;
|
char** extractList=NULL;
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
int excludeListSize=0;
|
int excludeListSize=0;
|
||||||
|
char *excludeFileName ="-";
|
||||||
|
FILE *fileList;
|
||||||
|
char file[256];
|
||||||
#endif
|
#endif
|
||||||
const char *tarName="-";
|
const char *tarName="-";
|
||||||
int listFlag = FALSE;
|
int listFlag = FALSE;
|
||||||
@ -198,7 +201,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
case 'e':
|
case 'e':
|
||||||
if (strcmp(*argv, "exclude")==0) {
|
if (strcmp(*argv, "xclude")==0) {
|
||||||
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||||
excludeList[excludeListSize] = *(++argv);
|
excludeList[excludeListSize] = *(++argv);
|
||||||
if (excludeList[excludeListSize] == NULL)
|
if (excludeList[excludeListSize] == NULL)
|
||||||
@ -211,6 +214,30 @@ extern int tar_main(int argc, char **argv)
|
|||||||
stopIt=TRUE;
|
stopIt=TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'X':
|
||||||
|
if (*excludeFileName != '-')
|
||||||
|
fatalError("Only one 'X' option allowed\n");
|
||||||
|
excludeFileName = *(++argv);
|
||||||
|
if (excludeFileName == NULL)
|
||||||
|
fatalError("Option requires an argument: No file specified\n");
|
||||||
|
fileList = fopen (excludeFileName, "rt");
|
||||||
|
if (! fileList)
|
||||||
|
fatalError("Exclude file: file not found\n");
|
||||||
|
while (!feof(fileList)) {
|
||||||
|
fscanf(fileList, "%s", file);
|
||||||
|
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||||
|
excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
|
||||||
|
strcpy(excludeList[excludeListSize],file);
|
||||||
|
/* Remove leading "/"s */
|
||||||
|
if (*excludeList[excludeListSize] == '/')
|
||||||
|
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
|
||||||
|
/* Tack a NULL onto the end of the list */
|
||||||
|
excludeList[++excludeListSize] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fileList);
|
||||||
|
stopIt=TRUE;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
case '-':
|
case '-':
|
||||||
break;
|
break;
|
||||||
|
2
usage.c
2
usage.c
@ -1218,6 +1218,7 @@ const char tar_usage[] =
|
|||||||
#endif
|
#endif
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
"[--exclude File] "
|
"[--exclude File] "
|
||||||
|
"[-X File]"
|
||||||
#endif
|
#endif
|
||||||
"[-f tarFile] [FILE(s)] ...\n"
|
"[-f tarFile] [FILE(s)] ...\n"
|
||||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||||
@ -1234,6 +1235,7 @@ const char tar_usage[] =
|
|||||||
"\tO\t\textract to stdout\n"
|
"\tO\t\textract to stdout\n"
|
||||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||||
"\texclude\t\tfile to exclude\n"
|
"\texclude\t\tfile to exclude\n"
|
||||||
|
"\tX\t\tfile with names to exclude\n"
|
||||||
#endif
|
#endif
|
||||||
"\nInformative output:\n"
|
"\nInformative output:\n"
|
||||||
"\tv\t\tverbosely list files processed\n"
|
"\tv\t\tverbosely list files processed\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user