Commit Graph

259 Commits

Author SHA1 Message Date
Michael Forney 3d8481f01d README: Add dd(1) to tool list 2021-06-17 19:09:25 -07:00
Michael Forney e5d8efb32f Import mknod from ubase
Although mknod is not a POSIX tool, it is widely available on nearly
all UNIX-like systems. It also can be implemented portably apart
from use of the makedev macros, which is already a requirement of
a couple other tools in sbase.

While we're at it, fix a few bugs:
- Include sys/sysmacros.h if makedev was not defined by sys/types.h
- The default mode should respect the user's umask, rather than
  assuming it is 022.
- Clear the umask when -m is specified explicitly so that nodes can
  be created with permissions wider than the user's umask.
- Utilize parsemode from libutil to support symbolic mode strings.
2020-03-01 16:33:11 -08:00
Michael Forney a0fae71977 Don't justify text in README 2019-06-30 13:17:17 -07:00
Michael Forney adcdc1b308 Move utility status to its own section at the end of README
This way the important information can be found easily at the top.
2019-06-30 13:13:07 -07:00
Mattias Andrée 28129a87c4 Add rev(1)
Signed-off-by: Mattias Andrée <>
2016-12-27 11:35:27 +01:00
FRIGN 7fd88bdc6f xargs(1) already supports NUL characters 2016-03-10 08:48:09 +00:00
FRIGN e537186ba4 Support NUL containing lines in uniq(1) 2016-03-10 08:48:09 +00:00
FRIGN b58884312c Support NUL containing lines in nl(1) and reuse the line-buffer(!) 2016-03-10 08:48:09 +00:00
FRIGN c25996924b Support NUL containing lines in join(1)
while also simplyfing the line-field-parser.
2016-03-10 08:48:09 +00:00
FRIGN d7741c7725 Support NUL containing lines in fold(1) and reuse the line-buffer(!) 2016-03-10 08:48:09 +00:00
FRIGN dc5190eab1 logger(1) is NUL compliant
because we can't call the syslog-syscall without becoming unportable.
The syslog() libc-function does not accept a length though, so we're
fucked. Anyway, let's carry on.
2016-03-10 08:48:09 +00:00
FRIGN 00b579566a Use the UTF8_POINT macro in cols(1)
No need for libutf any more
2016-03-10 08:48:09 +00:00
FRIGN cc3aefa488 Support NUL containing lines in cut(1) 2016-03-10 08:48:09 +00:00
FRIGN 698a14b1da Indent README headings properly 2016-03-10 08:48:09 +00:00
FRIGN 45b42516d4 Support NUL containing lines in head(1)
Very trivial this time.
2016-03-10 08:48:09 +00:00
FRIGN 886fca3fd6 Support NUL containing lines in tail(1)
This was rather simple this time.
2016-03-10 08:48:09 +00:00
FRIGN eebba22577 Support NUL containing lines in comm(1) 2016-03-10 08:48:09 +00:00
FRIGN 691c54750f Don't mark cols(1) as NUL-compliant as of yet
Thing is, we don't yet have an updated utflen() ready for use. Although
prints the lines completely, it does not add a proper spacing between
each entry. This will be fixed later.
2016-03-10 08:48:09 +00:00
FRIGN eb9bda8787 Support NUL-containing lines in sort(1)
For sort(1) we need memmem(), which I imported from OpenBSD.
Inside sort(1), the changes involved working with the explicit lengths
given by getlines() earlier and rewriting some of the functions.

Now we can handle NUL-characters in the input just fine.
2016-03-10 08:48:09 +00:00
FRIGN e4810f1cdb Support NUL-containing lines in cols(1)
This required an architectural change in getlines() by also storing
the line length.
2016-03-10 08:48:09 +00:00
FRIGN b83916ca27 Add symbol to mark NUL handling in each tool (and where it is missing)
The assumption of NUL-terminated strings is actually quite a good one in
most cases. You don't have to worry about paths, because they may not
contain NUL.
Same applies to arguments passed to you. Unless you have to unescape,
there is no way for you to receive a NUL.

There are two important exceptions though, and it's important that we
address them, or else we get unexpected behaviour:

	1) All tools using unescape() have to be strict about delimlen.
	   Else they end up for instance unescaping
	   which in C's string-vision is an empty string.

	2) All tools doing line wrenching and putting them out
	   again as lines again.
	   puts() will cut each line containing NULs off at the first
2016-02-26 09:54:46 +00:00
Mattias Andrée a392cd475e add sha512-224sum (SHA512/224) and sha512-256sum (SHA512/256)
Signed-off-by: Mattias Andrée <>
2016-02-24 10:40:57 +00:00
Mattias Andrée ae1da536bb add sha224sum and sha384sum
Signed-off-by: Mattias Andrée <>
2016-02-24 10:15:16 +00:00
sin 65159194fb Mark sort(1) as POSIX compliant 2016-02-17 08:39:11 +00:00
Mattias Andrée b44d4d8edd Add tsort(1)
Signed-off-by: Mattias Andrée <>
2016-02-17 08:24:53 +00:00
Mattias Andrée db952ed18c New command with corresponding man page. Includes the flags:
-s strip binary
-d create directory
-D create missing directories
-t DIR target directory
-m MODE permission bits
-o USER set owner
-g GROUP set group

