sbase/od.1
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

46 lines
929 B
Groff

.Dd 2015-10-08
.Dt OD 1
.Os sbase
.Sh NAME
.Nm od
.Nd octal dump
.Sh SYNOPSIS
.Nm
.Op Fl A Ar d|o|x|n
.Op Fl t Ar a|c|d|o|u|x
.Op Fl v
.Op Ar file...
.Sh DESCRIPTION
.Nm
writes an octal dump of each
.Ar file
to stdout. If no
.Ar file
is given, then
.Nm
reads from stdin.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl A Ar d|o|x|n
Display the address in base \fId\fRecimal | \fIo\fRctal |
he\fIx\fRadecimal | \fIn\fRone. If unspecified, the default is octal.
.It Fl t Ar a|c|d|o|u|x
Display the content as n\fIa\fRmed character, \fIc\fRharacter, signed
\fId\fRecimal, \fIo\fRctal, \fIu\fRnsigned decimal, or
he\fIx\fRadecimal. If unspecified, the default is octal.
.It Fl v
Always set. Write all input data, including duplicate lines.
.El
.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -p1003.1-2013
specification.
.Pp
The
.Op Fl v
flag is enabled by default and the 'd' parameter for the
.Op Fl t
flag is interpreted as 'u'.