aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMaxime Henrion <mux@FreeBSD.org>2003-06-01 21:40:35 +0000
committerMaxime Henrion <mux@FreeBSD.org>2003-06-01 21:40:35 +0000
commitb5938e81b674d0d6b0f1e32271da897f403abed6 (patch)
treeb851ec6917bd5a82d99889d69a61d79d4c495351 /usr.bin
parent3a054956589d5eab617d915c458342dc67faa89e (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xargs/xargs.111
-rw-r--r--usr.bin/xargs/xargs.c18
2 files changed, 24 insertions, 5 deletions
diff --git a/usr.bin/xargs/xargs.1 b/usr.bin/xargs/xargs.1
index 939994e03d0a..d6d39a117a8e 100644
--- a/usr.bin/xargs/xargs.1
+++ b/usr.bin/xargs/xargs.1
@@ -45,7 +45,7 @@
.Nd "construct argument list(s) and execute utility"
.Sh SYNOPSIS
.Nm
-.Op Fl 0pt
+.Op Fl 0opt
.Op Fl E Ar eofstr
.Oo
.Fl I Ar replstr
@@ -191,6 +191,13 @@ arguments remaining for the last invocation of
The current default value for
.Ar number
is 5000.
+.It Fl o
+Reopen stdin as
+.Dq /dev/tty
+in the child process before executing the command.
+This is useful if you want
+.Nm
+to run an interactive application.
.It Fl p
Echo each command to be executed and ask the user whether it should be
executed.
@@ -277,7 +284,7 @@ utility is expected to be
.St -p1003.2
compliant.
The
-.Fl J
+.Fl J , o
and
.Fl R
options are non-standard
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 96ad3b44d482..194015c1c26d 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>
#ifndef BOOTSTRAPPING
#include <langinfo.h>
#endif
@@ -80,7 +81,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;
extern char **environ;
@@ -120,7 +121,7 @@ main(int argc, char *argv[])
/* 1 byte for each '\0' */
nline -= strlen(*ep++) + 1 + sizeof(*ep);
}
- while ((ch = getopt(argc, argv, "0E:I:J:L:n:pR:s:tx")) != -1)
+ while ((ch = getopt(argc, argv, "0E:I:J:L:n:opR:s:tx")) != -1)
switch(ch) {
case 'E':
eofstr = optarg;
@@ -144,6 +145,9 @@ main(int argc, char *argv[])
if ((nargs = atoi(optarg)) <= 0)
errx(1, "illegal argument count");
break;
+ case 'o':
+ oflag = 1;
+ break;
case 'p':
pflag = 1;
break;
@@ -507,6 +511,14 @@ exec:
case -1:
err(1, "vfork");
case 0:
+ close(0);
+ if (oflag) {
+ if (open("/dev/tty", O_RDONLY) == -1)
+ err(1, "open /dev/tty");
+ } else {
+ if (open("/dev/null", O_RDONLY) == -1)
+ err(1, "open /dev/null");
+ }
execvp(argv[0], argv);
childerr = errno;
_exit(1);
@@ -561,7 +573,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] [-s size] [utility [argument ...]]\n");
exit(1);
}