aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMaxime Henrion <mux@FreeBSD.org>2003-03-23 18:29:52 +0000
committerMaxime Henrion <mux@FreeBSD.org>2003-03-23 18:29:52 +0000
commit98186e89da2131fd456a6d3033fd91de1b913fb1 (patch)
treed8dea2198fb4b799619a7cf539bb2ec6eaf22d25 /usr.bin
parentf949f795aa24d4c7cbb049622d61f6474dd38319 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xargs/xargs.111
-rw-r--r--usr.bin/xargs/xargs.c15
2 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/xargs/xargs.1 b/usr.bin/xargs/xargs.1
index 7c2f70bd39590..a36edd129fcfa 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
@@ -192,6 +192,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 Ar maxprocs
Parallel mode: run at most
.Ar maxprocs
@@ -287,7 +294,7 @@ utility is expected to be
.St -p1003.2
compliant.
The
-.Fl J , P
+.Fl J , o , P
and
.Fl R
options are non-standard
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);