Commit Graph

1433 Commits

Author SHA1 Message Date
Silvan Jegen
38f429a3d2 Add the tr program including man page 2014-01-20 11:22:28 +00:00
sin
cb005c150d Fix naming covention for uniq(1) 2014-01-20 10:49:28 +00:00
sin
13128a7aa0 Remove dead debug code 2014-01-18 11:50:51 +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
b744ad5216 If there's no newline we don't count the last word - fix it 2014-01-10 22:52:00 +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
7a5369ae04 Update xargs(1) manpage to mention the possible exit codes 2014-01-07 12:03:37 +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
9a1c5783c1 Remove mktemp(1) from TODO
We already have mktemp(1) implemented.
2014-01-04 13:41:47 +00:00
sin
18f9f3e141 Remove xargs(1) from TODO
We already have a barebones version.
2014-01-04 13:40:42 +00:00
sin
4bdf9a9658 Add initial version of xargs(1) 2014-01-04 00:04:05 +00:00
sin
71cbd12ede Revert "Fix relocation error on OpenBSD (amd64) when compiling with pcc"
This reverts commit 06d43e4832.

Let's stick to the most basic and common options for the default
case.
2013-12-21 13:39:29 +00:00
sin
1851c02a95 Show usage instead of exiting silently on an invalid option 2013-12-12 13:30:25 +00:00
sin
aff51008ea Add -R as a synonym to -r for cp(1)
List the available options in the usage line as well.
2013-12-12 13:30:17 +00:00
sin
7f6d5653c6 Add -R as a synonym to -r for rm(1)
Some scripts require this.
2013-12-12 13:15:47 +00:00
sin
544857623b Add -n support to sort(1) 2013-12-12 13:10:59 +00:00
sin
0b6b84886c Add newline at end of file 2013-12-04 17:42:33 +00:00
sin
5534e60703 Implement -G support for id(1) 2013-12-01 17:29:53 +00:00
Rob Pilling
d453be2ae1 id(1) can handle uid arguments 2013-12-01 14:29:16 +00:00
Rob Pilling
fd8c3b6438 curproc() isn't needed in id(1) 2013-12-01 14:29:01 +00:00
sin
dac77d3089 Add support to display user and group info for any user
Currently we only handle login names - it should be trivial to
fix to allow for parsing UIDs as well.
2013-12-01 10:43:56 +00:00
sin
137ebef3ac Factor out code printing information for the current process 2013-12-01 10:43:29 +00:00
sin
f1f0fba630 Forgot to remove argc from function decl
Thanks FRIGN for noticing this.
2013-11-30 21:12:40 +00:00
sin
38ca9a24c2 Be a bit more consistent and use uint8_t instead of unsigned char 2013-11-30 20:59:09 +00:00
sin
abd5a0e573 We do not name parameters in declarations 2013-11-30 20:58:49 +00:00
sin
7808f4161d Implement -m for mkfifo(1) 2013-11-30 20:58:15 +00:00
sin
651dbdd700 Rename __ARG_H__ to ARG_H__
__* is reserved so do not use it.
2013-11-25 21:29:20 +00:00
sin
7a2105f5bd Forgot to update manpage for mktemp(1) 2013-11-14 19:50:07 +00:00
sin
91a643411d Check for TMPDIR and if set use it 2013-11-14 19:47:22 +00:00
sin
a7b8eee6c0 Add dsp@2f30.org to LICENSE 2013-11-14 19:01:08 +00:00
sin
ee8084cec0 Fix indentation 2013-11-14 19:00:52 +00:00
sin
078fce3f77 Always print the program name
This is generally very useful for sbase, especially when we
hit some case that is not implemented and we want to know which
program failed.
2013-11-14 19:00:28 +00:00
sin
3b3dffd24f _brk, _argc and _argv are reserved for the implementation
Thanks to nsz@port70.net for reporting this, the mail excerpt below.

"actually __.* and _[A-Z].* are reserved for any usage and _.* is
reserved for file scope identifiers"

We just rename them to brk_, argc_ and argv_.
2013-11-14 10:44:56 +00:00