Commit Graph

30 Commits

Author SHA1 Message Date
FRIGN 31572c8b0e Clean up #includes 2015-02-14 21:12:23 +01:00
FRIGN 1436518f9d Use < 0 instead of == -1 2014-11-19 20:09:29 +00:00
FRIGN e17b9cdd0a Convert codebase to use emalloc.c utility-functions
This also definitely increases readability and makes OOM-conditions
more consistent.
2014-11-16 10:22:39 +00:00
FRIGN eee98ed3a4 Fix coding style
It was about damn time. Consistency is very important in such a
big codebase.
2014-11-13 18:08:43 +00:00
Hiltjo Posthuma 5b3a0a9382 build warnings: initialise values...
... to make fix gcc warnings with -Wall.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-05-12 12:06:14 +01:00
sin 16cf92119f Fix missing '-' in usage 2014-04-09 18:20:50 +01:00
Hiltjo Posthuma 1be58188ad xargs: implement -n
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-04-09 17:11:49 +01:00
sin 94e97f19cd No need to use enprintf() with EXIT_FAILURE
eprintf() does just that.
2014-01-30 14:55:26 +00:00
sin 7028920ff4 Rename `saved_errno' to `savederrno' 2014-01-27 15:18:42 +00:00
sin 7969fcd2c2 No need to dynamically allocate *cmd[] 2014-01-16 11:53:13 +00:00
sin 1bc2296bac Double NARGS
I just ran a simple one-liner[1] to find the average filepath
length on my system (absolute paths) and that came up with a value
~90 characters.  Assume this is out by a factor of two, we still
have potentially 5000 more arguments that we can put into the buffer.

Surely one might run xargs(1) on something that is not a filename.
We just choose to accomodate the common use-case as much as possible.

[1] find / 2>/dev/null | awk '{print length($0)}' \
	| awk '{a+=$1}END{print "average filepath length: ",a/NR}'
2014-01-16 11:01:10 +00:00
sin fbd786d22a Correctly handle leftover input
We cannot rely on ungetc() pushing back more than 1 character
reliably on all systems, so just note if we have leftover input and
process it in the next run.
2014-01-08 20:49:52 +00:00
sin 1963a7cfb3 Group related declaration 2014-01-08 20:49:39 +00:00
sin 602fd49b53 Allocate the arg buffer in once place 2014-01-08 20:35:25 +00:00
sin 2d64fa9483 Rename runcmd() to spawn() 2014-01-08 20:35:19 +00:00
sin 574e3d48ed No need to check for a positive `argbpos'
No need to deinput a separator.
2014-01-08 20:35:12 +00:00
sin cec487585c Rename pusharg() to deinputstr() 2014-01-08 20:35:05 +00:00
sin e96144118e Error out if a single argument cannot fit into the argument space 2014-01-08 20:34:56 +00:00
sin e585133012 Rename fillbuf() to fillargbuf() 2014-01-07 14:58:02 +00:00
sin 20c0a0b1e7 Factor out waiting for children into a separate function 2014-01-07 14:52:29 +00:00
sin e27c55aec3 Implement -E eofstr for xargs(1) 2014-01-07 12:03:50 +00:00
sin 59222b9193 Exit with error code 123 if one or more invocations of cmd failed 2014-01-06 18:53:30 +00:00
sin 3aec0ac2a4 Use a return value to signal an invalid backslash
Just for consistency with the rest of the code.
2014-01-06 18:22:00 +00:00
sin bb4d7a0e7e Don't allow backslash at EOF 2014-01-06 18:17:44 +00:00
sin 0511ecfd84 If eatspace() encounters EOF don't try to read again from stdin 2014-01-06 18:13:27 +00:00
sin ef57a609ca Exit with error 125 if the process is killed by a signal 2014-01-06 18:05:52 +00:00
sin 2dc105ebbc Use saved errno in case weprintf() fails internally 2014-01-04 14:07:34 +00:00
sin 567869a8fe Check the exit status and return it from the parent process 2014-01-04 14:02:40 +00:00
sin 7ec616e1e5 Exit with proper error codes
We still have a few error codes to do, namely when the process
is killed or stopped by a signal or when one or more invocations
of the command returned a nonzero exit status.
2014-01-04 13:53:59 +00:00
sin 4bdf9a9658 Add initial version of xargs(1) 2014-01-04 00:04:05 +00:00