printf is recommended instead of echo because it has a more predictable
behavior than echo (tip from the POSIX standard ;-). Using it allow us
to generate the _same_ manpage using sh, dash or bash.
sh and, consequently, dash interpret some escaped characters as control
sequences, so an echo '\f' outputs a form feed. To avoid this problem
in manpage generation, we have to escape "\f" sequences.
usage of the "-i" feature of sed is not entirely portable across
different operating systems. -i has an optional extension to save
a backup of the edited file, and different systems parse this option
in a different manner.
the sed in GNU, busybox, NetBSD, and OpenBSD expects the argument
to be immediately after, like `-i.bak`, if it is present.
the sed in macOS and FreeBSD expects the argument to follow after
a space, like `-i .bak`, but will accept the `-i.bak` form as well.
the issue is that when no backup is specified, the first requires
just `-i`, where the second requires `-i ''`. the easiest way around
this is to just add a backup, which is what i chose to do here. i
also added the .bak extension to the .gitignore.
additionally, all aforementioned seds except for GNU require the file
to be the final argument, and will not accept it between other options.
the + and - syntax on head and tail are only present, as far as i know,
in GNU coreutils, and are not present on any other UNIX or BSD systems.
this patch replaces those with a more portable processing chain, which
is tested to work on GNU coreutils, NetBSD, macOS, and busybox.