Installed files are copied, and default mode is 755.

Signed-off-by: Mattias Andrée <>
2016-02-15 09:41:58 +00:00
Mattias Andrée b445614f70 Add pathchk(1)
New command, including man page.
UTF-8 compatible and should be POSIX-compliant.

Signed-off-by: Mattias Andrée <>
2016-02-11 10:01:58 +00:00
Roberto E. Vargas Caballero 1de650edf5 Add ed(1) - the standard text editor 2015-12-14 12:14:52 +00:00
FRIGN 09c279285a Add whoami(1)
including manpage and other stuff. This program is a no-brainer.
This was inspired by an initial commit by Thanks!
2015-12-14 10:14:07 +00:00
sin 75b848bb09 Mark grep and tftp as audited
Gone through the code quite a few times.  Been using them frequently
without problems.
2015-11-06 10:52:49 +00:00
FRIGN a2536328aa Mark getconf as audited in README 2015-10-26 11:55:41 +00:00
FRIGN 86a99c5a03 Mark od(1) and getconf(1) as audited
They have just been (re)written, nothing to do here...
2015-10-26 11:55:41 +00:00
FRIGN 092c95b66c Rewrite od(1)
Looking at the old code, it became clear that the desired
functionality with the t-flag could not be added unless the
underlying data-structures were reworked.
Thus the only way to be successful was to rewrite the whole thing.

od(1) allows giving arbitrarily many type-specs per call, both via
-t x1o2... and -t x1 -t o2 and intermixed.
This fortunately is easy to parse.
Now, to be flexible, it should not only support types of integral
length. Erroring out like this is inacceptable:

$ echo -n "shrek"| od -t u3
od: invalid type string ‘u3’;
this system doesn't provide a 3-byte integral type

Thus, this new od(1) just collects the bytes until shortly before
printing, when the numbers are written into a long long with the
proper offset.
The bytes per line are just the lcm of all given type-lengths and >= 16.
They are equal to 16 for all types that are possible to print using
the old od(1)'s.

Endianness is of course also supported, needs some testing though,
especially on Big Endian systems.
2015-10-26 11:55:41 +00:00
sin 9a176e4011 Add flock entry in README 2015-10-07 10:27:47 +01:00
FRIGN 05996b997c Add getconf(1)
The logic is simple, it's just a pain in the ass to fill the
Some lines had to be commented out, as glibc/musl apparently
have not fully implemented the mandatory variables for the
2013 corrigendum of POSIX 2008.

Also added a manpage and the necessary entries in README.

I also removed it from the TODO.
2015-10-01 17:17:23 +01:00
FRIGN fc886aa144 Implement od(1) v-flag
If this flag is not given, od(1) automatically replaces duplicate
adjacent lines with an '*' for each reoccurence.
If this flag is set, thus, no such filtering occurs.

In this case this would mean having to somehow keep the last printed
line in some backbuffer, building the next line and then doing the
necessary comparisons. This basically means that we duplicate the
functionality provided with uniq(1).

So instead of

$ od -t a > dump

you'd rather do

$ od -t a | uniq -f 1 -c > dump

Skipping the first field is necessary, as the addresses obviously differ.

Now, I was thinking hard why this flag even exists. If POSIX mandated
to add the address before the asterisk, so we know the offset of duplicate
occurrences, this would make sense. However, this is not the case.

Using uniq(1) also gives nicer output:
~ $ echo "111111111111111111111111111111111111111111111111" | od -t a -v | uniq -f 1 -c
      3 0000000   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
      1 0000060  nl
      1 0000061

in comparison to

$ echo "111111111111111111111111111111111111111111111111" | od -t a
0000000   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
0000060  nl

Before working on od(1), I didn't even know it would filter out
duplicate adjacent lines like that. This is also a matter of

Concluding, the v-flag is implicitly set and users urged to just
use the existing tools provided by the system.
I don't think we would break scripts either. Firstly, it's rather
unlikely to have duplicate lines exactly matching the line-length of
od(1). Secondly, even if a script did that specifically, in the worst
case there would be a counting error or something.

Given od(1) is mostly used interactively, we can safely assume this
feature is for the benefit of the users.

Ditch this legacy POSIX crap!
 Please enter the commit message for your changes. Lines starting
2015-09-30 19:44:10 +01:00
FRIGN f8f2a56852 Add -j and -N to od(1) and update README
With parseoffset(), it's rather trivial to implement POSIX' rather
obscure commandments.
The -j and -N-flags should be ready to go!
2015-09-30 19:44:10 +01:00
Greg Reagle fd0d1e4567 Created od, with improvements suggested by FRIGN 2015-09-30 19:44:10 +01:00
sin 1fa942a0ee Add TFTP client as specified by RFC 1350
This client does not support the netascii mode.  The default mode
is octet/binary and should be sufficient.

