sbase/od.1

61 lines
1.3 KiB
Groff
Raw Normal View History

.Dd 2015-10-25
.Dt OD 1
.Os sbase
.Sh NAME
.Nm od
.Nd octal dump
.Sh SYNOPSIS
.Nm
2015-10-09 01:09:26 +00:00
.Op Fl A Ar addrformat
.Op Fl E | e
2015-10-09 01:09:26 +00:00
.Op Fl t Ar outputformat...
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 0000061 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 predictability. 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 10:54:24 +00:00
.Op Fl v
2015-10-09 01:09:26 +00:00
.Op Ar file ...
.Sh DESCRIPTION
.Nm
writes an octal dump of each
.Ar file
to stdout. If no
.Ar file
2015-10-09 01:09:26 +00:00
is given
.Nm
reads from stdin.
.Sh OPTIONS
.Bl -tag -width Ds
2015-10-09 01:09:26 +00:00
.It Fl A Ar addressformat
.Ar addressformat
is one of d|o|x|n and sets the address to be
either in \fId\fRecimal, \fIo\fRctal, he\fIx\fRadecimal or \fIn\fRot
printed at all. The default is octal.
.It Fl E | e
Force Little Endian
.Fl ( e )
or Big Endian
.Fl ( E )
system-independently.
2015-10-09 01:09:26 +00:00
.It Fl t Ar outputformat
.Ar outputformat
is a list of a|c|d|o|u|x followed by a digit or C|S|I|L and sets
the content to be in n\fIa\fRmed character, \fIc\fRharacter, signed
\fId\fRecimal, \fIo\fRctal, \fIu\fRnsigned decimal, or
2015-10-09 01:09:26 +00:00
he\fIx\fRadecimal format, processing the given amount of bytes or the length
of \fIC\fRhar, \fIS\fRhort, \fII\fRnteger or \fIL\fRong.
The default is octal with 4 bytes.
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 0000061 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 predictability. 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 10:54:24 +00:00
.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 except that the
.Op Fl v
flag is always enabled and the 'd' parameter for the
.Op Fl t
flag is interpreted as 'u'.
.Pp
The
.Op Ee
flags are an extension to that specification.