[hackers] [sbase] Implement -E eofstr for xargs(1) || sin
commit e27c55aec3550024a66a2b8a32047b7518b2cac1
Author: sin <sin_AT_2f30.org>
Date: Tue Jan 7 11:53:55 2014 +0000
Implement -E eofstr for xargs(1)
diff --git a/xargs.1 b/xargs.1
index 9313c67..c8b6669 100644
--- a/xargs.1
+++ b/xargs.1
_AT_@ -4,8 +4,10 @@ xargs \- constuct argument list(s) and execute command
.SH SYNOPSIS
.B xargs
.RB [ \-r ]
+.RB [ \-E
+.IR eofstr ]
.RI [ cmd
-.RI [arg... ] ]
+.IR [arg... ] ]
.SH DESCRIPTION
xargs reads space, tab, newline and EOF delimited strings from stdin
and executes the specified cmd with the strings as arguments.
_AT_@ -26,6 +28,9 @@ newlines, may be escaped by a backslash.
.BI \-r
Do not run the command if there are no arguments. Normally the command is
executed at least once even if there are no arguments.
+.TP
+.B \-E eofstr
+Use eofstr as a logical EOF marker.
.SH EXIT STATUS
xargs exits with one of the following values:
diff --git a/xargs.c b/xargs.c
index 1eb9bff..b77c90f 100644
--- a/xargs.c
+++ b/xargs.c
_AT_@ -27,12 +27,13 @@ static char *argb;
static size_t argbsz = 1;
static size_t argbpos;
static int nerrors = 0;
+static char *eofstr;
static int rflag = 0;
static void
usage(void)
{
- eprintf("usage: %s [-r] [cmd [arg...]]
", argv0);
+ eprintf("usage: %s [-r] [-E eofstr] [cmd [arg...]]
", argv0);
}
int
_AT_@ -46,6 +47,9 @@ main(int argc, char *argv[])
case 'r':
rflag = 1;
break;
+ case 'E':
+ eofstr = EARGF(usage());
+ break;
default:
usage();
} ARGEND;
_AT_@ -186,9 +190,8 @@ poparg(void)
while ((ch = inputc()) != EOF) {
switch (ch) {
case ' ': case ' ': case '
':
- fillbuf('
Received on Tue Jan 07 2014 - 13:04:06 CET
This archive was generated by hypermail 2.3.0
: Tue Jan 07 2014 - 13:12:13 CET