summaryrefslogtreecommitdiffstats
path: root/usr.bin/xargs/xargs.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC 1.22: Fix -0 vs -L/-I processing, mainly so that 'xargs -0 -I []' willgad2005-02-271-2/+9
| | | | | | | 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
* Call setlocale() with category LC_ALL instead of LC_MESSAGES. We needtjr2004-07-121-1/+1
| | | | | | LC_CTYPE and LC_COLLATE to correctly interpret regular expressions returned by nl_langinfo(YESEXPR), and it doesn't hurt to include the rest.
* - Use _PATH_TTY and _PATH_DEVNULL macros.mux2003-06-131-5/+9
| | | | | | | | | | | - 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
* Use waitpid, instead of wait3, which is more portable.jmallett2003-06-131-2/+2
| | | | | | Submitted by: "Todd C. Miller" <Todd.Miller@courtesan.com> Obtained from: OpenBSD Reviewed by: tjr
* Remove redundant return; from void function.jmallett2003-06-131-1/+0
| | | | | Submitted by: "Todd C. Miller" <Todd.Miller@courtesan.com> Obtained from: OpenBSD
* Don't shaddow exp(3).obrien2003-05-031-6/+5
|
* Migrate to a new way of dealing with building from old revisions ofimp2003-04-051-14/+1
| | | | | | | | | | | | | | | | | 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.
* Simplify compatibility ifdef.imp2003-04-041-4/+7
|
* When -o isn't specified, open /dev/null as stdin.mux2003-03-281-2/+5
| | | | Suggested by: jhb
* Add a new -o option to tell xargs(1) to reopen /dev/tty as stdin inmux2003-03-231-3/+12
| | | | | | | | | | | | 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
* Extend our -R extension which sets the number of arguments in which -I willjmallett2003-02-261-3/+6
| | | | | | | 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
* De-typo usage string.jmallett2003-02-261-1/+1
|
* Add the -P option which executes multiple copies of the specified utilitytjr2002-12-211-18/+48
| | | | in parallel. Idea from GNU xargs.
* Take __FreeBSD_version into account when BOOTSTRAPPING.ru2002-11-131-5/+7
|
* Fix typos; each file has at least one s/seperat/separat/schweikh2002-08-111-2/+2
| | | | | | | | | | (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
* Declare environ as char **environ like in environ(7), not char *environ[].tjr2002-07-011-1/+1
| | | | | | | | 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
* Stylistic nit:jmallett2002-06-221-5/+5
| | | | | main()'s argv argument is char*[], and functions that may inherit that arg should use char*[] as well.
* Err, duh, free(3) doesn't set its argument to NULL... Fix realloc of a freedjmallett2002-06-041-1/+3
| | | | chunk.
* Restructure sanity checks so that -I and -J just override eachother, ratherjmallett2002-05-301-5/+6
| | | | | | | 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
* Allow the input line to be NULL, and teach strnsubst() that NULL means to usejmallett2002-05-301-3/+3
| | | | a nil-string.
* Simplify prerun() in the case where there are no arguments. Can't do -I or -Jjmallett2002-05-171-1/+1
| | | | | substitution if `utility' is not specified and we're using the buildin echo; It has no arguments for us to abuse.
* xargs.c,v 1.33 broke the upgrade path from old versions of 4.x and 5.0.ru2002-05-101-1/+9
|
* -I and -J both set the same variable, replstr, to the string to replace withjmallett2002-05-061-0/+2
| | | | | a line of input, and both work differently, so prevent them from both being passed to xargs(1).
* Modify the -p implementation to use a user's locale, so they can respond tojmallett2002-05-051-12/+60
| | | | | | | | | | | | 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
* Fix a typo.jmallett2002-05-051-2/+3
| | | | | | Submitted by: Carl Schmidt <cschmidt@slackerbsd.org> Wrap an obscenely long line while I'm here.
* In an effort to make this utility easier to work with at a source level, movejmallett2002-05-051-141/+154
| | | | | | | | | | | | | | 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
* Grouping changes.jmallett2002-05-041-2/+2
| | | | Submitted by: Carl Schmidt <cschmidt@slackerbsd.org>
* Don't use pointers as booleans.jmallett2002-05-041-3/+3
|
* Replace calloc(3) with malloc(3), and set the tail of thejmallett2002-05-041-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Move substitution out to a function, prerun(), and replace use of run() withjmallett2002-05-031-85/+78
| | | | | | | 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
* Get rid of bogus holder for realloc(3).jmallett2002-05-031-6/+5
|
* Rewrite the loop that handles substitution in the -I case, and try to makejmallett2002-05-031-15/+75
| | | | | | | | | 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/
* Rename `lflag' to `Lflag' to match the option's case.jmallett2002-05-031-6/+6
|
* Revert revision 1.22. I incorrectly modified the Berkeley identifiers.jmallett2002-05-031-3/+12
| | | | Requested by: bde, mike
* __COPYRIGHT() and __SCCSID().jmallett2002-05-021-12/+3
|
* An explicit cast to size_t for an inline integer, since the two are not thejmallett2002-05-021-2/+2
| | | | | | | 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.
* Make -J a proper flag internal to the code (rather than just check forjmallett2002-05-021-8/+17
| | | | | | | | 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.
* Rework some of the -I support so I can't find a way to make xargs(1) core orjmallett2002-05-021-15/+9
| | | | | | | | 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.
* In the case where we can't open /dev/tty, fall back to -t behaviour.jmallett2002-04-191-9/+7
| | | | Submitted by: fenner
* Compound two fprintf(3)s into 1 using string concatenation.jmallett2002-04-191-2/+1
|
* After 3 months...jmallett2002-04-191-39/+134
| | | | | | | | | | | | | | | | | 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
* ANSIfy: Function declarations and prototypes, use of environ(7).jmallett2002-03-151-9/+8
| | | | | Reviewed by: mike Approved by: mike
* Change back to using vfork() now that execvp() is vfork()-safe. If execvp()des2002-03-091-7/+10
| | | | | | | | 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
* Leave the `copyright' variable exposed, since the main purpose of itmike2002-03-071-2/+2
| | | | | | is to put a copyright in the object file. Submitted by: bde
* Fix vendor ID (mostly obtained from Rev 1.1).mike2002-03-051-7/+8
|
* WARNS=2 fixes, remove register keyword, use __FBSDID()markm2001-12-111-10/+14
|
* Add a -J replstr option that allows the user to tell xargs to insertdd2001-05-151-5/+29
| | | | | | | | 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
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* xargs was spliting the input in a very different way from everyone else,jmz1999-05-231-20/+15
| | | | | | | | 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>
* Calls one or more of malloc(), warn(), err(), syslog(), execlp() ordes1998-10-131-3/+3
| | | | | | | | | | | 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
OpenPOWER on IntegriCloud