(2) Add -f flag to force xargs to ignore program status. (3) Fix includes.
SCCS-vsn: usr.bin/xargs/xargs.c 5.7
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)xargs.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)xargs.c 5.7 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
#endif /* not lint */
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
#include <limits.h>
#include "pathnames.h"
#define DEF_ARGC 255
int tflag;
#include <limits.h>
#include "pathnames.h"
#define DEF_ARGC 255
int tflag;
main(argc, argv)
int argc;
main(argc, argv)
int argc;
register int ch;
register char *p, *bp, *endbp, **bxp, **endxp, **xp;
int cnt, indouble, insingle, nargs, nline;
register int ch;
register char *p, *bp, *endbp, **bxp, **endxp, **xp;
int cnt, indouble, insingle, nargs, nline;
- char *mark, *prog, **xargs, *malloc();
+ char *mark, *prog, **xargs;
nargs = DEF_ARGC;
nline = _POSIX2_LINE_MAX;
nargs = DEF_ARGC;
nline = _POSIX2_LINE_MAX;
- while ((ch = getopt(argc, argv, "n:s:t")) != EOF)
+ while ((ch = getopt(argc, argv, "n:s:tf")) != EOF)
switch(ch) {
case 'n':
if ((nargs = atoi(optarg)) <= 0) {
switch(ch) {
case 'n':
if ((nargs = atoi(optarg)) <= 0) {
case 't':
tflag = 1;
break;
case 't':
tflag = 1;
break;
+ case 'f':
+ fflag = 1;
+ break;
case '?':
default:
usage();
case '?':
default:
usage();
if (p == bp) /* nothing to display */
exit(0);
if (mark == p) { /* nothing since last arg end */
if (p == bp) /* nothing to display */
exit(0);
if (mark == p) { /* nothing since last arg end */
run(prog, xargs);
exit(0);
}
run(prog, xargs);
exit(0);
}
"xargs: unterminated quote.\n");
exit(1);
}
"xargs: unterminated quote.\n");
exit(1);
}
run(prog, xargs);
if (ch == EOF)
exit(0);
run(prog, xargs);
if (ch == EOF)
exit(0);
"xargs: waitpid: %s.\n", strerror(errno));
exit(1);
}
"xargs: waitpid: %s.\n", strerror(errno));
exit(1);
}
+ if (!fflag && pstat.w_status)
usage()
{
(void)fprintf(stderr,
usage()
{
(void)fprintf(stderr,
- "xargs: [-t] [-n number] [-s size] [utility [argument ...]]\n");
+ "xargs: [-t] [-f] [-n number] [-s size] [utility [argument ...]]\n");