Added man pages.

This commit is contained in:
Ben Gras
2005-05-02 13:01:42 +00:00
parent 89ac678b9b
commit 141fe2c6e0
368 changed files with 50911 additions and 0 deletions
+2090
View File
File diff suppressed because it is too large Load Diff
+76
View File
@@ -0,0 +1,76 @@
.TH ASCII 7
.SH NAME
ascii \- the ASCII character set.
.SH DESCRIPTION
The ASCII character set is as follows:
.PP
.nf
.if t .ft C
|000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel|
|010 bs |011 ht |012 nl |013 vt |014 np |015 cr |016 so |017 si |
|020 dle|021 dc1|022 dc2|023 dc3|024 dc4|025 nak|026 syn|027 etb|
|030 can|031 em |032 sub|033 esc|034 fs |035 gs |036 rs |037 us |
|040 sp |041 ! |042 " |043 # |044 $ |045 % |046 & |047 ' |
|050 ( |051 ) |052 * |053 + |054 , |055 - |056 . |057 / |
|060 0 |061 1 |062 2 |063 3 |064 4 |065 5 |066 6 |067 7 |
|070 8 |071 9 |072 : |073 ; |074 < |075 = |076 > |077 ? |
|100 @ |101 A |102 B |103 C |104 D |105 E |106 F |107 G |
|110 H |111 I |112 J |113 K |114 L |115 M |116 N |117 O |
|120 P |121 Q |122 R |123 S |124 T |125 U |126 V |127 W |
|130 X |131 Y |132 Z |133 [ |134 \e |135 ] |136 ^ |137 _ |
|140 ` |141 a |142 b |143 c |144 d |145 e |146 f |147 g |
|150 h |151 i |152 j |153 k |154 l |155 m |156 n |157 o |
|160 p |161 q |162 r |163 s |164 t |165 u |166 v |167 w |
|170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 del|
|00 nul|01 soh|02 stx|03 etx|04 eot|05 enq|06 ack|07 bel|
|08 bs |09 ht |0A nl |0B vt |0C np |0D cr |0E so |0F si |
|10 dle|11 dc1|12 dc2|13 dc3|14 dc4|15 nak|16 syn|17 etb|
|18 can|19 em |1A sub|1B esc|1C fs |1D gs |1E rs |1F us |
|20 sp |21 ! |22 " |23 # |24 $ |25 % |26 & |27 ' |
|28 ( |29 ) |2A * |2B + |2C , |2D - |2E . |2F / |
|30 0 |31 1 |32 2 |33 3 |34 4 |35 5 |36 6 |37 7 |
|38 8 |39 9 |3A : |3B ; |3C < |3D = |3E > |3F ? |
|40 @ |41 A |42 B |43 C |44 D |45 E |46 F |47 G |
|48 H |49 I |4A J |4B K |4C L |4D M |4E N |4F O |
|50 P |51 Q |52 R |53 S |54 T |55 U |56 V |57 W |
|58 X |59 Y |5A Z |5B [ |5C \e |5D ] |5E ^ |5F _ |
|60 ` |61 a |62 b |63 c |64 d |65 e |66 f |67 g |
|68 h |69 i |6A j |6B k |6C l |6D m |6E n |6F o |
|70 p |71 q |72 r |73 s |74 t |75 u |76 v |77 w |
|78 x |79 y |7A z |7B { |7C | |7D } |7E ~ |7F del|
.if t .ft P
.nf
.bp
These are what your terminal shows for the top 96 codes:
.PP
.nf
.if t .ft C
|240   |241 ¡ |242 ¢ |243 £ |244 ¤ |245 ¥ |246 ¦ |247 § |
|250 ¨ |251 © |252 ª |253 « |254 ¬ |255 ­ |256 ® |257 ¯ |
|260 ° |261 ± |262 ² |263 ³ |264 ´ |265 µ |266 ¶ |267 · |
|270 ¸ |271 ¹ |272 º |273 » |274 ¼ |275 ½ |276 ¾ |277 ¿ |
|300 À |301 Á |302 Â |303 Ã |304 Ä |305 Å |306 Æ |307 Ç |
|310 È |311 É |312 Ê |313 Ë |314 Ì |315 Í |316 Î |317 Ï |
|320 Ð |321 Ñ |322 Ò |323 Ó |324 Ô |325 Õ |326 Ö |327 × |
|330 Ø |331 Ù |332 Ú |333 Û |334 Ü |335 Ý |336 Þ |337 ß |
|340 à |341 á |342 â |343 ã |344 ä |345 å |346 æ |347 ç |
|350 è |351 é |352 ê |353 ë |354 ì |355 í |356 î |357 ï |
|360 ð |361 ñ |362 ò |363 ó |364 ô |365 õ |366 ö |367 ÷ |
|370 ø |371 ù |372 ú |373 û |374 ü |375 ý |376 þ |377 ÿ |
|A0   |A1 ¡ |A2 ¢ |A3 £ |A4 ¤ |A5 ¥ |A6 ¦ |A7 § |
|A8 ¨ |A9 © |AA ª |AB « |AC ¬ |AD ­ |AE ® |AF ¯ |
|B0 ° |B1 ± |B2 ² |B3 ³ |B4 ´ |B5 µ |B6 ¶ |B7 · |
|B8 ¸ |B9 ¹ |BA º |BB » |BC ¼ |BD ½ |BE ¾ |BF ¿ |
|C0 À |C1 Á |C2 Â |C3 Ã |C4 Ä |C5 Å |C6 Æ |C7 Ç |
|C8 È |C9 É |CA Ê |CB Ë |CC Ì |CD Í |CE Î |CF Ï |
|D0 Ð |D1 Ñ |D2 Ò |D3 Ó |D4 Ô |D5 Õ |D6 Ö |D7 × |
|D8 Ø |D9 Ù |DA Ú |DB Û |DC Ü |DD Ý |DE Þ |DF ß |
|E0 à |E1 á |E2 â |E3 ã |E4 ä |E5 å |E6 æ |E7 ç |
|E8 è |E9 é |EA ê |EB ë |EC ì |ED í |EE î |EF ï |
|F0 ð |F1 ñ |F2 ò |F3 ó |F4 ô |F5 õ |F6 ö |F7 ÷ |
|F8 ø |F9 ù |FA ú |FB û |FC ü |FD ý |FE þ |FF ÿ |
.if t .ft P
.nf
+111
View File
@@ -0,0 +1,111 @@
.\" Copyright (c) 1983 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\"
.\" @(#)environ.7 6.1 (Berkeley) 5/20/85
.\"
.TH ENVIRON 7 "May 20, 1985"
.UC 5
.SH NAME
environ \- user environment
.SH SYNOPSIS
.B "extern char *const *environ;"
.SH DESCRIPTION
An array of strings called the `environment' is made available by
.BR execve (2)
when a process begins. By convention these strings have the form
.RI ` name = value '.
The following names are used by various commands:
.TP "\w'TERMCAP 'u"
.B PATH
The sequence of directory prefixes that
.BR sh ,
.BR time ,
.BR nice (1),
etc., apply in searching for a file known by an incomplete path name.
The prefixes are separated by `:'.
Login shells set
.BR PATH=:/bin:/usr/bin .
Note that the empty space between the `=' and the `:' indicates the current
directory. Security aware people move the extra `:' to the end of their
path or omit it.
.TP
.B HOME
A user's login directory, set by
.BR login (1)
from the password file
.BR passwd (5).
.TP
.B TERM
The kind of terminal for which output is to be prepared.
This information is used by programs that wish to exploit special
terminal capabilities, a screen oriented text editor for instance.
The terminal type is set by
.BR login (1)
from the tty database
.BR ttytab (5).
.TP
.B SHELL
The file name of the users login shell, set by
.BR login (1)
from the password file
.BR passwd (5).
.TP
.B TERMCAP
The string describing the terminal in TERM, or the name of the termcap file,
see
.BR termcap (5),
.BR termcap (3).
.TP
.B EXINIT
A startup list of commands read by
.BR elvis (1).
.TP
.B USER
The login name of the user, set by
.BR login (1)
from the password file
.BR passwd (5).
.TP
.B LOGNAME
Set to the same value as
.BR USER .
BSD derived systems have
.BR USER ,
System V has
.BR LOGNAME ,
so modern systems have both to avoid problems.
.TP
.PP
Further names may be placed in the environment by the
.B export
command and
.RI ` name = value '
arguments in
.BR sh (1).
Arguments may also be placed in their environment by
programs if they use
.BR putenv (3).
Or in the environment of another program by building a new environment
for one of the exec functions that accepts an environment list, like
.BR execle (2)
or
.BR execve (2).
It is unwise to conflict with certain
.BR sh (1)
variables that are frequently set and/or exported by `.profile' files:
.BR MAIL ,
.BR PS1 ,
.BR PS2 ,
.BR IFS .
.SH SEE ALSO
.BR elvis (1),
.BR login (1),
.BR sh (1),
.BR execl (3),
.BR execve (2),
.BR system (3),
.BR termcap (3),
.BR termcap (5),
.BR passwd (5),
.BR ttytab (5).
+195
View File
@@ -0,0 +1,195 @@
.TH HIER 7
.SH NAME
hier \- file system hierarchy
.SH DESCRIPTION
.de SP
.if t .sp 0.4
.if n .sp
..
A tour through the Minix directory hierarchy.
.nf
.SP
/ root
.SP
/bin/ Utility programs, cf /usr/bin/ (1)
cat Show files, \fBcat\fP(1)
sh Shell, \fBsh\fP(1)
mount Mount file systems, \fBmount\fP(8)
...
.SP
/boot Boot Monitor, \fBmonitor\fP(8)
.SP
/dev/ devices (4)
console
Main console, \fBtty\fP(4)
tty* Terminals, \fBtty\fP(4)
hd* Hard disk, \fBhd\fP(4)
fd* Floppy disk, \fBfd\fP(4)
...
.SP
/etc/ System configuration and data files, cf /usr/etc/ (1,5,8)
ethers Ethernet addresses database, \fBethers\fP(5)
fstab File system table, \fBfstab\fP(5)
group Groups database, \fBgroup\fP(5)
hostname.file
Name of the local system, \fBusage\fP(5)
hosts TCP/IP hosts database, \fBhosts\fP(5)
hosts.equiv
Network equivalent hosts, \fBhosts.equiv\fP(5)
inet.conf
Inet server config file, \fBinet\fP(8)
keymap Keymap for custom keyboard, \fBloadkeys\fP(8)
motd Message of the day, \fBlogin\fP(1)
mtab Mounted file system table, \fBfstab\fP(5)
passwd User database, \fBpasswd\fP(5)
profile
System wide shell profile, \fBsh\fP(1)
rc System startup script, \fBboot\fP(8)
resolv.conf
TCP/IP domain name system, \fBresolv.conf\fP(5)
services
TCP/IP names to services, \fBservices\fP(5)
serv.access
Internet service access control, \fBserv.access\fP(5)
shadow Shadow password database, \fBpasswd\fP(5)
termcap
Terminal type descriptions, \fBtermcap\fP(5)
ttytab Terminals device table, \fBttytab\fP(5)
utmp User login database, \fBlogin\fP(1)
...
.SP
/minix
Minix kernel image, \fBmonitor\fP(8)
.SP
/tmp/ Small, short-lived temporary files, cf /usr/tmp/
.SP
/usr/ Home directories and more system files
.SP
adm/ System administration files (1,5,8)
lastlog
Last logins, \fBlogin\fP(1)
log
Default log file
old
Last weeks log files
wtmp
User logins and logouts, \fBlogin\fP(1)
*.cache
Cached data of some programs
...
.SP
ast/ Honorary home directory of Andrew S. Tanenbaum
Also new user initial files
.SP
\fIuser\fP/ Home directory of \fIuser\fP
.ashrc Ash (shell) startup, \fBash\fP(1)
.ellepro.b1
Elle (editor) startup (compiled), \fBelle\fP(1)
.ellepro.e
Elle (editor) startup (text), \fBelle\fP(1)
.exrc Ex/vi (editor) startup, \fBex\fP(1)
.profile
Custom user shell profile, \fBsh\fP(1)
.rhosts Remote user permission file, \fBrhosts\fP(5)
...
.SP
bin/ User programs
cc C compiler, \fBcc\fP(1)
cp Copy files, \fBcp\fP(1)
ls List files, \fBls\fP(1)
man Show manual pages, \fBman\fP(1)
...
.SP
etc/ More system data files, cf /etc (8)
rc Continued system startup, \fBboot\fP(8)
daily
Daily system cleanup
...
.SP
include/
C-compiler include files
minix/ Minix kernel include files
...
...
.SP
lib/ Compiler libraries and other support stuff
cawf/ Text formatter support files, \fBcawf\fP(1)
crontab
Cron jobs, \fBcron\fP(8)
dict/ Word lists
words American English word list, \fBlook\fP(1)
...
libc.a C library (Minix-8086 only), \fBcc\fP(1)
\fIarch\fP Per architecture compiler binaries and
libaries, \fBcc\fP(1)
...
.SP
local/ Local software, cf /usr/
bin/ Local utilities
etc/ Local data files
rc Local system startup
...
man/ Local manual pages
src/ Local sources
...
.SP
man/ Manual pages, \fBman\fP(1)
cat*/ Preformatted manual pages
man0/ Section 0, Book style user commands
man1/ User commands
man2/ System calls
man3/ Library routines
man4/ Device files
man5/ File formats
man6/ Games
man7/ Miscellaneous
man8/ System utilities
whatis Table of manual pages, \fBwhatis\fP(5)
...
.SP
mdec/
boot Bootstrap code, \fBinstallboot\fP(8)
...
.SP
preserve/
Saved elvis editor buffers, \fBelvprsv\fP(8), \fBelvrec\fP(1)
.SP
spool/ Mail and command spooling
at/ At jobs, \fBat\fP(1)
past/ Completed at jobs
mail/ Mail drops, \fBmail\fP(1)
\fIuser\fP Mailbox of \fIuser\fP
...
...
.SP
src/ System and command sources (home of bin)
LICENSE
Minix license to use
commands/
Utility sources
crclist
CRC checksums of the source tree, \fBsrccrc\fP(8)
lib/ Library sources
fs/ File system
inet/ TCP/IP task
kernel/
Kernel
mm/ Memory manager
boot/ Boot Monitor
tools/ Kernel image making tools, \fBtools\fP(8)
.SP
tmp/ Large temporary files
.fi
.SH "SEE ALSO"
.BR ls (1),
.BR man (1),
.BR find (1),
.BR grep (1),
.BR checkhier (8).
.SH NOTES
Not all of the directories and files shown are present. They must be
created as needed.
.SH BUGS
Many of the listed manual references do not yet exist.
.SH AUTHOR
Kees J. Bot (kjb@cs.vu.nl)
+278
View File
@@ -0,0 +1,278 @@
.\" man(7) manpage by rosenkra@hall.cray.com (Bill Rosenkranz)
.\" Modified a bit for Minix by Kees J. Bot (kjb@cs.vu.nl)
.\"
.TH MAN 7
.SH NAME
man - nroff macro package for manual pages
.SH SYNOPSIS
.B nroff \-man
.IR file " ..."
.SH DESCRIPTION
.de SP
.if t .sp 0.4
.if n .sp
..
These macros are used to lay out reference pages for manuals.
.PP
Any text argument
.I t
may be zero to six words. Quotes may be used to include blanks in a 'word'.
.I Text
can be empty, but unlike normal \s-2UNIX\s+2 macros, the next line is not used.
.PP
A prevailing indent distance is remembered between successive
indented paragraphs, and is reset to default value upon
reaching a non-indented paragraph (i.e. at .SH or .SS).
.SH FILES
.TP 25n
/usr/lib/tmac/tmac.an
For standard Minix nroff.
.TP
/usr/lib/cawf/man.mac
For cawf.
.SH SEE ALSO
.BR nroff (1),
.BR man (1).
.SH "REQUEST SUMMARY"
.nf
.ta +15n +9n
Request Cause Explanation
Break?
\&.B t no Text t is bold. Quote to imbed blanks.
\&.I t no Text t is italic. Quote to imbed blanks.
\&.IP x yes Set prevailing indent to 5. Begin
indented paragraph with hanging tag
given by first argument. Tag x is
always placed on a separate line.
\&.LP yes Same as .PP.
\&.PP yes Begin paragraph. Set prevailing
indent to 5.
\&.RE yes End of relative indent. Set prevailing
indent to amount of starting .RS.
\&.RS yes Start relative indent, move left margin
in distance 5.
\&.SH t yes Subhead. Quote to imbed blanks.
\&.SS t yes Subsection. Quote to imbed blanks. No
indent for t.
\&.TH n s c v d yes Begin page named n of chapter s; c is
the chapter name; d is the date of the
most recent change; v is version number.
Sets prevailing indent and tabs to 5.
.fi
.SH EXAMPLE
The following illustrates some of the requests available
with this macro package:
.RS
.nf
\&.\e" this is a comment
\&.TH DEMO 1
\&.SH NAME
demo \e- show how to use \e-man package
\&.SH SYNOPSIS
\&.B demo
\&.RI [ options ]
\&.IR file " ..."
\&.SH DESCRIPTION
This is a test for showing how to use the
\&.BR nroff (1)
man package. It shows how to use .TH, .SH, .PP, .B, .I, and .IP
commands.
\&.PP
This will be a new paragraph. You can also use normal
\&.BR nroff (1)
commands in the text.
\&.SS Nroff Commands
\&.IP '\ee"'
This is the comment command. \e" You won't see this.
\&.IP nf
No fill mode (the normal mode is fill mode where things
get justified right and left).
\&.IP fi
Re-enter fill mode.
\&.IP br
Break line here no matter what.
\&.IP sp
Vertical space (also causes a break to occur).
\&.sp
Note that to continue an indent and make a new paragraph (as
is the case here), just put in a space (.sp).
\&.PP
Now we should be at a new paragraph.
.fi
.RE
.PP
Executing
.B nroff \-man demo.man
results in the following output: (Ignoring page headers and footers)
.PP
.RS
.B NAME
.RS
demo \e- show how to use \e-man package
.RE
.SP
.B SYNOPSIS
.RS
.B demo
.RI [ options ]
.IR file " ..."
.RE
.SP
.B DESCRIPTION
.RS
This is a test for showing how to use the
.BR nroff (1)
man package. It shows how to use .TH, .SH, .PP, .B, .I, and .IP
commands.
.SP
This will be a new paragraph. You can also use normal
.BR nroff (1)
commands in the text.
.RE
.SP
.ti +2n
.B Nroff Commands
.RS
.RS
.ta +5n
.SP
.ti -5n
\&'\e"' This is the comment command.
.SP
.ti -5n
nf No fill mode (the normal mode is fill mode where things
get justified right and left).
.SP
.ti -5n
fi Re-enter fill mode.
.SP
.ti -5n
br Break line here no matter what.
.SP
.ti -5n
sp Vertical space (also causes a break to occur).
.sp
Note that to continue an indent and make a new paragraph (as
is the case here), just put in a space (.sp).
.RE
.SP
Now we should be at a new paragraph.
.RE
.RE
.SH CONVENTIONS
A typical manual page for a command or function is laid out as follows:
.nf
.TH TITLE [1-8]
The name of the command or function in upper-case,
which serves as the title of the manual page. This is
followed by the number of the section in which it
appears.
.SH NAME
name - one-line summary
The name, or list of names, by which the command is
called, followed by a dash and then a one-line summary
of the action performed. All in roman font, this sec-
tion contains no troff(1) commands or escapes, and no
macro requests. It is used to generate the whatis(1)
database.
.SH SYNOPSIS
Commands:
The syntax of the command and its arguments as
typed on the command line. When in boldface, a
word must be typed exactly as printed. When in
italics, a word can be replaced with text that you
supply. Syntactic symbols appear in roman face:
[ ] An argument, when surrounded by brackets is
optional.
| Arguments separated by a vertical bar are
exclusive. You can supply only item from
such a list.
... Arguments followed by an elipsis can be
repeated. When an elipsis follows a brack-
eted set, the expression within the brackets
can be repeated.
Functions:
If required, the data declaration, or #include
directive, is shown first, followed by the func-
tion declaration. Otherwise, the function declara-
tion is shown.
.SH DESCRIPTION
A narrative description of the command or function in
detail, including how it interacts with files or data,
and how it handles the standard input, standard output
and standard error.
Filenames, and references to commands or functions
described elswhere in the manual, are italicised. The
names of options, variables and other literal terms are
in boldface.
.SH OPTIONS
The list of options along with a description of how
each affects the commands operation.
.SH ENVIRONMENT
Environment variables used.
.SH FILES
A list of files associated with the command or func-
tion.
.SH "SEE ALSO"
A comma-separated list of related manual pages,
followed by references to other published materials.
This section contains no troff(1) escapes or commands,
and no macro requests.
.SH DIAGNOSTICS
A list of diagnostic messages and an explanation of
each.
.SH NOTES
Any additional notes such as installation-dependent
functionality.
.SH BUGS
A description of limitations, known defects, and possi-
ble problems associated with the command or function.
.SH AUTHOR
The program's author and any pertinent release info.
.SH VERSION
The program's current version number and release date.
.fi
.SH BUGS
Even though
.BR cawf (1)
has a better chance at formatting a random manual page then the standard
Minix nroff, it has two annoying bugs in its macro set. Both .PP and .IP
reset the indentation level to the level set by .SH. This means that
you can't use them in a piece of text indented by .RS. For .IP this is
troublesome, you can see why in the unformatted source of this text. .PP
can simply be replaced by .sp, or better yet, by .SP with the following
macro defined somewhere in your text:
.PP
.RS
.nf
\&.de SP
\&.if t .sp 0.4
\&.if n .sp
\&..
.fi
.RE
.PP
This will make .SP use 4/10 of a line if formatted by troff, just like .PP.
+269
View File
@@ -0,0 +1,269 @@
.\" Copyright (c) 1992, 1993, 1994 Henry Spencer.
.\" Copyright (c) 1992, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Henry Spencer.
.\"
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. 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.
.\"
.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94
.\"
.TH RE_FORMAT 7 "March 20, 1994"
.SH NAME
re_format \- POSIX 1003.2 regular expressions
.SH DESCRIPTION
Regular expressions (``RE''s),
as defined in POSIX 1003.2, come in two forms:
modern REs (roughly those of
.BR egrep ;
1003.2 calls these ``extended'' REs)
and obsolete REs (roughly those of
.BR ed ;
1003.2 ``basic'' REs).
Obsolete REs mostly exist for backward compatibility in some old programs;
they will be discussed at the end.
1003.2 leaves some aspects of RE syntax and semantics open;
`\(dg' marks decisions on these aspects that
may not be fully portable to other 1003.2 implementations.
.PP
A (modern) RE is one\(dg or more non-empty\(dg \fIbranches\fR,
separated by `|'.
It matches anything that matches one of the branches.
.PP
A branch is one\(dg or more \fIpieces\fR, concatenated.
It matches a match for the first, followed by a match for the second, etc.
.PP
A piece is an \fIatom\fR possibly followed
by a single\(dg `*', `+', `?', or \fIbound\fR.
An atom followed by `*' matches a sequence of 0 or more matches of the atom.
An atom followed by `+' matches a sequence of 1 or more matches of the atom.
An atom followed by `?' matches a sequence of 0 or 1 matches of the atom.
.PP
A \fIbound\fR is `{' followed by an unsigned decimal integer,
possibly followed by `,'
possibly followed by another unsigned decimal integer,
always followed by `}'.
The integers must lie between 0 and RE_DUP_MAX (255\(dg) inclusive,
and if there are two of them, the first may not exceed the second.
An atom followed by a bound containing one integer \fIi\fR
and no comma matches
a sequence of exactly \fIi\fR matches of the atom.
An atom followed by a bound
containing one integer \fIi\fR and a comma matches
a sequence of \fIi\fR or more matches of the atom.
An atom followed by a bound
containing two integers \fIi\fR and \fIj\fR matches
a sequence of \fIi\fR through \fIj\fR (inclusive) matches of the atom.
.PP
An atom is a regular expression enclosed in `()' (matching a match for the
regular expression),
an empty set of `()' (matching the null string)\(dg,
a \fIbracket expression\fR (see below), `.'
(matching any single character), `^' (matching the null string at the
beginning of a line), `$' (matching the null string at the
end of a line), a `\e' followed by one of the characters
`^.[$()|*+?{\e'
(matching that character taken as an ordinary character),
a `\e' followed by any other character\(dg
(matching that character taken as an ordinary character,
as if the `\e' had not been present\(dg),
or a single character with no other significance (matching that character).
A `{' followed by a character other than a digit is an ordinary
character, not the beginning of a bound\(dg.
It is illegal to end an RE with `\e'.
.PP
A \fIbracket expression\fR is a list of characters enclosed in `[]'.
It normally matches any single character from the list (but see below).
If the list begins with `^',
it matches any single character
(but see below) \fInot\fR from the rest of the list.
If two characters in the list are separated by `\-', this is shorthand
for the full \fIrange\fR of characters between those two (inclusive) in the
collating sequence,
e.g. `[0-9]' in ASCII matches any decimal digit.
It is illegal\(dg for two ranges to share an
endpoint, e.g. `a-c-e'.
Ranges are very collating-sequence-dependent,
and portable programs should avoid relying on them.
.PP
To include a literal `]' in the list, make it the first character
(following a possible `^').
To include a literal `\-', make it the first or last character,
or the second endpoint of a range.
To use a literal `\-' as the first endpoint of a range,
enclose it in `[.' and `.]' to make it a collating element (see below).
With the exception of these and some combinations using `[' (see next
paragraphs), all other special characters, including `\e', lose their
special significance within a bracket expression.
.PP
Within a bracket expression, a collating element (a character,
a multi-character sequence that collates as if it were a single character,
or a collating-sequence name for either)
enclosed in `[.' and `.]' stands for the
sequence of characters of that collating element.
The sequence is a single element of the bracket expression's list.
A bracket expression containing a multi-character collating element
can thus match more than one character,
e.g. if the collating sequence includes a `ch' collating element,
then the RE `[[.ch.]]*c' matches the first five characters
of `chchcc'.
.PP
Within a bracket expression, a collating element enclosed in `[=' and
`=]' is an equivalence class, standing for the sequences of characters
of all collating elements equivalent to that one, including itself.
(If there are no other equivalent collating elements,
the treatment is as if the enclosing delimiters were `[.' and `.]'.)
For example, if o and \o'o^' are the members of an equivalence class,
then `[[=o=]]', `[[=\o'o^'=]]', and `[o\o'o^']' are all synonymous.
An equivalence class may not\(dg be an endpoint
of a range.
.PP
Within a bracket expression, the name of a \fIcharacter class\fR enclosed
in `[:' and `:]' stands for the list of all characters belonging to that
class.
Standard character class names are:
.PP
.RS
.nf
.ta 3c 6c 9c
alnum digit punct
alpha graph space
blank lower upper
cntrl print xdigit
.fi
.RE
.PP
These stand for the character classes defined in
.BR ctype (3).
A locale may provide others.
A character class may not be used as an endpoint of a range.
.PP
There are two special cases\(dg of bracket expressions:
the bracket expressions `[[:<:]]' and `[[:>:]]' match the null string at
the beginning and end of a word respectively.
A word is defined as a sequence of
word characters
which is neither preceded nor followed by
word characters.
A word character is an
.B alnum
character (as defined by
.BR ctype (3))
or an underscore.
This is an extension,
compatible with but not specified by POSIX 1003.2,
and should be used with
caution in software intended to be portable to other systems.
.PP
In the event that an RE could match more than one substring of a given
string,
the RE matches the one starting earliest in the string.
If the RE could match more than one substring starting at that point,
it matches the longest.
Subexpressions also match the longest possible substrings, subject to
the constraint that the whole match be as long as possible,
with subexpressions starting earlier in the RE taking priority over
ones starting later.
Note that higher-level subexpressions thus take priority over
their lower-level component subexpressions.
.PP
Match lengths are measured in characters, not collating elements.
A null string is considered longer than no match at all.
For example,
`bb*' matches the three middle characters of `abbbc',
`(wee|week)(knights|nights)' matches all ten characters of `weeknights',
when `(.*).*' is matched against `abc' the parenthesized subexpression
matches all three characters, and
when `(a*)*' is matched against `bc' both the whole RE and the parenthesized
subexpression match the null string.
.PP
If case-independent matching is specified,
the effect is much as if all case distinctions had vanished from the
alphabet.
When an alphabetic that exists in multiple cases appears as an
ordinary character outside a bracket expression, it is effectively
transformed into a bracket expression containing both cases,
e.g. `x' becomes `[xX]'.
When it appears inside a bracket expression, all case counterparts
of it are added to the bracket expression, so that (e.g.) `[x]'
becomes `[xX]' and `[^x]' becomes `[^xX]'.
.PP
No particular limit is imposed on the length of REs\(dg.
Programs intended to be portable should not employ REs longer
than 256 bytes,
as an implementation can refuse to accept such REs and remain
POSIX-compliant.
.PP
Obsolete (``basic'') regular expressions differ in several respects.
`|', `+', and `?' are ordinary characters and there is no equivalent
for their functionality.
The delimiters for bounds are `\e{' and `\e}',
with `{' and `}' by themselves ordinary characters.
The parentheses for nested subexpressions are `\e(' and `\e)',
with `(' and `)' by themselves ordinary characters.
`^' is an ordinary character except at the beginning of the
RE or\(dg the beginning of a parenthesized subexpression,
`$' is an ordinary character except at the end of the
RE or\(dg the end of a parenthesized subexpression,
and `*' is an ordinary character if it appears at the beginning of the
RE or the beginning of a parenthesized subexpression
(after a possible leading `^').
Finally, there is one new type of atom, a \fIback reference\fR:
`\e' followed by a non-zero decimal digit \fId\fR
matches the same sequence of characters
matched by the \fId\fRth parenthesized subexpression
(numbering subexpressions by the positions of their opening parentheses,
left to right),
so that (e.g.) `\e([bc]\e)\e1' matches `bb' or `cc' but not `bc'.
.SH SEE ALSO
regex(3)
.PP
POSIX 1003.2, section 2.8 (Regular Expression Notation).
.SH BUGS
Having two kinds of REs is a botch.
.PP
The current 1003.2 spec says that `)' is an ordinary character in
the absence of an unmatched `(';
this was an unintentional result of a wording error,
and change is likely.
Avoid relying on it.
.PP
Back references are a dreadful botch,
posing major problems for efficient implementations.
They are also somewhat vaguely defined
(does
`a\e(\e(b\e)*\e2\e)*d' match `abbbd'?).
Avoid using them.
.PP
1003.2's specification of case-independent matching is vague.
The ``one case implies all cases'' definition given above
is current consensus among implementors as to the right interpretation.
.PP
The syntax for word boundaries is incredibly ugly.