Commit Graph

106 Commits

Author SHA1 Message Date
Eitan Adler
a274be7720 Style(9) changes fo xargs.c 2013-05-10 03:49:05 +00:00
Xin LI
df4110b6cf Follow calloc convention in other code, this is functionally identical
to its previous form.
2013-01-05 00:23:58 +00:00
Jilles Tjoelker
7094589003 xargs: Before exiting, wait for all invocations of the utility.
This only has an effect with -P, otherwise errors are only detected when the
utility is not running.

Submitted by:	Matthew Story
2012-03-16 16:41:28 +00:00
Jilles Tjoelker
6e795141b2 xargs: Remove an unclear comment that only tried to repeat what the code did
Reported by:	bde
2012-02-26 23:06:30 +00:00
Jilles Tjoelker
c15adc89b3 xargs: Fix comma splice in error message.
Reported by:	bde
2012-02-26 17:39:46 +00:00
Jilles Tjoelker
23583c4fe1 xargs: If a utility exits with 255 or a signal, write an error message.
If a utility called by xargs exits with status 255 or because of a signal,
POSIX requires writing an error message.

PR:		165155
Submitted by:	Matthew Story matthewstory gmail com
2012-02-24 12:35:17 +00:00
Ruslan Ermilov
97b0bfc2e9 Discourage from using "cp -r". 2011-03-24 13:52:59 +00:00
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Stephen McKay
29afe03fd1 Various syntactic tweaks to satisfy style(9). No change to execution.
Submitted by:	gcooper@
2010-11-21 21:31:29 +00:00
Stephen McKay
92095ab601 xargs can be fooled by exiting children that it did not start, causing
it to kick off a new command before the previous has finished, resulting
in corrupted (interleaved) output.  It is also fooled by non-exiting
children it did not start, failing to exit until all extraneous children
have exited.

This patch makes xargs keep track of children it starts, ignoring
pre-existing ones.
2010-11-21 10:55:16 +00:00
Ed Schouten
b7946da96b Build usr.bin/ with WARNS=6 by default.
Also add some missing $FreeBSD$ to keep svn happy.
2010-01-02 10:27:05 +00:00
Giorgos Keramidas
86ca3fd005 Revive '-opt' flags which I accidentally removed.
Noticed by:	simon
2008-01-27 16:20:36 +00:00
Giorgos Keramidas
a502340a03 Document the no-op -r option of BSD xargs(1).
PR:		docs/106416
Submitted by:	Pete Slagle, freebsd-stable at voidcaptain.com
MFC after:	3 days
2008-01-26 12:38:19 +00:00
Ruslan Ermilov
cb29445a92 Markup fixes. 2006-09-29 15:20:48 +00:00
Juli Mallett
b65bc26736 NUL terminate buffer from fgetln(3). From fgsch@OpenBSD. 2006-01-01 22:59:54 +00:00
Juli Mallett
f22bf18027 Whitespace after switch.
Inspired by:	OpenBSD
2006-01-01 22:54:49 +00:00
Juli Mallett
4aeb63826e Check the entire length of the current argument for the EOF string with -E,
but don't expect a proper ASCII string to exist right here right now, don't
use strcmp(3) which checks for a NUL.  As we're still building the argument
up, the next character might be garbage.  It would probably be just as safe to
temporarily write a NUL there, but if we've reached the end of argument memory
that might not be the best idea, I think.  It's unclear.

Doing it this way seems to meet the most with the original intent.

PR:		85696
Prodded by:	stefanf
2005-12-31 09:06:45 +00:00
Juli Mallett
ba084f6a80 Add a FreeBSD-specific -S flag which controls the maximum size of an argument
having replacements done in it via -I.
2005-12-30 23:25:41 +00:00
Juli Mallett
38e62c6999 Handle maxsize==0 in such a way that we don't modify the string. 2005-12-30 23:22:50 +00:00
Dag-Erling Smørgrav
90c69417b6 Wording tweaks.
PR:		not quite docs/84620
MFC after:	2 weeks
2005-12-07 12:33:52 +00:00
Dag-Erling Smørgrav
2d14e0e547 Add -r option for GNU compatibility.
MFC after:	2 weeks
2005-12-07 12:20:08 +00:00
Ruslan Ermilov
f682f10c76 Sync program's usage() with manpage's SYNOPSIS. 2005-05-21 09:55:10 +00:00
Garance A Drosehn
46793db95b MFC 1.22: Fix -0 vs -L/-I processing, mainly so that 'xargs -0 -I []' will
do something sensible (namely: treat then '\0' as the EOL character, when
deciding what "a line" is for -N).  Note that  -I implies -N.

MFC after:	3 days
2005-02-27 01:35:54 +00:00
Ruslan Ermilov
a866e17077 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
Colin Percival
5578bd8c99 Modify behaviour of xargs -I in order to:
1. Conform to IEEE Std 1003.1-2004, which state that "Constructed
arguments cannot grow larger than 255 bytes", and
2. Avoid a buffer overflow.

Unfortunately the standard doesn't indicate how xargs is supposed to
handle arguments which (with the appropriate substitutions) would grow
larger than 255 bytes; this solution handles those by making as many
substitutions as possible without overflowing the buffer.

OpenBSD's xargs resolves this in a different direction, by making
all the substitutions and then silently truncating the resulting string.

