Commit Graph

75 Commits

Author SHA1 Message Date
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Ulrich Spörlein
c9e1c304c1 Fix type mismatches for malloc(3) and Co.
This is rather pedantic, as for most architectures it holds that
sizeof(type *) == sizeof(type **)

Found by:	clang static analyzer
Reviewed by:	ed
Differential Revision: https://reviews.freebsd.org/D4722
2015-12-29 11:24:41 +00:00
Allan Jude
c782f6f05e fix regression in xargs -Px (introduced in r286289) and add regression tests
PR:		202152
Submitted by:	jbeich (original),  Nikolai Lifanov (final)
Reviewed by:	jbeich
Approved by:	bapt (mentor)
Differential Revision:	https://reviews.freebsd.org/D3330
2015-08-08 18:37:20 +00:00
Allan Jude
e896b4a4f0 xargs now takes -P0, creating as many concurrent processes as possible
PR:		199976
Submitted by:	Nikolai Lifanov <lifanov@mail.lifanov.com>
Reviewed by:	mjg, bjk
Approved by:	bapt (mentor)
MFC after:	1 month
Relnotes:	yes
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D2616
2015-08-04 14:27:25 +00:00
Baptiste Daroussin
cffa7aa609 Convert atoi(3) to stronum(3) which allows to arguments and report proper errors
to the users

Obtained from:	OpenBSD
2015-07-14 19:16:14 +00:00
Eitan Adler
a274be7720 Style(9) changes fo xargs.c 2013-05-10 03:49:05 +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
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
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
Dag-Erling Smørgrav
2d14e0e547 Add -r option for GNU compatibility.
MFC after:	2 weeks
2005-12-07 12:20:08 +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
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
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
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
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
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
51f7a48bf0 Err, duh, free(3) doesn't set its argument to NULL... Fix realloc of a freed
chunk.
2002-06-04 04:08:18 +00:00
Juli Mallett
6ea89183fc Restructure sanity checks so that -I and -J just override eachother, rather
than triggering a usage().  Allow -R and -I to be specified in any order, and
thus change how -R checks for -I not being given and triggering a usage().

Partially requested by:	gad
2002-05-30 19:34:31 +00:00
Juli Mallett
986d829b8f Allow the input line to be NULL, and teach strnsubst() that NULL means to use
a nil-string.
2002-05-30 19:24:08 +00:00
Juli Mallett
be70f7d4da Simplify prerun() in the case where there are no arguments. Can't do -I or -J
substitution if `utility' is not specified and we're using the buildin echo;
It has no arguments for us to abuse.
2002-05-17 07:55:24 +00:00
Ruslan Ermilov
8e0a87c1b3 xargs.c,v 1.33 broke the upgrade path from old versions of 4.x and 5.0. 2002-05-10 13:06:34 +00:00
Juli Mallett
b23de8a352 -I and -J both set the same variable, replstr, to the string to replace with
a line of input, and both work differently, so prevent them from both being
passed to xargs(1).
2002-05-06 03:38:28 +00:00
Juli Mallett
305e39f49b Modify the -p implementation to use a user's locale, so they can respond to
the prompt in their native language.

Also make the prompt fit what POSIX asks for (?...).

This should not affect use of -p with yes(1) [as every locale I know of matches
'y' as YESEXPR as well], but that's what -t is for anyway.  -p is meant to be
really used interactively.

Submitted by:	tjr, jmallett
2002-05-05 06:42:44 +00:00
Juli Mallett
5eb40323b0 Fix a typo.
Submitted by:	Carl Schmidt <cschmidt@slackerbsd.org>

Wrap an obscenely long line while I'm here.
2002-05-05 05:15:16 +00:00
Juli Mallett
9104507502 In an effort to make this utility easier to work with at a source level, move
out the parse loop to a seperate function, and move local variables around as
is needed.  To keep the state of some variables and keep from having huge arg
lists to functions, make a bunch global.

Change use of err(3) in situations where malloc(3) will be setting errno to
errx(3) since assuming malloc(3) sets errno is non-portable, and provides no
more useful information in the context of FreeBSD.

Submitted by:	bde (err/errx), Carl Schmidt <cschmidt@slackerbsd.org> (some
		of the movement of the input loop to a function)
Approved by:	src/tools/regression/usr.bin/xargs
2002-05-05 02:46:53 +00:00
Juli Mallett
9bf450b850 Grouping changes.
Submitted by:	Carl Schmidt <cschmidt@slackerbsd.org>
2002-05-04 06:00:19 +00:00
Juli Mallett
3dca1afc60 Don't use pointers as booleans. 2002-05-04 05:53:02 +00:00
Juli Mallett
b6594dba8b Replace calloc(3) with malloc(3), and set the tail of the
argument list to NULL, to terminate the arguments passed
to execvp(2).

Thanks to:	bde (for pointing out some missing parens)

And with apologies to Ozzy Osbourne:

	On his way to dinner
	It took him by surprise
	When an email from bde
	Said his code was full of lies

	Style (indentation)
	And his bracing were all wrong
	He casted to size_t
	When he should have cast to long

	I don't mind

	Single letter identifiers
	Unwrapped Line
	Over 80 chars
	Far over 80 chars

	Who can we get to send diffs
	We need Bruce D. Evans
	Shows you comparason to his
	We need Bruce D. Evans again
2002-05-04 00:08:06 +00:00
Juli Mallett
263dc775f2 Move substitution out to a function, prerun(), and replace use of run() with
it.  It handles everything (right now) that needs done before run(), except
the -J case, because while that would be easy, I don't quite understand -J.

Reviewed by:	src/tools/regression/usr.bin/xargs
2002-05-03 17:41:54 +00:00
Juli Mallett
b9b03ba0bc Get rid of bogus holder for realloc(3). 2002-05-03 17:13:29 +00:00