tail: Process bytes with -c option, and add -m option for runes

POSIX says that -c specifies a number of bytes, not characters. This
flag is commonly used by scripts that operate on binary files to things
like extract a header. Treating the offsets as character offsets will
break things in mysterious ways.

Instead, add a -m option (chosen to match `wc -m`, which also operates
on characters) to handle character offsets.
This commit is contained in:
Michael Forney
2017-07-03 14:58:52 -07:00
committed by Anselm R Garbe
parent 1ab4ac60ff
commit ea8622a4ce
2 changed files with 27 additions and 8 deletions

6
tail.1
View File

@@ -7,7 +7,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl f
.Op Fl c Ar num | Fl n Ar num | Fl Ns Ar num
.Op Fl c Ar num | Fl m Ar num | Fl n Ar num | Fl Ns Ar num
.Op Ar file ...
.Sh DESCRIPTION
.Nm
@@ -20,10 +20,10 @@ is given,
reads from stdin.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl c Ar num | Fl n Ar num | Fl Ns Ar num
.It Fl c Ar num | Fl m Ar num | Fl n Ar num | Fl Ns Ar num
Display final
.Ar num
characters | lines |
bytes | characters | lines |
lines. If
.Ar num
begins with '+'