diff --git a/doc/zzcat.1.in b/doc/zzcat.1.in index f995f68..15f9bcb 100644 --- a/doc/zzcat.1.in +++ b/doc/zzcat.1.in @@ -2,7 +2,8 @@ .SH NAME zzcat \- concatenate files using different instruction sequences .SH SYNOPSIS -\fBzzcat\fR [\fB\-AbeEntTv\fR] [\fB\-x\fR \fIsequence\fR] [\fIFILE\fR]... +\fBzzcat\fR [\fB\-AbeEntTv\fR] [\fB\-r\fR \fIloops\fR] +[\fB\-x\fR \fIsequence\fR] [\fIFILE\fR]... .br \fBzzcat \-l\fR | \fB\-\-list\fR .br @@ -34,6 +35,9 @@ Display $ at end of each line. \fB\-n\fR, \fB\-\-number\fR Number all output lines. .TP +\fB\-r\fR, \fB\-\-repeat\fR=\fIloops\fR +Concatenate all files \fIloops\fR times. +.TP \fB\-t\fR Equivalent to \fB\-vT\fR. .TP diff --git a/src/zzcat.c b/src/zzcat.c index de2552b..9317e0e 100644 --- a/src/zzcat.c +++ b/src/zzcat.c @@ -62,6 +62,7 @@ static void version(void); static void usage(void); /* Global parameters */ +static int repeat = 1; static char escape_tabs = 0; static char escape_ends = 0; static char escape_other = 0; @@ -85,7 +86,7 @@ int main(int argc, char *argv[]) for (;;) { -#define OPTSTR "+AbeEnstTvx:lhV" +#define OPTSTR "+AbeEnr:stTvx:lhV" #define MOREINFO "Try `%s --help' for more information.\n" int option_index = 0; static struct myoption long_options[] = @@ -94,6 +95,7 @@ int main(int argc, char *argv[]) { "number-nonblank", 0, NULL, 'b' }, { "show-ends", 0, NULL, 'E' }, { "number", 0, NULL, 'n' }, + { "repeat", 1, NULL, 'r' }, { "squeeze-blank", 0, NULL, 's' }, { "show-tabs", 0, NULL, 'T' }, { "show-nonprinting", 0, NULL, 'v' }, @@ -125,6 +127,9 @@ int main(int argc, char *argv[]) case 'n': /* --number */ number_lines = 1; break; + case 'r': /* --repeat */ + repeat = atoi(optarg); + break; case 's': /* --squeeze-blank */ squeeze_lines = 1; break; @@ -164,12 +169,13 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - for (i = myoptind; i < argc; i++) - { - int ret = run(sequence, argv[i]); - if (ret) - return ret; - } + while (repeat-- > 0) + for (i = myoptind; i < argc; i++) + { + int ret = run(sequence, argv[i]); + if (ret) + return ret; + } return EXIT_SUCCESS; } @@ -788,10 +794,11 @@ static void usage(void) printf(" -e equivalent to -vE\n"); printf(" -E, --show-ends display $ at end of each line\n"); printf(" -n, --number number all output lines\n"); + printf(" -r, --repeat= concatenate command line files times\n"); printf(" -t equivalent to -vT\n"); printf(" -T, --show-tabs display TAB characters as ^I\n"); printf(" -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB\n"); - printf(" -x, --execute execute commands in \n"); + printf(" -x, --execute= execute commands in \n"); printf(" -l, --list list available program functions\n"); printf(" -h, --help display this help and exit\n"); printf(" -V, --version output version information and exit\n");