Commit Graph

1897 Commits

Author SHA1 Message Date
sin
3de142ba70 Delete dist when cleaning 2014-11-14 14:41:05 +00:00
sin
300eedc50a Add README and TODO to dist target 2014-11-14 11:58:42 +00:00
FRIGN
7fc5856e64 Tweak NULL-pointer checks
Use !p and p when comparing pointers as opposed to explicit
checks against NULL.  This is generally easier to read.
2014-11-14 10:54:30 +00:00
FRIGN
ec8246bbc6 Un-boolify sbase
It actually makes the binaries smaller, the code easier to read
(gems like "val == true", "val == false" are gone) and actually
predictable in the sense of that we actually know what we're
working with (one bitwise operator was quite adventurous and
should now be fixed).

This is also more consistent with the other suckless projects
around which don't use boolean types.
2014-11-14 10:54:20 +00:00
FRIGN
7d2683ddf2 Sort includes and more cleanup and fixes in util/ 2014-11-14 10:54:10 +00:00
Evan Gates
0810c61154 add -D_DEFAULT_SOURCE to placate gcc 2014-11-14 10:37:52 +00:00
sin
ee55fbe9e9 Just make $(HDR) a prereq for $(OBJ)
The result is always correct but it might do redundant builds.
Not really an issue as sbase builds very fast.  The alternative is
to track the header deps manually but this is already incomplete and
unlikely to be kept up to date.
2014-11-13 18:28:18 +00:00
sin
2c7516c716 Sort HDR in Makefile 2014-11-13 18:21:19 +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
sin
e35d9e62a5 Just use HOST_NAME_MAX in hostname(1)
Using sysconf() + malloc() is overkill.
2014-11-13 17:22:02 +00:00
sin
44b3ea8f76 Use _exit() instead of return if exec* fails 2014-11-13 17:06:41 +00:00
sin
2869adf458 Update TODO 2014-11-13 16:33:47 +00:00
sin
519a4f8105 Don't overwrite the line buffer when we hit EOF on one of the files in comm(1) 2014-11-13 16:01:53 +00:00
sin
d208659414 Add "-" support to comm(1) 2014-11-13 16:01:44 +00:00
sin
49c91462b3 Undef MIN/MAX in case they are defined somewhere else 2014-11-13 16:01:34 +00:00
sin
7ffe164106 Modify argv[0] in place 2014-11-13 16:01:22 +00:00
sin
6449db8691 Make both arguments to cmp(1) mandatory and handle "-" properly 2014-11-13 16:01:10 +00:00
sin
dfd0e6e77d Add a conformance table in the README
We should investigate the current state of the tools one by one
and mark out those that are complete and POSIX conformant.
2014-11-13 14:59:41 +00:00
sin
9f6dd58538 Remove unneeded statement 2014-11-13 14:56:43 +00:00
sin
f9a7a7e59f Fix argument naming in dirname(1) 2014-11-13 14:56:34 +00:00
sin
a7ad11ed5e Fix overflow in basename(1) 2014-11-13 14:56:25 +00:00
sin
c59894bd5c Implement cat -u and report correct exit condition 2014-11-13 14:56:15 +00:00
sin
5773a8f22b Implement concat() using read(2) and write(2)
This forces the data to be read as soon as they are available
and a simple cat(1) when stdin is referring to a tty works as
expected.
2014-11-13 14:56:06 +00:00
sin
a8c31586c5 Revert "config.mk: make cc the default $CC"
This reverts commit d2b527e369685606f812233a24dab12188d8930c.
2014-11-11 18:17:26 +00:00
sin
63f9f1ac14 Add special signal to the sigs table instead 2014-11-11 17:43:10 +00:00
sin
3ffe690384 Handle the special-case signal 0 and "0" properly 2014-11-11 17:40:26 +00:00
sin
f06ada4592 Simplify logic in kill(1) 2014-11-11 17:31:42 +00:00
sin
e4e47a617e Handle "--" for -l and -s as well in kill(1) 2014-11-11 17:13:10 +00:00
sin
c0f540162f Die early if signal is invalid in -signum 2014-11-11 16:34:33 +00:00
sin
0967d2e278 Factor out check for WTERMSIG 2014-11-11 16:34:28 +00:00
sin
e0b0741ba1 Add name2sig() and simplify kill(1) 2014-11-11 16:29:01 +00:00
sin
88f26b222b Actually print usage if kill -l is invoked with more than 1 arg 2014-11-11 16:09:24 +00:00
sin
a81544a810 kill -l accepts at most 1 arg 2014-11-11 16:08:30 +00:00
sin
aee8535a71 Fix outdated comments 2014-11-11 15:55:31 +00:00
sin
23d1dc6a55 Update manpage and usage for kill(1) 2014-11-11 15:53:26 +00:00
sin
61046dd39b Remove redundant check in kill(1) 2014-11-11 15:40:58 +00:00
sin
a0e9050925 Implement XSI extensions -signal_name and -signal_number for kill(1) 2014-11-11 15:37:26 +00:00
sin
237673302d Make kill(1) POSIX conformant
* XSI extensions support is missing, -signal_name and -signal_number.
2014-11-11 15:08:58 +00:00
sin
0444d16475 Fix kill -l 2014-11-10 23:56:10 +00:00
Hiltjo Posthuma
603d86f276 config.mk: make cc the default $CC 2014-11-10 23:56:10 +00:00
Hiltjo Posthuma
6d410168b8 style fix: fix indentation (double) 2014-11-10 23:56:10 +00:00
Evan Gates
5cf965ffbf return exit status of command in sbase-box 2014-11-08 13:50:55 +00:00
sin
9750071b97 Fix stupid GCC warning
tar.c:239:9: warning: missing braces around initializer [-Wmissing-braces]

