diff options
| author | Maxime Henrion <mux@FreeBSD.org> | 2003-03-23 18:29:52 +0000 |
|---|---|---|
| committer | Maxime Henrion <mux@FreeBSD.org> | 2003-03-23 18:29:52 +0000 |
| commit | 98186e89da2131fd456a6d3033fd91de1b913fb1 (patch) | |
| tree | d8dea2198fb4b799619a7cf539bb2ec6eaf22d25 /usr.bin/xargs/xargs.c | |
| parent | f949f795aa24d4c7cbb049622d61f6474dd38319 (diff) | |
Notes
Diffstat (limited to 'usr.bin/xargs/xargs.c')
| -rw-r--r-- | usr.bin/xargs/xargs.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index ec15af7555bc7..5e6c2b4f0748a 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include <err.h> #include <errno.h> +#include <fcntl.h> #if (__FreeBSD_version >= 450002 && __FreeBSD_version < 500000) || \ __FreeBSD_version >= 500017 #include <langinfo.h> @@ -82,7 +83,7 @@ static char echo[] = _PATH_ECHO; static char **av, **bxp, **ep, **exp, **xp; static char *argp, *bbp, *ebp, *inpline, *p, *replstr; static const char *eofstr; -static int count, insingle, indouble, pflag, tflag, Rflag, rval, zflag; +static int count, insingle, indouble, oflag, pflag, tflag, Rflag, rval, zflag; static int cnt, Iflag, jfound, Lflag, wasquoted, xflag; static int curprocs, maxprocs; @@ -127,7 +128,7 @@ main(int argc, char *argv[]) nline -= strlen(*ep++) + 1 + sizeof(*ep); } maxprocs = 1; - while ((ch = getopt(argc, argv, "0E:I:J:L:n:P:pR:s:tx")) != -1) + while ((ch = getopt(argc, argv, "0E:I:J:L:n:oP:pR:s:tx")) != -1) switch(ch) { case 'E': eofstr = optarg; @@ -151,6 +152,9 @@ main(int argc, char *argv[]) if ((nargs = atoi(optarg)) <= 0) errx(1, "illegal argument count"); break; + case 'o': + oflag = 1; + break; case 'P': if ((maxprocs = atoi(optarg)) <= 0) errx(1, "max. processes must be >0"); @@ -522,6 +526,11 @@ exec: case -1: err(1, "vfork"); case 0: + if (oflag) { + close(0); + if (open("/dev/tty", O_RDONLY) == -1) + err(1, "open"); + } execvp(argv[0], argv); childerr = errno; _exit(1); @@ -595,7 +604,7 @@ static void usage(void) { fprintf(stderr, -"usage: xargs [-0pt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]\n" +"usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]\n" " [-L number] [-n number [-x]] [-P maxprocs] [-s size]\n" " [utility [argument ...]]\n"); exit(1); |
