1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

libcmd: update unit suffix doc in head(1) & tail(1)

The documentation for the supported unit suffixes for options
accepting numeric arguments was woefully outdated in 'head --man'
and 'tail --man'.

A quick look at the very short head(1) code shows that it does not
know or care about unit suffixes at all – it leaves that to libast
optget(3) which in turn calls strtoll() which is implemented in
strtoi.h where the multiplier suffixes are handled.

Note that on GNU head/tail, single-letter suffixes use power-of-2
units, e.g. k == KiB, etc. Libast used to do the same but this is
not standards compliant and AT&T changed/fixed this in 2011. From
libast/RELEASE:
10-04-11 string/strtoi.h: k (1000) and ki (1024) now differentiated
(They didn't mention the same change applies to all handled units.)

Note that the tail(1) builtin is currently not compiled in by
default. This can be changed in src/cmd/ksh93/data/builtins.c.

src/lib/libcmd/head.c, src/lib/libcmd/tail.c:
- Update the internal head/tail man pages to reflect what is
  handled in strtoi.h.

Resolves: https://github.com/ksh93/ksh/issues/319
This commit is contained in:
Martijn Dekker 2021-11-05 03:01:28 +00:00
parent da929c4505
commit a3abad203a
2 changed files with 21 additions and 15 deletions

View file

@ -39,13 +39,16 @@ static const char usage[] =
"with the \b-q\b and \b-v\b options.]"
"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \bhead\b "
"copies from standard input starting at the current location.]"
"[+?The option argument for \b-c\b, and \b-s\b can optionally be "
"followed by one of the following characters to specify a different unit "
"other than a single byte:]"
"{"
"[+b?512 bytes.]"
"[+k?1-kilobyte.]"
"[+m?1-megabyte.]"
"[+?The option argument for \b-n\b, \b-c\b and \b-s\b may end in one of the following "
"case-insensitive unit suffixes, with an optional trailing \bB\b ignored:]{"
"[+b?512 (block)]"
"[+k?1000 (kilo)]"
"[+Ki?1024 (kibi)]"
"[+M?1000*1000 (mega)]"
"[+Mi?1024*1024 (mebi)]"
"[+G?1000*1000*1000 (giga)]"
"[+Gi?1024*1024*1024 (gibi)]"
"[+...?and so on for T, Ti, P, Pi, E, and Ei.]"
"}"
"[+?For backwards compatibility, \b-\b\anumber\a is equivalent to \b-n\b "
"\anumber\a.]"

View file

@ -41,13 +41,16 @@ static const char usage[] =
"[+?If no \afile\a is given, or if the \afile\a is \b-\b, \btail\b "
"copies from standard input. The start of the file is defined "
"as the current offset.]"
"[+?The option argument for \b-c\b can optionally be "
"followed by one of the following characters to specify a different "
"unit other than a single byte:]{"
"[+b?512 bytes.]"
"[+k?1 KiB.]"
"[+m?1 MiB.]"
"[+g?1 GiB.]"
"[+?The option argument for \b-n\b and \b-c\b may end in one of the following "
"case-insensitive unit suffixes, with an optional trailing \bB\b ignored:]{"
"[+b?512 (block)]"
"[+k?1000 (kilo)]"
"[+Ki?1024 (kibi)]"
"[+M?1000*1000 (mega)]"
"[+Mi?1024*1024 (mebi)]"
"[+G?1000*1000*1000 (giga)]"
"[+Gi?1024*1024*1024 (gibi)]"
"[+...?and so on for T, Ti, P, Pi, E, and Ei.]"
"}"
"[+?For backwards compatibility, \b-\b\anumber\a is equivalent to "
"\b-n\b \anumber\a and \b+\b\anumber\a is equivalent to "