Commit Graph

61 Commits

Author SHA1 Message Date
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
Juli Mallett
6fc8ba94c6 Note that this appeared at least as early as PWB UNIX.
Use the literal string 'PWB UNIX', as we still have no .At macro for it.
2002-06-10 22:59:59 +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
Ruslan Ermilov
809a3054f6 mdoc(7) police: punctuation, miscellaneous. 2002-05-30 06:50:52 +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
Juli Mallett
5706d2e811 Fix a "tiny and squeeby and little" markup mistake.
Submitted by:	fenner
2002-05-14 22:55:31 +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
38dff9a439 Fix a bug whereby we were getting ~0 and comparing it to maxsize, i.e. if
s1 was 0 length, and replstr was 0 length, etc., we would end up subtracting
one from zero and seeing if it was greater than the size_t (unsigned) var
maxsize...  This would cause us to return a string consisting of essentially
only match, which is not the right behaviour if we have 0 length inpline.
2002-05-03 19:45:41 +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
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
943e841433 A markup fix, and document -R as non-standard. 2002-05-02 03:29:38 +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
299ea75ab7 *str is spelled 's1' inside the body of the code.
Make 'this' not a local variable, since it isn't necessary or complex enough
to warrant such.
2002-05-02 02:15:06 +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
5e61dfa3ca Bump WARNS to 4. 2002-04-19 23:46:45 +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
ffb9c240d7 Spelling police: extention -> extension. 2001-07-05 08:51:08 +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
Dima Dorfman
a9bc34c882 Alphabetize command-line options in the synopsis. 2001-05-02 06:41:46 +00:00
Ruslan Ermilov
471b9c332c mdoc(7) police: Fixed typo and markup in rev.1.11. 2001-04-13 09:15:16 +00:00
Brian Somers
c42584e853 o The -s limit is ARG_MAX - 4K, not ARG_MAX - 2K.
o Mention that the current environment is part of the -s calculation.
o Add a BUGS section that warns against executing a program that increases
  the size of the argument list or the size of the environment.

  I have wondered for a while what the difference is between

    get a big list | xargs sudo command

  which fails and

    get a big list | sudo xargs command

  which succeeds.  The answer is that in the first case, sudo expands
  the environment and pushes the amount of data passed into execve over
  the E2BIG threshold.
2001-04-10 23:16:55 +00:00
Ruslan Ermilov
f4ddfb3865 Prepare for mdoc(7)NG. 2000-12-27 16:52:31 +00:00
Ruslan Ermilov
9b88faecd3 Prepare for mdoc(7)NG. 2000-12-19 16:00:12 +00:00
Ruslan Ermilov
8fe908ef0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
Philippe Charnier
5e8eb81aac Use .Xr 2000-03-26 15:05:40 +00:00