Since this change may break existing scripts which rely upon the buffer
overflow (255 bytes isn't really all that long...) it will not be MFCed.
2004-10-18 15:40:47 +00:00
Tim J. Robbins
f8fb286a84 Document incorrect handling of multibyte characters with -I and -J options. 2004-08-02 03:07:42 +00:00
Tim J. Robbins
f58b94cba4 Call setlocale() with category LC_ALL instead of LC_MESSAGES. We need
LC_CTYPE and LC_COLLATE to correctly interpret regular expressions
returned by nl_langinfo(YESEXPR), and it doesn't hurt to include the
rest.
2004-07-12 04:18:44 +00:00
Dima Dorfman
5c3fd35c88 Fix spelling error in my own paragraph. 2004-06-28 11:18:47 +00:00
Maxime Henrion
0792992c73 - Use _PATH_TTY and _PATH_DEVNULL macros.
- Don't fail if we can't open /dev/null since this can happen if
  xargs is jail'ed or chroot'ed.

These fixes were submitted by Todd Miller from the OpenBSD project.
There was one problem in those fixes that broke -o, which is corrected
here and should be committed to the OpenBSD repo by Todd soon.

MFC in:	3 days
2003-06-13 17:05:41 +00:00
Juli Mallett
004bd28e40 Use waitpid, instead of wait3, which is more portable.
Submitted by:	"Todd C. Miller" <Todd.Miller@courtesan.com>
Obtained from:	OpenBSD
Reviewed by:	tjr
2003-06-13 07:37:45 +00:00
Juli Mallett
815e414e17 Remove redundant return; from void function.
Submitted by:	"Todd C. Miller" <Todd.Miller@courtesan.com>
Obtained from:	OpenBSD
2003-06-13 07:25:15 +00:00
Ruslan Ermilov
fa7f4291ff Markup bits.
Approved by:	re (blanket)
2003-05-21 21:07:28 +00:00
David E. O'Brien
8eb2a3de8f Don't shaddow exp(3). 2003-05-03 19:09:11 +00:00
Warner Losh
30aaff1192 Migrate to a new way of dealing with building from old revisions of
FreeBSD.  This method attempts to centralize all the necessary hacks
or work arounds in one of two places in the tree (src/Makefile.inc1
and src/tools/build).  We build a small compatibility library
(libbuild.a) as well as selectively installing necessary include
files.  We then include this directory when building host binaries.

This removes all the past release compatibilty hacks from various
places in the tree.  We still build on tip of stable and current.  I
will work with those that want to support more, although I anticipate
it will just work.

Many thanks to ru@, obrien@ and jhb@ for providing valuable input at
various stage of implementation, as well as for working together to
positively effect a change for the better.
2003-04-05 20:30:30 +00:00
Warner Losh
76d94537fe Simplify compatibility ifdef. 2003-04-04 04:39:29 +00:00
Maxime Henrion
4351e43f7e xargs(1) is WARNS=6 clean.
Tested on:	i386, sparc64
2003-03-28 16:24:11 +00:00
Maxime Henrion
cec1ba8c9c When -o isn't specified, open /dev/null as stdin.
Suggested by:	jhb
2003-03-28 16:22:54 +00:00
Maxime Henrion
98186e89da Add a new -o option to tell xargs(1) to reopen /dev/tty as stdin in
the child process, before executing the command.  This is very useful
when you do stuff like ``find ... | xargs interactive_application''.
Without -o, the application would inherit the pipe as its stdin, and
you thus lose any control over it.

This flag has been carefully chosen to not conflit with other options
of other xargs utilities like GNU xargs.

Reviewed by:	jmallett
2003-03-23 18:29:52 +00:00
Juli Mallett
3c67516766 Extend our -R extension which sets the number of arguments in which -I will
replace to support magic values less than zero, which mean to just go nuts
and expand as many as we want.

MFC after:	2 weeks
2003-02-26 22:44:32 +00:00
Juli Mallett
08f16c7ae4 De-typo usage string. 2003-02-26 22:36:55 +00:00
Tom Rhodes
4bb2c6860a A few changes for clarity.
PR:		47170
Submitted by:	Gary W. Swearingen <swear@attbi.com> (original version)
2003-01-27 18:16:36 +00:00
Jens Schweikhardt
57bd0fc6e8 english(4) police. 2002-12-27 12:15:40 +00:00
Ruslan Ermilov
5a9a189b52 mdoc(7) police: most -mdoc macros can take multiple arguments. 2002-12-23 15:15:35 +00:00
Tim J. Robbins
330d23f50e Add the -P option which executes multiple copies of the specified utility
in parallel. Idea from GNU xargs.
2002-12-21 10:17:13 +00:00
Ruslan Ermilov
40c6b893d8 Take __FreeBSD_version into account when BOOTSTRAPPING. 2002-11-13 13:49:29 +00:00
Jens Schweikhardt
2b239dd118 Fix typos; each file has at least one s/seperat/separat/
(I skipped those in contrib/, gnu/ and crypto/)
While I was at it, fixed a lot more found by ispell that I
could identify with certainty to be errors. All of these
were in comments or text, not in actual code.

Suggested by:	bde
MFC after:	3 days
2002-08-11 13:05:30 +00:00
Tim J. Robbins
99a84ce108 Declare environ as char **environ like in environ(7), not char *environ[].
This corrects a problem whereby xargs could not walk the environment table
to count the amount of space it used, and treated it as if it were empty.
This problem was introduced in rev 1.15.

MFC after:	2 days
2002-07-01 03:21:05 +00:00
Juli Mallett
1926d4aaad Stylistic nit:
main()'s argv argument is char*[], and functions that may inherit that arg
should use char*[] as well.
2002-06-22 12:59:40 +00:00
Juli Mallett
5058dcb497 Check for results of repeated calls to strnsubst(), as well as for the
behaviour with NULL match string, as that has changed over time.
2002-06-22 12:58:42 +00:00
Juli Mallett
893305fe5e When giving an example that relies on shell expansion/globbing, don't use a
replstr for -J that will be interpereted by the shell.

MFC after:	1 day
2002-06-22 12:47:56 +00:00