Case Study

I now introduce a case study of a real-world manual, in particular the echo utility from OpenBSD. The original file may be viewed on-line at src/bin/echo/echo.1, file version 1.20. I choose this mainly because of its simplicity.

.\"    $​OpenBSD: echo.1,v 1.20 2010/09/03 09:53:20 jmc Exp $​
.\"    $​NetBSD: echo.1,v 1.7 1995/03/21 09:04:26 cgd Exp $​

These initial comments are automatically created by the source-control system cvs, which fills in information about the last editor. I'll talk about revision control and those funny dollar-sign enclosures in Part 3. These particular comments indicate that the file was initially imported from NetBSD in 1995, where it was last edited by cgd (a system name, not the user's real name). It was last edited in OpenBSD, its current form, by jmc in 2010.

If you're keeping your manual under source control, it's usually a good idea to begin your file with a similar line.

.\"    $​Id$

A tab character separates the comment marker from the text. Again, this will be covered later in this book — don't worry if it looks strange.

.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.

This long comment is the license and copyright of the source file. Of course, our use of this source file is compatible with the license, as may be read from the text itself!

.\" @(#)echo.1 8.1 (Berkeley) 7/22/93

This comment is of historical note. The @(#) sequence was inserted by the sccs utility (Source Code Control System). Although this utility is part of POSIX.1-2008, it has mostly been replaced by cvs. You'll probably never encounter this string in your own manuals, so it's safe to disregard.

At this point the manual content itself begins.

.Dd $​Mdocdate: September 3 2010 ​$
.Dt ECHO 1
.Os

This indicates that the manual's title is ECHO in category 1 (utilities) for the current installed operating system. The $​Mdocdate$ enclosure is similar to that as defined at the top of the file with $​OpenBSD$.

.Sh NAME
.Nm echo
.Nd write arguments to the standard output

This documents a single command, the echo command, which does as mentioned.

.Sh SYNOPSIS
.Nm echo
.Op Fl n
.Op Ar string ...

The command accepts a single optional flag, n, and an arbitrary number of optional arguments string. Note that re-stating the command name for the Nm is superfluous in this case.

.Sh DESCRIPTION
The
.Nm
utility writes any specified operands, separated by single blank
.Pq Sq \ \&
characters and followed by a newline
.Pq Sq \en
character, to the standard
output.
When no operands are given, only the newline is written.

The DESCRIPTION opens with a brief explanation of the utility and its output. The strange set of backslash-escaped characters \ \& is required to make the doubly-nested macros Pq and Sq (parenthesise and single-quote, respectively) correctly enclose a single space.

.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl n
Do not print the trailing newline character.
.El

This follows the standard form of documenting flags and arguments as a term/definition list. Each one — in this case only one — is documented in alphabetical order.

.Sh EXIT STATUS
.Ex -std echo

Notes the standard exit sequence. Note that the argument to Ex is superfluous, as only one command is listed for the manual.

.Sh SEE ALSO
.Xr csh 1 ,
.Xr ksh 1 ,
.Xr printf 1

Although these weren't cited in other sections of the manual, the author felt it necessary to link to them. This is probably because both csh and ksh include internal implementations of a function by the same name.

.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -p1003.1-2008
specification.
.Pp
The flag
.Op Fl n
is an extension to that specification.
.Pp
.Nm
also exists as a built-in to
.Xr csh 1
and
.Xr ksh 1 ,
though with a different syntax.

This last section fully describes the utility's conformance to the POSIX standard, which is very important to those writing portable utilities. The St macro expands into the relevant standard's full name, IEEE Std 1003.1-2008 (“POSIX.1”). For a full list of standards, consult your local documentation for the macro.

Last edited by $Author: kristaps $ on $Date: 2011/11/05 00:39:38 $. Copyright © 2011, Kristaps Dzonsons. CC BY-SA.