Commit Graph

75 Commits

Author SHA1 Message Date
Juli Mallett
1925cb245c Rewrite the loop that handles substitution in the -I case, and try to make
it easier to understand.  Making it easy to understand isn't all that easy,
so litter the code with comments so some other poor soul can come along some
day and work on this if they see fit to do so.  Avoid calling strlen(3) to
check for a nil-string, when we can just check for *str=='\0'.

Approved by:    src/tools/regression/usr.bin/xargs/
2002-05-03 17:05:25 +00:00
Juli Mallett
4f49da74db Rename lflag' to Lflag' to match the option's case. 2002-05-03 16:32:03 +00:00
Juli Mallett
d7a43b245d Revert revision 1.22. I incorrectly modified the Berkeley identifiers.
Requested by:	bde, mike
2002-05-03 14:50:31 +00:00
Juli Mallett
eee11f05b4 __COPYRIGHT() and __SCCSID(). 2002-05-02 05:21:35 +00:00
Juli Mallett
76ccb81ef2 An explicit cast to size_t for an inline integer, since the two are not the
same on Alpha and lint(1) pointed that out.

lint(1) on the same architecture pointed out how silly a cast to (u_int) to
malloc(3)'s argument was.  Change that to size_t.
2002-05-02 05:07:13 +00:00
Juli Mallett
b50a72861d Make -J a proper flag internal to the code (rather than just check for
use of replstr and lack of Iflag), and add -R, which when given with
-I controls the number of arguments on which replacement will be done.

Some people happen to think it's idiotic to limit to 5 arguments, so
let the user override it if they like.
2002-05-02 02:42:34 +00:00
Juli Mallett
0fa5e8dc42 Rework some of the -I support so I can't find a way to make xargs(1) core or
corrupt memory.  Simplifies the code in one or two places, also removes some
code that looks like it was bogus or incomplete.

Update strnsubst to have one or two extra conditions which maybe would make
it more efficient, or at least more versatile.  This is likely a no-op.
2002-05-02 02:06:03 +00:00
Juli Mallett
91ae52cb17 In the case where we can't open /dev/tty, fall back to -t behaviour.
Submitted by:	fenner
2002-04-19 23:58:00 +00:00
Juli Mallett
0c7c579ba6 Compound two fprintf(3)s into 1 using string concatenation. 2002-04-19 23:41:56 +00:00
Juli Mallett
fc17b349c8 After 3 months...
Merge xargs(1) with that of xMach.

Bring in xargs(1) changes to add -L and -I as per the Single Unix Specification
version 3.  Proper exit status numbers are implemented, and the manual page has
been updated to reflect reality.

The code has been ANSIfied, and a new file has been added to xargs(1) to do the
substring substitution as SUSv3 requires.

Traditional behaviour should not be affected, use of -J should be deprecated
in favor of the more portable -I (though -J has been left, for now).

Submitted by:	me, tjr (the exit status stuff)
Obtained from:	xMach
2002-04-19 23:28:54 +00:00
Juli Mallett
73385ac644 ANSIfy: Function declarations and prototypes, use of environ(7).
Reviewed by:	mike
Approved by:	mike
2002-03-15 22:54:58 +00:00
Dag-Erling Smørgrav
8ad749a45d Change back to using vfork() now that execvp() is vfork()-safe. If execvp()
fails, errno is saved to a volatile variable that the parent later inspects.

PR:		bin/34898
Submitted by:	Tim J. Robbins <tim@robbins.dropbear.id.au>
MFC after:	1 week
2002-03-09 22:08:14 +00:00
Mike Barcroft
064692095c Leave the `copyright' variable exposed, since the main purpose of it
is to put a copyright in the object file.

Submitted by:	bde
2002-03-07 10:06:00 +00:00
Mike Barcroft
51883012f6 Fix vendor ID (mostly obtained from Rev 1.1). 2002-03-05 05:17:30 +00:00
Mark Murray
16b07a33f9 WARNS=2 fixes, remove register keyword, use __FBSDID() 2001-12-11 22:36:26 +00:00
Dima Dorfman
8d904f1537 Add a -J replstr option that allows the user to tell xargs to insert
the data read from standard input at a specific point in the command
line arguments rather than at the end.

Submitted by:	dd, gad
Reviewed by:	gad, brian
2001-05-15 00:31:19 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Jean-Marc Zucconi
ef9866be68 xargs was spliting the input in a very different way from everyone else,
and was also a bit inconsistent: leading blanks, or any double blanks
generated empty arguments, but a trailing blank did not.

PR:		bin/2630, bin/10914
Submitted by:	Arne Henrik Juul <arnej@imf.unit.no>
1999-05-23 15:58:22 +00:00
Dag-Erling Smørgrav
1fd98d7d88 Calls one or more of malloc(), warn(), err(), syslog(), execlp() or
execvp() in the child branch of a vfork(). Changed to use fork()
instead.

Some of these (mv, find, apply, xargs) might benefit greatly from
being rewritten to use vfork() properly.

PR:		Loosely related to bin/8252
Approved by:	jkh and bde
1998-10-13 14:52:33 +00:00
Joseph Koshy
a3e5bc4fb5 Remove compile time dependency on ARG_MAX.
This fix only removes the dependency on compile time constants.  The code
has other (old) problems that need to be addressed.

PR: 1791
Reviewed-by: bde, tegge
1998-06-17 12:58:43 +00:00
Philippe Charnier
a51024e289 Use err(3) instead of local redefinition. 1997-08-27 06:26:23 +00:00
Warner Losh
1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Warner Losh
d919888163 Reviewed by: Warner Losh <imp@village.org>
Submitted by:	Marc Slemko <marcs@znep.com>
Obtained from:	OpenBSD

Add -0 for reading the results of find -0.
1996-11-01 18:46:05 +00:00
Satoshi Asami
e5009da0f9 Make xargs take into account the bytes occupied by the environment.
Original by: peter
1996-03-05 07:43:40 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00