I believe this is an unresolved bug in GCC.
2014-11-03 10:21:05 +00:00
sin
b03b2b1d5d Add Michael Forney to LICENSE 2014-11-03 10:17:41 +00:00
Michael Forney
62850af594 chown: Support numeric uids/gids 2014-11-03 10:15:40 +00:00
Michael Forney
6164445cce Fix symbolic mode parsing in parsemode
I found quite a lot of bugs, so I ended up pretty much rewriting as I
followed the spec¹.

Now, it works as follows:

- Determine a mask (who) of bits that can be modified for the subsequent
  operations. If none are specified, select all file mode bits.
- In a loop, determine which operation (+, -, =) to apply.
- If the next character is a permcopy (u, g, o), set the new permissions
  (perm) corresponding to the bits set in the user, group or other parts
  of the existing mode.
- Otherwise, set the new permissions by looping through the next r, w,
  x, s, t characters.
- Now, the set of bits we want to add or remove is (who & perm). Set or
  remove these bits according the the operation (first clearing the
  appropriate bits if the operation is =).
- Continue from the top if the next character is a comma, otherwise,
  process the next operation.

I tested this on some made up inputs, and I believe it is working
correctly now:

  parsemode("g+w", 0644, 0),    before: 0606, now: 0664, fixed
  parsemode("u+rx", 0222, 0),   before: 0077, now: 0722, fixed
  parsemode("+x", 0644, 023),   before: 0754, now: 0754, still works
  parsemode("+w", 0444, 022),   before: 0644, now: 0644, still works
  parsemode("+w", 0444, 0),     before: 0666, now: 0666, still works
  parsemode("+s", 0755, 0),     before: 0755, now: 6755, fixed
  parsemode("u+s", 0755, 0),    before: 0055, now: 4755, fixed
  parsemode("g+s", 0755, 0),    before: 0705, now: 2755, fixed
  parsemode("g=u", 0700, 0),    before: 0000, now: 0770, fixed
  parsemode("go=u-w", 0700, 0), before: 0000, now: 0755, fixed
  parsemode("o+u-g", 0641, 0),  before: 0000, now: 0643, fixed
  parsemode("u=rx,o+w,g-r", 0654, 0) before: error, now: 0516, fixed
  parsemode(",", 0654, 0), before: error, now: error, still works

¹ http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html
2014-11-03 10:15:29 +00:00
Michael Forney
6327290cf2 grep: Fix -c flag 2014-11-02 09:46:52 +00:00
Michael Forney
1ca8a314f8 grep: Remove newlines before matching a line
Otherwise, a pattern with a '$' anchor will never match and POSIX says that

  "By default, an input line shall be selected if any pattern ... matches any
   part of the line excluding the terminating <newline>"
2014-11-02 09:46:46 +00:00
Michael Forney
7ed4866556 tar: Implement -m flag
This changes the default behavior to adjust mtimes to what is present in
the file header.
2014-11-01 22:34:29 +00:00
Michael Forney
e1f87da43e tar: Handle archives with the prefix field
Also, handle names and prefixes that fill the entire field (and have no
NUL byte) by using a precision specifier.
2014-11-01 22:34:19 +00:00