One thing left to do is to check the source port of the server
to make sure it doesn't change.  If it does, we should ignore the
packet and send an error back without disturbing an existing
2015-08-14 13:11:16 +01:00
FRIGN 9d429de50d Mark manpages as done in the README for find(1) and sed(1) 2015-08-04 19:46:03 +01:00
FRIGN 5dc6f3c1e6 Note in the README that find(1) and sed(1) are lacking manpages 2015-08-04 12:08:13 +01:00
FRIGN 51390a3c51 Audit sort(1) and mark it as finished
1) Remove the function prototypes. No need for them, as the
   functions are ordered.
2) Add fieldseplen, so the length of the field-separator is not
   calculated nearly each time skipcolumn() is called.
3) rename next_col to skip_to_next_col so the purpose is clear,
   also reorder the conditional accordingly.
4) Put parentheses around certain ternary expressions.
5) BUGFIX: Don't just exit() in check(), but make it return something,
   so we can cleanly fshut() everything.
6) OFF-POSIX: Posix for no apparent reason does not allow more than
   one file when the -c or -C flags are given.
   This can be problematic when you want to check multiple files.
   With the change 5), rewriting check() to return a value, I went
   off-posix after discussing this with Dimitris to just allow
   arbitrary numbers of files. Obviously, this does not break scripts
   and is convenient for everybody who wants to quickly check a big
   amount of files.
   As soon as 1 file is "unsorted", the return value is 1, as expected.
   For convenience reasons, check()'s warning now includes the filename.
7) BUGFIX: Set ret to 2 instead of 1 when the fshut(fp, *argv) fails.
8) BUGFIX: Don't forget to fshut stderr at the end. This would improperly
   return 1 in the following case:
   $ sort -c unsorted_file 2> /dev/full
9) Other style changes, line length, empty line before return.
2015-08-04 12:08:13 +01:00
FRIGN e153447657 Make sort(1) utf-compliant and update README
Make it clear that <blank> characters just are spaces or tabs and
not a special group which needs special treatment for wide characters.

Also, and that was the only problem here, correctly calculate the
offset given by the key definitions for the start- and end-characters
using libutf-utility-functions.

Mark the progress in the README and put parentheses around the missing
flags which are insane to implement for no real gain.
2015-08-03 19:14:52 +01:00
FRIGN 198c45ee6d Remove col(1)
Where should I start? It's a rather irrelevant tool and broken as is.
We'll re-add it as soon as the code has been fixed by the original
Until then, better keep it out or some kids get hurt.
2015-06-04 23:54:09 +01:00
FRIGN b333176b8c Refactor and audit which(1)
Use the *at functions instead of building paths manually. We do
still have path-building in recurse() and other areas, but the
long-term goal is to rid most interfaces of that for practical
and security reasons.
In this case, it's more or less trivial.

Also, refactor the manpage to be more consistent with the others.

BUGFIX: Return exit status 3 on error.
2015-04-27 19:33:57 +01:00
Hiltjo Posthuma 58cb564bbd add which 2015-04-27 16:58:42 +01:00
Wolfgang Corcoran-Mathe cd0b771cbb Add join(1) 2015-04-20 11:24:12 +01:00
FRIGN 57dc7b94b0 POSIX 2013 audit
Mostly manpage-shuffling according to the changes in the corrigendum,
wording changes and more idiomatic expressions.
All this is finished up by marking the POSIX 2013 conformant tools
.St -p1003.1-2013
which is not available in older mandoc builds or nroff, but which
reflects what we actually did, so who cares?

This is a huge step and it's not far until we can release sbase 0.1.
2015-03-27 17:25:22 +01:00
FRIGN 4750b233ce Prepare POSIX 2013 audit
I can't believe we've come this far! The idea is to look at the
2013 POSIX corrigendum for each tool and deep-test features before
making the first 0.1 release.
To keep the noise low, I'll do this in batches, not on a per-tool-
basis (as many of these are trivial to test).
In the meantime, I'll also think of a fitting STANDARDS section
for the non-POSIX tools. Now that the audits are pretty much done,
I can also have a more relaxed view on standards compliance instead
of having to dig through some uncleaned mess.

To mark this "new beginning", the README has gotten a liftover.
The POSIX 2008-column was more or less useless and as I expect the
checks to go along pretty quickly, I "reset" the compliance state
of all but the non-POSIX tools and will then go along and check every
single one of them in the next few days.

Apart from the few missing flags and audits, sbase should then be
ready to hit the world with the first release after 4 years of work.
2015-03-23 16:22:00 +01:00
FRIGN 49e27c1b0c Add -m and -o flags to sort(1)
Sort comes pretty much automatically, as no script relies on the
undefined behaviour of the input _not_ being sorted, we might as well
sort the sorted input already.
The only downside is memory usage, which can be an issue for large
The o-flag was trivial to implement.
2015-03-22 23:39:48 +01:00