Changeset 4278


Ignore:
Timestamp:
Jan 18, 2010, 3:02:06 AM (7 years ago)
Author:
sam
Message:

Add a -r flag to zzcat to repeatedly cat file lists.

Location:
zzuf/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/doc/zzcat.1.in

    r4274 r4278  
    33zzcat \- concatenate files using different instruction sequences
    44.SH SYNOPSIS
    5 \fBzzcat\fR [\fB\-AbeEntTv\fR] [\fB\-x\fR \fIsequence\fR] [\fIFILE\fR]...
     5\fBzzcat\fR [\fB\-AbeEntTv\fR] [\fB\-r\fR \fIloops\fR]
     6[\fB\-x\fR \fIsequence\fR] [\fIFILE\fR]...
    67.br
    78\fBzzcat \-l\fR | \fB\-\-list\fR
     
    3435\fB\-n\fR, \fB\-\-number\fR
    3536Number all output lines.
     37.TP
     38\fB\-r\fR, \fB\-\-repeat\fR=\fIloops\fR
     39Concatenate all files \fIloops\fR times.
    3640.TP
    3741\fB\-t\fR
  • zzuf/trunk/src/zzcat.c

    r4273 r4278  
    6363
    6464/* Global parameters */
     65static int repeat = 1;
    6566static char escape_tabs = 0;
    6667static char escape_ends = 0;
     
    8687    for (;;)
    8788    {
    88 #define OPTSTR "+AbeEnstTvx:lhV"
     89#define OPTSTR "+AbeEnr:stTvx:lhV"
    8990#define MOREINFO "Try `%s --help' for more information.\n"
    9091        int option_index = 0;
     
    9596            { "show-ends",        0, NULL, 'E' },
    9697            { "number",           0, NULL, 'n' },
     98            { "repeat",           1, NULL, 'r' },
    9799            { "squeeze-blank",    0, NULL, 's' },
    98100            { "show-tabs",        0, NULL, 'T' },
     
    125127        case 'n': /* --number */
    126128            number_lines = 1;
     129            break;
     130        case 'r': /* --repeat */
     131            repeat = atoi(optarg);
    127132            break;
    128133        case 's': /* --squeeze-blank */
     
    165170    }
    166171
    167     for (i = myoptind; i < argc; i++)
    168     {
    169         int ret = run(sequence, argv[i]);
    170         if (ret)
    171             return ret;
    172     }
     172    while (repeat-- > 0)
     173        for (i = myoptind; i < argc; i++)
     174        {
     175            int ret = run(sequence, argv[i]);
     176            if (ret)
     177                return ret;
     178        }
    173179
    174180    return EXIT_SUCCESS;
     
    789795    printf("  -E, --show-ends           display $ at end of each line\n");
    790796    printf("  -n, --number              number all output lines\n");
     797    printf("  -r, --repeat=<loops>      concatenate command line files <loops> times\n");
    791798    printf("  -t                        equivalent to -vT\n");
    792799    printf("  -T, --show-tabs           display TAB characters as ^I\n");
    793800    printf("  -v, --show-nonprinting    use ^ and M- notation, except for LFD and TAB\n");
    794     printf("  -x, --execute <sequence>  execute commands in <sequence>\n");
     801    printf("  -x, --execute=<sequence>  execute commands in <sequence>\n");
    795802    printf("  -l, --list                list available program functions\n");
    796803    printf("  -h, --help                display this help and exit\n");
Note: See TracChangeset for help on using the changeset viewer.