diff options
Diffstat (limited to 'man1p')
-rw-r--r-- | man1p/admin.1p | 436 | ||||
-rw-r--r-- | man1p/alias.1p | 212 | ||||
-rw-r--r-- | man1p/ar.1p | 603 | ||||
-rw-r--r-- | man1p/asa.1p | 187 | ||||
-rw-r--r-- | man1p/at.1p | 706 | ||||
-rw-r--r-- | man1p/awk.1p | 2984 | ||||
-rw-r--r-- | man1p/basename.1p | 239 | ||||
-rw-r--r-- | man1p/batch.1p | 238 | ||||
-rw-r--r-- | man1p/bc.1p | 1354 | ||||
-rw-r--r-- | man1p/bg.1p | 205 | ||||
-rw-r--r-- | man1p/break.1p | 120 | ||||
-rw-r--r-- | man1p/c99.1p | 745 | ||||
-rw-r--r-- | man1p/cal.1p | 144 | ||||
-rw-r--r-- | man1p/cat.1p | 276 | ||||
-rw-r--r-- | man1p/cd.1p | 350 | ||||
-rw-r--r-- | man1p/cflow.1p | 250 | ||||
-rw-r--r-- | man1p/chgrp.1p | 212 | ||||
-rw-r--r-- | man1p/chmod.1p | 488 | ||||
-rw-r--r-- | man1p/chown.1p | 264 | ||||
-rw-r--r-- | man1p/cksum.1p | 351 | ||||
-rw-r--r-- | man1p/cmp.1p | 241 | ||||
-rw-r--r-- | man1p/colon.1p | 102 | ||||
-rw-r--r-- | man1p/comm.1p | 252 | ||||
-rw-r--r-- | man1p/command.1p | 484 | ||||
-rw-r--r-- | man1p/compress.1p | 216 | ||||
-rw-r--r-- | man1p/continue.1p | 102 | ||||
-rw-r--r-- | man1p/cp.1p | 634 | ||||
-rw-r--r-- | man1p/crontab.1p | 321 | ||||
-rw-r--r-- | man1p/csplit.1p | 269 | ||||
-rw-r--r-- | man1p/ctags.1p | 414 | ||||
-rw-r--r-- | man1p/cut.1p | 362 | ||||
-rw-r--r-- | man1p/cxref.1p | 181 | ||||
-rw-r--r-- | man1p/date.1p | 572 | ||||
-rw-r--r-- | man1p/dd.1p | 588 | ||||
-rw-r--r-- | man1p/delta.1p | 272 | ||||
-rw-r--r-- | man1p/df.1p | 296 | ||||
-rw-r--r-- | man1p/diff.1p | 646 | ||||
-rw-r--r-- | man1p/dirname.1p | 214 | ||||
-rw-r--r-- | man1p/dot.1p | 103 | ||||
-rw-r--r-- | man1p/du.1p | 244 | ||||
-rw-r--r-- | man1p/echo.1p | 246 | ||||
-rw-r--r-- | man1p/ed.1p | 1462 | ||||
-rw-r--r-- | man1p/env.1p | 233 | ||||
-rw-r--r-- | man1p/eval.1p | 90 | ||||
-rw-r--r-- | man1p/ex.1p | 6056 | ||||
-rw-r--r-- | man1p/exec.1p | 157 | ||||
-rw-r--r-- | man1p/exit.1p | 118 | ||||
-rw-r--r-- | man1p/expand.1p | 161 | ||||
-rw-r--r-- | man1p/export.1p | 160 | ||||
-rw-r--r-- | man1p/expr.1p | 411 | ||||
-rw-r--r-- | man1p/false.1p | 75 | ||||
-rw-r--r-- | man1p/fc.1p | 476 | ||||
-rw-r--r-- | man1p/fg.1p | 152 | ||||
-rw-r--r-- | man1p/file.1p | 786 | ||||
-rw-r--r-- | man1p/find.1p | 696 | ||||
-rw-r--r-- | man1p/fold.1p | 225 | ||||
-rw-r--r-- | man1p/fort77.1p | 500 | ||||
-rw-r--r-- | man1p/fuser.1p | 200 | ||||
-rw-r--r-- | man1p/gencat.1p | 237 | ||||
-rw-r--r-- | man1p/get.1p | 737 | ||||
-rw-r--r-- | man1p/getconf.1p | 459 | ||||
-rw-r--r-- | man1p/getopts.1p | 349 | ||||
-rw-r--r-- | man1p/grep.1p | 450 | ||||
-rw-r--r-- | man1p/hash.1p | 184 | ||||
-rw-r--r-- | man1p/head.1p | 176 | ||||
-rw-r--r-- | man1p/iconv.1p | 258 | ||||
-rw-r--r-- | man1p/id.1p | 323 | ||||
-rw-r--r-- | man1p/ipcrm.1p | 154 | ||||
-rw-r--r-- | man1p/ipcs.1p | 559 | ||||
-rw-r--r-- | man1p/jobs.1p | 313 | ||||
-rw-r--r-- | man1p/join.1p | 410 | ||||
-rw-r--r-- | man1p/kill.1p | 393 | ||||
-rw-r--r-- | man1p/lex.1p | 954 | ||||
-rw-r--r-- | man1p/link.1p | 127 | ||||
-rw-r--r-- | man1p/ln.1p | 262 | ||||
-rw-r--r-- | man1p/locale.1p | 441 | ||||
-rw-r--r-- | man1p/localedef.1p | 307 | ||||
-rw-r--r-- | man1p/logger.1p | 160 | ||||
-rw-r--r-- | man1p/logname.1p | 129 | ||||
-rw-r--r-- | man1p/lp.1p | 388 | ||||
-rw-r--r-- | man1p/ls.1p | 737 | ||||
-rw-r--r-- | man1p/m4.1p | 556 | ||||
-rw-r--r-- | man1p/mailx.1p | 2208 | ||||
-rw-r--r-- | man1p/make.1p | 1753 | ||||
-rw-r--r-- | man1p/man.1p | 244 | ||||
-rw-r--r-- | man1p/mesg.1p | 160 | ||||
-rw-r--r-- | man1p/mkdir.1p | 194 | ||||
-rw-r--r-- | man1p/mkfifo.1p | 163 | ||||
-rw-r--r-- | man1p/more.1p | 1069 | ||||
-rw-r--r-- | man1p/mv.1p | 376 | ||||
-rw-r--r-- | man1p/newgrp.1p | 267 | ||||
-rw-r--r-- | man1p/nice.1p | 253 | ||||
-rw-r--r-- | man1p/nl.1p | 285 | ||||
-rw-r--r-- | man1p/nm.1p | 392 | ||||
-rw-r--r-- | man1p/nohup.1p | 215 | ||||
-rw-r--r-- | man1p/od.1p | 642 | ||||
-rw-r--r-- | man1p/paste.1p | 300 | ||||
-rw-r--r-- | man1p/patch.1p | 509 | ||||
-rw-r--r-- | man1p/pathchk.1p | 358 | ||||
-rw-r--r-- | man1p/pax.1p | 2952 | ||||
-rw-r--r-- | man1p/pr.1p | 414 | ||||
-rw-r--r-- | man1p/printf.1p | 426 | ||||
-rw-r--r-- | man1p/prs.1p | 401 | ||||
-rw-r--r-- | man1p/ps.1p | 598 | ||||
-rw-r--r-- | man1p/pwd.1p | 156 | ||||
-rw-r--r-- | man1p/qalter.1p | 790 | ||||
-rw-r--r-- | man1p/qdel.1p | 175 | ||||
-rw-r--r-- | man1p/qhold.1p | 230 | ||||
-rw-r--r-- | man1p/qmove.1p | 154 | ||||
-rw-r--r-- | man1p/qmsg.1p | 214 | ||||
-rw-r--r-- | man1p/qrerun.1p | 146 | ||||
-rw-r--r-- | man1p/qrls.1p | 236 | ||||
-rw-r--r-- | man1p/qselect.1p | 763 | ||||
-rw-r--r-- | man1p/qsig.1p | 190 | ||||
-rw-r--r-- | man1p/qstat.1p | 368 | ||||
-rw-r--r-- | man1p/qsub.1p | 1024 | ||||
-rw-r--r-- | man1p/read.1p | 214 | ||||
-rw-r--r-- | man1p/readonly.1p | 151 | ||||
-rw-r--r-- | man1p/renice.1p | 251 | ||||
-rw-r--r-- | man1p/return.1p | 94 | ||||
-rw-r--r-- | man1p/rm.1p | 354 | ||||
-rw-r--r-- | man1p/rmdel.1p | 154 | ||||
-rw-r--r-- | man1p/rmdir.1p | 177 | ||||
-rw-r--r-- | man1p/sact.1p | 174 | ||||
-rw-r--r-- | man1p/sccs.1p | 411 | ||||
-rw-r--r-- | man1p/sed.1p | 733 | ||||
-rw-r--r-- | man1p/set.1p | 592 | ||||
-rw-r--r-- | man1p/sh.1p | 1358 | ||||
-rw-r--r-- | man1p/shift.1p | 93 | ||||
-rw-r--r-- | man1p/sleep.1p | 173 | ||||
-rw-r--r-- | man1p/sort.1p | 512 | ||||
-rw-r--r-- | man1p/split.1p | 258 | ||||
-rw-r--r-- | man1p/strings.1p | 222 | ||||
-rw-r--r-- | man1p/strip.1p | 128 | ||||
-rw-r--r-- | man1p/stty.1p | 697 | ||||
-rw-r--r-- | man1p/tabs.1p | 263 | ||||
-rw-r--r-- | man1p/tail.1p | 249 | ||||
-rw-r--r-- | man1p/talk.1p | 278 | ||||
-rw-r--r-- | man1p/tee.1p | 174 | ||||
-rw-r--r-- | man1p/test.1p | 757 | ||||
-rw-r--r-- | man1p/time.1p | 278 | ||||
-rw-r--r-- | man1p/times.1p | 102 | ||||
-rw-r--r-- | man1p/touch.1p | 344 | ||||
-rw-r--r-- | man1p/tput.1p | 228 | ||||
-rw-r--r-- | man1p/tr.1p | 538 | ||||
-rw-r--r-- | man1p/trap.1p | 240 | ||||
-rw-r--r-- | man1p/true.1p | 91 | ||||
-rw-r--r-- | man1p/tsort.1p | 154 | ||||
-rw-r--r-- | man1p/tty.1p | 147 | ||||
-rw-r--r-- | man1p/type.1p | 137 | ||||
-rw-r--r-- | man1p/ulimit.1p | 173 | ||||
-rw-r--r-- | man1p/umask.1p | 310 | ||||
-rw-r--r-- | man1p/unalias.1p | 146 | ||||
-rw-r--r-- | man1p/uname.1p | 200 | ||||
-rw-r--r-- | man1p/uncompress.1p | 163 | ||||
-rw-r--r-- | man1p/unexpand.1p | 182 | ||||
-rw-r--r-- | man1p/unget.1p | 174 | ||||
-rw-r--r-- | man1p/uniq.1p | 297 | ||||
-rw-r--r-- | man1p/unlink.1p | 124 | ||||
-rw-r--r-- | man1p/unset.1p | 142 | ||||
-rw-r--r-- | man1p/uucp.1p | 263 | ||||
-rw-r--r-- | man1p/uudecode.1p | 179 | ||||
-rw-r--r-- | man1p/uuencode.1p | 352 | ||||
-rw-r--r-- | man1p/uustat.1p | 159 | ||||
-rw-r--r-- | man1p/uux.1p | 295 | ||||
-rw-r--r-- | man1p/val.1p | 229 | ||||
-rw-r--r-- | man1p/vi.1p | 4963 | ||||
-rw-r--r-- | man1p/wait.1p | 314 | ||||
-rw-r--r-- | man1p/wc.1p | 230 | ||||
-rw-r--r-- | man1p/what.1p | 185 | ||||
-rw-r--r-- | man1p/who.1p | 311 | ||||
-rw-r--r-- | man1p/write.1p | 219 | ||||
-rw-r--r-- | man1p/xargs.1p | 515 | ||||
-rw-r--r-- | man1p/yacc.1p | 1285 | ||||
-rw-r--r-- | man1p/zcat.1p | 124 |
175 files changed, 79029 insertions, 0 deletions
diff --git a/man1p/admin.1p b/man1p/admin.1p new file mode 100644 index 000000000..28fe5afb5 --- /dev/null +++ b/man1p/admin.1p @@ -0,0 +1,436 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ADMIN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" admin +.SH NAME +admin \- create and administer SCCS files (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBadmin -i\fP\fB[\fP\fIname\fP\fB][\fP\fB-n\fP\fB][\fP\fB-a\fP +\fIlogin\fP\fB][\fP\fB-d\fP \fIflag\fP\fB][\fP\fB-e\fP \fIlogin\fP\fB][\fP\fB-f\fP +\fIflag\fP\fB][\fP\fB-m\fP +\fImrlist\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-r\fP +\fIrel\fP\fB][\fP\fB-t\fP\fB[\fP\fIname\fP\fB][\fP\fB-y\fP\fB[\fP\fIcomment\fP\fB]]\fP +\fInewfile\fP\fB +.br +.sp +admin -n\fP\fB[\fP\fB-a\fP \fIlogin\fP\fB][\fP\fB-d\fP \fIflag\fP\fB][\fP\fB-e\fP +\fIlogin\fP\fB][\fP\fB-f\fP +\fIflag\fP\fB][\fP\fB-m\fP \fImrlist\fP\fB][\fP\fB-t\fP\fB[\fP\fIname\fP\fB]]\fP\fB +.br +\ \ \ \ \ \ \fP \fB[\fP\fB-y\fP\fB[\fP\fIcomment\fP\fB]]\fP \fInewfile\fP +\fB\&... +.br +.sp +admin\fP \fB[\fP\fB-a\fP \fIlogin\fP\fB][\fP\fB-d\fP \fIflag\fP\fB][\fP\fB-m\fP +\fImrlist\fP\fB][\fP\fB-r\fP +\fIrel\fP\fB][\fP\fB-t\fP\fB[\fP\fIname\fP\fB]]\fP \fB\fP\fIfile\fP +\fB\&... +.br +.sp +admin -h\fP \fIfile\fP \fB... +.br +.sp +admin -z\fP \fIfile\fP \fB... \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIadmin\fP utility shall create new SCCS files or change parameters +of existing ones. If a named file does not exist, it +shall be created, and its parameters shall be initialized according +to the specified options. Parameters not initialized by an +option shall be assigned a default value. If a named file does exist, +parameters corresponding to specified options shall be +changed, and other parameters shall be left as is. +.LP +All SCCS filenames supplied by the application shall be of the form +s.\fIfilename\fP. New SCCS files shall be given read-only +permission mode. Write permission in the parent directory is required +to create a file. All writing done by \fIadmin\fP shall be +to a temporary \fIx-file\fP, named x.\fIfilename\fP (see \fIget\fP +) created with read-only mode if +\fIadmin\fP is creating a new SCCS file, or created with the same +mode as that of the SCCS file if the file already exists. After +successful execution of \fIadmin\fP, the SCCS file shall be removed +(if it exists), and the \fIx-file\fP shall be renamed with +the name of the SCCS file. This ensures that changes are made to the +SCCS file only if no errors occur. +.LP +The \fIadmin\fP utility shall also use a transient lock file (named +z.\fIfilename\fP), which is used to prevent simultaneous +updates to the SCCS file; see \fIget\fP . +.SH OPTIONS +.LP +The \fIadmin\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the \fB-i\fP, \fB-t\fP, and +\fB-y\fP options have optional option-arguments. These optional option-arguments +shall not be presented as separate arguments. The +following options are supported: +.TP 7 +\fB-n\fP +Create a new SCCS file. When \fB-n\fP is used without \fB-i\fP, the +SCCS file shall be created with control information but +without any file data. +.TP 7 +\fB-i[\fP\fIname\fP\fB]\fP +Specify the \fIname\fP of a file from which the text for a new SCCS +file shall be taken. The text constitutes the first delta +of the file (see the \fB-r\fP option for the delta numbering scheme). +If the \fB-i\fP option is used, but the \fIname\fP +option-argument is omitted, the text shall be obtained by reading +the standard input. If this option is omitted, the SCCS file +shall be created with control information but without any file data. +The \fB-i\fP option implies the \fB-n\fP option. +.TP 7 +\fB-r\ \fP \fISID\fP +Specify the SID of the initial delta to be inserted. This SID shall +be a trunk SID; that is, the branch and sequence numbers +shall be zero or missing. The level number is optional, and defaults +to 1. +.TP 7 +\fB-t[\fP\fIname\fP\fB]\fP +Specify the \fIname\fP of a file from which descriptive text for the +SCCS file shall be taken. In the case of existing SCCS +files (neither \fB-i\fP nor \fB-n\fP is specified): +.RS +.IP " *" 3 +A \fB-t\fP option without a \fIname\fP option-argument shall cause +the removal of descriptive text (if any) currently in the +SCCS file. +.LP +.IP " *" 3 +A \fB-t\fP option with a \fIname\fP option-argument shall cause the +text (if any) in the named file to replace the descriptive +text (if any) currently in the SCCS file. +.LP +.RE +.TP 7 +\fB-f\ \fP \fIflag\fP +Specify a \fIflag\fP, and, possibly, a value for the \fIflag\fP, to +be placed in the SCCS file. Several \fB-f\fP options may +be supplied on a single \fIadmin\fP command line. Implementations +shall recognize the following flags and associated values: +.TP 7 +\fBb\fP +.RS +Allow use of the \fB-b\fP option on a \fIget\fP command to create +branch deltas. +.RE +.TP 7 +\fBc\fP\fIceil\fP +.RS +Specify the highest release (that is, ceiling), a number less than +or equal to 9999, which may be retrieved by a \fIget\fP command for +editing. The default value for an unspecified \fBc\fP flag shall be +9999. +.RE +.TP 7 +\fBf\fP\fIfloor\fP +.RS +Specify the lowest release (that is, floor), a number greater than +0 but less than 9999, which may be retrieved by a \fIget\fP command +for editing. The default value for an unspecified \fBf\fP flag shall +be 1. +.RE +.TP 7 +\fBd\fP\fISID\fP +.RS +Specify the default delta number (SID) to be used by a \fIget\fP command. +.RE +.TP 7 +\fBi\fP\fIstr\fP +.RS +Treat the "No ID keywords" message issued by \fIget\fP or \fIdelta\fP +as a fatal error. In the absence of this flag, the message is only +a warning. The +message is issued if no SCCS identification keywords (see \fIget\fP +) are found in the text retrieved or +stored in the SCCS file. If a value is supplied, the application shall +ensure that the keywords exactly match the given string; +however, the string shall contain a keyword, and no embedded <newline>s. +.RE +.TP 7 +\fBj\fP +.RS +Allow concurrent \fIget\fP commands for editing on the same SID of +an SCCS file. This +allows multiple concurrent updates to the same version of the SCCS +file. +.RE +.TP 7 +\fBl\fP\fIlist\fP +.RS +Specify a \fIlist\fP of releases to which deltas can no longer be +made (that is, \fIget\fP \fB-e\fP against one of these locked releases +fails). Conforming applications shall use the +following syntax to specify a \fIlist\fP. Implementations may accept +additional forms as an extension: +.sp +.RS +.nf + +\fB<list> ::= a | <range-list> +<range-list> ::= <range> | <range-list>, <range> +<range> ::= <SID> +\fP +.fi +.RE +.LP +The character \fIa\fP in the \fIlist\fP shall be equivalent to specifying +all releases for the named SCCS file. The +non-terminal <\fISID\fP> in range shall be the delta number of an +existing delta associated with the SCCS file. +.RE +.TP 7 +\fBn\fP +.RS +Cause \fIdelta\fP to create a null delta in each of those releases +(if any) being +skipped when a delta is made in a new release (for example, in making +delta 5.1 after delta 2.7, releases 3 and 4 are skipped). +These null deltas shall serve as anchor points so that branch deltas +may later be created from them. The absence of this flag shall +cause skipped releases to be nonexistent in the SCCS file, preventing +branch deltas from being created from them in the future. +During the initial creation of an SCCS file, the \fBn\fP flag may +be ignored; that is, if the \fB-r\fP option is used to set the +release number of the initial SID to a value greater than 1, null +deltas need not be created for the "skipped" releases. +.RE +.TP 7 +\fBq\fP\fItext\fP +.RS +Substitute user-definable \fItext\fP for all occurrences of the %\fBQ\fP% +keyword in the SCCS file text retrieved by \fIget\fP. +.RE +.TP 7 +\fBm\fP\fImod\fP +.RS +Specify the module name of the SCCS file substituted for all occurrences +of the %\fBM\fP% keyword in the SCCS file text +retrieved by \fIget\fP. If the \fBm\fP flag is not specified, the +value assigned shall be the +name of the SCCS file with the leading \fB'.'\fP removed. +.RE +.TP 7 +\fBt\fP\fItype\fP +.RS +Specify the \fItype\fP of module in the SCCS file substituted for +all occurrences of the %\fBY\fP% keyword in the SCCS file +text retrieved by \fIget\fP. +.RE +.TP 7 +\fBv\fP\fIpgm\fP +.RS +Cause \fIdelta\fP to prompt for modification request (MR) numbers +as the reason for +creating a delta. The optional value specifies the name of an MR number +validation program. (If this flag is set when creating an +SCCS file, the application shall ensure that the \fBm\fP option is +also used even if its value is null.) +.RE +.sp +.TP 7 +\fB-d\ \fP \fIflag\fP +Remove (delete) the specified \fIflag\fP from an SCCS file. Several +\fB-d\fP options may be supplied on a single \fIadmin\fP +command. See the \fB-f\fP option for allowable \fIflag\fP names. (The +\fBl\fP \fIlist\fP flag gives a \fIlist\fP of releases +to be unlocked. See the \fB-f\fP option for further description of +the \fBl\fP flag and the syntax of a \fIlist\fP.) +.TP 7 +\fB-a\ \fP \fIlogin\fP +Specify a \fIlogin\fP name, or numerical group ID, to be added to +the list of users who may make deltas (changes) to the SCCS +file. A group ID shall be equivalent to specifying all \fIlogin\fP +names common to that group ID. Several \fB-a\fP options may be +used on a single \fIadmin\fP command line. As many \fIlogin\fPs, or +numerical group IDs, as desired may be on the list +simultaneously. If the list of users is empty, then anyone may add +deltas. If \fIlogin\fP or group ID is preceded by a +\fB'!'\fP , the users so specified shall be denied permission to make +deltas. +.TP 7 +\fB-e\ \fP \fIlogin\fP +Specify a \fIlogin\fP name, or numerical group ID, to be erased from +the list of users allowed to make deltas (changes) to the +SCCS file. Specifying a group ID is equivalent to specifying all \fIlogin\fP +names common to that group ID. Several \fB-e\fP +options may be used on a single \fIadmin\fP command line. +.TP 7 +\fB-y[\fP\fIcomment\fP\fB]\fP +Insert the \fIcomment\fP text into the SCCS file as a comment for +the initial delta in a manner identical to that of \fIdelta\fP. In +the POSIX locale, omission of the \fB-y\fP option shall result in +a default comment +line being inserted in the form: +.sp +.RS +.nf + +\fB"date and time created %s %s by %s", <\fP\fIdate\fP\fB>, <\fP\fItime\fP\fB>, <\fP\fIlogin\fP\fB> +\fP +.fi +.RE +.LP +where <\fIdate\fP> is expressed in the format of the \fIdate\fP utility's +\fB%y\fP / \fB%m\fP / \fB%d\fP conversion specification, <\fItime\fP> +in the format of the \fIdate\fP utility's \fB%T\fP conversion specification +format, and <\fIlogin\fP> is the +login name of the user creating the file. +.TP 7 +\fB-m\ \fP \fImrlist\fP +Insert the list of modification request (MR) numbers into the SCCS +file as the reason for creating the initial delta in a +manner identical to \fIdelta\fP. The application shall ensure that +the \fBv\fP flag is set +and the MR numbers are validated if the \fBv\fP flag has a value (the +name of an MR number validation program). A diagnostic +message shall be written if the \fBv\fP flag is not set or MR validation +fails. +.TP 7 +\fB-h\fP +Check the structure of the SCCS file and compare the newly computed +checksum with the checksum that is stored in the SCCS file. +If the newly computed checksum does not match the checksum in the +SCCS file, a diagnostic message shall be written. +.TP 7 +\fB-z\fP +Recompute the SCCS file checksum and store it in the first line of +the SCCS file (see the \fB-h\fP option above). Note that +use of this option on a truly corrupted file may prevent future detection +of the corruption. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file or a directory. If \fIfile\fP +is a directory, the \fIadmin\fP utility shall behave as +though each file in the directory were specified as a named file, +except that non-SCCS files (last component of the pathname does +not begin with \fBs.\fP) and unreadable files shall be silently ignored. +.TP 7 +\fInewfile\fP +A pathname of an SCCS file to be created. +.sp +.LP +If exactly one \fIfile\fP or \fInewfile\fP operand appears, and it +is \fB'-'\fP , the standard input shall be read; each +line of the standard input shall be taken to be the name of an SCCS +file to be processed. Non-SCCS files and unreadable files shall +be silently ignored. +.SH STDIN +.LP +The standard input shall be a text file used only if \fB-i\fP is specified +without an option-argument or if a \fIfile\fP or +\fInewfile\fP operand is specified as \fB'-'\fP . If the first character +of any standard input line is <SOH> in the POSIX +locale, the results are unspecified. +.SH INPUT FILES +.LP +The existing SCCS files shall be text files of an unspecified format. +.LP +The application shall ensure that the file named by the \fB-i\fP option's +\fIname\fP option-argument shall be a text file; if +the first character of any line in this file is <SOH> in the POSIX +locale, the results are unspecified. If this file contains +more than 99999 lines, the number of lines recorded in the header +for this file shall be 99999 for this delta. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIadmin\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +the contents of the default \fB-y\fP comment. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Any SCCS files created shall be text files of an unspecified format. +During processing of a \fIfile\fP, a locking +\fIz-file\fP, as described in \fIget\fP , may be created and deleted. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +It is recommended that directories containing SCCS files be writable +by the owner only, and that SCCS files themselves be +read-only. The mode of the directories should allow only the owner +to modify SCCS files contained in the directories. The mode of +the SCCS files prevents any modification at all except by SCCS commands. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIdelta\fP , \fIget\fP , \fIprs\fP , \fIwhat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/alias.1p b/man1p/alias.1p new file mode 100644 index 000000000..a5fb510f7 --- /dev/null +++ b/man1p/alias.1p @@ -0,0 +1,212 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ALIAS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" alias +.SH NAME +alias \- define or display aliases +.SH SYNOPSIS +.LP +\fBalias\fP \fB[\fP\fIalias-name\fP\fB[\fP\fB=\fP\fIstring\fP\fB]\fP +\fB\&...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIalias\fP utility shall create or redefine alias definitions +or write the values of existing alias definitions to +standard output. An alias definition provides a string value that +shall replace a command name when it is encountered; see \fIAlias +Substitution\fP . +.LP +An alias definition shall affect the current shell execution environment +and the execution environments of the subshells of the +current shell. When used as specified by this volume of IEEE\ Std\ 1003.1-2001, +the alias definition shall not affect the +parent process of the current shell nor any utility environment invoked +by the shell; see \fIShell Execution Environment\fP . +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIalias-name\fP +Write the alias definition to standard output. +.TP 7 +\fIalias-name\fP=\fIstring\fP +.sp +Assign the value of \fIstring\fP to the alias \fIalias-name\fP. +.sp +.LP +If no operands are given, all alias definitions shall be written to +standard output. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIalias\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The format for displaying aliases (when no operands or only \fIname\fP +operands are specified) shall be: +.sp +.RS +.nf + +\fB"%s=%s\\n",\fP \fIname\fP\fB,\fP \fIvalue\fP +.fi +.RE +.LP +The \fIvalue\fP string shall be written with appropriate quoting so +that it is suitable for reinput to the shell. See the +description of shell quoting in \fIQuoting\fP . +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +One of the \fIname\fP operands specified did not have an alias definition, +or an error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.IP " 1." 4 +Change \fIls\fP to give a columnated, more annotated output: +.sp +.RS +.nf + +\fBalias ls="ls -CF" +\fP +.fi +.RE +.LP +.IP " 2." 4 +Create a simple "redo" command to repeat previous entries in the command +history file: +.sp +.RS +.nf + +\fBalias r='fc -s' +\fP +.fi +.RE +.LP +.IP " 3." 4 +Use 1K units for \fIdu\fP: +.sp +.RS +.nf + +\fBalias du=du\\ -k +\fP +.fi +.RE +.LP +.IP " 4." 4 +Set up \fInohup\fP so that it can deal with an argument that is itself +an alias name: +.sp +.RS +.nf + +\fBalias nohup="nohup " +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fIalias\fP description is based on historical KornShell implementations. +Known differences exist between that and the C +shell. The KornShell version was adopted to be consistent with all +the other KornShell features in this volume of +IEEE\ Std\ 1003.1-2001, such as command line editing. +.LP +Since \fIalias\fP affects the current shell execution environment, +it is generally provided as a shell regular built-in. +.LP +Historical versions of the KornShell have allowed aliases to be exported +to scripts that are invoked by the same shell. This is +triggered by the \fIalias\fP \fB-x\fP flag; it is allowed by this +volume of IEEE\ Std\ 1003.1-2001 only when an explicit +extension such as \fB-x\fP is used. The standard developers considered +that aliases were of use primarily to interactive users and +that they should normally not affect shell scripts called by those +users; functions are available to such scripts. +.LP +Historical versions of the KornShell had not written aliases in a +quoted manner suitable for reentry to the shell, but this +volume of IEEE\ Std\ 1003.1-2001 has made this a requirement for all +similar output. Therefore, consistency with this +volume of IEEE\ Std\ 1003.1-2001 was chosen over this detail of historical +practice. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIFunction Definition Command\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ar.1p b/man1p/ar.1p new file mode 100644 index 000000000..bf9db7100 --- /dev/null +++ b/man1p/ar.1p @@ -0,0 +1,603 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "AR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ar +.SH NAME +ar \- create and maintain library archives +.SH SYNOPSIS +.LP +\fBar -d\fP\fB[\fP\fB-v\fP\fB]\fP \fIarchive file\fP \fB... \fP +\fB +.br +.sp +\fP +.LP +\fBar -m\fP \fB[\fP\fB-v\fP\fB]\fP \fIarchive file\fP \fB... +.br +.sp +ar -m -a\fP\fB[\fP\fB-v\fP\fB]\fP \fIposname archive file\fP \fB... +.br +.sp +ar -m -b\fP\fB[\fP\fB-v\fP\fB]\fP \fIposname archive file\fP \fB... +.br +.sp +ar -m -i\fP\fB[\fP\fB-v\fP\fB]\fP \fIposname archive file\fP \fB... +\fP +\fB +.br +.sp +ar -p\fP\fB[\fP\fB-v\fP\fB][\fP\fB-s\fP\fB]\fP\fIarchive\fP \fB[\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +.sp +\fP +.LP +\fBar -q\fP\fB[\fP\fB-cv\fP\fB]\fP \fIarchive file\fP \fB... \fP +\fB +.br +.sp +ar -r\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIarchive file\fP \fB... +.br +.sp +\fP +.LP +\fBar -r -a\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIposname archive file\fP +\fB\&... +.br +.sp +ar -r -b\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIposname archive file\fP \fB... +.br +.sp +ar -r -i\fP\fB[\fP\fB-cuv\fP\fB]\fP \fIposname archive file\fP \fB... +\fP +\fB +.br +.sp +ar -t\fP\fB[\fP\fB-v\fP\fB][\fP\fB-s\fP\fB]\fP\fIarchive\fP \fB[\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +.sp +ar -x\fP\fB[\fP\fB-v\fP\fB][\fP\fB-sCT\fP\fB]\fP\fIarchive\fP \fB[\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIar\fP utility is part of the Software Development Utilities +option. +.LP +The \fIar\fP utility can be used to create and maintain groups of +files combined into an archive. Once an archive has been +created, new files can be added, and existing files in an archive +can be extracted, deleted, or replaced. When an archive consists +entirely of valid object files, the implementation shall format the +archive so that it is usable as a library for link editing (see +\fIc99\fP and \fIfort77\fP). When some of the archived +files are not valid object files, the suitability of the archive for +library use is undefined. \ If an +archive consists entirely of printable files, the entire archive shall +be printable. +.LP +When \fIar\fP creates an archive, it creates administrative information +indicating whether a symbol table is present in the +archive. When there is at least one object file that \fIar\fP recognizes +as such in the archive, an archive symbol table shall be +created in the archive and maintained by \fIar\fP; it is used by the +link editor to search the archive. Whenever the \fIar\fP +utility is used to create or update the contents of such an archive, +the symbol table shall be rebuilt. The \fB-s\fP option shall +force the symbol table to be rebuilt. +.LP +All \fIfile\fP operands can be pathnames. However, files within archives +shall be named by a filename, which is the last +component of the pathname used when the file was entered into the +archive. The comparison of \fIfile\fP operands to the names of +files in archives shall be performed by comparing the last component +of the operand to the name of the file in the archive. +.LP +It is unspecified whether multiple files in the archive may be identically +named. In the case of such files, however, each +\fIfile\fP \ and \fIposname\fP operand shall match only the +first file in the archive having a name that is the same as the last +component of the operand. +.SH OPTIONS +.LP +The \fIar\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Position new files in the archive after the file named by the \fIposname\fP +operand. +.TP 7 +\fB-b\fP +Position new files in the archive before the file named by the \fIposname\fP +operand. +.TP 7 +\fB-c\fP +Suppress the diagnostic message that is written to standard error +by default when the archive \fIarchive\fP is created. +.TP 7 +\fB-C\fP +Prevent extracted files from replacing like-named files in the file +system. This option is useful when \fB-T\fP is also used, to +prevent truncated filenames from replacing files with the same prefix. +.TP 7 +\fB-d\fP +Delete one or more \fIfile\fPs from \fIarchive\fP. +.TP 7 +\fB-i\fP +Position new files in the archive before the file in the archive named +by the \fIposname\fP operand (equivalent to \fB-b\fP). +.TP 7 +\fB-m\fP +Move the named files in the archive. The \fB-a\fP, \fB-b\fP, or \fB-i\fP +options with the \fIposname\fP operand indicate the +position; otherwise, move the names files in the archive to the end +of the archive. +.TP 7 +\fB-p\fP +Write the contents of the \fIfile\fPs in the archive named by \fIfile\fP +operands from \fIarchive\fP to the standard output. +If no \fIfile\fP operands are specified, the contents of all files +in the archive shall be written in the order of the +archive. +.TP 7 +\fB-q\fP +Append the named files to the end of the archive. In this case \fIar\fP +does not check whether the added files are already in the +archive. This is useful to bypass the searching otherwise done when +creating a large archive piece by piece. +.TP 7 +\fB-r\fP +Replace or add \fIfile\fPs to \fIarchive\fP. If the archive named +by \fIarchive\fP does not exist, a new archive shall be +created and a diagnostic message shall be written to standard error +(unless the \fB-c\fP option is specified). If no \fIfile\fPs +are specified and the \fIarchive\fP exists, the results are undefined. +Files that replace existing files in the archive shall not +change the order of the archive. Files that do not replace existing +files in the archive shall be appended to the archive \ unless +a \fB-a\fP, \fB-b\fP, or \fB-i\fP option specifies another position. +.TP 7 +\fB-s\fP +Force the regeneration of the archive symbol table even if \fIar\fP +is not invoked with an option that modifies the archive +contents. This option is useful to restore the archive symbol table +after it has been stripped; see \fIstrip\fP. +.TP 7 +\fB-t\fP +Write a table of contents of \fIarchive\fP to the standard output. +The files specified by the \fIfile\fP operands shall be +included in the written list. If no \fIfile\fP operands are specified, +all files in \fIarchive\fP shall be included in the order +of the archive. +.TP 7 +\fB-T\fP +Allow filename truncation of extracted files whose archive names are +longer than the file system can support. By default, +extracting a file with a name that is too long shall be an error; +a diagnostic message shall be written and the file shall not be +extracted. +.TP 7 +\fB-u\fP +Update older files in the archive. When used with the \fB-r\fP option, +files in the archive shall be replaced only if the +corresponding \fIfile\fP has a modification time that is at least +as new as the modification time of the file in the archive. +.TP 7 +\fB-v\fP +Give verbose output. When used with the option characters \fB-d\fP, +\fB-r\fP, or \fB-x\fP, write a detailed file-by-file +description of the archive creation and maintenance activity, as described +in the STDOUT section. +.LP +When used with \fB-p\fP, write the name of the file in the archive +to the standard output before writing the file in the +archive itself to the standard output, as described in the STDOUT +section. +.LP +When used with \fB-t\fP, include a long listing of information about +the files in the archive, as described in the STDOUT +section. +.TP 7 +\fB-x\fP +Extract the files in the archive named by the \fIfile\fP operands +from \fIarchive\fP. The contents of the archive shall not +be changed. If no \fIfile\fP operands are given, all files in the +archive shall be extracted. The modification time of each file +extracted shall be set to the time the file is extracted from the +archive. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIarchive\fP +A pathname of the archive. +.TP 7 +\fIfile\fP +A pathname. Only the last component shall be used when comparing against +the names of files in the archive. If two or more +\fIfile\fP operands have the same last pathname component (basename), +the results are unspecified. The implementation's archive +format shall not truncate valid filenames of files added to or replaced +in the archive. +.TP 7 +\fIposname\fP +The name of a file in the archive, used for relative positioning; +see options \fB-m\fP and \fB-r\fP. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The archive named by \fIarchive\fP shall be a file in the format created +by \fIar\fP \fB-r\fP. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIar\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_TIME\fP +Determine the format and content for date and time strings written +by \fIar\fP \fB-tv\fP. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITMPDIR\fP +Determine the pathname that overrides the default directory for temporary +files, if any. +.TP 7 +\fITZ\fP +Determine the timezone used to calculate date and time strings written +by \fIar\fP \fB-tv\fP. If \fITZ\fP is unset or null, +an unspecified default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If the \fB-d\fP option is used with the \fB-v\fP option, the standard +output format shall be: +.sp +.RS +.nf + +\fB"d - %s\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +where \fIfile\fP is the operand specified on the command line. +.LP +If the \fB-p\fP option is used with the \fB-v\fP option, \fIar\fP +shall precede the contents of each file with: +.sp +.RS +.nf + +\fB"\\n<%s>\\n\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +where \fIfile\fP is the operand specified on the command line, if +\fIfile\fP operands were specified, and the name of the file +in the archive if they were not. +.LP +If the \fB-r\fP option is used with the \fB-v\fP option: +.IP " *" 3 +If \fIfile\fP is already in the archive, the standard output format +shall be: +.sp +.RS +.nf + +\fB"r - %s\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +where <\fIfile\fP> is the operand specified on the command line. +.LP +.IP " *" 3 +If \fIfile\fP is not already in the archive, the standard output format +shall be: +.sp +.RS +.nf + +\fB"a - %s\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +where <\fIfile\fP> is the operand specified on the command line. +.LP +.LP +If the \fB-t\fP option is used, \fIar\fP shall write the names of +the files in the archive to the standard output in the +format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +where \fIfile\fP is the operand specified on the command line, if +\fIfile\fP operands were specified, or the name of the file +in the archive if they were not. +.LP +If the \fB-t\fP option is used with the \fB-v\fP option, the standard +output format shall be: +.sp +.RS +.nf + +\fB"%s %u/%u %u %s %d %d:%d %d %s\\n", <\fP\fImember mode\fP\fB>, <\fP\fIuser ID\fP\fB>, + <\fP\fIgroup ID\fP\fB>, <\fP\fInumber of bytes in member\fP\fB>, + <\fP\fIabbreviated month\fP\fB>, <\fP\fIday-of-month\fP\fB>, <\fP\fIhour\fP\fB>, + <\fP\fIminute\fP\fB>, <\fP\fIyear\fP\fB>, <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +where: +.TP 7 +<\fIfile\fP> +Shall be the operand specified on the command line, if \fIfile\fP +operands were specified, or the name of the file in the +archive if they were not. +.TP 7 +<\fImember\ mode\fP> +.sp +Shall be formatted the same as the <\fIfile\ mode\fP> string defined +in the STDOUT section of \fIls\fP, except that the first character, +the <\fIentry\ type\fP>, is not used; the string +represents the file mode of the file in the archive at the time it +was added to or replaced in the archive. +.sp +.LP +The following represent the last-modification time of a file when +it was most recently added to or replaced in the archive: +.TP 7 +<\fIabbreviated\ month\fP> +.sp +Equivalent to the format of the \fB%b\fP conversion specification +format in \fIdate\fP. +.TP 7 +<\fIday-of-month\fP> +.sp +Equivalent to the format of the \fB%e\fP conversion specification +format in \fIdate\fP. +.TP 7 +<\fIhour\fP> +Equivalent to the format of the \fB%H\fP conversion specification +format in \fIdate\fP. +.TP 7 +<\fIminute\fP> +Equivalent to the format of the \fB%M\fP conversion specification +format in \fIdate\fP. +.TP 7 +<\fIyear\fP> +Equivalent to the format of the \fB%Y\fP conversion specification +format in \fIdate\fP. +.sp +.LP +When \fILC_TIME\fP does not specify the POSIX locale, a different +format and order of presentation of these fields relative to +each other may be used in a format appropriate in the specified locale. +.LP +If the \fB-x\fP option is used with the \fB-v\fP option, the standard +output format shall be: +.sp +.RS +.nf + +\fB"x - %s\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +where \fIfile\fP is the operand specified on the command line, if +\fIfile\fP operands were specified, or the name of the file +in the archive if they were not. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. The +diagnostic message about creating a new archive when +\fB-c\fP is not specified shall not modify the exit status. +.SH OUTPUT FILES +.LP +Archives are files with unspecified formats. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The archive format is not described. It is recognized that there are +several known \fIar\fP formats, which are not compatible. +The \fIar\fP utility is included, however, to allow creation of archives +that are intended for use only on one machine. The +archive is specified as a file, and it can be moved as a file. This +does allow an archive to be moved from one machine to another +machine that uses the same implementation of \fIar\fP. +.LP +Utilities such as \fIpax\fP (and its forebears \fItar\fP and \fIcpio\fP) +also provide +portable "archives". This is a not a duplication; the \fIar\fP utility +is included to provide an interface primarily for \fImake\fP and the +compilers, based on a historical model. +.LP +In historical implementations, the \fB-q\fP option (available on XSI-conforming +systems) is known to execute quickly because +\fIar\fP does not check on whether the added members are already in +the archive. This is useful to bypass the searching otherwise +done when creating a large archive piece-by-piece. These remarks may +but need not remain true for a brand new implementation of +this utility; hence, these remarks have been moved into the RATIONALE. +.LP +BSD implementations historically required applications to provide +the \fB-s\fP option whenever the archive was supposed to +contain a symbol table. As in this volume of IEEE\ Std\ 1003.1-2001, +System V historically creates or updates an archive +symbol table whenever an object file is removed from, added to, or +updated in the archive. +.LP +The OPERANDS section requires what might seem to be true without specifying +it: the archive cannot truncate the filenames below +{NAME_MAX}. Some historical implementations do so, however, causing +unexpected results for the application. Therefore, this volume +of IEEE\ Std\ 1003.1-2001 makes the requirement explicit to avoid +misunderstandings. +.LP +According to the System V documentation, the options \fB-dmpqrtx\fP +are not required to begin with a hyphen ( \fB'-'\fP ). +This volume of IEEE\ Std\ 1003.1-2001 requires that a conforming application +use the leading hyphen. +.LP +The archive format used by the 4.4 BSD implementation is documented +in this RATIONALE as an example: +A file created by \fIar\fP begins with the "magic" string \fB"!<arch>\\n"\fP +\&. The rest of the archive is +made up of objects, each of which is composed of a header for a file, +a possible filename, and the file contents. The header is +portable between machine architectures, and, if the file contents +are printable, the archive is itself printable. +.LP +The header is made up of six ASCII fields, followed by a two-character +trailer. The fields are the object name (16 characters), +the file last modification time (12 characters), the user and group +IDs (each 6 characters), the file mode (8 characters), and the +file size (10 characters). All numeric fields are in decimal, except +for the file mode, which is in octal. +.LP +The modification time is the file \fIst_mtime\fP field. The user and +group IDs are the file \fIst_uid\fP and \fIst_gid\fP +fields. The file mode is the file \fIst_mode\fP field. The file size +is the file \fIst_size\fP field. The two-byte trailer is the +string \fB"`<newline>"\fP . +.LP +Only the name field has any provision for overflow. If any filename +is more than 16 characters in length or contains an embedded +space, the string \fB"#1/"\fP followed by the ASCII length of the +name is written in the name field. The file size (stored in +the archive header) is incremented by the length of the name. The +name is then written immediately following the archive +header. +.LP +Any unused characters in any of these fields are written as <space>s. +If any fields are their particular maximum number of +characters in length, there is no separation between the fields. +.LP +Objects in the archive are always an even number of bytes long; files +that are an odd number of bytes long are padded with a +<newline>, although the size in the header does not reflect this. +.LP +The \fIar\fP utility description requires that (when all its members +are valid object files) \fIar\fP produce an object code +library, which the linkage editor can use to extract object modules. +If the linkage editor needs a symbol table to permit random +access to the archive, \fIar\fP must provide it; however, \fIar\fP +does not require a symbol table. +.LP +The BSD \fB-o\fP option was omitted. It is a rare conforming application +that uses \fIar\fP to extract object code from a +library with concern for its modification time, since this can only +be of importance to \fImake\fP. Hence, since this functionality is +not deemed important for applications portability, the +modification time of the extracted files is set to the current time. +.LP +There is at least one known implementation (for a small computer) +that can accommodate only object files for that system, +disallowing mixed object and other files. The ability to handle any +type of file is not only historical practice for most +implementations, but is also a reasonable expectation. +.LP +Consideration was given to changing the output format of \fIar\fP +\fB-tv\fP to the same format as the output of \fIls\fP \fB-l\fP. This +would have made parsing the output of \fIar\fP the same as that of +\fIls\fP. This was rejected in part because the current \fIar\fP format +is commonly used and changes +would break historical usage. Second, \fIar\fP gives the user ID and +group ID in numeric format separated by a slash. Changing +this to be the user name and group name would not be correct if the +archive were moved to a machine that contained a different user +database. Since \fIar\fP cannot know whether the archive was generated +on the same machine, it cannot tell what to report. +.LP +The text on the \fB-ur\fP option combination is historical practice-since +one filename can easily represent two different files +(for example, \fB/a/foo\fP and \fB/b/foo\fP), it is reasonable to +replace the file in the archive even when the modification time +in the archive is identical to that in the file system. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP , \fIdate\fP , \fIfort77\fP , \fIpax\fP , \fIstrip\fP the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 13, Headers, +\fI<unistd.h>\fP +description of {POSIX_NO_TRUNC} +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/asa.1p b/man1p/asa.1p new file mode 100644 index 000000000..73537f04d --- /dev/null +++ b/man1p/asa.1p @@ -0,0 +1,187 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ASA" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" asa +.SH NAME +asa \- interpret carriage-control characters +.SH SYNOPSIS +.LP +\fBasa\fP \fB[\fP \fIfile\fP \fB...\fP \fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIasa\fP utility shall write its input files to standard output, +mapping carriage-control characters from the text files +to line-printer control sequences in an implementation-defined manner. +.LP +The first character of every line shall be removed from the input, +and the following actions are performed. +.LP +If the character removed is: +.TP 7 +<space> +The rest of the line is output without change. +.TP 7 +0 +A <newline> is output, then the rest of the input line. +.TP 7 +1 +One or more implementation-defined characters that causes an advance +to the next page shall be output, followed by the rest of +the input line. +.TP 7 +\fB+\fP +The <newline> of the previous line shall be replaced with one or more +implementation-defined characters that causes +printing to return to column position 1, followed by the rest of the +input line. If the \fB'+'\fP is the first character in the +input, it shall be equivalent to <space>. +.sp +.LP +The action of the \fIasa\fP utility is unspecified upon encountering +any character other than those listed above as the first +character in a line. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.TP 7 +\fIfile\fP +A pathname of a text file used for input. If no \fIfile\fP operands +are specified, the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified; see the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIasa\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be the text from the input file modified +as described in the DESCRIPTION section. +.SH STDERR +.LP +None. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were output successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.IP " 1." 4 +The following command: +.sp +.RS +.nf + +\fBasa\fP \fIfile\fP +.fi +.RE +.LP +permits the viewing of \fIfile\fP (created by a program using FORTRAN-style +carriage-control characters) on a terminal. +.LP +.IP " 2." 4 +The following command: +.sp +.RS +.nf + +\fBa.out | asa | lp +\fP +.fi +.RE +.LP +formats the FORTRAN output of \fBa.out\fP and directs it to the printer. +.LP +.SH RATIONALE +.LP +The \fIasa\fP utility is needed to map "standard" FORTRAN 77 output +into a form acceptable to contemporary printers. Usually, +\fIasa\fP is used to pipe data to the \fIlp\fP utility; see \fIlp\fP. +.LP +This utility is generally used only by FORTRAN programs. The standard +developers decided to retain \fIasa\fP to avoid breaking +the historical large base of FORTRAN applications that put carriage-control +characters in their output files. There is no +requirement that a system have a FORTRAN compiler in order to run +applications that need \fIasa\fP. +.LP +Historical implementations have used an ASCII <form-feed> in response +to a 1 and an ASCII <carriage-return> in +response to a \fB'+'\fP . It is suggested that implementations treat +characters other than 0, 1, and \fB'+'\fP as +<space> in the absence of any compelling reason to do otherwise. However, +the action is listed here as "unspecified", +permitting an implementation to provide extensions to access fast +multiple-line slewing and channel seeking in a non-portable +manner. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIfort77\fP , \fIlp\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/at.1p b/man1p/at.1p new file mode 100644 index 000000000..db3af841f --- /dev/null +++ b/man1p/at.1p @@ -0,0 +1,706 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "AT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" at +.SH NAME +at \- execute commands at a later time +.SH SYNOPSIS +.LP +\fBat\fP \fB[\fP\fB-m\fP\fB][\fP\fB-f\fP \fIfile\fP\fB][\fP\fB-q\fP +\fIqueuename\fP\fB]\fP \fB-t\fP \fItime_arg\fP\fB +.br +.sp +at\fP \fB[\fP\fB-m\fP\fB][\fP\fB-f\fP \fIfile\fP\fB][\fP\fB-q\fP \fIqueuename\fP\fB]\fP +\fItimespec\fP +\fB\&... +.br +.sp +at -r\fP \fIat_job_id\fP \fB... +.br +.sp +at -l -q\fP \fIqueuename\fP\fB +.br +.sp +at -l\fP \fB[\fP\fIat_job_id\fP \fB...\fP\fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIat\fP utility shall read commands from standard input and group +them together as an \fIat-job\fP, to be executed at a +later time. +.LP +The at-job shall be executed in a separate invocation of the shell, +running in a separate process group with no controlling +terminal, except that the environment variables, current working directory, +file creation mask, and other implementation-defined +execution-time attributes in effect when the \fIat\fP utility is executed +shall be retained and used when the at-job is +executed. +.LP +When the at-job is submitted, the \fIat_job_id\fP and scheduled time +shall be written to standard error. The \fIat_job_id\fP +is an identifier that shall be a string consisting solely of alphanumeric +characters and the period character. The \fIat_job_id\fP +shall be assigned by the system when the job is scheduled such that +it uniquely identifies a particular job. +.LP +User notification and the processing of the job's standard output +and standard error are described under the \fB-m\fP +option. +.LP +Users shall be permitted to use \fIat\fP if their name appears in +the file \fB/usr/lib/cron/at.allow\fP. If that file does not +exist, the file \fB/usr/lib/cron/at.deny\fP shall be checked to determine +whether the user shall be denied access to \fIat\fP. If +neither file exists, only a process with the appropriate privileges +shall be allowed to submit a job. If only \fBat.deny\fP exists +and is empty, global usage shall be permitted. The \fBat.allow\fP +and \fBat.deny\fP files shall consist of one user name per +line. +.SH OPTIONS +.LP +The \fIat\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-f\ \fP \fIfile\fP +Specify the pathname of a file to be used as the source of the at-job, +instead of standard input. +.TP 7 +\fB-l\fP +(The letter ell.) Report all jobs scheduled for the invoking user +if no \fIat_job_id\fP operands are specified. If +\fIat_job_id\fPs are specified, report only information for these +jobs. The output shall be written to standard output. +.TP 7 +\fB-m\fP +Send mail to the invoking user after the at-job has run, announcing +its completion. Standard output and standard error produced +by the at-job shall be mailed to the user as well, unless redirected +elsewhere. Mail shall be sent even if the job produces no +output. +.LP +If \fB-m\fP is not used, the job's standard output and standard error +shall be provided to the user by means of mail, unless +they are redirected elsewhere; if there is no such output to provide, +the implementation need not notify the user of the job's +completion. +.TP 7 +\fB-q\ \fP \fIqueuename\fP +.sp +Specify in which queue to schedule a job for submission. When used +with the \fB-l\fP option, limit the search to that particular +queue. By default, at-jobs shall be scheduled in queue \fIa\fP. In +contrast, queue \fIb\fP shall be reserved for batch jobs; see +\fIbatch\fP. The meanings of all other \fIqueuename\fPs are implementation-defined. +If +\fB-q\fP is specified along with either of the \fB-t\fP \fItime_arg\fP +or \fItimespec\fP arguments, the results are +unspecified. +.TP 7 +\fB-r\fP +Remove the jobs with the specified \fIat_job_id\fP operands that were +previously scheduled by the \fIat\fP utility. +.TP 7 +\fB-t\ \fP \fItime_arg\fP +Submit the job to be run at the time specified by the \fItime\fP option-argument, +which the application shall ensure has the +format as specified by the \fItouch\fP \fB-t\fP \fItime\fP utility. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIat_job_id\fP +The name reported by a previous invocation of the \fIat\fP utility +at the time the job was scheduled. +.TP 7 +\fItimespec\fP +Submit the job to be run at the date and time specified. All of the +\fItimespec\fP operands are interpreted as if they were +separated by <space>s and concatenated, and shall be parsed as described +in the grammar at the end of this section. The date +and time shall be interpreted as being in the timezone of the user +(as determined by the \fITZ\fP variable), unless a timezone +name appears as part of \fItime\fP, below. +.LP +In the POSIX locale, the following describes the three parts of the +time specification string. All of the values from the +\fILC_TIME\fP categories in the POSIX locale shall be recognized in +a case-insensitive manner. +.TP 7 +\fItime\fP +.RS +The time can be specified as one, two, or four digits. One-digit and +two-digit numbers shall be taken to be hours; four-digit +numbers to be hours and minutes. The time can alternatively be specified +as two numbers separated by a colon, meaning +\fIhour\fP:\fIminute\fP. An AM/PM indication (one of the values from +the \fBam_pm\fP keywords in the \fILC_TIME\fP locale +category) can follow the time; otherwise, a 24-hour clock time shall +be understood. A timezone name can also follow to further +qualify the time. The acceptable timezone names are implementation-defined, +except that they shall be case-insensitive and the +string \fButc\fP is supported to indicate the time is in Coordinated +Universal Time. In the POSIX locale, the \fItime\fP field +can also be one of the following tokens: +.TP 7 +\fBmidnight\fP +.RS +Indicates the time 12:00 am (00:00). +.RE +.TP 7 +\fBnoon\fP +.RS +Indicates the time 12:00 pm. +.RE +.TP 7 +\fBnow\fP +.RS +Indicates the current day and time. Invoking \fIat\fP <\fBnow\fP> +shall submit an at-job for potentially immediate +execution (that is, subject only to unspecified scheduling delays). +.RE +.sp +.RE +.TP 7 +\fIdate\fP +.RS +An optional \fIdate\fP can be specified as either a month name (one +of the values from the \fBmon\fP or \fBabmon\fP keywords +in the \fILC_TIME\fP locale category) followed by a day number (and +possibly year number preceded by a comma), or a day of the +week (one of the values from the \fBday\fP or \fBabday\fP keywords +in the \fILC_TIME\fP locale category). In the POSIX locale, +two special days shall be recognized: +.TP 7 +\fBtoday\fP +.RS +Indicates the current day. +.RE +.TP 7 +\fBtomorrow\fP +.RS +Indicates the day following the current day. +.RE +.sp +.LP +If no \fIdate\fP is given, \fBtoday\fP shall be assumed if the given +time is greater than the current time, and +\fBtomorrow\fP shall be assumed if it is less. If the given month +is less than the current month (and no year is given), next year +shall be assumed. +.RE +.TP 7 +\fIincrement\fP +.RS +The optional \fIincrement\fP shall be a number preceded by a plus +sign ( \fB'+'\fP ) and suffixed by one of the following: +\fBminutes\fP, \fBhours\fP, \fBdays\fP, \fBweeks\fP, \fBmonths\fP, +or \fByears\fP. (The singular forms shall also be +accepted.) The keyword \fBnext\fP shall be equivalent to an increment +number of +1. For example, the following are equivalent +commands: +.sp +.RS +.nf + +\fBat 2pm + 1 week +at 2pm next week +\fP +.fi +.RE +.RE +.sp +.sp +.LP +The following grammar describes the precise format of \fItimespec\fP +in the POSIX locale. The general conventions for this +style of grammar are described in \fIGrammar Conventions\fP . This +formal syntax shall +take precedence over the preceding text syntax description. The longest +possible token or delimiter shall be recognized at a given +point. When used in a \fItimespec\fP, white space shall also delimit +tokens. +.sp +.RS +.nf + +\fB%token hr24clock_hr_min +%token hr24clock_hour +/* + An hr24clock_hr_min is a one, two, or four-digit number. A one-digit + or two-digit number constitutes an hr24clock_hour. An hr24clock_hour + may be any of the single digits [0,9], or may be double digits, ranging + from [00,23]. If an hr24clock_hr_min is a four-digit number, the + first two digits shall be a valid hr24clock_hour, while the last two + represent the number of minutes, from [00,59]. +*/ +.sp + +%token wallclock_hr_min +%token wallclock_hour +/* + A wallclock_hr_min is a one, two-digit, or four-digit number. + A one-digit or two-digit number constitutes a wallclock_hour. + A wallclock_hour may be any of the single digits [1,9], or may + be double digits, ranging from [01,12]. If a wallclock_hr_min + is a four-digit number, the first two digits shall be a valid + wallclock_hour, while the last two represent the number of + minutes, from [00,59]. +*/ +.sp + +%token minute +/* + A minute is a one or two-digit number whose value can be [0,9] + or [00,59]. +*/ +.sp + +%token day_number +/* + A day_number is a number in the range appropriate for the particular + month and year specified by month_name and year_number, respectively. + If no year_number is given, the current year is assumed if the given + date and time are later this year. If no year_number is given and + the date and time have already occurred this year and the month is + not the current month, next year is the assumed year. +*/ +.sp + +%token year_number +/* + A year_number is a four-digit number representing the year A.D., in + which the at_job is to be run. +*/ +.sp + +%token inc_number +/* + The inc_number is the number of times the succeeding increment + period is to be added to the specified date and time. +*/ +.sp + +%token timezone_name +/* + The name of an optional timezone suffix to the time field, in an + implementation-defined format. +*/ +.sp + +%token month_name +/* + One of the values from the mon or abmon keywords in the LC_TIME + locale category. +*/ +.sp + +%token day_of_week +/* + One of the values from the day or abday keywords in the LC_TIME + locale category. +*/ +.sp + +%token am_pm +/* + One of the values from the am_pm keyword in the LC_TIME locale + category. +*/ +.sp + +%start timespec +%% +timespec : time + | time date + | time increment + | time date increment + | nowspec + ; +.sp + +nowspec : "now" + | "now" increment + ; +.sp + +time : hr24clock_hr_min + | hr24clock_hr_min timezone_name + | hr24clock_hour ":" minute + | hr24clock_hour ":" minute timezone_name + | wallclock_hr_min am_pm + | wallclock_hr_min am_pm timezone_name + | wallclock_hour ":" minute am_pm + | wallclock_hour ":" minute am_pm timezone_name + | "noon" + | "midnight" + ; +.sp + +date : month_name day_number + | month_name day_number "," year_number + | day_of_week + | "today" + | "tomorrow" + ; +.sp + +increment : "+" inc_number inc_period + | "next" inc_period + ; +.sp + +inc_period : "minute" | "minutes" + | "hour" | "hours" + | "day" | "days" + | "week" | "weeks" + | "month" | "months" + | "year" | "years" + ; +\fP +.fi +.RE +.SH STDIN +.LP +The standard input shall be a text file consisting of commands acceptable +to the shell command language described in \fIShell Command Language\fP +\&. The standard input shall only be used if no \fB-f\fP \fIfile\fP +option is specified. +.SH INPUT FILES +.LP +See the STDIN section. +.LP +The text files \fB/usr/lib/cron/at.allow\fP and \fB/usr/lib/cron/at.deny\fP +shall contain zero or more user names, one per line, +of users who are, respectively, authorized or denied access to the +\fIat\fP and \fIbatch\fP +utilities. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIat\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fILC_TIME\fP +Determine the format and contents for date and time strings written +and accepted by \fIat\fP. +.TP 7 +\fISHELL\fP +Determine a name of a command interpreter to be used to invoke the +at-job. If the variable is unset or null, \fIsh\fP shall be used. +If it is set to a value other than a name for \fIsh\fP, the implementation +shall do one of the following: use that shell; use \fIsh\fP; use the +login shell from the user database; or any of the preceding accompanied +by a warning +diagnostic about which was chosen. +.TP 7 +\fITZ\fP +Determine the timezone. The job shall be submitted for execution at +the time specified by \fItimespec\fP or \fB-t\fP +\fItime\fP relative to the timezone specified by the \fITZ\fP variable. +If \fItimespec\fP specifies a timezone, it shall +override \fITZ .\fP If \fItimespec\fP does not specify a timezone +and \fITZ\fP is unset or null, an unspecified default timezone +shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When standard input is a terminal, prompts of unspecified format for +each line of the user input described in the STDIN section +may be written to standard output. +.LP +In the POSIX locale, the following shall be written to the standard +output for each job when jobs are listed in response to the +\fB-l\fP option: +.sp +.RS +.nf + +\fB"%s\\t%s\\n",\fP \fIat_job_id\fP\fB, <\fP\fIdate\fP\fB> +\fP +.fi +.RE +.LP +where \fIdate\fP shall be equivalent in format to the output of: +.sp +.RS +.nf + +\fBdate +"%a %b %e %T %Y" +\fP +.fi +.RE +.LP +The date and time written shall be adjusted so that they appear in +the timezone of the user (as determined by the \fITZ\fP +variable). +.SH STDERR +.LP +In the POSIX locale, the following shall be written to standard error +when a job has been successfully submitted: +.sp +.RS +.nf + +\fB"job %s at %s\\n",\fP \fIat_job_id\fP\fB, <\fP\fIdate\fP\fB> +\fP +.fi +.RE +.LP +where \fIdate\fP has the same format as that described in the STDOUT +section. Neither this, nor warning messages concerning the +selection of the command interpreter, shall be considered a diagnostic +that changes the exit status. +.LP +Diagnostic messages, if any, shall be written to standard error. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The \fIat\fP utility successfully submitted, removed, or listed a +job or jobs. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The job shall not be scheduled, removed, or listed. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The format of the \fIat\fP command line shown here is guaranteed only +for the POSIX locale. Other cultures may be supported +with substantially different interfaces, although implementations +are encouraged to provide comparable levels of functionality. +.LP +Since the commands run in a separate shell invocation, running in +a separate process group with no controlling terminal, open +file descriptors, traps, and priority inherited from the invoking +environment are lost. +.LP +Some implementations do not allow substitution of different shells +using \fISHELL .\fP System V systems, for example, have used +the login shell value for the user in \fB/etc/passwd\fP. To select +reliably another command interpreter, the user must include it +as part of the script, such as: +.sp +.RS +.nf + +\fB$\fP \fBat 1800 +myshell myscript +EOT +\fP\fBjob ... at ... +$\fP +.fi +.RE +.SH EXAMPLES +.IP " 1." 4 +This sequence can be used at a terminal: +.sp +.RS +.nf + +\fBat -m 0730 tomorrow +sort < file >outfile +EOT +\fP +.fi +.RE +.LP +.IP " 2." 4 +This sequence, which demonstrates redirecting standard error to a +pipe, is useful in a command procedure (the sequence of output +redirection specifications is significant): +.sp +.RS +.nf + +\fBat now + 1 hour <<! +diff file1 file2 2>&1 >outfile | mailx mygroup +! +\fP +.fi +.RE +.LP +.IP " 3." 4 +To have a job reschedule itself, \fIat\fP can be invoked from within +the at-job. For example, this daily processing script +named \fBmy.daily\fP runs every day (although \fIcrontab\fP is a more +appropriate vehicle +for such work): +.sp +.RS +.nf + +\fB# my.daily runs every day +\fP\fIdaily processing\fP\fBat now tomorrow < my.daily +\fP +.fi +.RE +.LP +.IP " 4." 4 +The spacing of the three portions of the POSIX locale \fItimespec\fP +is quite flexible as long as there are no ambiguities. +Examples of various times and operand presentation include: +.sp +.RS +.nf + +\fBat 0815am Jan 24 +at 8 :15amjan24 +at now "+ 1day" +at 5 pm FRIday +at '17 + utc+ + 30minutes' +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fIat\fP utility reads from standard input the commands to be +executed at a later time. It may be useful to redirect +standard output and standard error within the specified commands. +.LP +The \fB-t\fP \fItime\fP option was added as a new capability to support +an internationalized way of specifying a time for +execution of the submitted job. +.LP +Early proposals added a "jobname" concept as a way of giving submitted +jobs names that are meaningful to the user submitting +them. The historical, system-specified \fIat_job_id\fP gives no indication +of what the job is. Upon further reflection, it was +decided that the benefit of this was not worth the change in historical +interface. The \fIat\fP functionality is useful in simple +environments, but in large or complex situations, the functionality +provided by the Batch Services option is more suitable. +.LP +The \fB-q\fP option historically has been an undocumented option, +used mainly by the \fIbatch\fP utility. +.LP +The System V \fB-m\fP option was added to provide a method for informing +users that an at-job had completed. Otherwise, users +are only informed when output to standard error or standard output +are not redirected. +.LP +The behavior of \fIat\fP <\fBnow\fP> was changed in an early proposal +from being unspecified to submitting a job for +potentially immediate execution. Historical BSD \fIat\fP implementations +support this. Historical System V implementations give an +error in that case, but a change to the System V versions should have +no backwards-compatibility ramifications. +.LP +On BSD-based systems, a \fB-u\fP \fIuser\fP option has allowed those +with appropriate privileges to access the work of other +users. Since this is primarily a system administration feature and +is not universally implemented, it has been omitted. Similarly, +a specification for the output format for a user with appropriate +privileges viewing the queues of other users has been +omitted. +.LP +The \fB-f\fP \fIfile\fP option from System V is used instead of the +BSD method of using the last operand as the pathname. The +BSD method is ambiguous-does: +.sp +.RS +.nf + +\fBat 1200 friday +\fP +.fi +.RE +.LP +mean the same thing if there is a file named \fBfriday\fP in the current +directory? +.LP +The \fIat_job_id\fP is composed of a limited character set in historical +practice, and it is mandated here to invalidate +systems that might try using characters that require shell quoting +or that could not be easily parsed by shell scripts. +.LP +The \fIat\fP utility varies between System V and BSD systems in the +way timezones are used. On System V systems, the \fITZ\fP +variable affects the at-job submission times and the times displayed +for the user. On BSD systems, \fITZ\fP is not taken into +account. The BSD behavior is easily achieved with the current specification. +If the user wishes to have the timezone default to +that of the system, they merely need to issue the \fIat\fP command +immediately following an unsetting or null assignment to \fITZ +\&.\fP For example: +.sp +.RS +.nf + +\fBTZ= at noon ... +\fP +.fi +.RE +.LP +gives the desired BSD result. +.LP +While the \fIyacc\fP-like grammar specified in the OPERANDS section +is lexically +unambiguous with respect to the digit strings, a lexical analyzer +would probably be written to look for and return digit strings in +those cases. The parser could then check whether the digit string +returned is a valid \fIday_number\fP, \fIyear_number\fP, and so +on, based on the context. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIbatch\fP , \fIcrontab\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/awk.1p b/man1p/awk.1p new file mode 100644 index 000000000..b05fb641a --- /dev/null +++ b/man1p/awk.1p @@ -0,0 +1,2984 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "AWK" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" awk +.SH NAME +awk \- pattern scanning and processing language +.SH SYNOPSIS +.LP +\fBawk\fP \fB[\fP\fB-F\fP \fIERE\fP\fB][\fP\fB-v\fP \fIassignment\fP\fB]\fP +\fB\&...\fP \fIprogram\fP +\fB[\fP\fIargument\fP \fB...\fP\fB]\fP\fB +.br +.sp +awk\fP \fB[\fP\fB-F\fP \fIERE\fP\fB]\fP \fB-f\fP \fIprogfile\fP \fB...\fP +\fB[\fP\fB-v\fP +\fIassignment\fP\fB]\fP \fB...\fP\fB[\fP\fIargument\fP \fB...\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIawk\fP utility shall execute programs written in the \fIawk\fP +programming language, which is specialized for textual +data manipulation. An \fIawk\fP program is a sequence of patterns +and corresponding actions. When input is read that matches a +pattern, the action associated with that pattern is carried out. +.LP +Input shall be interpreted as a sequence of records. By default, a +record is a line, less its terminating <newline>, but +this can be changed by using the \fBRS\fP built-in variable. Each +record of input shall be matched in turn against each pattern in +the program. For each pattern matched, the associated action shall +be executed. +.LP +The \fIawk\fP utility shall interpret each input record as a sequence +of fields where, by default, a field is a string of non- +<blank>s. This default white-space field delimiter can be changed +by using the \fBFS\fP built-in variable or \fB-F\fP +\fIERE\fP. The \fIawk\fP utility shall denote the first field in a +record $1, the second $2, and so on. The symbol $0 shall refer +to the entire record; setting any other field causes the re-evaluation +of $0. Assigning to $0 shall reset the values of all other +fields and the \fBNF\fP built-in variable. +.SH OPTIONS +.LP +The \fIawk\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-F\ \fP \fIERE\fP +Define the input field separator to be the extended regular expression +\fIERE\fP, before any input is read; see Regular Expressions . +.TP 7 +\fB-f\ \fP \fIprogfile\fP +Specify the pathname of the file \fIprogfile\fP containing an \fIawk\fP +program. If multiple instances of this option are +specified, the concatenation of the files specified as \fIprogfile\fP +in the order specified shall be the \fIawk\fP program. The +\fIawk\fP program can alternatively be specified in the command line +as a single argument. +.TP 7 +\fB-v\ \fP \fIassignment\fP +The application shall ensure that the \fIassignment\fP argument is +in the same form as an \fIassignment\fP operand. The specified +variable assignment shall occur prior to executing the \fIawk\fP program, +including the actions associated with \fBBEGIN\fP +patterns (if any). Multiple occurrences of this option can be specified. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIprogram\fP +If no \fB-f\fP option is specified, the first operand to \fIawk\fP +shall be the text of the \fIawk\fP program. The +application shall supply the \fIprogram\fP operand as a single argument +to \fIawk\fP. If the text does not end in a +<newline>, \fIawk\fP shall interpret the text as if it did. +.TP 7 +\fIargument\fP +Either of the following two types of \fIargument\fP can be intermixed: +.TP 7 +\fIfile\fP +.RS +A pathname of a file that contains the input to be read, which is +matched against the set of patterns in the program. If no +\fIfile\fP operands are specified, or if a \fIfile\fP operand is \fB'-'\fP +, the standard input shall be used. +.RE +.TP 7 +\fIassignment\fP +.RS +An operand that begins with an underscore or alphabetic character +from the portable character set (see the table in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable +Character Set), followed by a sequence of underscores, digits, and +alphabetics from the portable character set, followed by the +\fB'='\fP character, shall specify a variable assignment rather than +a pathname. The characters before the \fB'='\fP +represent the name of an \fIawk\fP variable; if that name is an \fIawk\fP +reserved word (see Grammar ) the behavior is undefined. The characters +following the equal sign shall be interpreted as if they +appeared in the \fIawk\fP program preceded and followed by a double-quote +( \fB' )'\fP character, as a \fBSTRING\fP token (see +Grammar ), except that if the last character is an unescaped backslash, +it shall be interpreted as a +literal backslash rather than as the first character of the sequence +\fB"\\""\fP . The variable shall be assigned the value of +that \fBSTRING\fP token and, if appropriate, shall be considered a +\fInumeric string\fP (see Expressions in awk ), the variable shall +also be assigned its numeric value. Each such variable assignment +shall occur just prior to the processing of the following \fIfile\fP, +if any. Thus, an assignment before the first \fIfile\fP +argument shall be executed after the \fBBEGIN\fP actions (if any), +while an assignment after the last \fIfile\fP argument shall +occur before the \fBEND\fP actions (if any). If there are no \fIfile\fP +arguments, assignments shall be executed before +processing the standard input. +.RE +.sp +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP ; +see the INPUT FILES section. If the \fIawk\fP program contains no +actions and no patterns, but is otherwise a valid \fIawk\fP +program, standard input and any \fIfile\fP operands shall not be read +and \fIawk\fP shall exit with a return status of zero. +.SH INPUT FILES +.LP +Input files to the \fIawk\fP program from any of the following sources +shall be text files: +.IP " *" 3 +Any \fIfile\fP operands or their equivalents, achieved by modifying +the \fIawk\fP variables \fBARGV\fP and \fBARGC\fP +.LP +.IP " *" 3 +Standard input in the absence of any \fIfile\fP operands +.LP +.IP " *" 3 +Arguments to the \fBgetline\fP function +.LP +.LP +Whether the variable \fBRS\fP is set to a value other than a <newline> +or not, for these files, implementations shall +support records terminated with the specified separator up to {LINE_MAX} +bytes and may support longer records. +.LP +If \fB-f\fP \fIprogfile\fP is specified, the application shall ensure +that the files named by each of the \fIprogfile\fP +option-arguments are text files and their concatenation, in the same +order as they appear in the arguments, is an \fIawk\fP +program. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIawk\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions and in comparisons of string values. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +behavior of character classes within regular expressions, the +identification of characters as letters, and the mapping of uppercase +and lowercase characters for the \fBtoupper\fP and +\fBtolower\fP functions. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_NUMERIC\fP +Determine the radix character used when interpreting numeric input, +performing conversions between numeric and string values, and +formatting numeric output. Regardless of locale, the period character +(the decimal-point character of the POSIX locale) is the +decimal-point character recognized in processing \fIawk\fP programs +(including assignments in command line arguments). +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the search path when looking for commands executed by \fIsystem\fP(\fIexpr\fP), +or input and output pipes; see the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables. +.sp +.LP +In addition, all environment variables shall be visible via the \fIawk\fP +variable \fBENVIRON\fP. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The nature of the output files depends on the \fIawk\fP program. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The nature of the output files depends on the \fIawk\fP program. +.SH EXTENDED DESCRIPTION +.SS Overall Program Structure +.LP +An \fIawk\fP program is composed of pairs of the form: +.sp +.RS +.nf + +\fIpattern\fP \fB{\fP \fIaction\fP \fB} +\fP +.fi +.RE +.LP +Either the pattern or the action (including the enclosing brace characters) +can be omitted. +.LP +A missing pattern shall match any record of input, and a missing action +shall be equivalent to: +.sp +.RS +.nf + +\fB{ print } +\fP +.fi +.RE +.LP +Execution of the \fIawk\fP program shall start by first executing +the actions associated with all \fBBEGIN\fP patterns in the +order they occur in the program. Then each \fIfile\fP operand (or +standard input if no files were specified) shall be processed in +turn by reading data from the file until a record separator is seen +( <newline> by default). Before the first reference to a +field in the record is evaluated, the record shall be split into fields, +according to the rules in Regular Expressions , using the value of +\fBFS\fP that was current at the time the record was read. Each +pattern in the program then shall be evaluated in the order of occurrence, +and the action associated with each pattern that matches +the current record executed. The action for a matching pattern shall +be executed before evaluating subsequent patterns. Finally, +the actions associated with all \fBEND\fP patterns shall be executed +in the order they occur in the program. +.SS Expressions in awk +.LP +Expressions describe computations used in \fIpatterns\fP and \fIactions\fP. +In the following table, valid expression +operations are given in groups from highest precedence first to lowest +precedence last, with equal-precedence operators grouped +between horizontal lines. In expression evaluation, where the grammar +is formally ambiguous, higher precedence operators shall be +evaluated before lower precedence operators. In this table \fIexpr\fP, +\fIexpr1\fP, \fIexpr2\fP, and \fIexpr3\fP represent any +expression, while lvalue represents any entity that can be assigned +to (that is, on the left side of an assignment operator). The +precise syntax of expressions is given in Grammar . +.sp +.ce 1 +\fBTable: Expressions in Decreasing Precedence in \fIawk\fP\fP +.TS C +center; l1 l1 l1 l. +\fBSyntax\fP \fBName\fP \fBType of Result\fP \fBAssociativity\fP +( \fIexpr\fP ) Grouping Type of \fIexpr\fP N/A +$\fIexpr\fP Field reference String N/A +++ lvalue Pre-increment Numeric N/A +-- lvalue Pre-decrement Numeric N/A +lvalue ++ Post-increment Numeric N/A +lvalue -- Post-decrement Numeric N/A +\fIexpr\fP ^ \fIexpr\fP Exponentiation Numeric Right +! \fIexpr\fP Logical not Numeric N/A ++ \fIexpr\fP Unary plus Numeric N/A +- \fIexpr\fP Unary minus Numeric N/A +\fIexpr\fP * \fIexpr\fP Multiplication Numeric Left +\fIexpr\fP / \fIexpr\fP Division Numeric Left +\fIexpr\fP % \fIexpr\fP Modulus Numeric Left +\fIexpr\fP + \fIexpr\fP Addition Numeric Left +\fIexpr\fP - \fIexpr\fP Subtraction Numeric Left +\fIexpr\fP \fIexpr\fP String concatenation String Left +\fIexpr\fP < \fIexpr\fP Less than Numeric None +\fIexpr\fP <= \fIexpr\fP Less than or equal to Numeric None +\fIexpr\fP != \fIexpr\fP Not equal to Numeric None +\fIexpr\fP == \fIexpr\fP Equal to Numeric None +\fIexpr\fP > \fIexpr\fP Greater than Numeric None +\fIexpr\fP >= \fIexpr\fP Greater than or equal to Numeric None +\fIexpr\fP ~ \fIexpr\fP ERE match Numeric None +\fIexpr\fP !~ \fIexpr\fP ERE non-match Numeric None +\fIexpr\fP in array Array membership Numeric Left +( \fIindex\fP ) in \fIarray\fP Multi-dimension array Numeric Left +\ membership \ \ +\fIexpr\fP && \fIexpr\fP Logical AND Numeric Left +\fIexpr\fP || \fIexpr\fP Logical OR Numeric Left +\fIexpr1\fP ? \fIexpr2\fP : \fIexpr3\fP Conditional expression Type of selected Right +\ \ \fIexpr2\fP or \fIexpr3\fP \ +lvalue ^= \fIexpr\fP Exponentiation assignment Numeric Right +lvalue %= \fIexpr\fP Modulus assignment Numeric Right +lvalue *= \fIexpr\fP Multiplication assignment Numeric Right +lvalue /= \fIexpr\fP Division assignment Numeric Right +lvalue += \fIexpr\fP Addition assignment Numeric Right +lvalue -= \fIexpr\fP Subtraction assignment Numeric Right +lvalue = \fIexpr\fP Assignment Type of \fIexpr\fP Right +.TE +.LP +Each expression shall have either a string value, a numeric value, +or both. Except as stated for specific contexts, the value of +an expression shall be implicitly converted to the type needed for +the context in which it is used. A string value shall be +converted to a numeric value by the equivalent of the following calls +to functions defined by the ISO\ C standard: +.sp +.RS +.nf + +\fBsetlocale(LC_NUMERIC, ""); +\fP\fInumeric_value\fP \fB= atof(\fP\fIstring_value\fP\fB); +\fP +.fi +.RE +.LP +A numeric value that is exactly equal to the value of an integer (see +\fIConcepts Derived +from the ISO C Standard\fP ) shall be converted to a string by the +equivalent of a call to the \fBsprintf\fP function (see String Functions +) with the string \fB"%d"\fP as the \fIfmt\fP argument and the numeric +value being +converted as the first and only \fIexpr\fP argument. Any other numeric +value shall be converted to a string by the equivalent of a +call to the \fBsprintf\fP function with the value of the variable +\fBCONVFMT\fP as the \fIfmt\fP argument and the numeric value +being converted as the first and only \fIexpr\fP argument. The result +of the conversion is unspecified if the value of +\fBCONVFMT\fP is not a floating-point format specification. This volume +of IEEE\ Std\ 1003.1-2001 specifies no explicit +conversions between numbers and strings. An application can force +an expression to be treated as a number by adding zero to it, or +can force it to be treated as a string by concatenating the null string +( \fB""\fP ) to it. +.LP +A string value shall be considered a \fInumeric string\fP if it comes +from one of the following: +.IP " 1." 4 +Field variables +.LP +.IP " 2." 4 +Input from the \fIgetline\fP() function +.LP +.IP " 3." 4 +\fBFILENAME\fP +.LP +.IP " 4." 4 +\fBARGV\fP array elements +.LP +.IP " 5." 4 +\fBENVIRON\fP array elements +.LP +.IP " 6." 4 +Array elements created by the \fIsplit\fP() function +.LP +.IP " 7." 4 +A command line variable assignment +.LP +.IP " 8." 4 +Variable assignment from another numeric string variable +.LP +.LP +and after all the following conversions have been applied, the resulting +string would lexically be recognized as a \fBNUMBER\fP +token as described by the lexical conventions in Grammar : +.IP " *" 3 +All leading and trailing <blank>s are discarded. +.LP +.IP " *" 3 +If the first non- <blank> is \fB'+'\fP or \fB'-'\fP , it is discarded. +.LP +.IP " *" 3 +Changing each occurrence of the decimal point character from the current +locale to a period. +.LP +.LP +If a \fB'-'\fP character is ignored in the preceding description, +the numeric value of the \fInumeric string\fP shall be the +negation of the numeric value of the recognized \fBNUMBER\fP token. +Otherwise, the numeric value of the \fInumeric string\fP +shall be the numeric value of the recognized \fBNUMBER\fP token. Whether +or not a string is a \fInumeric string\fP shall be +relevant only in contexts where that term is used in this section. +.LP +When an expression is used in a Boolean context, if it has a numeric +value, a value of zero shall be treated as false and any +other value shall be treated as true. Otherwise, a string value of +the null string shall be treated as false and any other value +shall be treated as true. A Boolean context shall be one of the following: +.IP " *" 3 +The first subexpression of a conditional expression +.LP +.IP " *" 3 +An expression operated on by logical NOT, logical AND, or logical +OR +.LP +.IP " *" 3 +The second expression of a \fBfor\fP statement +.LP +.IP " *" 3 +The expression of an \fBif\fP statement +.LP +.IP " *" 3 +The expression of the \fBwhile\fP clause in either a \fBwhile\fP or +\fBdo\fP... \fBwhile\fP statement +.LP +.IP " *" 3 +An expression used as a pattern (as in Overall Program Structure) +.LP +.LP +All arithmetic shall follow the semantics of floating-point arithmetic +as specified by the ISO\ C standard (see \fIConcepts Derived from +the ISO C Standard\fP ). +.LP +The value of the expression: +.sp +.RS +.nf + +\fIexpr1\fP \fB^\fP \fIexpr2\fP +.fi +.RE +.LP +shall be equivalent to the value returned by the ISO\ C standard function +call: +.sp +.RS +.nf + +\fBpow(\fP\fIexpr1\fP\fB,\fP \fIexpr2\fP\fB) +\fP +.fi +.RE +.LP +The expression: +.sp +.RS +.nf + +\fBlvalue ^=\fP \fIexpr\fP +.fi +.RE +.LP +shall be equivalent to the ISO\ C standard expression: +.sp +.RS +.nf + +\fBlvalue = pow(lvalue,\fP \fIexpr\fP\fB) +\fP +.fi +.RE +.LP +except that lvalue shall be evaluated only once. The value of the +expression: +.sp +.RS +.nf + +\fIexpr1\fP \fB%\fP \fIexpr2\fP +.fi +.RE +.LP +shall be equivalent to the value returned by the ISO\ C standard function +call: +.sp +.RS +.nf + +\fBfmod(\fP\fIexpr1\fP\fB,\fP \fIexpr2\fP\fB) +\fP +.fi +.RE +.LP +The expression: +.sp +.RS +.nf + +\fBlvalue %=\fP \fIexpr\fP +.fi +.RE +.LP +shall be equivalent to the ISO\ C standard expression: +.sp +.RS +.nf + +\fBlvalue = fmod(lvalue,\fP \fIexpr\fP\fB) +\fP +.fi +.RE +.LP +except that lvalue shall be evaluated only once. +.LP +Variables and fields shall be set by the assignment statement: +.sp +.RS +.nf + +\fBlvalue =\fP \fIexpression\fP +.fi +.RE +.LP +and the type of \fIexpression\fP shall determine the resulting variable +type. The assignment includes the arithmetic +assignments ( \fB"+="\fP , \fB"-="\fP , \fB"*="\fP , \fB"/="\fP , +\fB"%="\fP , \fB"^="\fP , \fB"++"\fP , +\fB"--"\fP ) all of which shall produce a numeric result. The left-hand +side of an assignment and the target of increment and +decrement operators can be one of a variable, an array with index, +or a field selector. +.LP +The \fIawk\fP language supplies arrays that are used for storing numbers +or strings. Arrays need not be declared. They shall +initially be empty, and their sizes shall change dynamically. The +subscripts, or element identifiers, are strings, providing a type +of associative array capability. An array name followed by a subscript +within square brackets can be used as an lvalue and thus as +an expression, as described in the grammar; see Grammar . Unsubscripted +array names can be used in +only the following contexts: +.IP " *" 3 +A parameter in a function definition or function call +.LP +.IP " *" 3 +The \fBNAME\fP token following any use of the keyword \fBin\fP as +specified in the grammar (see Grammar ); if the name used in this +context is not an array name, the behavior is undefined +.LP +.LP +A valid array \fIindex\fP shall consist of one or more comma-separated +expressions, similar to the way in which +multi-dimensional arrays are indexed in some programming languages. +Because \fIawk\fP arrays are really one-dimensional, such a +comma-separated list shall be converted to a single string by concatenating +the string values of the separate expressions, each +separated from the other by the value of the \fBSUBSEP\fP variable. +Thus, the following two index operations shall be +equivalent: +.sp +.RS +.nf + +\fIvar\fP\fB[\fP\fIexpr1\fP\fB,\fP \fIexpr2\fP\fB, ...\fP \fIexprn\fP\fB] +.sp + +\fP\fIvar\fP\fB[\fP\fIexpr1\fP \fBSUBSEP\fP \fIexpr2\fP \fBSUBSEP ... SUBSEP\fP \fIexprn\fP\fB]\fP +.fi +.RE +.LP +The application shall ensure that a multi-dimensioned \fIindex\fP +used with the \fBin\fP operator is parenthesized. The +\fBin\fP operator, which tests for the existence of a particular array +element, shall not cause that element to exist. Any other +reference to a nonexistent array element shall automatically create +it. +.LP +Comparisons (with the \fB'<'\fP , \fB"<="\fP , \fB"!="\fP , \fB"=="\fP +, \fB'>'\fP , and +\fB">="\fP operators) shall be made numerically if both operands are +numeric, if one is numeric and the other has a string +value that is a numeric string, or if one is numeric and the other +has the uninitialized value. Otherwise, operands shall be +converted to strings as required and a string comparison shall be +made using the locale-specific collation sequence. The value of +the comparison expression shall be 1 if the relation is true, or 0 +if the relation is false. +.SS Variables and Special Variables +.LP +Variables can be used in an \fIawk\fP program by referencing them. +With the exception of function parameters (see User-Defined Functions +), they are not explicitly declared. Function parameter names shall +be local to the +function; all other variable names shall be global. The same name +shall not be used as both a function parameter name and as the +name of a function or a special \fIawk\fP variable. The same name +shall not be used both as a variable name with global scope and +as the name of a function. The same name shall not be used within +the same scope both as a scalar variable and as an array. +Uninitialized variables, including scalar variables, array elements, +and field variables, shall have an uninitialized value. An +uninitialized value shall have both a numeric value of zero and a +string value of the empty string. Evaluation of variables with an +uninitialized value, to either string or numeric, shall be determined +by the context in which they are used. +.LP +Field variables shall be designated by a \fB'$'\fP followed by a number +or numerical expression. The effect of the field +number \fIexpression\fP evaluating to anything other than a non-negative +integer is unspecified; uninitialized variables or string +values need not be converted to numeric values in this context. New +field variables can be created by assigning a value to them. +References to nonexistent fields (that is, fields after $\fBNF\fP), +shall evaluate to the uninitialized value. Such references +shall not create new fields. However, assigning to a nonexistent field +(for example, $(\fBNF\fP+2)=5) shall increase the value of +\fBNF\fP; create any intervening fields with the uninitialized value; +and cause the value of $0 to be recomputed, with the fields +being separated by the value of \fBOFS\fP. Each field variable shall +have a string value or an uninitialized value when created. +Field variables shall have the uninitialized value when created from +$0 using \fBFS\fP and the variable does not contain any +characters. If appropriate, the field variable shall be considered +a numeric string (see Expressions in +awk ). +.LP +Implementations shall support the following other special variables +that are set by \fIawk\fP: +.TP 7 +\fBARGC\fP +The number of elements in the \fBARGV\fP array. +.TP 7 +\fBARGV\fP +An array of command line arguments, excluding options and the \fIprogram\fP +argument, numbered from zero to \fBARGC\fP-1. +.LP +The arguments in \fBARGV\fP can be modified or added to; \fBARGC\fP +can be altered. As each input file ends, \fIawk\fP shall +treat the next non-null element of \fBARGV\fP, up to the current value +of \fBARGC\fP-1, inclusive, as the name of the next input +file. Thus, setting an element of \fBARGV\fP to null means that it +shall not be treated as an input file. The name \fB'-'\fP +indicates the standard input. If an argument matches the format of +an \fIassignment\fP operand, this argument shall be treated as +an \fIassignment\fP rather than a \fIfile\fP argument. +.TP 7 +\fBCONVFMT\fP +The \fBprintf\fP format for converting numbers to strings (except +for output statements, where \fBOFMT\fP is used); +\fB"%.6g"\fP by default. +.TP 7 +\fBENVIRON\fP +An array representing the value of the environment, as described in +the \fIexec\fP functions defined in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001. The indices of the array shall be +strings consisting of the names of the environment +variables, and the value of each array element shall be a string consisting +of the value of that variable. If appropriate, the +environment variable shall be considered a \fInumeric string\fP (see +Expressions in awk ); the +array element shall also have its numeric value. +.LP +In all cases where the behavior of \fIawk\fP is affected by environment +variables (including the environment of any commands +that \fIawk\fP executes via the \fBsystem\fP function or via pipeline +redirections with the \fBprint\fP statement, the +\fBprintf\fP statement, or the \fBgetline\fP function), the environment +used shall be the environment at the time \fIawk\fP +began executing; it is implementation-defined whether any modification +of \fBENVIRON\fP affects this environment. +.TP 7 +\fBFILENAME\fP +A pathname of the current input file. Inside a \fBBEGIN\fP action +the value is undefined. Inside an \fBEND\fP action the +value shall be the name of the last input file processed. +.TP 7 +\fBFNR\fP +The ordinal number of the current record in the current file. Inside +a \fBBEGIN\fP action the value shall be zero. Inside an +\fBEND\fP action the value shall be the number of the last record +processed in the last file processed. +.TP 7 +\fBFS\fP +Input field separator regular expression; a <space> by default. +.TP 7 +\fBNF\fP +The number of fields in the current record. Inside a \fBBEGIN\fP action, +the use of \fBNF\fP is undefined unless a +\fBgetline\fP function without a \fIvar\fP argument is executed previously. +Inside an \fBEND\fP action, \fBNF\fP shall retain +the value it had for the last record read, unless a subsequent, redirected, +\fBgetline\fP function without a \fIvar\fP argument +is performed prior to entering the \fBEND\fP action. +.TP 7 +\fBNR\fP +The ordinal number of the current record from the start of input. +Inside a \fBBEGIN\fP action the value shall be zero. Inside +an \fBEND\fP action the value shall be the number of the last record +processed. +.TP 7 +\fBOFMT\fP +The \fBprintf\fP format for converting numbers to strings in output +statements (see Output +Statements ); \fB"%.6g"\fP by default. The result of the conversion +is unspecified if the value of \fBOFMT\fP is not a +floating-point format specification. +.TP 7 +\fBOFS\fP +The \fBprint\fP statement output field separation; <space> by default. +.TP 7 +\fBORS\fP +The \fBprint\fP statement output record separator; a <newline> by +default. +.TP 7 +\fBRLENGTH\fP +The length of the string matched by the \fBmatch\fP function. +.TP 7 +\fBRS\fP +The first character of the string value of \fBRS\fP shall be the input +record separator; a <newline> by default. If +\fBRS\fP contains more than one character, the results are unspecified. +If \fBRS\fP is null, then records are separated by +sequences consisting of a <newline> plus one or more blank lines, +leading or trailing blank lines shall not result in empty +records at the beginning or end of the input, and a <newline> shall +always be a field separator, no matter what the value of +\fBFS\fP is. +.TP 7 +\fBRSTART\fP +The starting position of the string matched by the \fBmatch\fP function, +numbering from 1. This shall always be equivalent to +the return value of the \fBmatch\fP function. +.TP 7 +\fBSUBSEP\fP +The subscript separator string for multi-dimensional arrays; the default +value is implementation-defined. +.sp +.SS Regular Expressions +.LP +The \fIawk\fP utility shall make use of the extended regular expression +notation (see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 9.4, Extended Regular Expressions) +except that it shall allow the use of C-language conventions for escaping +special characters within the EREs, as specified in the +table in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter +5, File +Format Notation ( \fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP +, \fB'\\n'\fP , \fB'\\r'\fP , \fB'\\t'\fP +, \fB'\\v'\fP ) and the following table; these escape sequences shall +be recognized both inside and outside bracket expressions. +Note that records need not be separated by <newline>s and string constants +can contain <newline>s, so even the +\fB"\\n"\fP sequence is valid in \fIawk\fP EREs. Using a slash character +within an ERE requires the escaping shown in the +following table. +.br +.sp +.ce 1 +\fBTable: Escape Sequences in \fIawk\fP\fP +.TS C +center; l1 lw(30)1 lw(30). +\fBEscape\fP T{ +.na +\fB\ \fP +.ad +T} T{ +.na +\fB\ \fP +.ad +T} +\fBSequence\fP T{ +.na +\fBDescription\fP +.ad +T} T{ +.na +\fBMeaning\fP +.ad +T} +\\" T{ +.na +Backslash quotation-mark +.ad +T} T{ +.na +Quotation-mark character +.ad +T} +\\/ T{ +.na +Backslash slash +.ad +T} T{ +.na +Slash character +.ad +T} +\\ddd T{ +.na +A backslash character followed by the longest sequence of one, two, or three octal-digit characters (01234567). If all of the digits are 0 (that is, representation of the NUL character), the behavior is undefined. +.ad +T} T{ +.na +The character whose encoding is represented by the one, two, or three-digit octal integer. Multi-byte characters require multiple, concatenated escape sequences of this type, including the leading \fB'\\'\fP for each byte. +.ad +T} +\\c T{ +.na +A backslash character followed by any character not described in this table or in the table in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation ( \fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , \fB'\\n'\fP , \fB'\\r'\fP , \fB'\\t'\fP , \fB'\\v'\fP ). +.ad +T} T{ +.na +Undefined +.ad +T} +.TE +.LP +A regular expression can be matched against a specific field or string +by using one of the two regular expression matching +operators, \fB'~'\fP and \fB"!~"\fP . These operators shall interpret +their right-hand operand as a regular +expression and their left-hand operand as a string. If the regular +expression matches the string, the \fB'~'\fP expression +shall evaluate to a value of 1, and the \fB"!~"\fP expression shall +evaluate to a value of 0. (The regular expression +matching operation is as defined by the term matched in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 9.1, Regular Expression +Definitions, where a match occurs on any part of the +string unless the regular expression is limited with the circumflex +or dollar sign special characters.) If the regular expression +does not match the string, the \fB'~'\fP expression shall evaluate +to a value of 0, and the \fB"!~"\fP expression +shall evaluate to a value of 1. If the right-hand operand is any expression +other than the lexical token \fBERE\fP, the string +value of the expression shall be interpreted as an extended regular +expression, including the escape conventions described above. +Note that these same escape conventions shall also be applied in determining +the value of a string literal (the lexical token +\fBSTRING\fP), and thus shall be applied a second time when a string +literal is used in this context. +.LP +When an \fBERE\fP token appears as an expression in any context other +than as the right-hand of the \fB'~'\fP or +\fB"!~"\fP operator or as one of the built-in function arguments described +below, the value of the resulting expression +shall be the equivalent of: +.sp +.RS +.nf + +\fB$0 ~ /\fP\fIere\fP\fB/ +\fP +.fi +.RE +.LP +The \fIere\fP argument to the \fBgsub\fP, \fBmatch\fP, \fBsub\fP functions, +and the \fIfs\fP argument to the \fBsplit\fP +function (see String Functions ) shall be interpreted as extended +regular expressions. These can be +either \fBERE\fP tokens or arbitrary expressions, and shall be interpreted +in the same manner as the right-hand side of the +\fB'~'\fP or \fB"!~"\fP operator. +.LP +An extended regular expression can be used to separate fields by using +the \fB-F\fP \fIERE\fP option or by assigning a string +containing the expression to the built-in variable \fBFS\fP. The default +value of the \fBFS\fP variable shall be a single +<space>. The following describes \fBFS\fP behavior: +.IP " 1." 4 +If \fBFS\fP is a null string, the behavior is unspecified. +.LP +.IP " 2." 4 +If \fBFS\fP is a single character: +.RS +.IP " a." 4 +If \fBFS\fP is <space>, skip leading and trailing <blank>s; fields +shall be delimited by sets of one or more +<blank>s. +.LP +.IP " b." 4 +Otherwise, if \fBFS\fP is any other character \fIc\fP, fields shall +be delimited by each single occurrence of \fIc\fP. +.LP +.RE +.LP +.IP " 3." 4 +Otherwise, the string value of \fBFS\fP shall be considered to be +an extended regular expression. Each occurrence of a sequence +matching the extended regular expression shall delimit fields. +.LP +.LP +Except for the \fB'~'\fP and \fB"!~"\fP operators, and in the \fBgsub\fP, +\fBmatch\fP, \fBsplit\fP, and +\fBsub\fP built-in functions, ERE matching shall be based on input +records; that is, record separator characters (the first +character of the value of the variable \fBRS\fP, <newline> by default) +cannot be embedded in the expression, and no +expression shall match the record separator character. If the record +separator is not <newline>, <newline>s embedded in +the expression can be matched. For the \fB'~'\fP and \fB"!~"\fP operators, +and in those four built-in functions, +ERE matching shall be based on text strings; that is, any character +(including <newline> and the record separator) can be +embedded in the pattern, and an appropriate pattern shall match any +character. However, in all \fIawk\fP ERE matching, the use of +one or more NUL characters in the pattern, input record, or text string +produces undefined results. +.SS Patterns +.LP +A \fIpattern\fP is any valid \fIexpression\fP, a range specified by +two expressions separated by a comma, or one of the two +special patterns \fBBEGIN\fP or \fBEND\fP. +.SS Special Patterns +.LP +The \fIawk\fP utility shall recognize two special patterns, \fBBEGIN\fP +and \fBEND\fP. Each \fBBEGIN\fP pattern shall be +matched once and its associated action executed before the first record +of input is read (except possibly by use of the +\fBgetline\fP function-see Input/Output and General Functions - in +a prior \fBBEGIN\fP action) and +before command line assignment is done. Each \fBEND\fP pattern shall +be matched once and its associated action executed after the +last record of input has been read. These two patterns shall have +associated actions. +.LP +\fBBEGIN\fP and \fBEND\fP shall not combine with other patterns. Multiple +\fBBEGIN\fP and \fBEND\fP patterns shall be +allowed. The actions associated with the \fBBEGIN\fP patterns shall +be executed in the order specified in the program, as are the +\fBEND\fP actions. An \fBEND\fP pattern can precede a \fBBEGIN\fP +pattern in a program. +.LP +If an \fIawk\fP program consists of only actions with the pattern +\fBBEGIN\fP, and the \fBBEGIN\fP action contains no +\fBgetline\fP function, \fIawk\fP shall exit without reading its input +when the last statement in the last \fBBEGIN\fP action is +executed. If an \fIawk\fP program consists of only actions with the +pattern \fBEND\fP or only actions with the patterns +\fBBEGIN\fP and \fBEND\fP, the input shall be read before the statements +in the \fBEND\fP actions are executed. +.SS Expression Patterns +.LP +An expression pattern shall be evaluated as if it were an expression +in a Boolean context. If the result is true, the pattern +shall be considered to match, and the associated action (if any) shall +be executed. If the result is false, the action shall not be +executed. +.SS Pattern Ranges +.LP +A pattern range consists of two expressions separated by a comma; +in this case, the action shall be performed for all records +between a match of the first expression and the following match of +the second expression, inclusive. At this point, the pattern +range can be repeated starting at input records subsequent to the +end of the matched range. +.SS Actions +.LP +An action is a sequence of statements as shown in the grammar in Grammar +\&. Any single statement +can be replaced by a statement list enclosed in braces. The application +shall ensure that statements in a statement list are +separated by <newline>s or semicolons. Statements in a statement list +shall be executed sequentially in the order that they +appear. +.LP +The \fIexpression\fP acting as the conditional in an \fBif\fP statement +shall be evaluated and if it is non-zero or non-null, +the following statement shall be executed; otherwise, if \fBelse\fP +is present, the statement following the \fBelse\fP shall be +executed. +.LP +The \fBif\fP, \fBwhile\fP, \fBdo\fP... \fBwhile\fP, \fBfor\fP, \fBbreak\fP, +and \fBcontinue\fP statements are based on +the ISO\ C standard (see \fIConcepts Derived from the ISO C Standard\fP +), except +that the Boolean expressions shall be treated as described in Expressions +in awk , and except in the +case of: +.sp +.RS +.nf + +\fBfor (\fP\fIvariable\fP \fBin\fP \fIarray\fP\fB) +\fP +.fi +.RE +.LP +which shall iterate, assigning each \fIindex\fP of \fIarray\fP to +\fIvariable\fP in an unspecified order. The results of +adding new elements to \fIarray\fP within such a \fBfor\fP loop are +undefined. If a \fBbreak\fP or \fBcontinue\fP statement +occurs outside of a loop, the behavior is undefined. +.LP +The \fBdelete\fP statement shall remove an individual array element. +Thus, the following code deletes an entire array: +.sp +.RS +.nf + +\fBfor (index in array) + delete array[index] +\fP +.fi +.RE +.LP +The \fBnext\fP statement shall cause all further processing of the +current input record to be abandoned. The behavior is +undefined if a \fBnext\fP statement appears or is invoked in a \fBBEGIN\fP +or \fBEND\fP action. +.LP +The \fBexit\fP statement shall invoke all \fBEND\fP actions in the +order in which they occur in the program source and then +terminate the program without reading further input. An \fBexit\fP +statement inside an \fBEND\fP action shall terminate the +program without further execution of \fBEND\fP actions. If an expression +is specified in an \fBexit\fP statement, its numeric +value shall be the exit status of \fIawk\fP, unless subsequent errors +are encountered or a subsequent \fBexit\fP statement with +an expression is executed. +.SS Output Statements +.LP +Both \fBprint\fP and \fBprintf\fP statements shall write to standard +output by default. The output shall be written to the +location specified by \fIoutput_redirection\fP if one is supplied, +as follows: +.sp +.RS +.nf + +\fB>\fP \fIexpression\fP\fB>>\fP \fIexpression\fP\fB|\fP \fIexpression\fP +.fi +.RE +.LP +In all cases, the \fIexpression\fP shall be evaluated to produce a +string that is used as a pathname into which to write (for +\fB'>'\fP or \fB">>"\fP ) or as a command to be executed (for \fB'|'\fP +). Using the first two forms, if the file +of that name is not currently open, it shall be opened, creating it +if necessary and using the first form, truncating the file. The +output then shall be appended to the file. As long as the file remains +open, subsequent calls in which \fIexpression\fP evaluates +to the same string value shall simply append output to the file. The +file remains open until the \fBclose\fP function (see Input/Output +and General Functions ) is called with an expression that evaluates +to the same string +value. +.LP +The third form shall write output onto a stream piped to the input +of a command. The stream shall be created if no stream is +currently open with the value of \fIexpression\fP as its command name. +The stream created shall be equivalent to one created by a +call to the \fIpopen\fP() function defined in the System Interfaces +volume of +IEEE\ Std\ 1003.1-2001 with the value of \fIexpression\fP as the \fIcommand\fP +argument and a value of \fIw\fP as the +\fImode\fP argument. As long as the stream remains open, subsequent +calls in which \fIexpression\fP evaluates to the same string +value shall write output to the existing stream. The stream shall +remain open until the \fBclose\fP function (see Input/Output and General +Functions ) is called with an expression that evaluates to the same +string value. +At that time, the stream shall be closed as if by a call to the \fIpclose\fP() +function +defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001. +.LP +As described in detail by the grammar in Grammar , these output statements +shall take a +comma-separated list of \fIexpression\fPs referred to in the grammar +by the non-terminal symbols \fBexpr_list\fP, +\fBprint_expr_list\fP, or \fBprint_expr_list_opt\fP. This list is +referred to here as the \fIexpression list\fP, and each member +is referred to as an \fIexpression argument\fP. +.LP +The \fBprint\fP statement shall write the value of each expression +argument onto the indicated output stream separated by the +current output field separator (see variable \fBOFS\fP above), and +terminated by the output record separator (see variable +\fBORS\fP above). All expression arguments shall be taken as strings, +being converted if necessary; this conversion shall be as +described in Expressions in awk , with the exception that the \fBprintf\fP +format in \fBOFMT\fP +shall be used instead of the value in \fBCONVFMT\fP. An empty expression +list shall stand for the whole input record ($0). +.LP +The \fBprintf\fP statement shall produce output based on a notation +similar to the File Format Notation used to describe file +formats in this volume of IEEE\ Std\ 1003.1-2001 (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation). +Output shall be produced as specified with the first +\fIexpression\fP argument as the string \fIformat\fP and subsequent +\fIexpression\fP arguments as the strings \fIarg1\fP to +\fIargn\fP, inclusive, with the following exceptions: +.IP " 1." 4 +The \fIformat\fP shall be an actual character string rather than a +graphical representation. Therefore, it cannot contain empty +character positions. The <space> in the \fIformat\fP string, in any +context other than a \fIflag\fP of a conversion +specification, shall be treated as an ordinary character that is copied +to the output. +.LP +.IP " 2." 4 +If the character set contains a \fB' '\fP character and that character +appears in +the \fIformat\fP string, it shall be treated as an ordinary character +that is copied to the output. +.LP +.IP " 3." 4 +The \fIescape sequences\fP beginning with a backslash character shall +be treated as sequences of ordinary characters that are +copied to the output. Note that these same sequences shall be interpreted +lexically by \fIawk\fP when they appear in literal +strings, but they shall not be treated specially by the \fBprintf\fP +statement. +.LP +.IP " 4." 4 +A \fIfield width\fP or \fIprecision\fP can be specified as the \fB'*'\fP +character instead of a digit string. In this case +the next argument from the expression list shall be fetched and its +numeric value taken as the field width or precision. +.LP +.IP " 5." 4 +The implementation shall not precede or follow output from the \fBd\fP +or \fBu\fP conversion specifier characters with +<blank>s not specified by the \fIformat\fP string. +.LP +.IP " 6." 4 +The implementation shall not precede output from the \fBo\fP conversion +specifier character with leading zeros not specified +by the \fIformat\fP string. +.LP +.IP " 7." 4 +For the \fBc\fP conversion specifier character: if the argument has +a numeric value, the character whose encoding is that +value shall be output. If the value is zero or is not the encoding +of any character in the character set, the behavior is +undefined. If the argument does not have a numeric value, the first +character of the string value shall be output; if the string +does not contain any characters, the behavior is undefined. +.LP +.IP " 8." 4 +For each conversion specification that consumes an argument, the next +expression argument shall be evaluated. With the exception +of the \fBc\fP conversion specifier character, the value shall be +converted (according to the rules specified in Expressions in awk +) to the appropriate type for the conversion specification. +.LP +.IP " 9." 4 +If there are insufficient expression arguments to satisfy all the +conversion specifications in the \fIformat\fP string, the +behavior is undefined. +.LP +.IP "10." 4 +If any character sequence in the \fIformat\fP string begins with a +\fB'%'\fP character, but does not form a valid conversion +specification, the behavior is unspecified. +.LP +.LP +Both \fBprint\fP and \fBprintf\fP can output at least {LINE_MAX} bytes. +.SS Functions +.LP +The \fIawk\fP language has a variety of built-in functions: arithmetic, +string, input/output, and general. +.SS Arithmetic Functions +.LP +The arithmetic functions, except for \fBint\fP, shall be based on +the ISO\ C standard (see \fIConcepts Derived from the ISO C Standard\fP +). The behavior is undefined in cases where the +ISO\ C standard specifies that an error be returned or that the behavior +is undefined. Although the grammar (see Grammar ) permits built-in +functions to appear with no arguments or parentheses, unless the argument +or +parentheses are indicated as optional in the following list (by displaying +them within the \fB"[]"\fP brackets), such use is +undefined. +.TP 7 +\fBatan2\fP(\fIy\fP,\fIx\fP) +Return arctangent of \fIy\fP/\fIx\fP in radians in the range [-pi,pi]. +.TP 7 +\fBcos\fP(\fIx\fP) +Return cosine of \fIx\fP, where \fIx\fP is in radians. +.TP 7 +\fBsin\fP(\fIx\fP) +Return sine of \fIx\fP, where \fIx\fP is in radians. +.TP 7 +\fBexp\fP(\fIx\fP) +Return the exponential function of \fIx\fP. +.TP 7 +\fBlog\fP(\fIx\fP) +Return the natural logarithm of \fIx\fP. +.TP 7 +\fBsqrt\fP(\fIx\fP) +Return the square root of \fIx\fP. +.TP 7 +\fBint\fP(\fIx\fP) +Return the argument truncated to an integer. Truncation shall be toward +0 when \fIx\fP>0. +.TP 7 +\fBrand\fP() +Return a random number \fIn\fP, such that 0<=\fIn\fP<1. +.TP 7 +\fBsrand\fP(\fB[\fP\fIexpr\fP\fB]\fP) +Set the seed value for \fIrand\fP to \fIexpr\fP or use the time of +day if \fIexpr\fP is omitted. The previous seed value +shall be returned. +.sp +.SS String Functions +.LP +The string functions in the following list shall be supported. Although +the grammar (see Grammar +) permits built-in functions to appear with no arguments or parentheses, +unless the argument or parentheses are indicated as +optional in the following list (by displaying them within the \fB"[]"\fP +brackets), such use is undefined. +.TP 7 +\fBgsub\fP(\fIere\fP,\ \fIrepl\fP\fB[\fP,\ \fIin\fP\fB]\fP) +Behave like \fBsub\fP (see below), except that it shall replace all +occurrences of the regular expression (like the \fIed\fP utility global +substitute) in $0 or in the \fIin\fP argument, when specified. +.TP 7 +\fBindex\fP(\fIs\fP,\ \fIt\fP) +Return the position, in characters, numbering from 1, in string \fIs\fP +where string \fIt\fP first occurs, or zero if it does +not occur at all. +.TP 7 +\fBlength[\fP(\fB[\fP\fIs\fP\fB]\fP)\fB]\fP +Return the length, in characters, of its argument taken as a string, +or of the whole record, $0, if there is no argument. +.TP 7 +\fBmatch\fP(\fIs\fP,\ \fIere\fP) +Return the position, in characters, numbering from 1, in string \fIs\fP +where the extended regular expression \fIere\fP +occurs, or zero if it does not occur at all. RSTART shall be set to +the starting position (which is the same as the returned +value), zero if no match is found; RLENGTH shall be set to the length +of the matched string, -1 if no match is found. +.TP 7 +\fBsplit\fP(\fIs\fP,\ \fIa\fP\fB[\fP,\ \fIfs\ \fP \fB]\fP) +Split the string \fIs\fP into array elements \fIa\fP[1], \fIa\fP[2], +\&..., \fIa\fP[\fIn\fP], and return \fIn\fP. All elements +of the array shall be deleted before the split is performed. The separation +shall be done with the ERE \fIfs\fP or with the field +separator \fBFS\fP if \fIfs\fP is not given. Each array element shall +have a string value when created and, if appropriate, the +array element shall be considered a numeric string (see Expressions +in awk ). The effect of a null +string as the value of \fIfs\fP is unspecified. +.TP 7 +\fBsprintf\fP(\fIfmt\fP,\ \fIexpr\fP,\ \fIexpr\fP,\ ...) +Format the expressions according to the \fBprintf\fP format given +by \fIfmt\fP and return the resulting string. +.TP 7 +\fBsub(\fP\fIere\fP,\ \fIrepl\fP\fB[\fP,\ \fIin\ \fP \fB]\fP) +Substitute the string \fIrepl\fP in place of the first instance of +the extended regular expression \fIERE\fP in string \fIin\fP +and return the number of substitutions. An ampersand ( \fB'&'\fP ) +appearing in the string \fIrepl\fP shall be replaced by +the string from \fIin\fP that matches the ERE. An ampersand preceded +with a backslash ( \fB'\\'\fP ) shall be interpreted as the +literal ampersand character. An occurrence of two consecutive backslashes +shall be interpreted as just a single literal backslash +character. Any other occurrence of a backslash (for example, preceding +any other character) shall be treated as a literal backslash +character. Note that if \fIrepl\fP is a string literal (the lexical +token \fBSTRING\fP; see Grammar ), the handling of the ampersand character +occurs after any lexical processing, including any +lexical backslash escape sequence processing. If \fIin\fP is specified +and it is not an lvalue (see Expressions in awk ), the behavior is +undefined. If \fIin\fP is omitted, \fIawk\fP shall use the current +record ($0) in its place. +.TP 7 +\fBsubstr\fP(\fIs\fP,\ \fIm\fP\fB[\fP,\ \fIn\ \fP \fB]\fP) +Return the at most \fIn\fP-character substring of \fIs\fP that begins +at position \fIm\fP, numbering from 1. If \fIn\fP is +omitted, or if \fIn\fP specifies more characters than are left in +the string, the length of the substring shall be limited by the +length of the string \fIs\fP. +.TP 7 +\fBtolower\fP(\fIs\fP) +Return a string based on the string \fIs\fP. Each character in \fIs\fP +that is an uppercase letter specified to have a +\fBtolower\fP mapping by the \fILC_CTYPE\fP category of the current +locale shall be replaced in the returned string by the +lowercase letter specified by the mapping. Other characters in \fIs\fP +shall be unchanged in the returned string. +.TP 7 +\fBtoupper\fP(\fIs\fP) +Return a string based on the string \fIs\fP. Each character in \fIs\fP +that is a lowercase letter specified to have a +\fBtoupper\fP mapping by the \fILC_CTYPE\fP category of the current +locale is replaced in the returned string by the uppercase +letter specified by the mapping. Other characters in \fIs\fP are unchanged +in the returned string. +.sp +.LP +All of the preceding functions that take \fIERE\fP as a parameter +expect a pattern or a string valued expression that is a +regular expression as defined in Regular Expressions . +.SS Input/Output and General Functions +.LP +The input/output and general functions are: +.TP 7 +\fBclose\fP(\fIexpression\fP) +Close the file or pipe opened by a \fBprint\fP or \fBprintf\fP statement +or a call to \fBgetline\fP with the same string-valued +\fIexpression\fP. The limit on the number of open \fIexpression\fP +arguments is implementation-defined. If the close was +successful, the function shall return zero; otherwise, it shall return +non-zero. +.TP 7 +\fIexpression\ |\ \fP \fBgetline\ [\fP\fIvar\fP\fB]\fP +Read a record of input from a stream piped from the output of a command. +The stream shall be created if no stream is currently open +with the value of \fIexpression\fP as its command name. The stream +created shall be equivalent to one created by a call to the \fIpopen\fP() +function with the value of \fIexpression\fP as the \fIcommand\fP argument +and a +value of \fIr\fP as the \fImode\fP argument. As long as the stream +remains open, subsequent calls in which \fIexpression\fP +evaluates to the same string value shall read subsequent records from +the stream. The stream shall remain open until the +\fBclose\fP function is called with an expression that evaluates to +the same string value. At that time, the stream shall be +closed as if by a call to the \fIpclose\fP() function. If \fIvar\fP +is omitted, $0 and +\fBNF\fP shall be set; otherwise, \fIvar\fP shall be set and, if appropriate, +it shall be considered a numeric string (see Expressions in awk ). +.LP +The \fBgetline\fP operator can form ambiguous constructs when there +are unparenthesized operators (including concatenate) to +the left of the \fB'|'\fP (to the beginning of the expression containing +\fBgetline\fP). In the context of the \fB'$'\fP +operator, \fB'|'\fP shall behave as if it had a lower precedence than +\fB'$'\fP . The result of evaluating other operators is +unspecified, and conforming applications shall parenthesize properly +all such usages. +.TP 7 +\fBgetline\fP +Set $0 to the next input record from the current input file. This +form of \fBgetline\fP shall set the \fBNF\fP, \fBNR\fP, +and \fBFNR\fP variables. +.TP 7 +\fBgetline\ \fP \fIvar\fP +Set variable \fIvar\fP to the next input record from the current input +file and, if appropriate, \fIvar\fP shall be +considered a numeric string (see Expressions in awk ). This form of +\fBgetline\fP shall set the +\fBFNR\fP and \fBNR\fP variables. +.TP 7 +\fBgetline\ [\fP\fIvar\fP\fB]\ \fP <\ \fIexpression\fP +Read the next record of input from a named file. The \fIexpression\fP +shall be evaluated to produce a string that is used as a +pathname. If the file of that name is not currently open, it shall +be opened. As long as the stream remains open, subsequent calls +in which \fIexpression\fP evaluates to the same string value shall +read subsequent records from the file. The file shall remain +open until the \fBclose\fP function is called with an expression that +evaluates to the same string value. If \fIvar\fP is +omitted, $0 and \fBNF\fP shall be set; otherwise, \fIvar\fP shall +be set and, if appropriate, it shall be considered a numeric +string (see Expressions in awk ). +.LP +The \fBgetline\fP operator can form ambiguous constructs when there +are unparenthesized binary operators (including +concatenate) to the right of the \fB'<'\fP (up to the end of the expression +containing the \fBgetline\fP). The result of +evaluating such a construct is unspecified, and conforming applications +shall parenthesize properly all such usages. +.TP 7 +\fBsystem\fP(\fIexpression\fP) +Execute the command given by \fIexpression\fP in a manner equivalent +to the \fIsystem\fP() +function defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001 +and return the exit status of the command. +.sp +.LP +All forms of \fBgetline\fP shall return 1 for successful input, zero +for end-of-file, and -1 for an error. +.LP +Where strings are used as the name of a file or pipeline, the application +shall ensure that the strings are textually identical. +The terminology "same string value" implies that "equivalent strings", +even those that differ only by <space>s, represent +different files. +.SS User-Defined Functions +.LP +The \fIawk\fP language also provides user-defined functions. Such +functions can be defined as: +.sp +.RS +.nf + +\fBfunction\fP \fIname\fP\fB(\fP\fB[\fP\fIparameter\fP\fB, ...\fP\fB]\fP\fB) {\fP \fIstatements\fP \fB} +\fP +.fi +.RE +.LP +A function can be referred to anywhere in an \fIawk\fP program; in +particular, its use can precede its definition. The scope of +a function is global. +.LP +Function parameters, if present, can be either scalars or arrays; +the behavior is undefined if an array name is passed as a +parameter that the function uses as a scalar, or if a scalar expression +is passed as a parameter that the function uses as an +array. Function parameters shall be passed by value if scalar and +by reference if array name. +.LP +The number of parameters in the function definition need not match +the number of parameters in the function call. Excess formal +parameters can be used as local variables. If fewer arguments are +supplied in a function call than are in the function definition, +the extra parameters that are used in the function body as scalars +shall evaluate to the uninitialized value until they are +otherwise initialized, and the extra parameters that are used in the +function body as arrays shall be treated as uninitialized +arrays where each element evaluates to the uninitialized value until +otherwise initialized. +.LP +When invoking a function, no white space can be placed between the +function name and the opening parenthesis. Function calls can +be nested and recursive calls can be made upon functions. Upon return +from any nested or recursive function call, the values of all +of the calling function's parameters shall be unchanged, except for +array parameters passed by reference. The \fBreturn\fP +statement can be used to return a value. If a \fBreturn\fP statement +appears outside of a function definition, the behavior is +undefined. +.LP +In the function definition, <newline>s shall be optional before the +opening brace and after the closing brace. Function +definitions can appear anywhere in the program where a \fIpattern-action\fP +pair is allowed. +.SS Grammar +.LP +The grammar in this section and the lexical conventions in the following +section shall together describe the syntax for +\fIawk\fP programs. The general conventions for this style of grammar +are described in \fIGrammar Conventions\fP . A valid program can be +represented as the non-terminal symbol +\fIprogram\fP in the grammar. This formal syntax shall take precedence +over the preceding text syntax description. +.sp +.RS +.nf + +\fB%token NAME NUMBER STRING ERE +%token FUNC_NAME /* Name followed by '(' without white space. */ +.sp + +/* Keywords */ +%token Begin End +/* 'BEGIN' 'END' */ +.sp + +%token Break Continue Delete Do Else +/* 'break' 'continue' 'delete' 'do' 'else' */ +.sp + +%token Exit For Function If In +/* 'exit' 'for' 'function' 'if' 'in' */ +.sp + +%token Next Print Printf Return While +/* 'next' 'print' 'printf' 'return' 'while' */ +.sp + +/* Reserved function names */ +%token BUILTIN_FUNC_NAME + /* One token for the following: + * atan2 cos sin exp log sqrt int rand srand + * gsub index length match split sprintf sub + * substr tolower toupper close system + */ +%token GETLINE + /* Syntactically different from other built-ins. */ +.sp + +/* Two-character tokens. */ +%token ADD_ASSIGN SUB_ASSIGN MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN POW_ASSIGN +/* '+=' '-=' '*=' '/=' '%=' '^=' */ +.sp + +%token OR AND NO_MATCH EQ LE GE NE INCR DECR APPEND +/* '||' '&&' '!~' '==' '<=' '>=' '!=' '++' '--' '>>' */ +.sp + +/* One-character tokens. */ +%token '{' '}' '(' ')' '[' ']' ',' ';' NEWLINE +%token '+' '-' '*' '%' '^' '!' '>' '<' '|' '?' ':' '~' '$' '=' +.sp + +%start program +%% +.sp + +program : item_list + | actionless_item_list + ; +.sp + +item_list : newline_opt + | actionless_item_list item terminator + | item_list item terminator + | item_list action terminator + ; +.sp + +actionless_item_list : item_list pattern terminator + | actionless_item_list pattern terminator + ; +.sp + +item : pattern action + | Function NAME '(' param_list_opt ')' + newline_opt action + | Function FUNC_NAME '(' param_list_opt ')' + newline_opt action + ; +.sp + +param_list_opt : /* empty */ + | param_list + ; +.sp + +param_list : NAME + | param_list ',' NAME + ; +.sp + +pattern : Begin + | End + | expr + | expr ',' newline_opt expr + ; +.sp + +action : '{' newline_opt '}' + | '{' newline_opt terminated_statement_list '}' + | '{' newline_opt unterminated_statement_list '}' + ; +.sp + +terminator : terminator ';' + | terminator NEWLINE + | ';' + | NEWLINE + ; +.sp + +terminated_statement_list : terminated_statement + | terminated_statement_list terminated_statement + ; +.sp + +unterminated_statement_list : unterminated_statement + | terminated_statement_list unterminated_statement + ; +.sp + +terminated_statement : action newline_opt + | If '(' expr ')' newline_opt terminated_statement + | If '(' expr ')' newline_opt terminated_statement + Else newline_opt terminated_statement + | While '(' expr ')' newline_opt terminated_statement + | For '(' simple_statement_opt ';' + expr_opt ';' simple_statement_opt ')' newline_opt + terminated_statement + | For '(' NAME In NAME ')' newline_opt + terminated_statement + | ';' newline_opt + | terminatable_statement NEWLINE newline_opt + | terminatable_statement ';' newline_opt + ; +.sp + +unterminated_statement : terminatable_statement + | If '(' expr ')' newline_opt unterminated_statement + | If '(' expr ')' newline_opt terminated_statement + Else newline_opt unterminated_statement + | While '(' expr ')' newline_opt unterminated_statement + | For '(' simple_statement_opt ';' + expr_opt ';' simple_statement_opt ')' newline_opt + unterminated_statement + | For '(' NAME In NAME ')' newline_opt + unterminated_statement + ; +.sp + +terminatable_statement : simple_statement + | Break + | Continue + | Next + | Exit expr_opt + | Return expr_opt + | Do newline_opt terminated_statement While '(' expr ')' + ; +.sp + +simple_statement_opt : /* empty */ + | simple_statement + ; +.sp + +simple_statement : Delete NAME '[' expr_list ']' + | expr + | print_statement + ; +.sp + +print_statement : simple_print_statement + | simple_print_statement output_redirection + ; +.sp + +simple_print_statement : Print print_expr_list_opt + | Print '(' multiple_expr_list ')' + | Printf print_expr_list + | Printf '(' multiple_expr_list ')' + ; +.sp + +output_redirection : '>' expr + | APPEND expr + | '|' expr + ; +.sp + +expr_list_opt : /* empty */ + | expr_list + ; +.sp + +expr_list : expr + | multiple_expr_list + ; +.sp + +multiple_expr_list : expr ',' newline_opt expr + | multiple_expr_list ',' newline_opt expr + ; +.sp + +expr_opt : /* empty */ + | expr + ; +.sp + +expr : unary_expr + | non_unary_expr + ; +.sp + +unary_expr : '+' expr + | '-' expr + | unary_expr '^' expr + | unary_expr '*' expr + | unary_expr '/' expr + | unary_expr '%' expr + | unary_expr '+' expr + | unary_expr '-' expr + | unary_expr non_unary_expr + | unary_expr '<' expr + | unary_expr LE expr + | unary_expr NE expr + | unary_expr EQ expr + | unary_expr '>' expr + | unary_expr GE expr + | unary_expr '~' expr + | unary_expr NO_MATCH expr + | unary_expr In NAME + | unary_expr AND newline_opt expr + | unary_expr OR newline_opt expr + | unary_expr '?' expr ':' expr + | unary_input_function + ; +.sp + +non_unary_expr : '(' expr ')' + | '!' expr + | non_unary_expr '^' expr + | non_unary_expr '*' expr + | non_unary_expr '/' expr + | non_unary_expr '%' expr + | non_unary_expr '+' expr + | non_unary_expr '-' expr + | non_unary_expr non_unary_expr + | non_unary_expr '<' expr + | non_unary_expr LE expr + | non_unary_expr NE expr + | non_unary_expr EQ expr + | non_unary_expr '>' expr + | non_unary_expr GE expr + | non_unary_expr '~' expr + | non_unary_expr NO_MATCH expr + | non_unary_expr In NAME + | '(' multiple_expr_list ')' In NAME + | non_unary_expr AND newline_opt expr + | non_unary_expr OR newline_opt expr + | non_unary_expr '?' expr ':' expr + | NUMBER + | STRING + | lvalue + | ERE + | lvalue INCR + | lvalue DECR + | INCR lvalue + | DECR lvalue + | lvalue POW_ASSIGN expr + | lvalue MOD_ASSIGN expr + | lvalue MUL_ASSIGN expr + | lvalue DIV_ASSIGN expr + | lvalue ADD_ASSIGN expr + | lvalue SUB_ASSIGN expr + | lvalue '=' expr + | FUNC_NAME '(' expr_list_opt ')' + /* no white space allowed before '(' */ + | BUILTIN_FUNC_NAME '(' expr_list_opt ')' + | BUILTIN_FUNC_NAME + | non_unary_input_function + ; +.sp + +print_expr_list_opt : /* empty */ + | print_expr_list + ; +.sp + +print_expr_list : print_expr + | print_expr_list ',' newline_opt print_expr + ; +.sp + +print_expr : unary_print_expr + | non_unary_print_expr + ; +.sp + +unary_print_expr : '+' print_expr + | '-' print_expr + | unary_print_expr '^' print_expr + | unary_print_expr '*' print_expr + | unary_print_expr '/' print_expr + | unary_print_expr '%' print_expr + | unary_print_expr '+' print_expr + | unary_print_expr '-' print_expr + | unary_print_expr non_unary_print_expr + | unary_print_expr '~' print_expr + | unary_print_expr NO_MATCH print_expr + | unary_print_expr In NAME + | unary_print_expr AND newline_opt print_expr + | unary_print_expr OR newline_opt print_expr + | unary_print_expr '?' print_expr ':' print_expr + ; +.sp + +non_unary_print_expr : '(' expr ')' + | '!' print_expr + | non_unary_print_expr '^' print_expr + | non_unary_print_expr '*' print_expr + | non_unary_print_expr '/' print_expr + | non_unary_print_expr '%' print_expr + | non_unary_print_expr '+' print_expr + | non_unary_print_expr '-' print_expr + | non_unary_print_expr non_unary_print_expr + | non_unary_print_expr '~' print_expr + | non_unary_print_expr NO_MATCH print_expr + | non_unary_print_expr In NAME + | '(' multiple_expr_list ')' In NAME + | non_unary_print_expr AND newline_opt print_expr + | non_unary_print_expr OR newline_opt print_expr + | non_unary_print_expr '?' print_expr ':' print_expr + | NUMBER + | STRING + | lvalue + | ERE + | lvalue INCR + | lvalue DECR + | INCR lvalue + | DECR lvalue + | lvalue POW_ASSIGN print_expr + | lvalue MOD_ASSIGN print_expr + | lvalue MUL_ASSIGN print_expr + | lvalue DIV_ASSIGN print_expr + | lvalue ADD_ASSIGN print_expr + | lvalue SUB_ASSIGN print_expr + | lvalue '=' print_expr + | FUNC_NAME '(' expr_list_opt ')' + /* no white space allowed before '(' */ + | BUILTIN_FUNC_NAME '(' expr_list_opt ')' + | BUILTIN_FUNC_NAME + ; +.sp + +lvalue : NAME + | NAME '[' expr_list ']' + | '$' expr + ; +.sp + +non_unary_input_function : simple_get + | simple_get '<' expr + | non_unary_expr '|' simple_get + ; +.sp + +unary_input_function : unary_expr '|' simple_get + ; +.sp + +simple_get : GETLINE + | GETLINE lvalue + ; +.sp + +newline_opt : /* empty */ + | newline_opt NEWLINE + ; +\fP +.fi +.RE +.LP +This grammar has several ambiguities that shall be resolved as follows: +.IP " *" 3 +Operator precedence and associativity shall be as described in Expressions +in Decreasing Precedence in \fIawk\fP . +.LP +.IP " *" 3 +In case of ambiguity, an \fBelse\fP shall be associated with the most +immediately preceding \fBif\fP that would satisfy the +grammar. +.LP +.IP " *" 3 +In some contexts, a slash ( \fB'/'\fP ) that is used to surround an +ERE could also be the division operator. This shall be +resolved in such a way that wherever the division operator could appear, +a slash is assumed to be the division operator. (There is +no unary division operator.) +.LP +.LP +One convention that might not be obvious from the formal grammar is +where <newline>s are acceptable. There are several +obvious placements such as terminating a statement, and a backslash +can be used to escape <newline>s between any lexical +tokens. In addition, <newline>s without backslashes can follow a comma, +an open brace, logical AND operator ( +\fB"&&"\fP ), logical OR operator ( \fB"||"\fP ), the \fBdo\fP keyword, +the \fBelse\fP keyword, and the closing +parenthesis of an \fBif\fP, \fBfor\fP, or \fBwhile\fP statement. For +example: +.sp +.RS +.nf + +\fB{ print $1, + $2 } +\fP +.fi +.RE +.SS Lexical Conventions +.LP +The lexical conventions for \fIawk\fP programs, with respect to the +preceding grammar, shall be as follows: +.IP " 1." 4 +Except as noted, \fIawk\fP shall recognize the longest possible token +or delimiter beginning at a given point. +.LP +.IP " 2." 4 +A comment shall consist of any characters beginning with the number +sign character and terminated by, but excluding the next +occurrence of, a <newline>. Comments shall have no effect, except +to delimit lexical tokens. +.LP +.IP " 3." 4 +The <newline> shall be recognized as the token \fBNEWLINE\fP. +.LP +.IP " 4." 4 +A backslash character immediately followed by a <newline> shall have +no effect. +.LP +.IP " 5." 4 +The token \fBSTRING\fP shall represent a string constant. A string +constant shall begin with the character \fB' .'\fP Within +a string constant, a backslash character shall be considered to begin +an escape sequence as specified in the table in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 5, File Format +Notation ( +\fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , \fB'\\n'\fP +, \fB'\\r'\fP , \fB'\\t'\fP , \fB'\\v'\fP ). In +addition, the escape sequences in Expressions in Decreasing Precedence +in \fIawk\fP shall be recognized. A <newline> shall not +occur within a string constant. A string constant shall be terminated +by the first unescaped occurrence of the character +\fB''\fP after the one that begins the string constant. The value +of the string shall be the sequence of all unescaped +characters and values of escape sequences between, but not including, +the two delimiting \fB''\fP characters. +.LP +.IP " 6." 4 +The token \fBERE\fP represents an extended regular expression constant. +An ERE constant shall begin with the slash character. +Within an ERE constant, a backslash character shall be considered +to begin an escape sequence as specified in the table in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 5, File Format +Notation. In +addition, the escape sequences in Expressions in Decreasing Precedence +in \fIawk\fP shall be recognized. The application shall +ensure that a <newline> does not occur within an ERE constant. An +ERE constant shall be terminated by the first unescaped +occurrence of the slash character after the one that begins the ERE +constant. The extended regular expression represented by the +ERE constant shall be the sequence of all unescaped characters and +values of escape sequences between, but not including, the two +delimiting slash characters. +.LP +.IP " 7." 4 +A <blank> shall have no effect, except to delimit lexical tokens or +within \fBSTRING\fP or \fBERE\fP tokens. +.LP +.IP " 8." 4 +The token \fBNUMBER\fP shall represent a numeric constant. Its form +and numeric value shall be equivalent to either of the +tokens \fBfloating-constant\fP or \fBinteger-constant\fP as specified +by the ISO\ C standard, with the following +exceptions: +.RS +.IP " a." 4 +An integer constant cannot begin with 0x or include the hexadecimal +digits \fB'a'\fP , \fB'b'\fP , \fB'c'\fP , +\fB'd'\fP , \fB'e'\fP , \fB'f'\fP , \fB'A'\fP , \fB'B'\fP , \fB'C'\fP +, \fB'D'\fP , \fB'E'\fP , or +\fB'F'\fP . +.LP +.IP " b." 4 +The value of an integer constant beginning with 0 shall be taken in +decimal rather than octal. +.LP +.IP " c." 4 +An integer constant cannot include a suffix ( \fB'u'\fP , \fB'U'\fP +, \fB'l'\fP , or \fB'L'\fP ). +.LP +.IP " d." 4 +A floating constant cannot include a suffix ( \fB'f'\fP , \fB'F'\fP +, \fB'l'\fP , or \fB'L'\fP ). +.LP +.RE +.LP +If the value is too large or too small to be representable (see \fIConcepts +Derived from +the ISO C Standard\fP ), the behavior is undefined. +.LP +.IP " 9." 4 +A sequence of underscores, digits, and alphabetics from the portable +character set (see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character Set), beginning +with an underscore or alphabetic, shall be considered a word. +.LP +.IP "10." 4 +The following words are keywords that shall be recognized as individual +tokens; the name of the token is the same as the +keyword: +.TS C +center; lw(13) lw(13) lw(13) lw(13) lw(13) lw(13). +T{ +\fB +.br +BEGIN +.br +break +.br +continue +.br +\fP +T} T{ +\fB +.br +delete +.br +do +.br +else +.br +\fP +T} T{ +\fB +.br +END +.br +exit +.br +for +.br +\fP +T} T{ +\fB +.br +function +.br +getline +.br +if +.br +\fP +T} T{ +\fB +.br +in +.br +next +.br +print +.br +\fP +T} T{ +\fB +.br +printf +.br +return +.br +while +.br +\fP +T} +.TE +.LP +.IP "11." 4 +The following words are names of built-in functions and shall be recognized +as the token \fBBUILTIN_FUNC_NAME\fP: +.TS C +center; lw(13) lw(13) lw(13) lw(13) lw(13) lw(13). +T{ +\fB +.br +atan2 +.br +close +.br +cos +.br +exp +.br +\fP +T} T{ +\fB +.br +gsub +.br +index +.br +int +.br +length +.br +\fP +T} T{ +\fB +.br +log +.br +match +.br +rand +.br +sin +.br +\fP +T} T{ +\fB +.br +split +.br +sprintf +.br +sqrt +.br +srand +.br +\fP +T} T{ +\fB +.br +sub +.br +substr +.br +system +.br +tolower +.br +\fP +T} T{ +\fB +.br +toupper +.br +\fP +T} +.TE +.LP +The above-listed keywords and names of built-in functions are considered +reserved words. +.LP +.IP "12." 4 +The token \fBNAME\fP shall consist of a word that is not a keyword +or a name of a built-in function and is not followed +immediately (without any delimiters) by the \fB'('\fP character. +.LP +.IP "13." 4 +The token \fBFUNC_NAME\fP shall consist of a word that is not a keyword +or a name of a built-in function, followed immediately +(without any delimiters) by the \fB'('\fP character. The \fB'('\fP +character shall not be included as part of the token. +.LP +.IP "14." 4 +The following two-character sequences shall be recognized as the named +tokens: +.TS C +center; l l l l. +\fBToken Name\fP \fBSequence\fP \fBToken Name\fP \fBSequence\fP +\fBADD_ASSIGN\fP += \fBNO_MATCH\fP !~ +\fBSUB_ASSIGN\fP -= \fBEQ\fP == +\fBMUL_ASSIGN\fP *= \fBLE\fP <= +\fBDIV_ASSIGN\fP /= \fBGE\fP >= +\fBMOD_ASSIGN\fP %= \fBNE\fP != +\fBPOW_ASSIGN\fP ^= \fBINCR\fP ++ +\fBOR\fP || \fBDECR\fP -- +\fBAND\fP && \fBAPPEND\fP >> +.TE +.LP +.IP "15." 4 +The following single characters shall be recognized as tokens whose +names are the character: +.sp +.RS +.nf + +\fB<newline> { } ( ) [ ] , ; + - * % ^ ! > < | ? : ~ $ = +\fP +.fi +.RE +.LP +.LP +There is a lexical ambiguity between the token \fBERE\fP and the tokens +\fB'/'\fP and \fBDIV_ASSIGN\fP. When an input +sequence begins with a slash character in any syntactic context where +the token \fB'/'\fP or \fBDIV_ASSIGN\fP could appear as +the next token in a valid program, the longer of those two tokens +that can be recognized shall be recognized. In any other +syntactic context where the token \fBERE\fP could appear as the next +token in a valid program, the token \fBERE\fP shall be +recognized. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were processed successfully. +.TP 7 +>0 +An error occurred. +.sp +.LP +The exit status can be altered within the program by using an \fBexit\fP +expression. +.SH CONSEQUENCES OF ERRORS +.LP +If any \fIfile\fP operand is specified and the named file cannot be +accessed, \fIawk\fP shall write a diagnostic message to +standard error and terminate without any further action. +.LP +If the program specified by either the \fIprogram\fP operand or a +\fIprogfile\fP operand is not a valid \fIawk\fP program (as +specified in the EXTENDED DESCRIPTION section), the behavior is undefined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fBindex\fP, \fBlength\fP, \fBmatch\fP, and \fBsubstr\fP functions +should not be confused with similar functions in the +ISO\ C standard; the \fIawk\fP versions deal with characters, while +the ISO\ C standard deals with bytes. +.LP +Because the concatenation operation is represented by adjacent expressions +rather than an explicit operator, it is often +necessary to use parentheses to enforce the proper evaluation precedence. +.SH EXAMPLES +.LP +The \fIawk\fP program specified in the command line is most easily +specified within single-quotes (for example, +'\fIprogram\fP') for applications using \fIsh\fP, because \fIawk\fP +programs commonly contain +characters that are special to the shell, including double-quotes. +In the cases where an \fIawk\fP program contains single-quote +characters, it is usually easiest to specify most of the program as +strings within single-quotes concatenated by the shell with +quoted single-quote characters. For example: +.sp +.RS +.nf + +\fBawk '/'\\''/ { print "quote:", $0 }' +\fP +.fi +.RE +.LP +prints all lines from the standard input containing a single-quote +character, prefixed with \fIquote\fP:. +.LP +The following are examples of simple \fIawk\fP programs: +.IP " 1." 4 +Write to the standard output all input lines for which field 3 is +greater than 5: +.sp +.RS +.nf + +\fB$3 > 5 +\fP +.fi +.RE +.LP +.IP " 2." 4 +Write every tenth line: +.sp +.RS +.nf + +\fB(NR % 10) == 0 +\fP +.fi +.RE +.LP +.IP " 3." 4 +Write any line with a substring matching the regular expression: +.sp +.RS +.nf + +\fB/(G|D)(2[0-9][[:alpha:]]*)/ +\fP +.fi +.RE +.LP +.IP " 4." 4 +Print any line with a substring containing a \fB'G'\fP or \fB'D'\fP +, followed by a sequence of digits and characters. +This example uses character classes \fBdigit\fP and \fBalpha\fP to +match language-independent digit and alphabetic characters +respectively: +.sp +.RS +.nf + +\fB/(G|D)([[:digit:][:alpha:]]*)/ +\fP +.fi +.RE +.LP +.IP " 5." 4 +Write any line in which the second field matches the regular expression +and the fourth field does not: +.sp +.RS +.nf + +\fB$2 ~ /xyz/ && $4 !~ /xyz/ +\fP +.fi +.RE +.LP +.IP " 6." 4 +Write any line in which the second field contains a backslash: +.sp +.RS +.nf + +\fB$2 ~ /\\\\/ +\fP +.fi +.RE +.LP +.IP " 7." 4 +Write any line in which the second field contains a backslash. Note +that backslash escapes are interpreted twice; once in +lexical processing of the string and once in processing the regular +expression: +.sp +.RS +.nf + +\fB$2 ~ "\\\\\\\\" +\fP +.fi +.RE +.LP +.IP " 8." 4 +Write the second to the last and the last field in each line. Separate +the fields by a colon: +.sp +.RS +.nf + +\fB{OFS=":";print $(NF-1), $NF} +\fP +.fi +.RE +.LP +.IP " 9." 4 +Write the line number and number of fields in each line. The three +strings representing the line number, the colon, and the +number of fields are concatenated and that string is written to standard +output: +.sp +.RS +.nf + +\fB{print NR ":" NF} +\fP +.fi +.RE +.LP +.IP "10." 4 +Write lines longer than 72 characters: +.sp +.RS +.nf + +\fBlength($0) > 72 +\fP +.fi +.RE +.LP +.IP "11." 4 +Write the first two fields in opposite order separated by \fBOFS\fP: +.sp +.RS +.nf + +\fB{ print $2, $1 } +\fP +.fi +.RE +.LP +.IP "12." 4 +Same, with input fields separated by a comma or <space>s and <tab>s, +or both: +.sp +.RS +.nf + +\fBBEGIN { FS = ",[ \\t]*|[ \\t]+" } + { print $2, $1 } +\fP +.fi +.RE +.LP +.IP "13." 4 +Add up the first column, print sum, and average: +.sp +.RS +.nf + +\fB {s += $1 } +END {print "sum is ", s, " average is", s/NR} +\fP +.fi +.RE +.LP +.IP "14." 4 +Write fields in reverse order, one per line (many lines out for each +line in): +.sp +.RS +.nf + +\fB{ for (i = NF; i > 0; --i) print $i } +\fP +.fi +.RE +.LP +.IP "15." 4 +Write all lines between occurrences of the strings \fBstart\fP and +\fBstop\fP: +.sp +.RS +.nf + +\fB/start/, /stop/ +\fP +.fi +.RE +.LP +.IP "16." 4 +Write all lines whose first field is different from the previous one: +.sp +.RS +.nf + +\fB$1 != prev { print; prev = $1 } +\fP +.fi +.RE +.LP +.IP "17." 4 +Simulate \fIecho\fP: +.sp +.RS +.nf + +\fBBEGIN { + for (i = 1; i < ARGC; ++i) + printf("%s%s", ARGV[i], i==ARGC-1?"\\n":" ") +} +\fP +.fi +.RE +.LP +.IP "18." 4 +Write the path prefixes contained in the \fIPATH\fP environment variable, +one per line: +.sp +.RS +.nf + +\fBBEGIN { + n = split (ENVIRON["PATH"], path, ":") + for (i = 1; i <= n; ++i) + print path[i] +} +\fP +.fi +.RE +.LP +.IP "19." 4 +If there is a file named \fBinput\fP containing page headers of the +form: +.sp +.RS +.nf + +Page # +.fi +.RE +.LP +and a file named \fBprogram\fP that contains: +.sp +.RS +.nf + +\fB/Page/ { $2 = n++; } + { print } +\fP +.fi +.RE +.LP +then the command line: +.sp +.RS +.nf + +\fBawk -f program n=5 input +\fP +.fi +.RE +.LP +prints the file \fBinput\fP, filling in page numbers starting at 5. +.LP +.SH RATIONALE +.LP +This description is based on the new \fIawk\fP, "nawk", (see the referenced +\fIThe AWK Programming Language\fP), which +introduced a number of new features to the historical \fIawk\fP: +.IP " 1." 4 +New keywords: \fBdelete\fP, \fBdo\fP, \fBfunction\fP, \fBreturn\fP +.LP +.IP " 2." 4 +New built-in functions: \fBatan2\fP, \fBclose\fP, \fBcos\fP, \fBgsub\fP, +\fBmatch\fP, \fBrand\fP, \fBsin\fP, +\fBsrand\fP, \fBsub\fP, \fBsystem\fP +.LP +.IP " 3." 4 +New predefined variables: \fBFNR\fP, \fBARGC\fP, \fBARGV\fP, \fBRSTART\fP, +\fBRLENGTH\fP, \fBSUBSEP\fP +.LP +.IP " 4." 4 +New expression operators: \fB?\fP, \fB:\fP, \fB,\fP, \fB^\fP +.LP +.IP " 5." 4 +The \fBFS\fP variable and the third argument to \fBsplit\fP, now treated +as extended regular expressions. +.LP +.IP " 6." 4 +The operator precedence, changed to more closely match the C language. +Two examples of code that operate differently are: +.sp +.RS +.nf + +\fBwhile ( n /= 10 > 1) ... +if (!"wk" ~ /bwk/) ... +\fP +.fi +.RE +.LP +.LP +Several features have been added based on newer implementations of +\fIawk\fP: +.IP " *" 3 +Multiple instances of \fB-f\fP \fIprogfile\fP are permitted. +.LP +.IP " *" 3 +The new option \fB-v\fP \fIassignment.\fP +.LP +.IP " *" 3 +The new predefined variable \fBENVIRON\fP. +.LP +.IP " *" 3 +New built-in functions \fBtoupper\fP and \fBtolower\fP. +.LP +.IP " *" 3 +More formatting capabilities are added to \fBprintf\fP to match the +ISO\ C standard. +.LP +.LP +The overall \fIawk\fP syntax has always been based on the C language, +with a few features from the shell command language and +other sources. Because of this, it is not completely compatible with +any other language, which has caused confusion for some users. +It is not the intent of the standard developers to address such issues. +A few relatively minor changes toward making the language +more compatible with the ISO\ C standard were made; most of these +changes are based on similar changes in recent +implementations, as described above. There remain several C-language +conventions that are not in \fIawk\fP. One of the notable +ones is the comma operator, which is commonly used to specify multiple +expressions in the C language \fBfor\fP statement. Also, +there are various places where \fIawk\fP is more restrictive than +the C language regarding the type of expression that can be used +in a given context. These limitations are due to the different features +that the \fIawk\fP language does provide. +.LP +Regular expressions in \fIawk\fP have been extended somewhat from +historical implementations to make them a pure superset of +extended regular expressions, as defined by IEEE\ Std\ 1003.1-2001 +(see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 9.4, Extended Regular Expressions). +The +main extensions are internationalization features and interval expressions. +Historical implementations of \fIawk\fP have long +supported backslash escape sequences as an extension to extended regular +expressions, and this extension has been retained despite +inconsistency with other utilities. The number of escape sequences +recognized in both extended regular expressions and strings has +varied (generally increasing with time) among implementations. The +set specified by IEEE\ Std\ 1003.1-2001 includes most +sequences known to be supported by popular implementations and by +the ISO\ C standard. One sequence that is not supported is +hexadecimal value escapes beginning with \fB'\\x'\fP . This would +allow values expressed in more than 9 bits to be used within +\fIawk\fP as in the ISO\ C standard. However, because this syntax +has a non-deterministic length, it does not permit the +subsequent character to be a hexadecimal digit. This limitation can +be dealt with in the C language by the use of lexical string +concatenation. In the \fIawk\fP language, concatenation could also +be a solution for strings, but not for extended regular +expressions (either lexical ERE tokens or strings used dynamically +as regular expressions). Because of this limitation, the feature +has not been added to IEEE\ Std\ 1003.1-2001. +.LP +When a string variable is used in a context where an extended regular +expression normally appears (where the lexical token ERE +is used in the grammar) the string does not contain the literal slashes. +.LP +Some versions of \fIawk\fP allow the form: +.sp +.RS +.nf + +\fBfunc name(args, ... ) { statements } +\fP +.fi +.RE +.LP +This has been deprecated by the authors of the language, who asked +that it not be specified. +.LP +Historical implementations of \fIawk\fP produce an error if a \fBnext\fP +statement is executed in a \fBBEGIN\fP action, and +cause \fIawk\fP to terminate if a \fBnext\fP statement is executed +in an \fBEND\fP action. This behavior has not been +documented, and it was not believed that it was necessary to standardize +it. +.LP +The specification of conversions between string and numeric values +is much more detailed than in the documentation of historical +implementations or in the referenced \fIThe AWK Programming Language\fP. +Although most of the behavior is designed to be +intuitive, the details are necessary to ensure compatible behavior +from different implementations. This is especially important in +relational expressions since the types of the operands determine whether +a string or numeric comparison is performed. From the +perspective of an application writer, it is usually sufficient to +expect intuitive behavior and to force conversions (by adding +zero or concatenating a null string) when the type of an expression +does not obviously match what is needed. The intent has been to +specify historical practice in almost all cases. The one exception +is that, in historical implementations, variables and constants +maintain both string and numeric values after their original value +is converted by any use. This means that referencing a variable +or constant can have unexpected side effects. For example, with historical +implementations the following program: +.sp +.RS +.nf + +\fB{ + a = "+2" + b = 2 + if (NR % 2) + c = a + b + if (a == b) + print "numeric comparison" + else + print "string comparison" +} +\fP +.fi +.RE +.LP +would perform a numeric comparison (and output numeric comparison) +for each odd-numbered line, but perform a string comparison +(and output string comparison) for each even-numbered line. IEEE\ Std\ 1003.1-2001 +ensures that comparisons will be numeric +if necessary. With historical implementations, the following program: +.sp +.RS +.nf + +\fBBEGIN { + OFMT = "%e" + print 3.14 + OFMT = "%f" + print 3.14 +} +\fP +.fi +.RE +.LP +would output \fB"3.140000e+00"\fP twice, because in the second \fBprint\fP +statement the constant \fB"3.14"\fP would have +a string value from the previous conversion. IEEE\ Std\ 1003.1-2001 +requires that the output of the second \fBprint\fP +statement be \fB"3.140000"\fP . The behavior of historical implementations +was seen as too unintuitive and unpredictable. +.LP +It was pointed out that with the rules contained in early drafts, +the following script would print nothing: +.sp +.RS +.nf + +\fBBEGIN { + y[1.5] = 1 + OFMT = "%e" + print y[1.5] +} +\fP +.fi +.RE +.LP +Therefore, a new variable, \fBCONVFMT\fP, was introduced. The \fBOFMT\fP +variable is now restricted to affecting output +conversions of numbers to strings and \fBCONVFMT\fP is used for internal +conversions, such as comparisons or array indexing. The +default value is the same as that for \fBOFMT\fP, so unless a program +changes \fBCONVFMT\fP (which no historical program would +do), it will receive the historical behavior associated with internal +string conversions. +.LP +The POSIX \fIawk\fP lexical and syntactic conventions are specified +more formally than in other sources. Again the intent has +been to specify historical practice. One convention that may not be +obvious from the formal grammar as in other verbal descriptions +is where <newline>s are acceptable. There are several obvious placements +such as terminating a statement, and a backslash can +be used to escape <newline>s between any lexical tokens. In addition, +<newline>s without backslashes can follow a +comma, an open brace, a logical AND operator ( \fB"&&"\fP ), a logical +OR operator ( \fB"||"\fP ), the \fBdo\fP +keyword, the \fBelse\fP keyword, and the closing parenthesis of an +\fBif\fP, \fBfor\fP, or \fBwhile\fP statement. For +example: +.sp +.RS +.nf + +\fB{ print $1, + $2 } +\fP +.fi +.RE +.LP +The requirement that \fIawk\fP add a trailing <newline> to the program +argument text is to simplify the grammar, making +it match a text file in form. There is no way for an application or +test suite to determine whether a literal <newline> is +added or whether \fIawk\fP simply acts as if it did. +.LP +IEEE\ Std\ 1003.1-2001 requires several changes from historical implementations +in order to support +internationalization. Probably the most subtle of these is the use +of the decimal-point character, defined by the \fILC_NUMERIC\fP +category of the locale, in representations of floating-point numbers. +This locale-specific character is used in recognizing numeric +input, in converting between strings and numeric values, and in formatting +output. However, regardless of locale, the period +character (the decimal-point character of the POSIX locale) is the +decimal-point character recognized in processing \fIawk\fP +programs (including assignments in command line arguments). This is +essentially the same convention as the one used in the +ISO\ C standard. The difference is that the C language includes the +\fIsetlocale\fP() function, which permits an application to modify +its locale. Because of this +capability, a C application begins executing with its locale set to +the C locale, and only executes in the environment-specified +locale after an explicit call to \fIsetlocale\fP(). However, adding +such an elaborate +new feature to the \fIawk\fP language was seen as inappropriate for +IEEE\ Std\ 1003.1-2001. It is possible to execute an +\fIawk\fP program explicitly in any desired locale by setting the +environment in the shell. +.LP +The undefined behavior resulting from NULs in extended regular expressions +allows future extensions for the GNU \fIgawk\fP +program to process binary data. +.LP +The behavior in the case of invalid \fIawk\fP programs (including +lexical, syntactic, and semantic errors) is undefined because +it was considered overly limiting on implementations to specify. In +most cases such errors can be expected to produce a diagnostic +and a non-zero exit status. However, some implementations may choose +to extend the language in ways that make use of certain +invalid constructs. Other invalid constructs might be deemed worthy +of a warning, but otherwise cause some reasonable behavior. +Still other constructs may be very difficult to detect in some implementations. +Also, different implementations might detect a +given error during an initial parsing of the program (before reading +any input files) while others might detect it when executing +the program after reading some input. Implementors should be aware +that diagnosing errors as early as possible and producing useful +diagnostics can ease debugging of applications, and thus make an implementation +more usable. +.LP +The unspecified behavior from using multi-character \fBRS\fP values +is to allow possible future extensions based on extended +regular expressions used for record separators. Historical implementations +take the first character of the string and ignore the +others. +.LP +Unspecified behavior when \fIsplit\fP( \fIstring\fP, \fIarray\fP, +<null>) is used +is to allow a proposed future extension that would split up a string +into an array of individual characters. +.LP +In the context of the \fBgetline\fP function, equally good arguments +for different precedences of the \fB|\fP and \fB<\fP +operators can be made. Historical practice has been that: +.sp +.RS +.nf + +\fBgetline < "a" "b" +\fP +.fi +.RE +.LP +is parsed as: +.sp +.RS +.nf + +\fB( getline < "a" ) "b" +\fP +.fi +.RE +.LP +although many would argue that the intent was that the file \fBab\fP +should be read. However: +.sp +.RS +.nf + +\fBgetline < "x" + 1 +\fP +.fi +.RE +.LP +parses as: +.sp +.RS +.nf + +\fBgetline < ( "x" + 1 ) +\fP +.fi +.RE +.LP +Similar problems occur with the \fB|\fP version of \fBgetline\fP, +particularly in combination with \fB$\fP. For example: +.sp +.RS +.nf + +\fB$"echo hi" | getline +\fP +.fi +.RE +.LP +(This situation is particularly problematic when used in a \fBprint\fP +statement, where the \fB|getline\fP part might be a +redirection of the \fBprint\fP.) +.LP +Since in most cases such constructs are not (or at least should not) +be used (because they have a natural ambiguity for which +there is no conventional parsing), the meaning of these constructs +has been made explicitly unspecified. (The effect is that a +conforming application that runs into the problem must parenthesize +to resolve the ambiguity.) There appeared to be few if any +actual uses of such constructs. +.LP +Grammars can be written that would cause an error under these circumstances. +Where backwards-compatibility is not a large +consideration, implementors may wish to use such grammars. +.LP +Some historical implementations have allowed some built-in functions +to be called without an argument list, the result being a +default argument list chosen in some "reasonable" way. Use of \fBlength\fP +as a synonym for \fBlength($0)\fP is the only one of +these forms that is thought to be widely known or widely used; this +particular form is documented in various places (for example, +most historical \fIawk\fP reference pages, although not in the referenced +\fIThe AWK Programming Language\fP) as legitimate +practice. With this exception, default argument lists have always +been undocumented and vaguely defined, and it is not at all clear +how (or if) they should be generalized to user-defined functions. +They add no useful functionality and preclude possible future +extensions that might need to name functions without calling them. +Not standardizing them seems the simplest course. The standard +developers considered that \fBlength\fP merited special treatment, +however, since it has been documented in the past and sees +possibly substantial use in historical programs. Accordingly, this +usage has been made legitimate, but Issue\ 5 removed the +obsolescent marking for XSI-conforming implementations and many otherwise +conforming applications depend on this feature. +.LP +In \fBsub\fP and \fBgsub\fP, if \fIrepl\fP is a string literal (the +lexical token \fBSTRING\fP), then two consecutive +backslash characters should be used in the string to ensure a single +backslash will precede the ampersand when the resultant string +is passed to the function. (For example, to specify one literal ampersand +in the replacement string, use \fBgsub\fP( \fBERE\fP, +\fB"\\\\&"\fP ).) +.LP +Historically the only special character in the \fIrepl\fP argument +of \fBsub\fP and \fBgsub\fP string functions was the +ampersand ( \fB'&'\fP ) character and preceding it with the backslash +character was used to turn off its special +meaning. +.LP +The description in the ISO\ POSIX-2:1993 standard introduced behavior +such that the backslash character was another special +character and it was unspecified whether there were any other special +characters. This description introduced several portability +problems, some of which are described below, and so it has been replaced +with the more historical description. Some of the problems +include: +.IP " *" 3 +Historically, to create the replacement string, a script could use +\fBgsub\fP( \fBERE\fP, \fB"\\\\&"\fP ), but with the +ISO\ POSIX-2:1993 standard wording, it was necessary to use \fBgsub\fP( +\fBERE\fP, \fB"\\\\\\\\&"\fP ). Backslash +characters are doubled here because all string literals are subject +to lexical analysis, which would reduce each pair of backslash +characters to a single backslash before being passed to \fBgsub\fP. +.LP +.IP " *" 3 +Since it was unspecified what the special characters were, for portable +scripts to guarantee that characters are printed +literally, each character had to be preceded with a backslash. (For +example, a portable script had to use \fBgsub\fP( \fBERE\fP, +\fB"\\\\h\\\\i"\fP ) to produce a replacement string of \fB"hi"\fP +\&.) +.LP +.LP +The description for comparisons in the ISO\ POSIX-2:1993 standard +did not properly describe historical practice because of +the way numeric strings are compared as numbers. The current rules +cause the following code: +.sp +.RS +.nf + +\fBif (0 == "000") + print "strange, but true" +else + print "not true" +\fP +.fi +.RE +.LP +to do a numeric comparison, causing the \fBif\fP to succeed. It should +be intuitively obvious that this is incorrect behavior, +and indeed, no historical implementation of \fIawk\fP actually behaves +this way. +.LP +To fix this problem, the definition of \fInumeric string\fP was enhanced +to include only those values obtained from specific +circumstances (mostly external sources) where it is not possible to +determine unambiguously whether the value is intended to be a +string or a numeric. +.LP +Variables that are assigned to a numeric string shall also be treated +as a numeric string. (For example, the notion of a numeric +string can be propagated across assignments.) In comparisons, all +variables having the uninitialized value are to be treated as a +numeric operand evaluating to the numeric value zero. +.LP +Uninitialized variables include all types of variables including scalars, +array elements, and fields. The definition of an +uninitialized value in Variables and Special Variables is necessary +to describe the value placed on +uninitialized variables and on fields that are valid (for example, +\fB<\fP \fB$NF\fP) but have no characters in them and to +describe how these variables are to be used in comparisons. A valid +field, such as \fB$1\fP, that has no characters in it can be +obtained from an input line of \fB"\\t\\t"\fP when \fBFS=\fP \fB'\\t'\fP +\&. Historically, the comparison ( \fB$1<\fP10) was +done numerically after evaluating \fB$1\fP to the value zero. +.LP +The phrase "... also shall have the numeric value of the numeric string" +was removed from several sections of the +ISO\ POSIX-2:1993 standard because is specifies an unnecessary implementation +detail. It is not necessary for +IEEE\ Std\ 1003.1-2001 to specify that these objects be assigned two +different values. It is only necessary to specify that +these objects may evaluate to two different values depending on context. +.LP +The description of numeric string processing is based on the behavior +of the \fIatof\fP() +function in the ISO\ C standard. While it is not a requirement for +an implementation to use this function, many historical +implementations of \fIawk\fP do. In the ISO\ C standard, floating-point +constants use a period as a decimal point character +for the language itself, independent of the current locale, but the +\fIatof\fP() function and +the associated \fIstrtod\fP() function use the decimal point character +of the current +locale when converting strings to numeric values. Similarly in \fIawk\fP, +floating-point constants in an \fIawk\fP script use a +period independent of the locale, but input strings use the decimal +point character of the locale. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIGrammar Conventions\fP , \fIgrep\fP , \fIlex\fP , \fIsed\fP , the +System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIatof\fP(), +\fIexec\fP, \fIpopen\fP(), \fIsetlocale\fP(), \fIstrtod\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/basename.1p b/man1p/basename.1p new file mode 100644 index 000000000..f8956e4e3 --- /dev/null +++ b/man1p/basename.1p @@ -0,0 +1,239 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "BASENAME" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" basename +.SH NAME +basename \- return non-directory portion of a pathname +.SH SYNOPSIS +.LP +\fBbasename\fP \fIstring\fP \fB[\fP\fIsuffix\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIstring\fP operand shall be treated as a pathname, as defined +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 3.266, Pathname. The string +\fIstring\fP shall be converted to the filename corresponding to the +last pathname component in \fIstring\fP and then the suffix +string \fIsuffix\fP, if present, shall be removed. This shall be done +by performing actions equivalent to the following steps in +order: +.IP " 1." 4 +If \fIstring\fP is a null string, it is unspecified whether the resulting +string is \fB'.'\fP or a null string. In either +case, skip steps 2 through 6. +.LP +.IP " 2." 4 +If \fIstring\fP is \fB"//"\fP , it is implementation-defined whether +steps 3 to 6 are skipped or processed. +.LP +.IP " 3." 4 +If \fIstring\fP consists entirely of slash characters, \fIstring\fP +shall be set to a single slash character. In this case, +skip steps 4 to 6. +.LP +.IP " 4." 4 +If there are any trailing slash characters in \fIstring\fP, they shall +be removed. +.LP +.IP " 5." 4 +If there are any slash characters remaining in \fIstring\fP, the prefix +of \fIstring\fP up to and including the last slash +character in \fIstring\fP shall be removed. +.LP +.IP " 6." 4 +If the \fIsuffix\fP operand is present, is not identical to the characters +remaining in \fIstring\fP, and is identical to a +suffix of the characters remaining in \fIstring\fP, the suffix \fIsuffix\fP +shall be removed from \fIstring\fP. Otherwise, +\fIstring\fP is not modified by this step. It shall not be considered +an error if \fIsuffix\fP is not found in \fIstring\fP. +.LP +.LP +The resulting string shall be written to standard output. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIstring\fP +A string. +.TP 7 +\fIsuffix\fP +A string. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIbasename\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIbasename\fP utility shall write a line to the standard output +in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIresulting string\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The definition of \fIpathname\fP specifies implementation-defined +behavior for pathnames starting with two slash characters. +Therefore, applications shall not arbitrarily add slashes to the beginning +of a pathname unless they can ensure that there are more +or less than two or are prepared to deal with the implementation-defined +consequences. +.SH EXAMPLES +.LP +If the string \fIstring\fP is a valid pathname: +.sp +.RS +.nf + +\fB$(basename "\fP\fIstring\fP\fB") +\fP +.fi +.RE +.LP +produces a filename that could be used to open the file named by \fIstring\fP +in the directory returned by: +.sp +.RS +.nf + +\fB$(dirname "\fP\fIstring\fP\fB") +\fP +.fi +.RE +.LP +If the string \fIstring\fP is not a valid pathname, the same algorithm +is used, but the result need not be a valid filename. +The \fIbasename\fP utility is not expected to make any judgements +about the validity of \fIstring\fP as a pathname; it just +follows the specified algorithm to produce a result string. +.LP +The following shell script compiles \fB/usr/src/cmd/cat.c\fP and moves +the output to a file named \fBcat\fP in the current +directory when invoked with the argument \fB/usr/src/cmd/cat\fP or +with the argument \fB/usr/src/cmd/cat.c\fP: +.sp +.RS +.nf + +\fBc99 $(dirname "$1")/$(basename "$1" .c).c +mv a.out $(basename "$1" .c) +\fP +.fi +.RE +.SH RATIONALE +.LP +The behaviors of \fIbasename\fP and \fIdirname\fP have been coordinated +so that when +\fIstring\fP is a valid pathname: +.sp +.RS +.nf + +\fB$(basename "\fP\fIstring\fP\fB") +\fP +.fi +.RE +.LP +would be a valid filename for the file in the directory: +.sp +.RS +.nf + +\fB$(dirname "\fP\fIstring\fP\fB") +\fP +.fi +.RE +.LP +This would not work for the early proposal versions of these utilities +due to the way it specified handling of trailing +slashes. +.LP +Since the definition of \fIpathname\fP specifies implementation-defined +behavior for pathnames starting with two slash +characters, this volume of IEEE\ Std\ 1003.1-2001 specifies similar +implementation-defined behavior for the \fIbasename\fP +and \fIdirname\fP utilities. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIParameters and Variables\fP , \fIdirname\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/batch.1p b/man1p/batch.1p new file mode 100644 index 000000000..c8c984520 --- /dev/null +++ b/man1p/batch.1p @@ -0,0 +1,238 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "BATCH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" batch +.SH NAME +batch \- schedule commands to be executed in a batch queue +.SH SYNOPSIS +.LP +\fB\fP \fIbatch\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIbatch\fP utility shall read commands from standard input and +schedule them for execution in a batch queue. It shall be +the equivalent of the command: +.sp +.RS +.nf + +\fBat -q b -m now +\fP +.fi +.RE +.LP +where queue \fIb\fP is a special \fIat\fP queue, specifically for +batch jobs. Batch jobs +shall be submitted to the batch queue with no time constraints and +shall be run by the system using algorithms, based on +unspecified factors, that may vary with each invocation of \fIbatch\fP. +.LP +Users shall be permitted to use \fIbatch\fP if their name appears +in the file \fB/usr/lib/cron/at.allow\fP. If that file does not +exist, the file \fB/usr/lib/cron/at.deny\fP shall be checked to determine +whether the user shall be denied access to \fIbatch\fP. +If neither file exists, only a process with the appropriate privileges +shall be allowed to submit a job. If only \fBat.deny\fP +exists and is empty, global usage shall be permitted. The \fBat.allow\fP +and \fBat.deny\fP files shall consist of one user name +per line. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +The standard input shall be a text file consisting of commands acceptable +to the shell command language described in \fIShell Command Language\fP +\&. +.SH INPUT FILES +.LP +The text files \fB/usr/lib/cron/at.allow\fP and \fB/usr/lib/cron/at.deny\fP +shall contain zero or more user names, one per line, +of users who are, respectively, authorized or denied access to the +\fIat\fP and \fIbatch\fP +utilities. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIbatch\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fILC_TIME\fP +Determine the format and contents for date and time strings written +by \fIbatch\fP. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fISHELL\fP +Determine the name of a command interpreter to be used to invoke the +at-job. If the variable is unset or null, \fIsh\fP shall be used. +If it is set to a value other than a name for \fIsh\fP, the implementation +shall do one of the following: use that shell; use \fIsh\fP; use the +login shell from the user database; any of the preceding accompanied +by a warning +diagnostic about which was chosen. +.TP 7 +\fITZ\fP +Determine the timezone. The job shall be submitted for execution at +the time specified by \fItimespec\fP or \fB-t\fP +\fItime\fP relative to the timezone specified by the \fITZ\fP variable. +If \fItimespec\fP specifies a timezone, it overrides +\fITZ .\fP If \fItimespec\fP does not specify a timezone and \fITZ\fP +is unset or null, an unspecified default timezone shall be +used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When standard input is a terminal, prompts of unspecified format for +each line of the user input described in the STDIN section +may be written to standard output. +.SH STDERR +.LP +The following shall be written to standard error when a job has been +successfully submitted: +.sp +.RS +.nf + +\fB"job %s at %s\\n",\fP \fIat_job_id\fP\fB, <\fP\fIdate\fP\fB> +\fP +.fi +.RE +.LP +where \fIdate\fP shall be equivalent in format to the output of: +.sp +.RS +.nf + +\fBdate +"%a %b %e %T %Y" +\fP +.fi +.RE +.LP +The date and time written shall be adjusted so that they appear in +the timezone of the user (as determined by the \fITZ\fP +variable). +.LP +Neither this, nor warning messages concerning the selection of the +command interpreter, are considered a diagnostic that changes +the exit status. +.LP +Diagnostic messages, if any, shall be written to standard error. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The job shall not be scheduled. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +It may be useful to redirect standard output within the specified +commands. +.SH EXAMPLES +.IP " 1." 4 +This sequence can be used at a terminal: +.sp +.RS +.nf + +\fBbatch +sort < file >outfile +EOT +\fP +.fi +.RE +.LP +.IP " 2." 4 +This sequence, which demonstrates redirecting standard error to a +pipe, is useful in a command procedure (the sequence of output +redirection specifications is significant): +.sp +.RS +.nf + +\fBbatch << +! diff file1 file2 2>&1 >outfile | mailx mygroup +! +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +Early proposals described \fIbatch\fP in a manner totally separated +from \fIat\fP, even +though the historical model treated it almost as a synonym for \fIat\fP +\fB-qb\fP. A number of +features were added to list and control batch work separately from +those in \fIat\fP. Upon +further reflection, it was decided that the benefit of this did not +merit the change to the historical interface. +.LP +The \fB-m\fP option was included on the equivalent \fIat\fP command +because it is +historical practice to mail results to the submitter, even if all +job-produced output is redirected. As explained in the RATIONALE +for \fIat\fP, the \fBnow\fP keyword submits the job for immediate +execution (after scheduling +delays), despite some historical systems where \fIat\fP \fBnow\fP +would have been considered +an error. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/bc.1p b/man1p/bc.1p new file mode 100644 index 000000000..a2860dc69 --- /dev/null +++ b/man1p/bc.1p @@ -0,0 +1,1354 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "BC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" bc +.SH NAME +bc \- arbitrary-precision arithmetic language +.SH SYNOPSIS +.LP +\fBbc\fP \fB[\fP\fB-l\fP\fB] [\fP\fIfile\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIbc\fP utility shall implement an arbitrary precision calculator. +It shall take input from any files given, then read +from the standard input. If the standard input and standard output +to \fIbc\fP are attached to a terminal, the invocation of +\fIbc\fP shall be considered to be \fIinteractive\fP, causing behavioral +constraints described in the following sections. +.SH OPTIONS +.LP +The \fIbc\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-l\fP +(The letter ell.) Define the math functions and initialize \fIscale\fP +to 20, instead of the default zero; see the EXTENDED +DESCRIPTION section. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a text file containing \fIbc\fP program statements. +After all \fIfile\fPs have been read, \fIbc\fP shall read +the standard input. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +Input files shall be text files containing a sequence of comments, +statements, and function definitions that shall be executed +as they are read. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIbc\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The output of the \fIbc\fP utility shall be controlled by the program +read, and consist of zero or more lines containing the +value of all executed expressions without assignments. The radix and +precision of the output shall be controlled by the values of +the \fBobase\fP and \fBscale\fP variables; see the EXTENDED DESCRIPTION +section. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.SS Grammar +.LP +The grammar in this section and the lexical conventions in the following +section shall together describe the syntax for +\fIbc\fP programs. The general conventions for this style of grammar +are described in \fIGrammar Conventions\fP . A valid program can be +represented as the non-terminal symbol +\fBprogram\fP in the grammar. This formal syntax shall take precedence +over the text syntax description. +.sp +.RS +.nf + +\fB%token EOF NEWLINE STRING LETTER NUMBER +.sp + +%token MUL_OP +/* '*', '/', '%' */ +.sp + +%token ASSIGN_OP +/* '=', '+=', '-=', '*=', '/=', '%=', '^=' */ +.sp + +%token REL_OP +/* '==', '<=', '>=', '!=', '<', '>' */ +.sp + +%token INCR_DECR +/* '++', '--' */ +.sp + +%token Define Break Quit Length +/* 'define', 'break', 'quit', 'length' */ +.sp + +%token Return For If While Sqrt +/* 'return', 'for', 'if', 'while', 'sqrt' */ +.sp + +%token Scale Ibase Obase Auto +/* 'scale', 'ibase', 'obase', 'auto' */ +.sp + +%start program +.sp + +%% +.sp + +program : EOF + | input_item program + ; +.sp + +input_item : semicolon_list NEWLINE + | function + ; +.sp + +semicolon_list : /* empty */ + | statement + | semicolon_list ';' statement + | semicolon_list ';' + ; +.sp + +statement_list : /* empty */ + | statement + | statement_list NEWLINE + | statement_list NEWLINE statement + | statement_list ';' + | statement_list ';' statement + ; +.sp + +statement : expression + | STRING + | Break + | Quit + | Return + | Return '(' return_expression ')' + | For '(' expression ';' + relational_expression ';' + expression ')' statement + | If '(' relational_expression ')' statement + | While '(' relational_expression ')' statement + | '{' statement_list '}' + ; +.sp + +function : Define LETTER '(' opt_parameter_list ')' + '{' NEWLINE opt_auto_define_list + statement_list '}' + ; +.sp + +opt_parameter_list : /* empty */ + | parameter_list + ; +.sp + +parameter_list : LETTER + | define_list ',' LETTER + ; +.sp + +opt_auto_define_list : /* empty */ + | Auto define_list NEWLINE + | Auto define_list ';' + ; +.sp + +define_list : LETTER + | LETTER '[' ']' + | define_list ',' LETTER + | define_list ',' LETTER '[' ']' + ; +.sp + +opt_argument_list : /* empty */ + | argument_list + ; +.sp + +argument_list : expression + | LETTER '[' ']' ',' argument_list + ; +.sp + +relational_expression : expression + | expression REL_OP expression + ; +.sp + +return_expression : /* empty */ + | expression + ; +.sp + +expression : named_expression + | NUMBER + | '(' expression ')' + | LETTER '(' opt_argument_list ')' + | '-' expression + | expression '+' expression + | expression '-' expression + | expression MUL_OP expression + | expression '^' expression + | INCR_DECR named_expression + | named_expression INCR_DECR + | named_expression ASSIGN_OP expression + | Length '(' expression ')' + | Sqrt '(' expression ')' + | Scale '(' expression ')' + ; +.sp + +named_expression : LETTER + | LETTER '[' expression ']' + | Scale + | Ibase + | Obase + ; +\fP +.fi +.RE +.SS Lexical Conventions in bc +.LP +The lexical conventions for \fIbc\fP programs, with respect to the +preceding grammar, shall be as follows: +.IP " 1." 4 +Except as noted, \fIbc\fP shall recognize the longest possible token +or delimiter beginning at a given point. +.LP +.IP " 2." 4 +A comment shall consist of any characters beginning with the two adjacent +characters \fB"/*"\fP and terminated by the next +occurrence of the two adjacent characters \fB"*/"\fP . Comments shall +have no effect except to delimit lexical tokens. +.LP +.IP " 3." 4 +The <newline> shall be recognized as the token \fBNEWLINE\fP. +.LP +.IP " 4." 4 +The token \fBSTRING\fP shall represent a string constant; it shall +consist of any characters beginning with the double-quote +character ( \fB' )'\fP and terminated by another occurrence of the +double-quote character. The value of the string is the +sequence of all characters between, but not including, the two double-quote +characters. All characters shall be taken literally +from the input, and there is no way to specify a string containing +a double-quote character. The length of the value of each string +shall be limited to {BC_STRING_MAX} bytes. +.LP +.IP " 5." 4 +A <blank> shall have no effect except as an ordinary character if +it appears within a \fBSTRING\fP token, or to delimit a +lexical token other than \fBSTRING\fP. +.LP +.IP " 6." 4 +The combination of a backslash character immediately followed by a +<newline> shall have no effect other than to delimit +lexical tokens with the following exceptions: +.RS +.IP " *" 3 +It shall be interpreted as the character sequence \fB"\\<newline>"\fP +in \fBSTRING\fP tokens. +.LP +.IP " *" 3 +It shall be ignored as part of a multi-line \fBNUMBER\fP token. +.LP +.RE +.LP +.IP " 7." 4 +The token \fBNUMBER\fP shall represent a numeric constant. It shall +be recognized by the following grammar: +.sp +.RS +.nf + +\fBNUMBER : integer + | '.' integer + | integer '.' + | integer '.' integer + ; +.sp + +integer : digit + | integer digit + ; +.sp + +digit : 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 + | 8 | 9 | A | B | C | D | E | F + ; +\fP +.fi +.RE +.LP +.IP " 8." 4 +The value of a \fBNUMBER\fP token shall be interpreted as a numeral +in the base specified by the value of the internal register +\fBibase\fP (described below). Each of the \fBdigit\fP characters +shall have the value from 0 to 15 in the order listed here, and +the period character shall represent the radix point. The behavior +is undefined if digits greater than or equal to the value of +\fBibase\fP appear in the token. However, note the exception for single-digit +values being assigned to \fBibase\fP and +\fBobase\fP themselves, in Operations in bc . +.LP +.IP " 9." 4 +The following keywords shall be recognized as tokens: +.TS C +center; lw(15) lw(15) lw(15) lw(15) lw(15). +T{ +\fB +.br +auto +.br +break +.br +define +.br +\fP +T} T{ +\fB +.br +ibase +.br +if +.br +for +.br +\fP +T} T{ +\fB +.br +length +.br +obase +.br +quit +.br +\fP +T} T{ +\fB +.br +return +.br +scale +.br +sqrt +.br +\fP +T} T{ +\fB +.br +while +.br +\fP +T} +.TE +.LP +.IP "10." 4 +Any of the following characters occurring anywhere except within a +keyword shall be recognized as the token \fBLETTER\fP: +.sp +.RS +.nf + +\fBa b c d e f g h i j k l m n o p q r s t u v w x y z +\fP +.fi +.RE +.LP +.IP "11." 4 +The following single-character and two-character sequences shall be +recognized as the token \fBASSIGN_OP\fP: +.sp +.RS +.nf + +\fB= += -= *= /= %= ^= +\fP +.fi +.RE +.LP +.IP "12." 4 +If an \fB'='\fP character, as the beginning of a token, is followed +by a \fB'-'\fP character with no intervening +delimiter, the behavior is undefined. +.LP +.IP "13." 4 +The following single-characters shall be recognized as the token \fBMUL_OP\fP: +.sp +.RS +.nf + +\fB* / % +\fP +.fi +.RE +.LP +.IP "14." 4 +The following single-character and two-character sequences shall be +recognized as the token \fBREL_OP\fP: +.sp +.RS +.nf + +\fB== <= >= != < > +\fP +.fi +.RE +.LP +.IP "15." 4 +The following two-character sequences shall be recognized as the token +\fBINCR_DECR\fP: +.sp +.RS +.nf + +\fB++ -- +\fP +.fi +.RE +.LP +.IP "16." 4 +The following single characters shall be recognized as tokens whose +names are the character: +.sp +.RS +.nf + +\fB<newline> ( ) , + - ; [ ] ^ { } +\fP +.fi +.RE +.LP +.IP "17." 4 +The token \fBEOF\fP is returned when the end of input is reached. +.LP +.SS Operations in bc +.LP +There are three kinds of identifiers: ordinary identifiers, array +identifiers, and function identifiers. All three types consist +of single lowercase letters. Array identifiers shall be followed by +square brackets ( \fB"[]"\fP ). An array subscript is +required except in an argument or auto list. Arrays are singly dimensioned +and can contain up to {BC_DIM_MAX} elements. Indexing +shall begin at zero so an array is indexed from 0 to {BC_DIM_MAX}-1. +Subscripts shall be truncated to integers. The application +shall ensure that function identifiers are followed by parentheses, +possibly enclosing arguments. The three types of identifiers do +not conflict. +.LP +The following table summarizes the rules for precedence and associativity +of all operators. Operators on the same line shall +have the same precedence; rows are in order of decreasing precedence. +.sp +.ce 1 +\fBTable: Operators in \fIbc\fP\fP +.TS C +center; l l. +\fBOperator\fP \fBAssociativity\fP +++, -- N/A +unary - N/A +^ Right to left +*, /, % Left to right ++, binary - Left to right +=, +=, -=, *=, /=, %=, ^= Right to left +==, <=, >=, !=, <, > None +.TE +.LP +Each expression or named expression has a \fIscale\fP, which is the +number of decimal digits that shall be maintained as the +fractional portion of the expression. +.LP +\fINamed expressions\fP are places where values are stored. Named +expressions shall be valid on the left side of an assignment. +The value of a named expression shall be the value stored in the place +named. Simple identifiers and array elements are named +expressions; they have an initial value of zero and an initial scale +of zero. +.LP +The internal registers \fBscale\fP, \fBibase\fP, and \fBobase\fP are +all named expressions. The scale of an expression +consisting of the name of one of these registers shall be zero; values +assigned to any of these registers are truncated to +integers. The \fBscale\fP register shall contain a global value used +in computing the scale of expressions (as described below). +The value of the register \fBscale\fP is limited to 0 <= \fBscale\fP +<= {BC_SCALE_MAX} and shall have a default value of +zero. The \fBibase\fP and \fBobase\fP registers are the input and +output number radix, respectively. The value of \fBibase\fP +shall be limited to: +.sp +.RS +.nf + +\fB2 <= ibase <= 16 +\fP +.fi +.RE +.LP +The value of \fBobase\fP shall be limited to: +.sp +.RS +.nf + +\fB2 <= obase <= {BC_BASE_MAX} +\fP +.fi +.RE +.LP +When either \fBibase\fP or \fBobase\fP is assigned a single \fBdigit\fP +value from the list in Lexical Conventions in bc , the value shall +be assumed in hexadecimal. (For example, \fBibase\fP=A sets to +base ten, regardless of the current \fBibase\fP value.) Otherwise, +the behavior is undefined when digits greater than or equal to +the value of \fBibase\fP appear in the input. Both \fBibase\fP and +\fBobase\fP shall have initial values of 10. +.LP +Internal computations shall be conducted as if in decimal, regardless +of the input and output bases, to the specified number of +decimal digits. When an exact result is not achieved (for example, +\fBscale\fP=0;\ 3.2/1)\fB,\fP the result shall be +truncated. +.LP +For all values of \fBobase\fP specified by this volume of IEEE\ Std\ 1003.1-2001, +\fIbc\fP shall output numeric values +by performing each of the following steps in order: +.IP " 1." 4 +If the value is less than zero, a hyphen ( \fB'-'\fP ) character shall +be output. +.LP +.IP " 2." 4 +One of the following is output, depending on the numerical value: +.RS +.IP " *" 3 +If the absolute value of the numerical value is greater than or equal +to one, the integer portion of the value shall be output +as a series of digits appropriate to \fBobase\fP (as described below), +most significant digit first. The most significant non-zero +digit shall be output next, followed by each successively less significant +digit. +.LP +.IP " *" 3 +If the absolute value of the numerical value is less than one but +greater than zero and the scale of the numerical value is +greater than zero, it is unspecified whether the character 0 is output. +.LP +.IP " *" 3 +If the numerical value is zero, the character 0 shall be output. +.LP +.RE +.LP +.IP " 3." 4 +If the scale of the value is greater than zero and the numeric value +is not zero, a period character shall be output, followed +by a series of digits appropriate to \fBobase\fP (as described below) +representing the most significant portion of the fractional +part of the value. If \fIs\fP represents the scale of the value being +output, the number of digits output shall be \fIs\fP if +\fBobase\fP is 10, less than or equal to \fIs\fP if \fBobase\fP is +greater than 10, or greater than or equal to \fIs\fP if +\fBobase\fP is less than 10. For \fBobase\fP values other than 10, +this should be the number of digits needed to represent a +precision of 10**\fIs\fP. +.LP +.LP +For \fBobase\fP values from 2 to 16, valid digits are the first \fBobase\fP +of the single characters: +.sp +.RS +.nf + +\fB0 1 2 3 4 5 6 7 8 9 A B C D E F +\fP +.fi +.RE +.LP +which represent the values zero to 15, inclusive, respectively. +.LP +For bases greater than 16, each digit shall be written as a separate +multi-digit decimal number. Each digit except the most +significant fractional digit shall be preceded by a single <space>. +For bases from 17 to 100, \fIbc\fP shall write two-digit +decimal numbers; for bases from 101 to 1000, three-digit decimal strings, +and so on. For example, the decimal number 1024 in base +25 would be written as: +.sp +.RS +.nf + +\fB 01 15 24 +\fP +.fi +.RE +.LP +and in base 125, as: +.sp +.RS +.nf + +\fB 008 024 +\fP +.fi +.RE +.LP +Very large numbers shall be split across lines with 70 characters +per line in the POSIX locale; other locales may split at +different character boundaries. Lines that are continued shall end +with a backslash ( \fB'\\'\fP ). +.LP +A function call shall consist of a function name followed by parentheses +containing a comma-separated list of expressions, which +are the function arguments. A whole array passed as an argument shall +be specified by the array name followed by empty square +brackets. All function arguments shall be passed by value. As a result, +changes made to the formal parameters shall have no effect +on the actual arguments. If the function terminates by executing a +\fBreturn\fP statement, the value of the function shall be the +value of the expression in the parentheses of the \fBreturn\fP statement +or shall be zero if no expression is provided or if there +is no \fBreturn\fP statement. +.LP +The result of \fBsqrt\fP( \fIexpression\fP) shall be the square root +of the expression. The result shall be truncated in the +least significant decimal place. The scale of the result shall be +the scale of the expression or the value of \fBscale\fP, +whichever is larger. +.LP +The result of \fBlength\fP( \fIexpression\fP) shall be the total number +of significant decimal digits in the expression. The +scale of the result shall be zero. +.LP +The result of \fBscale\fP( \fIexpression\fP) shall be the scale of +the expression. The scale of the result shall be zero. +.LP +A numeric constant shall be an expression. The scale shall be the +number of digits that follow the radix point in the input +representing the constant, or zero if no radix point appears. +.LP +The sequence (\ \fIexpression\fP\ ) shall be an expression with the +same value and scale as \fIexpression\fP. The +parentheses can be used to alter the normal precedence. +.LP +The semantics of the unary and binary operators are as follows: +.TP 7 +-\fIexpression\fP +.sp +The result shall be the negative of the \fIexpression\fP. The scale +of the result shall be the scale of \fIexpression\fP. +.sp +.LP +The unary increment and decrement operators shall not modify the scale +of the named expression upon which they operate. The +scale of the result shall be the scale of that named expression. +.TP 7 +++\fInamed-expression\fP +.sp +The named expression shall be incremented by one. The result shall +be the value of the named expression after incrementing. +.TP 7 +--\fInamed-expression\fP +.sp +The named expression shall be decremented by one. The result shall +be the value of the named expression after decrementing. +.TP 7 +\fInamed-expression\fP++ +.sp +The named expression shall be incremented by one. The result shall +be the value of the named expression before incrementing. +.TP 7 +\fInamed-expression\fP-- +.sp +The named expression shall be decremented by one. The result shall +be the value of the named expression before decrementing. +.sp +.LP +The exponentiation operator, circumflex ( \fB'^'\fP ), shall bind +right to left. +.TP 7 +\fIexpression\fP^\fIexpression\fP +.sp +The result shall be the first \fIexpression\fP raised to the power +of the second \fIexpression\fP. If the second expression is +not an integer, the behavior is undefined. If \fIa\fP is the scale +of the left expression and \fIb\fP is the absolute value of +the right expression, the scale of the result shall be: +.sp +.RS +.nf + +\fBif b >= 0 min(a * b, max(scale, a)) if b < 0 scale +\fP +.fi +.RE +.sp +The multiplicative operators ( \fB'*'\fP , \fB'/'\fP , \fB'%'\fP ) +shall bind left to right. +.TP 7 +\fIexpression\fP*\fIexpression\fP +.sp +The result shall be the product of the two expressions. If \fIa\fP +and \fIb\fP are the scales of the two expressions, then the +scale of the result shall be: +.sp +.RS +.nf + +\fBmin(a+b,max(scale,a,b)) +\fP +.fi +.RE +.TP 7 +\fIexpression\fP/\fIexpression\fP +.sp +The result shall be the quotient of the two expressions. The scale +of the result shall be the value of \fBscale\fP. +.TP 7 +\fIexpression\fP%\fIexpression\fP +.sp +For expressions \fIa\fP and \fIb\fP, \fIa\fP% \fIb\fP shall be evaluated +equivalent to the steps: +.RS +.IP " 1." 4 +Compute \fIa\fP/ \fIb\fP to current scale. +.LP +.IP " 2." 4 +Use the result to compute: +.sp +.RS +.nf + +\fBa - (a / b) * b +\fP +.fi +.RE +.LP +to scale: +.sp +.RS +.nf + +\fBmax(scale + scale(b), scale(a)) +\fP +.fi +.RE +.LP +.RE +The scale of the result shall be: +.sp +.RS +.nf + +\fBmax(scale + scale(b), scale(a)) +\fP +.fi +.RE +.LP +When \fBscale\fP is zero, the \fB'%'\fP operator is the mathematical +remainder operator. +.sp +.LP +The additive operators ( \fB'+'\fP , \fB'-'\fP ) shall bind left to +right. +.TP 7 +\fIexpression\fP+\fIexpression\fP +.sp +The result shall be the sum of the two expressions. The scale of the +result shall be the maximum of the scales of the +expressions. +.TP 7 +\fIexpression\fP-\fIexpression\fP +.sp +The result shall be the difference of the two expressions. The scale +of the result shall be the maximum of the scales of the +expressions. +.sp +.LP +The assignment operators ( \fB'='\fP , \fB"+="\fP , \fB"-="\fP , \fB"*="\fP +, \fB"/="\fP , \fB"%="\fP , +\fB"^="\fP ) shall bind right to left. +.TP 7 +\fInamed-expression\fP=\fIexpression\fP +.sp +This expression shall result in assigning the value of the expression +on the right to the named expression on the left. The scale +of both the named expression and the result shall be the scale of +\fIexpression\fP. +.sp +.LP +The compound assignment forms: +.sp +.RS +.nf + +\fInamed-expression\fP \fB<\fP\fIoperator\fP\fB>=\fP \fIexpression\fP +.fi +.RE +.LP +shall be equivalent to: +.sp +.RS +.nf + +\fInamed-expression\fP\fB=\fP\fInamed-expression\fP \fB<\fP\fIoperator\fP\fB>\fP \fIexpression\fP +.fi +.RE +.LP +except that the \fInamed-expression\fP shall be evaluated only once. +.LP +Unlike all other operators, the relational operators ( \fB'<'\fP , +\fB'>'\fP , \fB"<="\fP , \fB">="\fP , +\fB"=="\fP , \fB"!="\fP ) shall be only valid as the object of an +\fBif\fP, \fBwhile\fP, or inside a \fBfor\fP +statement. +.TP 7 +\fIexpression1\fP<\fIexpression2\fP +.sp +The relation shall be true if the value of \fIexpression1\fP is strictly +less than the value of \fIexpression2\fP. +.TP 7 +\fIexpression1\fP>\fIexpression2\fP +.sp +The relation shall be true if the value of \fIexpression1\fP is strictly +greater than the value of \fIexpression2\fP. +.TP 7 +\fIexpression1\fP<=\fIexpression2\fP +.sp +The relation shall be true if the value of \fIexpression1\fP is less +than or equal to the value of \fIexpression2\fP. +.TP 7 +\fIexpression1\fP>=\fIexpression2\fP +.sp +The relation shall be true if the value of \fIexpression1\fP is greater +than or equal to the value of \fIexpression2\fP. +.TP 7 +\fIexpression1\fP==\fIexpression2\fP +.sp +The relation shall be true if the values of \fIexpression1\fP and +\fIexpression2\fP are equal. +.TP 7 +\fIexpression1\fP!=\fIexpression2\fP +.sp +The relation shall be true if the values of \fIexpression1\fP and +\fIexpression2\fP are unequal. +.sp +.LP +There are only two storage classes in \fIbc\fP: global and automatic +(local). Only identifiers that are local to a function +need be declared with the \fBauto\fP command. The arguments to a function +shall be local to the function. All other identifiers +are assumed to be global and available to all functions. All identifiers, +global and local, have initial values of zero. +Identifiers declared as auto shall be allocated on entry to the function +and released on returning from the function. They +therefore do not retain values between function calls. Auto arrays +shall be specified by the array name followed by empty square +brackets. On entry to a function, the old values of the names that +appear as parameters and as automatic variables shall be pushed +onto a stack. Until the function returns, reference to these names +shall refer only to the new values. +.LP +References to any of these names from other functions that are called +from this function also refer to the new value until one +of those functions uses the same name for a local variable. +.LP +When a statement is an expression, unless the main operator is an +assignment, execution of the statement shall write the value +of the expression followed by a <newline>. +.LP +When a statement is a string, execution of the statement shall write +the value of the string. +.LP +Statements separated by semicolons or <newline>s shall be executed +sequentially. In an interactive invocation of +\fIbc\fP, each time a <newline> is read that satisfies the grammatical +production: +.sp +.RS +.nf + +\fBinput_item : semicolon_list NEWLINE +\fP +.fi +.RE +.LP +the sequential list of statements making up the \fBsemicolon_list\fP +shall be executed immediately and any output produced by +that execution shall be written without any delay due to buffering. +.LP +In an \fBif\fP statement ( \fBif\fP( \fIrelation\fP) \fIstatement\fP), +the \fIstatement\fP shall be executed if the +relation is true. +.LP +The \fBwhile\fP statement ( \fBwhile\fP( \fIrelation\fP) \fIstatement\fP) +implements a loop in which the \fIrelation\fP is +tested; each time the \fIrelation\fP is true, the \fIstatement\fP +shall be executed and the \fIrelation\fP retested. When the +\fIrelation\fP is false, execution shall resume after \fIstatement\fP. +.LP +A \fBfor\fP statement( \fBfor\fP( \fIexpression\fP; \fIrelation\fP; +\fIexpression\fP) \fIstatement\fP) shall be the same +as: +.sp +.RS +.nf + +\fIfirst-expression\fP\fBwhile (\fP\fIrelation\fP\fB) { + \fP \fIstatement\fP \fB \fP \fIlast-expression\fP\fB} +\fP +.fi +.RE +The application shall ensure that all three expressions are present. +.LP +The \fBbreak\fP statement shall cause termination of a \fBfor\fP or +\fBwhile\fP statement. +.LP +The \fBauto\fP statement ( \fBauto\fP \fIidentifier\fP \fB[\fP, \fIidentifier\fP +\fB]\fP ...) shall cause the values of +the identifiers to be pushed down. The identifiers can be ordinary +identifiers or array identifiers. Array identifiers shall be +specified by following the array name by empty square brackets. The +application shall ensure that the \fBauto\fP statement is the +first statement in a function definition. +.LP +A \fBdefine\fP statement: +.sp +.RS +.nf + +\fBdefine\fP \fILETTER\fP \fB(\fP \fIopt_parameter_list\fP \fB) { + \fP \fIopt_auto_define_list\fP \fB \fP \fIstatement_list\fP\fB} +\fP +.fi +.RE +.LP +defines a function named \fBLETTER\fP. If a function named \fBLETTER\fP +was previously defined, the \fBdefine\fP statement +shall replace the previous definition. The expression: +.sp +.RS +.nf + +\fBLETTER (\fP \fIopt_argument_list\fP \fB) +\fP +.fi +.RE +.LP +shall invoke the function named \fBLETTER\fP. The behavior is undefined +if the number of arguments in the invocation does not +match the number of parameters in the definition. Functions shall +be defined before they are invoked. A function shall be +considered to be defined within its own body, so recursive calls are +valid. The values of numeric constants within a function shall +be interpreted in the base specified by the value of the \fBibase\fP +register when the function is invoked. +.LP +The \fBreturn\fP statements ( \fBreturn\fP and \fBreturn\fP( \fIexpression\fP)) +shall cause termination of a function, +popping of its auto variables, and specification of the result of +the function. The first form shall be equivalent to +\fBreturn\fP(0). The value and scale of the result returned by the +function shall be the value and scale of the expression +returned. +.LP +The \fBquit\fP statement ( \fBquit\fP) shall stop execution of a \fIbc\fP +program at the point where the statement occurs in +the input, even if it occurs in a function definition, or in an \fBif\fP, +\fBfor\fP, or \fBwhile\fP statement. +.LP +The following functions shall be defined when the \fB-l\fP option +is specified: +.TP 7 +\fBs\fP(\ \fIexpression\fP\ ) +.sp +Sine of argument in radians. +.TP 7 +\fBc\fP(\ \fIexpression\fP\ ) +.sp +Cosine of argument in radians. +.TP 7 +\fBa\fP(\ \fIexpression\fP\ ) +.sp +Arctangent of argument. +.TP 7 +\fBl\fP(\ \fIexpression\fP\ ) +.sp +Natural logarithm of argument. +.TP 7 +\fBe\fP(\ \fIexpression\fP\ ) +.sp +Exponential function of argument. +.TP 7 +\fBj\fP(\ \fIexpression\fP,\ \fIexpression\fP\ ) +.sp +Bessel function of integer order. +.sp +.LP +The scale of the result returned by these functions shall be the value +of the \fBscale\fP register at the time the function is +invoked. The value of the \fBscale\fP register after these functions +have completed their execution shall be the same value it had +upon invocation. The behavior is undefined if any of these functions +is invoked with an argument outside the domain of the +mathematical function. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +0 +All input files were processed successfully. +.TP 7 +\fIunspecified\fP +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If any \fIfile\fP operand is specified and the named file cannot be +accessed, \fIbc\fP shall write a diagnostic message to +standard error and terminate without any further action. +.LP +In an interactive invocation of \fIbc\fP, the utility should print +an error message and recover following any error in the +input. In a non-interactive invocation of \fIbc\fP, invalid input +causes undefined behavior. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Automatic variables in \fIbc\fP do not work in exactly the same way +as in either C or PL/1. +.LP +For historical reasons, the exit status from \fIbc\fP cannot be relied +upon to indicate that an error has occurred. Returning +zero after an error is possible. Therefore, \fIbc\fP should be used +primarily by interactive users (who can react to error +messages) or by application programs that can somehow validate the +answers returned as not including error messages. +.LP +The \fIbc\fP utility always uses the period ( \fB'.'\fP ) character +to represent a radix point, regardless of any +decimal-point character specified as part of the current locale. In +languages like C or \fIawk\fP, the period character is used in program +source, so it can be portable and unambiguous, +while the locale-specific character is used in input and output. Because +there is no distinction between source and input in +\fIbc\fP, this arrangement would not be possible. Using the locale-specific +character in \fIbc\fP's input would introduce +ambiguities into the language; consider the following example in a +locale with a comma as the decimal-point character: +.sp +.RS +.nf + +\fBdefine f(a,b) { + ... +} +\&... +.sp + +f(1,2,3) +\fP +.fi +.RE +.LP +Because of such ambiguities, the period character is used in input. +Having input follow different conventions from output would +be confusing in either pipeline usage or interactive usage, so the +period is also used in output. +.SH EXAMPLES +.LP +In the shell, the following assigns an approximation of the first +ten digits of \fB'pi'\fP to the variable \fIx\fP: +.sp +.RS +.nf + +\fBx=$(printf "%s\\n" 'scale = 10; 104348/33215' | bc) +\fP +.fi +.RE +.LP +The following \fIbc\fP program prints the same approximation of \fB'pi'\fP +, with a +label, to standard output: +.sp +.RS +.nf + +\fBscale = 10 +"pi equals " +104348 / 33215 +\fP +.fi +.RE +.LP +The following defines a function to compute an approximate value of +the exponential function (note that such a function is +predefined if the \fB-l\fP option is specified): +.sp +.RS +.nf + +\fBscale = 20 +define e(x){ + auto a, b, c, i, s + a = 1 + b = 1 + s = 1 + for (i = 1; 1 == 1; i++){ + a = a*x + b = b*i + c = a/b + if (c == 0) { + return(s) + } + s = s+c + } +} +\fP +.fi +.RE +.LP +The following prints approximate values of the exponential function +of the first ten integers: +.sp +.RS +.nf + +\fBfor (i = 1; i <= 10; ++i) { + e(i) +} +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fIbc\fP utility is implemented historically as a front-end processor +for \fIdc\fP; \fIdc\fP was not selected to be part +of this volume of IEEE\ Std\ 1003.1-2001 because \fIbc\fP was thought +to have a more intuitive programmatic interface. +Current implementations that implement \fIbc\fP using \fIdc\fP are +expected to be compliant. +.LP +The exit status for error conditions has been left unspecified for +several reasons: +.IP " *" 3 +The \fIbc\fP utility is used in both interactive and non-interactive +situations. Different exit codes may be appropriate for +the two uses. +.LP +.IP " *" 3 +It is unclear when a non-zero exit should be given; divide-by-zero, +undefined functions, and syntax errors are all +possibilities. +.LP +.IP " *" 3 +It is not clear what utility the exit status has. +.LP +.IP " *" 3 +In the 4.3 BSD, System V, and Ninth Edition implementations, \fIbc\fP +works in conjunction with \fIdc\fP. The \fIdc\fP +utility is the parent, \fIbc\fP is the child. This was done to cleanly +terminate \fIbc\fP if \fIdc\fP aborted. +.LP +.LP +The decision to have \fIbc\fP exit upon encountering an inaccessible +input file is based on the belief that \fIbc\fP +\fIfile1\fP \fIfile2\fP is used most often when at least \fIfile1\fP +contains data/function declarations/initializations. Having +\fIbc\fP continue with prerequisite files missing is probably not +useful. There is no implication in the CONSEQUENCES OF ERRORS +section that \fIbc\fP must check all its files for accessibility before +opening any of them. +.LP +There was considerable debate on the appropriateness of the language +accepted by \fIbc\fP. Several reviewers preferred to see +either a pure subset of the C language or some changes to make the +language more compatible with C. While the \fIbc\fP language +has some obvious similarities to C, it has never claimed to be compatible +with any version of C. An interpreter for a subset of C +might be a very worthwhile utility, and it could potentially make +\fIbc\fP obsolete. However, no such utility is known in +historical practice, and it was not within the scope of this volume +of IEEE\ Std\ 1003.1-2001 to define such a language and +utility. If and when they are defined, it may be appropriate to include +them in a future version of IEEE\ Std\ 1003.1. This +left the following alternatives: +.IP " 1." 4 +Exclude any calculator language from this volume of IEEE\ Std\ 1003.1-2001. +.LP +The consensus of the standard developers was that a simple programmatic +calculator language is very useful for both applications +and interactive users. The only arguments for excluding any calculator +were that it would become obsolete if and when a +C-compatible one emerged, or that the absence would encourage the +development of such a C-compatible one. These arguments did not +sufficiently address the needs of current application writers. +.LP +.IP " 2." 4 +Standardize the historical \fIdc\fP, possibly with minor modifications. +.LP +The consensus of the standard developers was that \fIdc\fP is a fundamentally +less usable language and that that would be far +too severe a penalty for avoiding the issue of being similar to but +incompatible with C. +.LP +.IP " 3." 4 +Standardize the historical \fIbc\fP, possibly with minor modifications. +.LP +This was the approach taken. Most of the proponents of changing the +language would not have been satisfied until most or all of +the incompatibilities with C were resolved. Since most of the changes +considered most desirable would break historical applications +and require significant modification to historical implementations, +almost no modifications were made. The one significant +modification that was made was the replacement of the historical \fIbc\fP +assignment operators \fB"=+"\fP , and so on, with the +more modern \fB"+="\fP , and so on. The older versions are considered +to be fundamentally flawed because of the lexical +ambiguity in uses like \fIa\fP=-1. +.LP +In order to permit implementations to deal with backwards-compatibility +as they see fit, the behavior of this one ambiguous +construct was made undefined. (At least three implementations have +been known to support this change already, so the degree of +change involved should not be great.) +.LP +.LP +The \fB'%'\fP operator is the mathematical remainder operator when +\fBscale\fP is zero. The behavior of this operator for +other values of \fBscale\fP is from historical implementations of +\fIbc\fP, and has been maintained for the sake of historical +applications despite its non-intuitive nature. +.LP +Historical implementations permit setting \fBibase\fP and \fBobase\fP +to a broader range of values. This includes values less +than 2, which were not seen as sufficiently useful to standardize. +These implementations do not interpret input properly for values +of \fBibase\fP that are greater than 16. This is because numeric constants +are recognized syntactically, rather than lexically, as +described in this volume of IEEE\ Std\ 1003.1-2001. They are built +from lexical tokens of single hexadecimal digits and +periods. Since <blank>s between tokens are not visible at the syntactic +level, it is not possible to recognize the +multi-digit "digits" used in the higher bases properly. The ability +to recognize input in these bases was not considered useful +enough to require modifying these implementations. Note that the recognition +of numeric constants at the syntactic level is not a +problem with conformance to this volume of IEEE\ Std\ 1003.1-2001, +as it does not impact the behavior of conforming +applications (and correct \fIbc\fP programs). Historical implementations +also accept input with all of the digits \fB'0'\fP - +\fB'9'\fP and \fB'A'\fP - \fB'F'\fP regardless of the value of \fBibase\fP; +since digits with value greater than or equal +to \fBibase\fP are not really appropriate, the behavior when they +appear is undefined, except for the common case of: +.sp +.RS +.nf + +\fBibase=8; + /* Process in octal base. */ +\&... +ibase=A + /* Restore decimal base. */ +\fP +.fi +.RE +.LP +In some historical implementations, if the expression to be written +is an uninitialized array element, a leading <space> +and/or up to four leading 0 characters may be output before the character +zero. This behavior is considered a bug; it is unlikely +that any currently conforming application relies on: +.sp +.RS +.nf + +\fBecho 'b[3]' | bc +\fP +.fi +.RE +.LP +returning 00000 rather than 0. +.LP +Exact calculation of the number of fractional digits to output for +a given value in a base other than 10 can be computationally +expensive. Historical implementations use a faster approximation, +and this is permitted. Note that the requirements apply only to +values of \fBobase\fP that this volume of IEEE\ Std\ 1003.1-2001 requires +implementations to support (in particular, not +to 1, 0, or negative bases, if an implementation supports them as +an extension). +.LP +Historical implementations of \fIbc\fP did not allow array parameters +to be passed as the last parameter to a function. New +implementations are encouraged to remove this restriction even though +it is not required by the grammar. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIGrammar Conventions\fP , \fIawk\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/bg.1p b/man1p/bg.1p new file mode 100644 index 000000000..5fbf2fac3 --- /dev/null +++ b/man1p/bg.1p @@ -0,0 +1,205 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "BG" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" bg +.SH NAME +bg \- run jobs in the background +.SH SYNOPSIS +.LP +\fBbg\fP \fB[\fP\fIjob_id\fP \fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +If job control is enabled (see the description of \fIset\fP \fB-m\fP), +the +\fIbg\fP utility shall resume suspended jobs from the current environment +(see \fIShell +Execution Environment\fP ) by running them as background jobs. If +the job specified by \fIjob_id\fP is already a running +background job, the \fIbg\fP utility shall have no effect and shall +exit successfully. +.LP +Using \fIbg\fP to place a job into the background shall cause its +process ID to become "known in the current shell execution +environment", as if it had been started as an asynchronous list; see +\fIAsynchronous +Lists\fP . +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIjob_id\fP +Specify the job to be resumed as a background job. If no \fIjob_id\fP +operand is given, the most recently suspended job shall +be used. The format of \fIjob_id\fP is described in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 3.203, Job Control Job ID. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIbg\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The output of \fIbg\fP shall consist of a line in the format: +.sp +.RS +.nf + +\fB"[%d] %s\\n", <\fP\fIjob-number\fP\fB>, <\fP\fIcommand\fP\fB> +\fP +.fi +.RE +.LP +where the fields are as follows: +.TP 7 +<\fIjob-number\fP> +A number that can be used to identify the job to the \fIwait\fP, \fIfg\fP, +and \fIkill\fP utilities. Using these utilities, the +job can be identified by prefixing the job number with \fB'%'\fP . +.TP 7 +<\fIcommand\fP> +The associated command that was given to the shell. +.sp +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If job control is disabled, the \fIbg\fP utility shall exit with an +error and no job shall be placed in the background. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +A job is generally suspended by typing the SUSP character (<control>-Z +on most systems); see the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +At that +point, \fIbg\fP can put the job into the background. This is most +effective when the job is expecting no terminal input and its +output has been redirected to non-terminal files. A background job +can be forced to stop when it has terminal output by issuing the +command: +.sp +.RS +.nf + +\fBstty tostop +\fP +.fi +.RE +.LP +A background job can be stopped with the command: +.sp +.RS +.nf + +\fBkill -s stop\fP \fIjob ID\fP +.fi +.RE +.LP +The \fIbg\fP utility does not work as expected when it is operating +in its own utility execution environment because that +environment has no suspended jobs. In the following examples: +.sp +.RS +.nf + +\fB\&... | xargs bg +(bg) +\fP +.fi +.RE +.LP +each \fIbg\fP operates in a different environment and does not share +its parent shell's understanding of jobs. For this reason, +\fIbg\fP is generally implemented as a shell regular built-in. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The extensions to the shell specified in this volume of IEEE\ Std\ 1003.1-2001 +have mostly been based on features +provided by the KornShell. The job control features provided by \fIbg\fP, +\fIfg\fP, and \fIjobs\fP are also based on the KornShell. The standard +developers examined the characteristics +of the C shell versions of these utilities and found that differences +exist. Despite widespread use of the C shell, the KornShell +versions were selected for this volume of IEEE\ Std\ 1003.1-2001 to +maintain a degree of uniformity with the rest of the +KornShell features selected (such as the very popular command line +editing features). +.LP +The \fIbg\fP utility is expected to wrap its output if the output +exceeds the number of display columns. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIAsynchronous Lists\fP , \fIfg\fP , \fIkill\fP() , \fIjobs\fP , +\fIwait\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/break.1p b/man1p/break.1p new file mode 100644 index 000000000..75c5ef623 --- /dev/null +++ b/man1p/break.1p @@ -0,0 +1,120 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "BREAK" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" break +.SH NAME +break \- exit from for, while, or until loop +.SH SYNOPSIS +.LP +\fBbreak\fP \fB[\fP\fIn\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIbreak\fP utility shall exit from the smallest enclosing \fBfor\fP, +\fBwhile\fP, or \fBuntil\fP loop, if any; or from +the \fIn\fPth enclosing loop if \fIn\fP is specified. The value of +\fIn\fP is an unsigned decimal integer greater than or equal +to 1. The default shall be equivalent to \fIn\fP=1. If \fIn\fP is +greater than the number of enclosing loops, the outermost +enclosing loop shall be exited. Execution shall continue with the +command immediately following the loop. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +The \fIn\fP value was not an unsigned decimal integer greater than +or equal to 1. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fBfor i in * do + if test -d "$i" then break fi done +\fP +.fi +.RE +.SH RATIONALE +.LP +In early proposals, consideration was given to expanding the syntax +of \fIbreak\fP and \fIcontinue\fP to refer to a label associated with +the appropriate loop as a preferable +alternative to the \fIn\fP method. However, this volume of IEEE\ Std\ 1003.1-2001 +does reserve the name space of command +names ending with a colon. It is anticipated that a future implementation +could take advantage of this and provide something +like: +.sp +.RS +.nf + +\fBoutofloop: for i in a b c d e +do + for j in 0 1 2 3 4 5 6 7 8 9 + do + if test -r "${i}${j}" + then break outofloop + fi + done +done +\fP +.fi +.RE +.LP +and that this might be standardized after implementation experience +is achieved. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/c99.1p b/man1p/c99.1p new file mode 100644 index 000000000..58b2b2352 --- /dev/null +++ b/man1p/c99.1p @@ -0,0 +1,745 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "C99" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" c99 +.SH NAME +c99 \- compile standard C programs +.SH SYNOPSIS +.LP +\fBc99\fP \fB[\fP\fB-c\fP\fB][\fP\fB-D\fP +\fIname\fP\fB[\fP\fB=\fP\fIvalue\fP\fB]]\fP\fB...\fP\fB[\fP\fB-E\fP\fB][\fP\fB-g\fP\fB][\fP\fB-I\fP +\fIdirectory\fP\fB]\fP \fB...\fP \fB[\fP\fB-L\fP \fIdirectory\fP\fB]\fP\fB +.br +\ \ \ \ \ \ ...\fP \fB[\fP\fB-o\fP +\fIoutfile\fP\fB][\fP\fB-O\fP\fIoptlevel\fP\fB][\fP\fB-s\fP\fB][\fP\fB-U\fP +\fIname\fP\fB]\fP\fB...\fP +\fIoperand\fP \fB... \fP +.SH DESCRIPTION +.LP +The \fIc99\fP utility is an interface to the standard C compilation +system; it shall accept source code conforming to the +ISO\ C standard. The system conceptually consists of a compiler and +link editor. The files referenced by \fIoperand\fPs shall +be compiled and linked to produce an executable file. (It is unspecified +whether the linking occurs entirely within the operation +of \fIc99\fP; some implementations may produce objects that are not +fully resolved until the file is executed.) +.LP +If the \fB-c\fP option is specified, for all pathname operands of +the form \fIfile\fP \fB.c\fP, the files: +.sp +.RS +.nf + +\fB$(basename\fP \fIpathname\fP \fB.c).o +\fP +.fi +.RE +.LP +shall be created as the result of successful compilation. If the \fB-c\fP +option is not specified, it is unspecified whether +such \fB.o\fP files are created or deleted for the \fIfile\fP \fB.c\fP +operands. +.LP +If there are no options that prevent link editing (such as \fB-c\fP +or \fB-E\fP), and all operands compile and link without +error, the resulting executable file shall be written according to +the \fB-o\fP \fIoutfile\fP option (if present) or to the file +\fBa.out\fP. +.LP +The executable file shall be created as specified in \fIFile Read, +Write, and +Creation\fP , except that the file permission bits shall be set to: +.sp +.RS +.nf + +S_IRWXO | S_IRWXG | S_IRWXU +.fi +.RE +.LP +and the bits specified by the \fIumask\fP of the process shall be +cleared. +.SH OPTIONS +.LP +The \fIc99\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that: +.IP " *" 3 +The \fB-l\fP \fIlibrary\fP operands have the format of options, but +their position within a list of operands affects the order +in which libraries are searched. +.LP +.IP " *" 3 +The order of specifying the \fB-I\fP and \fB-L\fP options is significant. +.LP +.IP " *" 3 +Conforming applications shall specify each option separately; that +is, grouping option letters (for example, \fB-cO\fP) need +not be recognized by all implementations. +.LP +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Suppress the link-edit phase of the compilation, and do not remove +any object files that are produced. +.TP 7 +\fB-g\fP +Produce symbolic information in the object or executable files; the +nature of this information is unspecified, and may be +modified by implementation-defined interactions with other options. +.TP 7 +\fB-s\fP +Produce object or executable files, or both, from which symbolic and +other information not required for proper execution using +the \fIexec\fP family defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001 +has been removed (stripped). If +both \fB-g\fP and \fB-s\fP options are present, the action taken is +unspecified. +.TP 7 +\fB-o\ \fP \fIoutfile\fP +Use the pathname \fIoutfile\fP, instead of the default \fBa.out\fP, +for the executable file produced. If the \fB-o\fP option +is present with \fB-c\fP or \fB-E\fP, the result is unspecified. +.TP 7 +\fB-D\ \fP \fIname\fP\fB[=\fP\fIvalue\fP\fB]\fP +.sp +Define \fIname\fP as if by a C-language \fB#define\fP directive. If +no = \fIvalue\fP is given, a value of 1 shall be used. The +\fB-D\fP option has lower precedence than the \fB-U\fP option. That +is, if \fIname\fP is used in both a \fB-U\fP and a +\fB-D\fP option, \fIname\fP shall be undefined regardless of the order +of the options. Additional implementation-defined +\fIname\fPs may be provided by the compiler. Implementations shall +support at least 2048 bytes of \fB-D\fP definitions and 256 +\fInames\fP. +.TP 7 +\fB-E\fP +Copy C-language source files to standard output, expanding all preprocessor +directives; no compilation shall be performed. If +any operand is not a text file, the effects are unspecified. +.TP 7 +\fB-I\ \fP \fIdirectory\fP +Change the algorithm for searching for headers whose names are not +absolute pathnames to look in the directory named by the +\fIdirectory\fP pathname before looking in the usual places. Thus, +headers whose names are enclosed in double-quotes ( \fB""\fP +) shall be searched for first in the directory of the file with the +\fB#include\fP line, then in directories named in \fB-I\fP +options, and last in the usual places. For headers whose names are +enclosed in angle brackets ( \fB"<>"\fP ), the header +shall be searched for only in directories named in \fB-I\fP options +and then in the usual places. Directories named in \fB-I\fP +options shall be searched in the order specified. Implementations +shall support at least ten instances of this option in a single +\fIc99\fP command invocation. +.TP 7 +\fB-L\ \fP \fIdirectory\fP +Change the algorithm of searching for the libraries named in the \fB-l\fP +objects to look in the directory named by the +\fIdirectory\fP pathname before looking in the usual places. Directories +named in \fB-L\fP options shall be searched in the order +specified. Implementations shall support at least ten instances of +this option in a single \fIc99\fP command invocation. If a +directory specified by a \fB-L\fP option contains files named \fBlibc.a\fP, +\fBlibm.a\fP, \fBlibl.a\fP, or \fBliby.a\fP, the +results are unspecified. +.TP 7 +\fB-O\ \fP \fIoptlevel\fP +Specify the level of code optimization. If the \fIoptlevel\fP option-argument +is the digit \fB'0'\fP , all special code +optimizations shall be disabled. If it is the digit \fB'1'\fP , the +nature of the optimization is unspecified. If the \fB-O\fP +option is omitted, the nature of the system's default optimization +is unspecified. It is unspecified whether code generated in the +presence of the \fB-O\fP 0 option is the same as that generated when +\fB-O\fP is omitted. Other \fIoptlevel\fP values may be +supported. +.TP 7 +\fB-U\ \fP \fIname\fP +Remove any initial definition of \fIname\fP. +.sp +.LP +Multiple instances of the \fB-D\fP, \fB-I\fP, \fB-U\fP, and \fB-L\fP +options can be specified. +.SH OPERANDS +.LP +An \fIoperand\fP is either in the form of a pathname or the form \fB-l\fP +\fIlibrary\fP. The application shall ensure that at +least one operand of the pathname form is specified. The following +operands shall be supported: +.TP 7 +\fIfile.\fP\fBc\fP +A C-language source file to be compiled and optionally linked. The +application shall ensure that the operand is of this form if +the \fB-c\fP option is used. +.TP 7 +\fIfile.\fP\fBa\fP +A library of object files typically produced by the \fIar\fP utility, +and passed directly +to the link editor. Implementations may recognize implementation-defined +suffixes other than \fB.a\fP as denoting object file +libraries. +.TP 7 +\fIfile.\fP\fBo\fP +An object file produced by \fIc99\fP \fB-c\fP and passed directly +to the link editor. Implementations may recognize +implementation-defined suffixes other than \fB.o\fP as denoting object +files. +.sp +.LP +The processing of other files is implementation-defined. +.TP 7 +\fI-l\ library\fP +(The letter ell.) Search the library named: +.sp +.RS +.nf + +\fBlib\fP\fIlibrary\fP\fB.a +\fP +.fi +.RE +.LP +A library shall be searched when its name is encountered, so the placement +of a \fB-l\fP operand is significant. Several +standard libraries can be specified in this manner, as described in +the EXTENDED DESCRIPTION section. Implementations may recognize +implementation-defined suffixes other than \fB.a\fP as denoting libraries. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The input file shall be one of the following: a text file containing +a C-language source program, an object file in the format +produced by \fIc99\fP \fB-c\fP, or a library of object files, in the +format produced by archiving zero or more object files, +using \fIar\fP. Implementations may supply additional utilities that +produce files in these +formats. Additional input file formats are implementation-defined. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIc99\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITMPDIR\fP +Provide a pathname that should override the default directory for +temporary files, if any. \ On +XSI-conforming systems, provide a pathname that shall override the +default directory for temporary files, if any. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If more than one \fIfile\fP operand ending in \fB.c\fP (or possibly +other unspecified suffixes) is given, for each such +file: +.sp +.RS +.nf + +\fB"%s:\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +may be written. These messages, if written, shall precede the processing +of each input file; they shall not be written to the +standard output if they are written to the standard error, as described +in the STDERR section. +.LP +If the \fB-E\fP option is specified, the standard output shall be +a text file that represents the results of the preprocessing +stage of the language; it may contain extra information appropriate +for subsequent compilation passes. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. If +more than one \fIfile\fP operand ending in \fB.c\fP (or +possibly other unspecified suffixes) is given, for each such file: +.sp +.RS +.nf + +\fB"%s:\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +may be written to allow identification of the diagnostic and warning +messages with the appropriate input file. These messages, +if written, shall precede the processing of each input file; they +shall not be written to the standard error if they are written to +the standard output, as described in the STDOUT section. +.LP +This utility may produce warning messages about certain conditions +that do not warrant returning an error (non-zero) exit +value. +.SH OUTPUT FILES +.LP +Object files or executable files or both are produced in unspecified +formats. +.SH EXTENDED DESCRIPTION +.SS Standard Libraries +.LP +The \fIc99\fP utility shall recognize the following \fB-l\fP operands +for standard libraries: +.TP 7 +\fB-l\ c\fP +This operand shall make visible all functions referenced in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, +with the possible exception of those functions listed as residing +in \fI<aio.h>\fP, \fI<arpa/inet.h>\fP, \fI<complex.h>\fP, \fI<fenv.h>\fP, +\fI<math.h>\fP, \fI<mqueue.h>\fP, \fI<netdb.h>\fP, \fI<netinet/in.h>\fP, +\fI<pthread.h>\fP, \fI<sched.h>\fP, \fI<semaphore.h>\fP, \fI<spawn.h>\fP, +\fI<sys/socket.h>\fP, \fIpthread_kill\fP(), and \fIpthread_sigmask\fP() +in \fI<signal.h>\fP, \fI<trace.h>\fP, functions +marked as extensions other than as part of the MF or MPR extensions +in \fI<sys/mman.h>\fP, functions marked as ADV in \fI<fcntl.h>\fP, +and functions marked as CS, CPT, and TMR in \fI<time.h>\fP. This operand +shall not be required to be present to cause a search of this +library. +.TP 7 +\fB-l\ l\fP +This operand shall make visible all functions required by the C-language +output of \fIlex\fP that are not made available through the \fB-l\ c\fP +operand. +.TP 7 +\fB-l\ pthread\fP +This operand shall make visible all functions referenced in \fI<pthread.h>\fP +and \fIpthread_kill\fP() and \fIpthread_sigmask\fP() referenced in +\fI<signal.h>\fP. An implementation may search this library in the +absence of this +operand. +.TP 7 +\fB-l\ m\fP +This operand shall make visible all functions referenced in \fI<math.h>\fP, +\fI<complex.h>\fP, and \fI<fenv.h>\fP. An +implementation may search this library in the absence of this operand. +.TP 7 +\fB-l\ rt\fP +This operand shall make visible all functions referenced in \fI<aio.h>\fP, +\fI<mqueue.h>\fP, \fI<sched.h>\fP, \fI<semaphore.h>\fP, and \fI<spawn.h>\fP, +functions marked as extensions other than as part of the MF or MPR +extensions in \fI<sys/mman.h>\fP, functions marked as ADV in \fI<fcntl.h>\fP, +and functions marked as CS, CPT, and TMR in \fI<time.h>\fP. An implementation +may search this library in the absence of this operand. +.TP 7 +\fB-l\ trace\fP +This operand shall make visible all functions referenced in \fI<trace.h>\fP. +An +implementation may search this library in the absence of this operand. +.TP 7 +\fB-l\ xnet\fP +This operand makes visible all functions referenced in \fI<arpa/inet.h>\fP, +\fI<netdb.h>\fP, \fI<netinet/in.h>\fP, and \fI<sys/socket.h>\fP. An +implementation may search this library in the absence of this +operand. +.TP 7 +\fB-l\ y\fP +This operand shall make visible all functions required by the C-language +output of \fIyacc\fP that are not made available through the \fB-l\ c\fP +operand. +.sp +.LP +In the absence of options that inhibit invocation of the link editor, +such as \fB-c\fP or \fB-E\fP, the \fIc99\fP utility +shall cause the equivalent of a \fB-l\ c\fP operand to be passed to +the link editor as the last \fB-l\fP operand, causing it +to be searched after all other object files and libraries are loaded. +.LP +It is unspecified whether the libraries \fBlibc.a\fP, \fBlibm.a\fP, +\fBlibrt.a\fP, \fBlibpthread.a\fP, \fBlibl.a\fP, +\fBliby.a\fP, or \fBlibxnet.a\fP exist as regular files. The implementation +may accept as \fB-l\fP operands names of objects +that do not exist as regular files. +.SS External Symbols +.LP +The C compiler and link editor shall support the significance of external +symbols up to a length of at least 31 bytes; the +action taken upon encountering symbols exceeding the implementation-defined +maximum symbol length is unspecified. +.LP +The compiler and link editor shall support a minimum of 511 external +symbols per source or object file, and a minimum of 4095 +external symbols in total. A diagnostic message shall be written to +the standard output if the implementation-defined limit is +exceeded; other actions are unspecified. +.SS Programming Environments +.LP +All implementations shall support one of the following programming +environments as a default. Implementations may support more +than one of the following programming environments. Applications can +use \fIsysconf\fP() +or \fIgetconf\fP to determine which programming environments are supported. +.br +.sp +.ce 1 +\fBTable: Programming Environments: Type Sizes\fP +.TS C +center; l2 l2 l2 l2 l. +\fBProgramming Environment\fP \fBBits in\fP \fBBits in\fP \fBBits in\fP \fBBits in\fP +\fB\fIgetconf\fP Name\fP \fBint\fP \fBlong\fP \fBpointer\fP \fBoff_t\fP +_POSIX_V6_ILP32_OFF32 32 32 32 32 +_POSIX_V6_ILP32_OFFBIG 32 32 32 >=64 +_POSIX_V6_LP64_OFF64 32 64 64 64 +_POSIX_V6_LPBIG_OFFBIG >=32 >=64 >=64 >=64 +.TE +.LP +All implementations shall support one or more environments where the +widths of the following types are no greater than the width +of type \fBlong\fP: +\fBblksize_t\fP, \fBcc_t\fP, \fBmode_t\fP, \fBnfds_t\fP, \fBpid_t\fP, +\fBptrdiff_t\fP, \fBsize_t\fP, +\fBspeed_t\fP, \fBssize_t\fP, \fBsuseconds_t\fP, \fBtcflag_t\fP, \fBuseconds_t\fP, +\fBwchar_t\fP, \fBwint_t\fP +.LP +The executable files created when these environments are selected +shall be in a proper format for execution by the \fIexec\fP +family of functions. Each environment may be one of the ones in Programming +Environments: Type Sizes , or +it may be another environment. The names for the environments that +meet this requirement shall be output by a \fIgetconf\fP command using +the _POSIX_V6_WIDTH_RESTRICTED_ENVS argument. If more than one +environment meets the requirement, the names of all such environments +shall be output on separate lines. Any of these names can +then be used in a subsequent \fIgetconf\fP command to obtain the flags +specific to that +environment with the following suffixes added as appropriate: +.TP 7 +_CFLAGS +To get the C compiler flags. +.TP 7 +_LDFLAGS +To get the linker/loader flags. +.TP 7 +_LIBS +To get the libraries. +.sp +.LP +This requirement may be removed in a future version of IEEE\ Std\ 1003.1. +.LP +When this utility processes a file containing a function called \fImain\fP(), +it shall be defined with a return type equivalent +to \fBint\fP. Using return from the initial call to \fImain\fP() shall +be equivalent (other than with respect to language scope +issues) to calling \fIexit\fP() with the returned value. Reaching +the end of the initial call +to \fImain\fP() shall be equivalent to calling \fIexit\fP(0). The +implementation shall not declare a prototype for this +function. +.LP +Implementations provide configuration strings for C compiler flags, +linker/loader flags, and libraries for each supported +environment. When an application needs to use a specific programming +environment rather than the implementation default programming +environment while compiling, the application shall first verify that +the implementation supports the desired environment. If the +desired programming environment is supported, the application shall +then invoke \fIc99\fP with the appropriate C compiler flags as +the first options for the compile, the appropriate linker/loader flags +after any other options but before any operands, and the +appropriate libraries at the end of the operands. +.LP +Conforming applications shall not attempt to link together object +files compiled for different programming models. Applications +shall also be aware that binary data placed in shared memory or in +files might not be recognized by applications built for other +programming models. +.br +.sp +.ce 1 +\fBTable: Programming Environments: \fIc99\fP and \fIcc\fP Arguments\fP +.TS C +center; l1 l1 l. +\fBProgramming Environment\fP \fB\ \fP \fB\fIc99\fP and \fIcc\fP Arguments\fP +\fB\fIgetconf\fP Name\fP \fBUse\fP \fB\fIgetconf\fP Name\fP +_POSIX_V6_ILP32_OFF32 C Compiler Flags POSIX_V6_ILP32_OFF32_CFLAGS +\ Linker/Loader Flags POSIX_V6_ILP32_OFF32_LDFLAGS +\ Libraries POSIX_V6_ILP32_OFF32_LIBS +_POSIX_V6_ILP32_OFFBIG C Compiler Flags POSIX_V6_ILP32_OFFBIG_CFLAGS +\ Linker/Loader Flags POSIX_V6_ILP32_OFFBIG_LDFLAGS +\ Libraries POSIX_V6_ILP32_OFFBIG_LIBS +_POSIX_V6_LP64_OFF64 C Compiler Flags POSIX_V6_LP64_OFF64_CFLAGS +\ Linker/Loader Flags POSIX_V6_LP64_OFF64_LDFLAGS +\ Libraries POSIX_V6_LP64_OFF64_LIBS +_POSIX_V6_LPBIG_OFFBIG C Compiler Flags POSIX_V6_LPBIG_OFFBIG_CFLAGS +\ Linker/Loader Flags POSIX_V6_LPBIG_OFFBIG_LDFLAGS +\ Libraries POSIX_V6_LPBIG_OFFBIG_LIBS +.TE +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful compilation or link edit. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +When \fIc99\fP encounters a compilation error that causes an object +file not to be created, it shall write a diagnostic to +standard error and continue to compile other source code operands, +but it shall not perform the link phase and return a non-zero +exit status. If the link edit is unsuccessful, a diagnostic message +shall be written to standard error and \fIc99\fP exits with a +non-zero status. A conforming application shall rely on the exit status +of \fIc99\fP, rather than on the existence or mode of the +executable file. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since the \fIc99\fP utility usually creates files in the current directory +during the compilation process, it is typically +necessary to run the \fIc99\fP utility in a directory in which a file +can be created. +.LP +On systems providing POSIX Conformance (see the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Chapter 2, Conformance), \fIc99\fP is required +only with the C-Language Development +option; XSI-conformant systems always provide \fIc99\fP. +.LP +Some historical implementations have created \fB.o\fP files when \fB-c\fP +is not specified and more than one source file is +given. Since this area is left unspecified, the application cannot +rely on \fB.o\fP files being created, but it also must be +prepared for any related \fB.o\fP files that already exist being deleted +at the completion of the link edit. +.LP +Some historical implementations have permitted \fB-L\fP options to +be interspersed with \fB-l\fP operands on the command line. +For an application to compile consistently on systems that do not +behave like this, it is necessary for a conforming application to +supply all \fB-L\fP options before any of the \fB-l\fP options. +.LP +There is the possible implication that if a user supplies versions +of the standard functions (before they would be encountered +by an implicit \fB-l\ c\fP or explicit \fB-l\ m\fP), that those versions +would be used in place of the standard versions. +There are various reasons this might not be true (functions defined +as macros, manipulations for clean name space, and so on), so +the existence of files named in the same manner as the standard libraries +within the \fB-L\fP directories is explicitly stated to +produce unspecified behavior. +.LP +All of the functions specified in the System Interfaces volume of +IEEE\ Std\ 1003.1-2001 may be made visible by +implementations when the Standard C Library is searched. Conforming +applications must explicitly request searching the other +standard libraries when functions made visible by those libraries +are used. +.SH EXAMPLES +.IP " 1." 4 +The following usage example compiles \fBfoo.c\fP and creates the executable +file \fBfoo\fP: +.sp +.RS +.nf + +\fBc99 -o foo foo.c +\fP +.fi +.RE +.LP +The following usage example compiles \fBfoo.c\fP and creates the object +file \fBfoo.o\fP: +.sp +.RS +.nf + +\fBc99 -c foo.c +\fP +.fi +.RE +.LP +The following usage example compiles \fBfoo.c\fP and creates the executable +file \fBa.out\fP: +.sp +.RS +.nf + +\fBc99 foo.c +\fP +.fi +.RE +.LP +The following usage example compiles \fBfoo.c\fP, links it with \fBbar.o\fP, +and creates the executable file \fBa.out\fP. It +may also create and leave \fBfoo.o\fP: +.sp +.RS +.nf + +\fBc99 foo.c bar.o +\fP +.fi +.RE +.LP +.IP " 2." 4 +The following example shows how an application using threads interfaces +can test for support of and use a programming +environment supporting 32-bit \fBint\fP, \fBlong\fP, and \fBpointer\fP +types and an \fBoff_t\fP type using at least 64 +bits: +.sp +.RS +.nf + +\fBif [ $(getconf _POSIX_V6_ILP32_OFFBIG) != "-1" ] +then + c99 $(getconf POSIX_V6_ILP32_OFFBIG_CFLAGS) -D_XOPEN_SOURCE=600 \\ + $(getconf POSIX_V6_ILP32_OFFBIG_LDFLAGS) foo.c -o foo \\ + $(getconf POSIX_V6_ILP32_OFFBIG_LIBS) -l pthread +else + echo ILP32_OFFBIG programming environment not supported + exit 1 +fi +\fP +.fi +.RE +.LP +.IP " 3." 4 +The following examples clarify the use and interactions of \fB-L\fP +options and \fB-l\fP operands. +.LP +Consider the case in which module \fBa.c\fP calls function \fIf\fP() +in library \fBlibQ.a\fP, and module \fBb.c\fP calls +function \fIg\fP() in library \fBlibp.a\fP. Assume that both libraries +reside in \fB/a/b/c\fP. The command line to compile and +link in the desired way is: +.sp +.RS +.nf + +\fBc99 -L /a/b/c main.o a.c -l Q b.c -l p +\fP +.fi +.RE +.LP +In this case the \fB-l\ Q\fP operand need only precede the first \fB-l\ p\fP +operand, since both \fBlibQ.a\fP and +\fBlibp.a\fP reside in the same directory. +.LP +Multiple \fB-L\fP operands can be used when library name collisions +occur. Building on the previous example, suppose that the +user wants to use a new \fBlibp.a\fP, in \fB/a/a/a\fP, but still wants +\fIf\fP() from \fB/a/b/c/libQ.a\fP: +.sp +.RS +.nf + +\fBc99 -L /a/a/a -L /a/b/c main.o a.c -l Q b.c -l p +\fP +.fi +.RE +.LP +In this example, the linker searches the \fB-L\fP options in the order +specified, and finds \fB/a/a/a/libp.a\fP before +\fB/a/b/c/libp.a\fP when resolving references for \fBb.c\fP. The order +of the \fB-l\fP operands is still important, however. +.LP +.IP " 4." 4 +The following example shows how an application can use a programming +environment where the widths of the following types: +\fBblksize_t\fP, \fBcc_t\fP, \fBmode_t\fP, \fBnfds_t\fP, \fBpid_t\fP, +\fBptrdiff_t\fP, \fBsize_t\fP, +\fBspeed_t\fP, \fBssize_t\fP, \fBsuseconds_t\fP, \fBtcflag_t\fP, \fBuseconds_t\fP, +\fBwchar_t\fP, \fBwint_t\fP +.LP +are no greater than the width of type \fBlong\fP: +.sp +.RS +.nf + +\fB# First choose one of the listed environments ... +.sp + +# ... if there are no additional constraints, the first one will do: +CENV=$(getconf _POSIX_V6_WIDTH_RESTRICTED_ENVS | head -n l) +.sp + +# ... or, if an environment that supports large files is preferred, +# look for names that contain "OFF64" or "OFFBIG". (This chooses +# the last one in the list if none match.) +for CENV in $(getconf _POSIX_V6_WIDTH_RESTRICTED_ENVS) +do + case $CENV in + *OFF64*|*OFFBIG*) break ;; + esac +done +.sp + +# The chosen environment name can now be used like this: +.sp + +c99 $(getconf ${CENV}_CFLAGS) -D _POSIX_C_SOURCE=200112L \\ +$(getconf ${CENV}_LDFLAGS) foo.c -o foo \\ +$(getconf ${CENV}_LIBS) +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fIc99\fP utility is based on the \fIc89\fP utility originally +introduced in the ISO\ POSIX-2:1993 standard. +.LP +Some of the changes from \fIc89\fP include the modification to the +contents of the Standard Libraries section to account for +new headers and options; for example, \fI<spawn.h>\fP added to the +\fB-l\ rt\fP +operand, and the \fB-l\fP trace operand added for the Tracing functions. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIFile Read, Write, and Creation\fP , \fIar\fP , \fIgetconf\fP , +\fImake\fP , \fInm\fP , \fIstrip\fP , \fIumask\fP() , the System Interfaces +volume of +IEEE\ Std\ 1003.1-2001, \fIexec\fP, \fIsysconf\fP(), the Base Definitions +volume +of IEEE\ Std\ 1003.1-2001, Chapter 13, Headers +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cal.1p b/man1p/cal.1p new file mode 100644 index 000000000..6ac3eaf41 --- /dev/null +++ b/man1p/cal.1p @@ -0,0 +1,144 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CAL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cal +.SH NAME +cal \- print a calendar +.SH SYNOPSIS +.LP +\fBcal\fP \fB[[\fP\fImonth\fP\fB]\fP \fIyear\fP \fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIcal\fP utility shall write a calendar to standard output using +the Julian calendar for dates from January 1, 1 through +September 2, 1752 and the Gregorian calendar for dates from September +14, 1752 through December 31, 9999 as though the Gregorian +calendar had been adopted on September 14, 1752. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fImonth\fP +Specify the month to be displayed, represented as a decimal integer +from 1 (January) to 12 (December). The default shall be the +current month. +.TP 7 +\fIyear\fP +Specify the year for which the calendar is displayed, represented +as a decimal integer from 1 to 9999. The default shall be the +current year. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcal\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error, +and informative messages written to standard output. +.TP 7 +\fILC_TIME\fP +Determine the format and contents of the calendar. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone used to calculate the value of the current +month. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be used to display the calendar, in an unspecified +format. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Note that: +.sp +.RS +.nf + +\fBcal 83 +\fP +.fi +.RE +.LP +refers to A.D. 83, not 1983. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +A future version of IEEE\ Std\ 1003.1-2001 may support locale-specific +recognition of the date of adoption of the +Gregorian calendar. +.SH SEE ALSO +.LP +None. +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cat.1p b/man1p/cat.1p new file mode 100644 index 000000000..c2184a1be --- /dev/null +++ b/man1p/cat.1p @@ -0,0 +1,276 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CAT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cat +.SH NAME +cat \- concatenate and print files +.SH SYNOPSIS +.LP +\fBcat\fP \fB[\fP\fB-u\fP\fB][\fP\fIfile\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIcat\fP utility shall read files in sequence and shall write +their contents to the standard output in the same +sequence. +.SH OPTIONS +.LP +The \fIcat\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-u\fP +Write bytes from the input file to the standard output without delay +as each is read. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If no \fIfile\fP operands are specified, +the standard input shall be used. If a \fIfile\fP is +\fB'-'\fP , the \fIcat\fP utility shall read from the standard input +at that point in the sequence. The \fIcat\fP utility +shall not close and reopen standard input when it is referenced in +this way, but shall accept multiple occurrences of \fB'-'\fP +as a \fIfile\fP operand. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP . +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files can be any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcat\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall contain the sequence of bytes read from +the input files. Nothing else shall be written to the standard +output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were output successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-u\fP option has value in prototyping non-blocking reads from +FIFOs. The intent is to support the following +sequence: +.sp +.RS +.nf + +\fBmkfifo foo +cat -u foo > /dev/tty13 & +cat -u > foo +\fP +.fi +.RE +.LP +It is unspecified whether standard output is or is not buffered in +the default case. This is sometimes of interest when standard +output is associated with a terminal, since buffering may delay the +output. The presence of the \fB-u\fP option guarantees that +unbuffered I/O is available. It is implementation-defined whether +the \fIcat\fP utility buffers output if the \fB-u\fP option is +not specified. Traditionally, the \fB-u\fP option is implemented using +the equivalent of the \fIsetvbuf\fP() function defined in the System +Interfaces volume of +IEEE\ Std\ 1003.1-2001. +.SH EXAMPLES +.LP +The following command: +.sp +.RS +.nf + +\fBcat myfile +\fP +.fi +.RE +.LP +writes the contents of the file \fBmyfile\fP to standard output. +.LP +The following command: +.sp +.RS +.nf + +\fBcat doc1 doc2 > doc.all +\fP +.fi +.RE +.LP +concatenates the files \fBdoc1\fP and \fBdoc2\fP and writes the result +to \fBdoc.all\fP. +.LP +Because of the shell language mechanism used to perform output redirection, +a command such as this: +.sp +.RS +.nf + +\fBcat doc doc.end > doc +\fP +.fi +.RE +.LP +causes the original data in \fBdoc\fP to be lost. +.LP +The command: +.sp +.RS +.nf + +\fBcat start - middle - end > file +\fP +.fi +.RE +.LP +when standard input is a terminal, gets two arbitrary pieces of input +from the terminal with a single invocation of \fIcat\fP. +Note, however, that if standard input is a regular file, this would +be equivalent to the command: +.sp +.RS +.nf + +\fBcat start - middle /dev/null end > file +\fP +.fi +.RE +.LP +because the entire contents of the file would be consumed by \fIcat\fP +the first time \fB'-'\fP was used as a \fIfile\fP +operand and an end-of-file condition would be detected immediately +when \fB'-'\fP was referenced the second time. +.SH RATIONALE +.LP +Historical versions of the \fIcat\fP utility include the options \fB-e\fP, +\fB-t\fP, and \fB-v\fP, which permit the ends of +lines, <tab>s, and invisible characters, respectively, to be rendered +visible in the output. The standard developers omitted +these options because they provide too fine a degree of control over +what is made visible, and similar output can be obtained using +a command such as: +.sp +.RS +.nf + +\fBsed -n -e 's/$/$/' -e l pathname +\fP +.fi +.RE +.LP +The \fB-s\fP option was omitted because it corresponds to different +functions in BSD and System V-based systems. The BSD +\fB-s\fP option to squeeze blank lines can be accomplished by the +shell script shown in the following example: +.sp +.RS +.nf + +\fBsed -n ' +# Write non-empty lines. +/./ { + p + d + } +# Write a single empty line, then look for more empty lines. +/^$/ p +# Get next line, discard the held <newline> (empty line), +# and look for more empty lines. +:Empty +/^$/ { + N + s/.// + b Empty + } +# Write the non-empty line before going back to search +# for the first in a set of empty lines. + p +' +\fP +.fi +.RE +.LP +The System V \fB-s\fP option to silence error messages can be accomplished +by redirecting the standard error. Note that the BSD +documentation for \fIcat\fP uses the term "blank line" to mean the +same as the POSIX "empty line'': a line consisting only of a +<newline>. +.LP +The BSD \fB-n\fP option was omitted because similar functionality +can be obtained from the \fB-n\fP option of the \fIpr\fP utility. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fImore\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIsetvbuf\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cd.1p b/man1p/cd.1p new file mode 100644 index 000000000..4729ac48a --- /dev/null +++ b/man1p/cd.1p @@ -0,0 +1,350 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cd +.SH NAME +cd \- change the working directory +.SH SYNOPSIS +.LP +\fBcd\fP \fB[\fP\fB-L | -P\fP\fB] [\fP\fIdirectory\fP\fB]\fP\fB +.br +.sp +cd - +.br +\fP +.SH DESCRIPTION +.LP +The \fIcd\fP utility shall change the working directory of the current +shell execution environment (see \fIShell Execution Environment\fP +) by executing the following steps in sequence. (In the +following steps, the symbol \fBcurpath\fP represents an intermediate +value used to simplify the description of the algorithm used +by \fIcd\fP. There is no requirement that \fBcurpath\fP be made visible +to the application.) +.IP " 1." 4 +If no \fIdirectory\fP operand is given and the \fIHOME\fP environment +variable is empty or undefined, the default behavior is +implementation-defined and no further steps shall be taken. +.LP +.IP " 2." 4 +If no \fIdirectory\fP operand is given and the \fIHOME\fP environment +variable is set to a non-empty value, the \fIcd\fP +utility shall behave as if the directory named in the \fIHOME\fP environment +variable was specified as the \fIdirectory\fP +operand. +.LP +.IP " 3." 4 +If the \fIdirectory\fP operand begins with a slash character, set +\fBcurpath\fP to the operand and proceed to step 7. +.LP +.IP " 4." 4 +If the first component of the \fIdirectory\fP operand is dot or dot-dot, +proceed to step 6. +.LP +.IP " 5." 4 +Starting with the first pathname in the colon-separated pathnames +of \fICDPATH\fP (see the ENVIRONMENT VARIABLES section) if +the pathname is non-null, test if the concatenation of that pathname, +a slash character, and the \fIdirectory\fP operand names a +directory. If the pathname is null, test if the concatenation of dot, +a slash character, and the operand names a directory. In +either case, if the resulting string names an existing directory, +set \fBcurpath\fP to that string and proceed to step 7. +Otherwise, repeat this step with the next pathname in \fICDPATH\fP +until all pathnames have been tested. +.LP +.IP " 6." 4 +Set \fBcurpath\fP to the string formed by the concatenation of the +value of \fIPWD ,\fP a slash character, and the +operand. +.LP +.IP " 7." 4 +If the \fB-P\fP option is in effect, the \fIcd\fP utility shall perform +actions equivalent to the \fIchdir\fP() function, called with \fBcurpath\fP +as the \fIpath\fP argument. If these actions +succeed, the \fIPWD\fP environment variable shall be set to an absolute +pathname for the current working directory and shall not +contain filename components that, in the context of pathname resolution, +refer to a file of type symbolic link. If there is +insufficient permission on the new directory, or on any parent of +that directory, to determine the current working directory, the +value of the \fIPWD\fP environment variable is unspecified. If the +actions equivalent to \fIchdir\fP() fail for any reason, the \fIcd\fP +utility shall display an appropriate error message +and not alter the \fIPWD\fP environment variable. Whether the actions +equivalent to \fIchdir\fP() succeed or fail, no further steps shall +be taken. +.LP +.IP " 8." 4 +The \fBcurpath\fP value shall then be converted to canonical form +as follows, considering each component from beginning to end, +in sequence: +.RS +.IP " a." 4 +Dot components and any slashes that separate them from the next component +shall be deleted. +.LP +.IP " b." 4 +For each dot-dot component, if there is a preceding component and +it is neither root nor dot-dot, the preceding component, all +slashes separating the preceding component from dot-dot, dot-dot and +all slashes separating dot-dot from the following component +shall be deleted. +.LP +.IP " c." 4 +An implementation may further simplify \fBcurpath\fP by removing any +trailing slash characters that are not also leading +slashes, replacing multiple non-leading consecutive slashes with a +single slash, and replacing three or more leading slashes with a +single slash. If, as a result of this canonicalization, the \fBcurpath\fP +variable is null, no further steps shall be taken. +.LP +.RE +.LP +.IP " 9." 4 +The \fIcd\fP utility shall then perform actions equivalent to the +\fIchdir\fP() function +called with \fBcurpath\fP as the \fIpath\fP argument. If these actions +failed for any reason, the \fIcd\fP utility shall display +an appropriate error message and no further steps shall be taken. +The \fIPWD\fP environment variable shall be set to +\fBcurpath\fP. +.LP +.LP +If, during the execution of the above steps, the \fIPWD\fP environment +variable is changed, the \fIOLDPWD\fP environment +variable shall also be changed to the value of the old working directory +(that is the current working directory immediately prior +to the call to \fIcd\fP). +.SH OPTIONS +.LP +The \fIcd\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-L\fP +Handle the operand dot-dot logically; symbolic link components shall +not be resolved before dot-dot components are processed +(see steps 8. and 9. in the DESCRIPTION). +.TP 7 +\fB-P\fP +Handle the operand dot-dot physically; symbolic link components shall +be resolved before dot-dot components are processed (see +step 7. in the DESCRIPTION). +.sp +.LP +If both \fB-L\fP and \fB-P\fP options are specified, the last of these +options shall be used and all others ignored. If +neither \fB-L\fP nor \fB-P\fP is specified, the operand shall be handled +dot-dot logically; see the DESCRIPTION. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIdirectory\fP +An absolute or relative pathname of the directory that shall become +the new working directory. The interpretation of a relative +pathname by \fIcd\fP depends on the \fB-L\fP option and the \fICDPATH\fP +and \fIPWD\fP environment variables. If +\fIdirectory\fP is an empty string, the results are unspecified. +.TP 7 +- +When a hyphen is used as the operand, this shall be equivalent to +the command: +.sp +.RS +.nf + +\fBcd "$OLDPWD" && pwd +\fP +.fi +.RE +.LP +which changes to the previous working directory and then writes its +name. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcd\fP: +.TP 7 +\fICDPATH\fP +A colon-separated list of pathnames that refer to directories. The +\fIcd\fP utility shall use this list in its attempt to +change the directory, as described in the DESCRIPTION. An empty string +in place of a directory pathname represents the current +directory. If \fICDPATH\fP is not set, it shall be treated as if it +were an empty string. +.TP 7 +\fIHOME\fP +The name of the directory, used when no \fIdirectory\fP operand is +specified. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIOLDPWD\fP +A pathname of the previous working directory, used by \fIcd\fP \fB-\fP. +.TP 7 +\fIPWD\fP +This variable shall be set as specified in the DESCRIPTION. If an +application sets or unsets the value of \fIPWD ,\fP the +behavior of \fIcd\fP is unspecified. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If a non-empty directory name from \fICDPATH\fP is used, or if \fIcd\fP +\fB-\fP is used, an absolute pathname of the new +working directory shall be written to the standard output as follows: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fInew directory\fP\fB> +\fP +.fi +.RE +.LP +Otherwise, there shall be no output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The directory was successfully changed. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The working directory shall remain unchanged. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since \fIcd\fP affects the current shell execution environment, it +is always provided as a shell regular built-in. If it is +called in a subshell or separate utility execution environment, such +as one of the following: +.sp +.RS +.nf + +\fB(cd /tmp) +nohup cd +find . -exec cd {} \\; +\fP +.fi +.RE +.LP +it does not affect the working directory of the caller's environment. +.LP +The user must have execute (search) permission in \fIdirectory\fP +in order to change to it. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The use of the \fICDPATH\fP was introduced in the System V shell. +Its use is analogous to the use of the \fIPATH\fP variable +in the shell. The BSD C shell used a shell parameter \fIcdpath\fP +for this purpose. +.LP +A common extension when \fIHOME\fP is undefined is to get the login +directory from the user database for the invoking user. +This does not occur on System V implementations. +.LP +Some historical shells, such as the KornShell, took special actions +when the directory name contained a dot-dot component, +selecting the logical parent of the directory, rather than the actual +parent directory; that is, it moved up one level toward the +\fB'/'\fP in the pathname, remembering what the user typed, rather +than performing the equivalent of: +.sp +.RS +.nf + +\fBchdir(".."); +\fP +.fi +.RE +.LP +In such a shell, the following commands would not necessarily produce +equivalent output for all directories: +.sp +.RS +.nf + +\fBcd .. && ls ls .. +\fP +.fi +.RE +.LP +This behavior is now the default. It is not consistent with the definition +of dot-dot in most historical practice; that is, +while this behavior has been optionally available in the KornShell, +other shells have historically not supported this +functionality. The logical pathname is stored in the \fIPWD\fP environment +variable when the \fIcd\fP utility completes and this +value is used to construct the next directory name if \fIcd\fP is +invoked with the \fB-L\fP option. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Execution Environment\fP , \fIpwd\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIchdir\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cflow.1p b/man1p/cflow.1p new file mode 100644 index 000000000..2e64995ff --- /dev/null +++ b/man1p/cflow.1p @@ -0,0 +1,250 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CFLOW" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cflow +.SH NAME +cflow \- generate a C-language flowgraph (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBcflow\fP \fB[\fP\fB-r\fP\fB][\fP\fB-d\fP \fInum\fP\fB][\fP\fB-D\fP +\fIname\fP\fB[\fP\fB=\fP\fIdef\fP\fB]]\fP \fB...\fP \fB[\fP\fB-i\fP +\fIincl\fP\fB][\fP\fB-I\fP +\fIdir\fP\fB]\fP \fB... +.br +\ \ \ \ \ \ \fP \fB[\fP\fB-U\fP \fIdir\fP\fB]\fP \fB...\fP \fIfile\fP +\fB\&... \fP +.SH DESCRIPTION +.LP +The \fIcflow\fP utility shall analyze a collection of object files +or assembler, C-language, \fIlex\fP, or \fIyacc\fP source files, and +attempt to build a +graph, written to standard output, charting the external references. +.SH OPTIONS +.LP +The \fIcflow\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the order of the \fB-D\fP, +\fB-I\fP, and \fB-U\fP options (which are identical to their interpretation +by \fIc99\fP) is +significant. +.LP +The following options shall be supported: +.TP 7 +\fB-d\ \fP \fInum\fP +Indicate the depth at which the flowgraph is cut off. The application +shall ensure that the argument \fInum\fP is a decimal +integer. By default this is a very large number (typically greater +than 32000). Attempts to set the cut-off depth to a non-positive +integer shall be ignored. +.TP 7 +\fB-i\ \fP \fIincl\fP +Increase the number of included symbols. The \fIincl\fP option-argument +is one of the following characters: +.TP 7 +\fIx\fP +.RS +Include external and static data symbols. The default shall be to +include only functions in the flowgraph. +.RE +.TP 7 +\fB_\fP +.RS +(Underscore) Include names that begin with an underscore. The default +shall be to exclude these functions (and data if +\fB-i\ x\fP is used). +.RE +.sp +.TP 7 +\fB-r\fP +Reverse the caller:callee relationship, producing an inverted listing +showing the callers of each function. The listing shall +also be sorted in lexicographical order by callee. +.sp +.SH OPERANDS +.LP +The following operand is supported: +.TP 7 +\fIfile\fP +The pathname of a file for which a graph is to be generated. Filenames +suffixed by \fB.l\fP shall shall be taken to be \fIlex\fP input, \fB.y\fP +as \fIyacc\fP input, \fB.c\fP +as \fIc99\fP input, and \fB.i\fP as the output of \fIc99\fP \fB-E\fP. +Such files shall be processed as appropriate, determined by their +suffix. +.LP +Files suffixed by \fB.s\fP (conventionally assembler source) may have +more limited information extracted from them. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The input files shall be object files or assembler, C-language, \fIlex\fP, +or \fIyacc\fP source files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcflow\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the ordering of the output when the \fB-r\fP +option is used. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The flowgraph written to standard output shall be formatted as follows: +.sp +.RS +.nf + +\fB"%d %s:%s\\n", <\fP\fIreference number\fP\fB>, <\fP\fIglobal\fP\fB>, <\fP\fIdefinition\fP\fB> +\fP +.fi +.RE +.LP +Each line of output begins with a reference (that is, line) number, +followed by indentation of at least one column position per +level. This is followed by the name of the global, a colon, and its +definition. Normally globals are only functions not defined as +an external or beginning with an underscore; see the OPTIONS section +for the \fB-i\fP inclusion option. For information extracted +from C-language source, the definition consists of an abstract type +declaration (for example, \fBchar *\fP) and, delimited by +angle brackets, the name of the source file and the line number where +the definition was found. Definitions extracted from object +files indicate the filename and location counter under which the symbol +appeared (for example, \fItext\fP). +.LP +Once a definition of a name has been written, subsequent references +to that name contain only the reference number of the line +where the definition can be found. For undefined references, only +\fB"<>"\fP shall be written. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Files produced by \fIlex\fP and \fIyacc\fP cause the +reordering of line number declarations, and this can confuse \fIcflow\fP. +To obtain proper results, the input of \fIyacc\fP or \fIlex\fP must +be directed to \fIcflow\fP. +.SH EXAMPLES +.LP +Given the following in \fBfile.c\fP: +.sp +.RS +.nf + +\fBint i; +int f(); +int g(); +int h(); +int +main() +{ + f(); + g(); + f(); +} +int +f() +{ + i = h(); +} +\fP +.fi +.RE +.LP +The command: +.sp +.RS +.nf + +\fBcflow -i x file.c +\fP +.fi +.RE +.LP +produces the output: +.sp +.RS +.nf + +\fB1 main: int(), <file.c 6> +2 f: int(), <file.c 13> +3 h: <> +4 i: int, <file.c 1> +5 g: <> +\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP , \fIlex\fP , \fIyacc\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/chgrp.1p b/man1p/chgrp.1p new file mode 100644 index 000000000..25c91f557 --- /dev/null +++ b/man1p/chgrp.1p @@ -0,0 +1,212 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CHGRP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" chgrp +.SH NAME +chgrp \- change the file group ownership +.SH SYNOPSIS +.LP +\fBchgrp\fP \fB[\fP\fB-hR\fP\fB]\fP \fIgroup file\fP \fB... +.br +.sp +chgrp -R\fP \fB[\fP\fB-H | -L | -P\fP \fB]\fP \fIgroup file\fP \fB... +.br +\fP +.SH DESCRIPTION +.LP +The \fIchgrp\fP utility shall set the group ID of the file named by +each \fIfile\fP operand to the group ID specified by the +\fIgroup\fP operand. +.LP +For each \fIfile\fP operand, or, if the \fB-R\fP option is used, each +file encountered while walking the directory trees +specified by the \fIfile\fP operands, the \fIchgrp\fP utility shall +perform actions equivalent to the \fIchown\fP() function defined in +the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +called with the following arguments: +.IP " *" 3 +The \fIfile\fP operand shall be used as the \fIpath\fP argument. +.LP +.IP " *" 3 +The user ID of the file shall be used as the \fIowner\fP argument. +.LP +.IP " *" 3 +The specified group ID shall be used as the \fIgroup\fP argument. +.LP +.LP +Unless \fIchgrp\fP is invoked by a process with appropriate privileges, +the set-user-ID and set-group-ID bits of a regular file +shall be cleared upon successful completion; the set-user-ID and set-group-ID +bits of other file types may be cleared. +.SH OPTIONS +.LP +The \fIchgrp\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-h\fP +If the system supports group IDs for symbolic links, for each \fIfile\fP +operand that names a file of type symbolic link, +\fIchgrp\fP shall attempt to set the group ID of the symbolic link +instead of the file referenced by the symbolic link. If the +system does not support group IDs for symbolic links, for each \fIfile\fP +operand that names a file of type symbolic link, +\fIchgrp\fP shall do nothing more with the current file and shall +go on to any remaining files. +.TP 7 +\fB-H\fP +If the \fB-R\fP option is specified and a symbolic link referencing +a file of type directory is specified on the command line, +\fIchgrp\fP shall change the group of the directory referenced by +the symbolic link and all files in the file hierarchy below +it. +.TP 7 +\fB-L\fP +If the \fB-R\fP option is specified and a symbolic link referencing +a file of type directory is specified on the command line +or encountered during the traversal of a file hierarchy, \fIchgrp\fP +shall change the group of the directory referenced by the +symbolic link and all files in the file hierarchy below it. +.TP 7 +\fB-P\fP +If the \fB-R\fP option is specified and a symbolic link is specified +on the command line or encountered during the traversal +of a file hierarchy, \fIchgrp\fP shall change the group ID of the +symbolic link if the system supports this operation. The +\fIchgrp\fP utility shall not follow the symbolic link to any other +part of the file hierarchy. +.TP 7 +\fB-R\fP +Recursively change file group IDs. For each \fIfile\fP operand that +names a directory, \fIchgrp\fP shall change the group of +the directory and all files in the file hierarchy below it. Unless +a \fB-H\fP, \fB-L\fP, or \fB-P\fP option is specified, it is +unspecified which of these options will be used as the default. +.sp +.LP +Specifying more than one of the mutually-exclusive options \fB-H\fP, +\fB-L\fP, and \fB-P\fP shall not be considered an error. +The last option specified shall determine the behavior of the utility. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIgroup\fP +A group name from the group database or a numeric group ID. Either +specifies a group ID to be given to each file named by one +of the \fIfile\fP operands. If a numeric \fIgroup\fP operand exists +in the group database as a group name, the group ID number +associated with that group name is used as the group ID. +.TP 7 +\fIfile\fP +A pathname of a file whose group ID is to be modified. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIchgrp\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The utility executed successfully and all requested changes were made. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Only the owner of a file or the user with appropriate privileges may +change the owner or group of a file. +.LP +Some implementations restrict the use of \fIchgrp\fP to a user with +appropriate privileges when the \fIgroup\fP specified is +not the effective group ID or one of the supplementary group IDs of +the calling process. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The System V and BSD versions use different exit status codes. Some +implementations used the exit status as a count of the +number of errors that occurred; this practice is unworkable since +it can overflow the range of valid exit status values. The +standard developers chose to mask these by specifying only 0 and >0 +as exit values. +.LP +The functionality of \fIchgrp\fP is described substantially through +references to \fIchown\fP(). In this way, there is no duplication +of effort required for describing the +interactions of permissions, multiple groups, and so on. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIchmod\fP() , \fIchown\fP() , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIchown\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/chmod.1p b/man1p/chmod.1p new file mode 100644 index 000000000..e5438eb24 --- /dev/null +++ b/man1p/chmod.1p @@ -0,0 +1,488 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CHMOD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" chmod +.SH NAME +chmod \- change the file modes +.SH SYNOPSIS +.LP +\fBchmod\fP \fB[\fP\fB-R\fP\fB]\fP \fImode file\fP \fB...\fP +.SH DESCRIPTION +.LP +The \fIchmod\fP utility shall change any or all of the file mode bits +of the file named by each \fIfile\fP operand in the way +specified by the \fImode\fP operand. +.LP +It is implementation-defined whether and how the \fIchmod\fP utility +affects any alternate or additional file access control +mechanism (see the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 4.4, File Access Permissions) being used for the specified +file. +.LP +Only a process whose effective user ID matches the user ID of the +file, or a process with the appropriate privileges, shall be +permitted to change the file mode bits of a file. +.SH OPTIONS +.LP +The \fIchmod\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-R\fP +Recursively change file mode bits. For each \fIfile\fP operand that +names a directory, \fIchmod\fP shall change the file mode +bits of the directory and all files in the file hierarchy below it. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fImode\fP +Represents the change to be made to the file mode bits of each file +named by one of the \fIfile\fP operands; see the EXTENDED +DESCRIPTION section. +.TP 7 +\fIfile\fP +A pathname of a file whose file mode bits shall be modified. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIchmod\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The \fImode\fP operand shall be either a \fIsymbolic_mode\fP expression +or a non-negative octal integer. The +\fIsymbolic_mode\fP form is described by the grammar later in this +section. +.LP +Each \fBclause\fP shall specify an operation to be performed on the +current file mode bits of each \fIfile\fP. The operations +shall be performed on each \fIfile\fP in the order in which the \fBclause\fPs +are specified. +.LP +The \fBwho\fP symbols \fBu\fP, \fBg\fP, and \fBo\fP shall specify +the \fIuser\fP, \fIgroup\fP, and \fIother\fP parts of +the file mode bits, respectively. A \fBwho\fP consisting of the symbol +\fBa\fP shall be equivalent to \fBugo\fP. +.LP +The \fBperm\fP symbols \fBr\fP, \fBw\fP, and \fBx\fP represent the +\fIread\fP, \fIwrite\fP, and \fIexecute\fP/ +\fIsearch\fP portions of file mode bits, respectively. The \fBperm\fP +symbol \fBs\fP shall represent the +\fIset-user-ID-on-execution\fP (when \fBwho\fP contains or implies +\fBu\fP) and \fIset-group-ID-on-execution\fP (when +\fBwho\fP contains or implies \fBg\fP) bits. +.LP +The \fBperm\fP symbol \fBX\fP shall represent the execute/search portion +of the file mode bits if the file is a directory or +if the current (unmodified) file mode bits have at least one of the +execute bits (S_IXUSR, S_IXGRP, or S_IXOTH) set. It shall be +ignored if the file is not a directory and none of the execute bits +are set in the current file mode bits. +.LP +The \fBpermcopy\fP symbols \fBu\fP, \fBg\fP, and \fBo\fP shall represent +the current permissions associated with the user, +group, and other parts of the file mode bits, respectively. For the +remainder of this section, \fBperm\fP refers to the +non-terminals \fBperm\fP and \fBpermcopy\fP in the grammar. +.LP +If multiple \fBactionlist\fPs are grouped with a single \fBwholist\fP +in the grammar, each \fBactionlist\fP shall be applied +in the order specified with that \fBwholist\fP. The \fIop\fP symbols +shall represent the operation performed, as follows: +.TP 7 +\fB+\fP +If \fBperm\fP is not specified, the \fB'+'\fP operation shall not +change the file mode bits. +.LP +If \fBwho\fP is not specified, the file mode bits represented by \fBperm\fP +for the owner, group, and other permissions, +except for those with corresponding bits in the file mode creation +mask of the invoking process, shall be set. +.LP +Otherwise, the file mode bits represented by the specified \fBwho\fP +and \fBperm\fP values shall be set. +.TP 7 +\fB-\fP +If \fBperm\fP is not specified, the \fB'-'\fP operation shall not +change the file mode bits. +.LP +If \fBwho\fP is not specified, the file mode bits represented by \fBperm\fP +for the owner, group, and other permissions, +except for those with corresponding bits in the file mode creation +mask of the invoking process, shall be cleared. +.LP +Otherwise, the file mode bits represented by the specified \fBwho\fP +and \fBperm\fP values shall be cleared. +.TP 7 +\fB=\fP +Clear the file mode bits specified by the \fBwho\fP value, or, if +no \fBwho\fP value is specified, all of the file mode bits +specified in this volume of IEEE\ Std\ 1003.1-2001. +.LP +If \fBperm\fP is not specified, the \fB'='\fP operation shall make +no further modifications to the file mode bits. +.LP +If \fBwho\fP is not specified, the file mode bits represented by \fBperm\fP +for the owner, group, and other permissions, +except for those with corresponding bits in the file mode creation +mask of the invoking process, shall be set. +.LP +Otherwise, the file mode bits represented by the specified \fBwho\fP +and \fBperm\fP values shall be set. +.sp +.LP +When using the symbolic mode form on a regular file, it is implementation-defined +whether or not: +.IP " *" 3 +Requests to set the set-user-ID-on-execution or set-group-ID-on-execution +bit when all execute bits are currently clear and none +are being set are ignored. +.LP +.IP " *" 3 +Requests to clear all execute bits also clear the set-user-ID-on-execution +and set-group-ID-on-execution bits. +.LP +.IP " *" 3 +Requests to clear the set-user-ID-on-execution or set-group-ID-on-execution +bits when all execute bits are currently clear are +ignored. However, if the command \fIls\fP \fB-l\fP \fIfile\fP writes +an \fIs\fP in the +position indicating that the set-user-ID-on-execution or set-group-ID-on-execution +is set, the commands \fIchmod\fP \fBu-s\fP +\fIfile\fP or \fIchmod\fP \fBg-s\fP \fIfile\fP, respectively, shall +not be ignored. +.LP +.LP +When using the symbolic mode form on other file types, it is implementation-defined +whether or not requests to set or clear the +set-user-ID-on-execution or set-group-ID-on-execution bits are honored. +.LP +If the \fBwho\fP symbol \fBo\fP is used in conjunction with the \fBperm\fP +symbol \fBs\fP with no other \fBwho\fP symbols +being specified, the set-user-ID-on-execution and set-group-ID-on-execution +bits shall not be modified. It shall not be an error to +specify the \fBwho\fP symbol \fBo\fP in conjunction with the \fBperm\fP +symbol \fBs\fP. +.LP +The \fBperm\fP symbol \fBt\fP shall specify the S_ISVTX bit. When +used with a file of type directory, it can be used with the +\fBwho\fP symbol \fBa\fP, or with no \fBwho\fP symbol. It shall not +be an error to specify a \fBwho\fP symbol of \fBu\fP, +\fBg\fP, or \fBo\fP in conjunction with the \fBperm\fP symbol \fBt\fP, +but the meaning of these combinations is unspecified. +The effect when using the \fBperm\fP symbol \fBt\fP with any file +type other than directory is unspecified. +.LP +For an octal integer \fImode\fP operand, the file mode bits shall +be set absolutely. +.LP +For each bit set in the octal number, the corresponding file permission +bit shown in the following table shall be set; all other +file permission bits shall be cleared. For regular files, for each +bit set in the octal number corresponding to the +set-user-ID-on-execution or the set-group-ID-on-execution, bits shown +in the following table shall be set; if these bits are not +set in the octal number, they are cleared. For other file types, it +is implementation-defined whether or not requests to set or +clear the set-user-ID-on-execution or set-group-ID-on-execution bits +are honored. +.TS C +center; l1 l1 l1 l1 l1 l1 l1 l. +\fBOctal\fP \fBMode Bit\fP \fBOctal\fP \fBMode Bit\fP \fBOctal\fP \fBMode Bit\fP \fBOctal\fP \fBMode Bit\fP +\fB4000\fP S_ISUID \fB0400\fP S_IRUSR \fB0040\fP S_IRGRP \fB0004\fP S_IROTH +\fB2000\fP S_ISGID \fB0200\fP S_IWUSR \fB0020\fP S_IWGRP \fB0002\fP S_IWOTH +\fB1000\fP S_ISVTX \fB0100\fP S_IXUSR \fB0010\fP S_IXGRP \fB0001\fP S_IXOTH +.TE +.LP +When bits are set in the octal number other than those listed in the +table above, the behavior is unspecified. +.SS Grammar for chmod +.LP +The grammar and lexical conventions in this section describe the syntax +for the \fIsymbolic_mode\fP operand. The general +conventions for this style of grammar are described in \fIGrammar +Conventions\fP . A valid +\fIsymbolic_mode\fP can be represented as the non-terminal symbol +\fIsymbolic_mode\fP in the grammar. This formal syntax shall +take precedence over the preceding text syntax description. +.LP +The lexical processing is based entirely on single characters. Implementations +need not allow <blank>s within the single +argument being processed. +.sp +.RS +.nf + +\fB%start symbolic_mode +%% +.sp + +symbolic_mode : clause + | symbolic_mode ',' clause + ; +.sp + +clause : actionlist + | wholist actionlist + ; +.sp + +wholist : who + | wholist who + ; +.sp + +who : 'u' | 'g' | 'o' | 'a' + ; +.sp + +actionlist : action + | actionlist action + ; +.sp + +action : op + | op permlist + | op permcopy + ; +.sp + +permcopy : 'u' | 'g' | 'o' + ; +.sp + +op : '+' | '-' | '=' + ; +.sp + +permlist : perm + | perm permlist + ; +.sp + + +perm : 'r' | 'w' | 'x' | 'X' | 's' | 't' + ; +\fP +.fi +.RE +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The utility executed successfully and all requested changes were made. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Some implementations of the \fIchmod\fP utility change the mode of +a directory before the files in the directory when +performing a recursive ( \fB-R\fP option) change; others change the +directory mode after the files in the directory. If an +application tries to remove read or search permission for a file hierarchy, +the removal attempt fails if the directory is changed +first; on the other hand, trying to re-enable permissions to a restricted +hierarchy fails if directories are changed last. Users +should not try to make a hierarchy inaccessible to themselves. +.LP +Some implementations of \fIchmod\fP never used the process' \fIumask\fP +when changing +modes; systems conformant with this volume of IEEE\ Std\ 1003.1-2001 +do so when \fBwho\fP is not specified. Note the +difference between: +.sp +.RS +.nf + +\fBchmod a-w file +\fP +.fi +.RE +.LP +which removes all write permissions, and: +.sp +.RS +.nf + +\fBchmod -- -w file +\fP +.fi +.RE +.LP +which removes write permissions that would be allowed if \fBfile\fP +was created with the same \fIumask\fP. +.LP +Conforming applications should never assume that they know how the +set-user-ID and set-group-ID bits on directories are +interpreted. +.SH EXAMPLES +.TS C +center; l lw(40). +\fBMode\fP T{ +.na +\fBResults\fP +.ad +T} +\fIa\fP+= T{ +.na +Equivalent to \fIa\fP+, \fIa\fP=; clears all file mode bits. +.ad +T} +\fIgo\fP+-w T{ +.na +Equivalent to \fIgo\fP+, \fIgo\fP- \fIw\fP; clears group and other write bits. +.ad +T} +\fIg\fP=\fIo\fP-\fIw\fP T{ +.na +Equivalent to \fIg\fP= \fIo\fP, \fIg\fP- \fIw\fP; sets group bit to match other bits and then clears group write bit. +.ad +T} +\fIg\fP-\fIr\fP+\fIw\fP T{ +.na +Equivalent to \fIg\fP- \fIr\fP, \fIg\fP+ \fIw\fP; clears group read bit and sets group write bit. +.ad +T} +\fIuo\fP=\fIg\fP T{ +.na +Sets owner bits to match group bits and sets other bits to match group bits. +.ad +T} +.TE +.SH RATIONALE +.LP +The functionality of \fIchmod\fP is described substantially through +references to concepts defined in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001. In this way, there is less duplication +of effort required for describing the interactions +of permissions. However, the behavior of this utility is not described +in terms of the \fIchmod\fP() function from the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 because +that specification requires certain side effects upon alternate file +access control mechanisms that might not be appropriate, +depending on the implementation. +.LP +Implementations that support mandatory file and record locking as +specified by the 1984 /usr/group standard historically used +the combination of set-group-ID bit set and group execute bit clear +to indicate mandatory locking. This condition is usually set or +cleared with the symbolic mode \fBperm\fP symbol \fBl\fP instead of +the \fBperm\fP symbols \fBs\fP and \fBx\fP so that the +mandatory locking mode is not changed without explicit indication +that that was what the user intended. Therefore, the details on +how the implementation treats these conditions must be defined in +the documentation. This volume of IEEE\ Std\ 1003.1-2001 +does not require mandatory locking (nor does the System Interfaces +volume of IEEE\ Std\ 1003.1-2001), but does allow it as +an extension. However, this volume of IEEE\ Std\ 1003.1-2001 does +require that the \fIls\fP and \fIchmod\fP utilities work consistently +in this area. If \fIls\fP \fB-l\fP \fIfile\fP indicates that the set-group-ID +bit is set, \fIchmod\fP \fBg-s\fP +\fIfile\fP must clear it (assuming appropriate privileges exist to +change modes). +.LP +The System V and BSD versions use different exit status codes. Some +implementations used the exit status as a count of the +number of errors that occurred; this practice is unworkable since +it can overflow the range of valid exit status values. This +problem is avoided here by specifying only 0 and >0 as exit values. +.LP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001 indicates that +implementation-defined restrictions may cause the +S_ISUID and S_ISGID bits to be ignored. This volume of IEEE\ Std\ 1003.1-2001 +allows the \fIchmod\fP utility to choose to +modify these bits before calling \fIchmod\fP() (or some function providing +equivalent +capabilities) for non-regular files. Among other things, this allows +implementations that use the set-user-ID and set-group-ID bits +on directories to enable extended features to handle these extensions +in an intelligent manner. +.LP +The \fBX\fP \fBperm\fP symbol was adopted from BSD-based systems because +it provides commonly desired functionality when doing +recursive ( \fB-R\fP option) modifications. Similar functionality +is not provided by the \fIfind\fP utility. Historical BSD versions +of \fIchmod\fP, however, only supported \fBX\fP with +\fIop\fP+; it has been extended in this volume of IEEE\ Std\ 1003.1-2001 +because it is also useful with \fIop\fP=. (It +has also been added for \fIop\fP- even though it duplicates \fBx\fP, +in this case, because it is intuitive and easier to +explain.) +.LP +The grammar was extended with the \fIpermcopy\fP non-terminal to allow +historical-practice forms of symbolic modes like +\fBo\fP= \fBu\fP \fB-g\fP (that is, set the "other" permissions to +the permissions of "owner" minus the permissions of +"group"). +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIls\fP , \fIumask\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIchmod\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/chown.1p b/man1p/chown.1p new file mode 100644 index 000000000..e4075b83b --- /dev/null +++ b/man1p/chown.1p @@ -0,0 +1,264 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CHOWN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" chown +.SH NAME +chown \- change the file ownership +.SH SYNOPSIS +.LP +\fBchown\fP \fB[\fP\fB-hR\fP\fB]\fP \fIowner\fP\fB[\fP\fB:\fP\fIgroup\fP\fB]\fP +\fIfile\fP \fB... +.br +.sp +chown -R\fP \fB[\fP\fB-H | -L | -P\fP \fB]\fP \fIowner\fP\fB[\fP\fB:\fP\fIgroup\fP\fB]\fP +\fIfile\fP \fB... +.br +\fP +.SH DESCRIPTION +.LP +The \fIchown\fP utility shall set the user ID of the file named by +each \fIfile\fP operand to the user ID specified by the +\fIowner\fP operand. +.LP +For each \fIfile\fP operand, or, if the \fB-R\fP option is used, each +file encountered while walking the directory trees +specified by the \fIfile\fP operands, the \fIchown\fP utility shall +perform actions equivalent to the \fIchown\fP() function defined in +the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +called with the following arguments: +.IP " 1." 4 +The \fIfile\fP operand shall be used as the \fIpath\fP argument. +.LP +.IP " 2." 4 +The user ID indicated by the \fIowner\fP portion of the first operand +shall be used as the \fIowner\fP argument. +.LP +.IP " 3." 4 +If the \fIgroup\fP portion of the first operand is given, the group +ID indicated by it shall be used as the \fIgroup\fP +argument; otherwise, the group ownership shall not be changed. +.LP +.LP +Unless \fIchown\fP is invoked by a process with appropriate privileges, +the set-user-ID and set-group-ID bits of a regular file +shall be cleared upon successful completion; the set-user-ID and set-group-ID +bits of other file types may be cleared. +.SH OPTIONS +.LP +The \fIchown\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-h\fP +If the system supports user IDs for symbolic links, for each \fIfile\fP +operand that names a file of type symbolic link, +\fIchown\fP shall attempt to set the user ID of the symbolic link. +If the system supports group IDs for symbolic links, and a +group ID was specified, for each \fIfile\fP operand that names a file +of type symbolic link, \fIchown\fP shall attempt to set the +group ID of the symbolic link. If the system does not support user +or group IDs for symbolic links, for each \fIfile\fP operand +that names a file of type symbolic link, \fIchown\fP shall do nothing +more with the current file and shall go on to any remaining +files. +.TP 7 +\fB-H\fP +If the \fB-R\fP option is specified and a symbolic link referencing +a file of type directory is specified on the command line, +\fIchown\fP shall change the user ID (and group ID, if specified) +of the directory referenced by the symbolic link and all files +in the file hierarchy below it. +.TP 7 +\fB-L\fP +If the \fB-R\fP option is specified and a symbolic link referencing +a file of type directory is specified on the command line +or encountered during the traversal of a file hierarchy, \fIchown\fP +shall change the user ID (and group ID, if specified) of the +directory referenced by the symbolic link and all files in the file +hierarchy below it. +.TP 7 +\fB-P\fP +If the \fB-R\fP option is specified and a symbolic link is specified +on the command line or encountered during the traversal +of a file hierarchy, \fIchown\fP shall change the owner ID (and group +ID, if specified) of the symbolic link if the system +supports this operation. The \fIchown\fP utility shall not follow +the symbolic link to any other part of the file hierarchy. +.TP 7 +\fB-R\fP +Recursively change file user and group IDs. For each \fIfile\fP operand +that names a directory, \fIchown\fP shall change the +user ID (and group ID, if specified) of the directory and all files +in the file hierarchy below it. Unless a \fB-H\fP, \fB-L\fP, +or \fB-P\fP option is specified, it is unspecified which of these +options will be used as the default. +.sp +.LP +Specifying more than one of the mutually-exclusive options \fB-H\fP, +\fB-L\fP, and \fB-P\fP shall not be considered an error. +The last option specified shall determine the behavior of the utility. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIowner\fP\fB[\fP:\fIgroup\fP\fB]\fP +A user ID and optional group ID to be assigned to \fIfile\fP. The +\fIowner\fP portion of this operand shall be a user name +from the user database or a numeric user ID. Either specifies a user +ID which shall be given to each file named by one of the +\fIfile\fP operands. If a numeric \fIowner\fP operand exists in the +user database as a user name, the user ID number associated +with that user name shall be used as the user ID. Similarly, if the +\fIgroup\fP portion of this operand is present, it shall be a +group name from the group database or a numeric group ID. Either specifies +a group ID which shall be given to each file. If a +numeric group operand exists in the group database as a group name, +the group ID number associated with that group name shall be +used as the group ID. +.TP 7 +\fIfile\fP +A pathname of a file whose user ID is to be modified. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIchown\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The utility executed successfully and all requested changes were made. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Only the owner of a file or the user with appropriate privileges may +change the owner or group of a file. +.LP +Some implementations restrict the use of \fIchown\fP to a user with +appropriate privileges. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The System V and BSD versions use different exit status codes. Some +implementations used the exit status as a count of the +number of errors that occurred; this practice is unworkable since +it can overflow the range of valid exit status values. These are +masked by specifying only 0 and >0 as exit values. +.LP +The functionality of \fIchown\fP is described substantially through +references to functions in the System Interfaces volume of +IEEE\ Std\ 1003.1-2001. In this way, there is no duplication of effort +required for describing the interactions of +permissions, multiple groups, and so on. +.LP +The 4.3 BSD method of specifying both owner and group was included +in this volume of IEEE\ Std\ 1003.1-2001 because: +.IP " *" 3 +There are cases where the desired end condition could not be achieved +using the \fIchgrp\fP and \fIchown\fP (that only changed the user +ID) utilities. (If the current owner is not +a member of the desired group and the desired owner is not a member +of the current group, the \fIchown\fP() function could fail unless +both owner and group are changed at the same time.) +.LP +.IP " *" 3 +Even if they could be changed independently, in cases where both are +being changed, there is a 100% performance penalty caused +by being forced to invoke both utilities. +.LP +.LP +The BSD syntax \fIuser\fP[. \fIgroup\fP] was changed to \fIuser\fP[: +\fIgroup\fP] in this volume of +IEEE\ Std\ 1003.1-2001 because the period is a valid character in +login names (as specified by the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, login names consist of characters in the +portable filename character set). The colon character +was chosen as the replacement for the period character because it +would never be allowed as a character in a user name or group +name on historical implementations. +.LP +The \fB-R\fP option is considered by some observers as an undesirable +departure from the historical UNIX system tools approach; +since a tool, \fIfind\fP, already exists to recurse over directories, +there seemed to be no +good reason to require other tools to have to duplicate that functionality. +However, the \fB-R\fP option was deemed an important +user convenience, is far more efficient than forking a separate process +for each element of the directory hierarchy, and is in +widespread historical use. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIchmod\fP , \fIchgrp\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIchown\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cksum.1p b/man1p/cksum.1p new file mode 100644 index 000000000..f88581a98 --- /dev/null +++ b/man1p/cksum.1p @@ -0,0 +1,351 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CKSUM" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cksum +.SH NAME +cksum \- write file checksums and sizes +.SH SYNOPSIS +.LP +\fBcksum\fP \fB[\fP\fIfile\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIcksum\fP utility shall calculate and write to standard output +a cyclic redundancy check (CRC) for each input file, and +also write to standard output the number of octets in each file. The +CRC used is based on the polynomial used for CRC error +checking in the ISO/IEC\ 8802-3:1996 standard (Ethernet). +.LP +The encoding for the CRC checksum is defined by the generating polynomial: +.sp +.RS +.nf + +\fIG\fP\fB(\fP\fIx\fP\fB)=\fP\fIx\fP\fB**32+\fP\fIx\fP\fB**26+\fP\fIx\fP\fB**23+\fP\fIx\fP\fB**22+\fP\fIx\fP\fB**16+\fP\fIx\fP\fB**12+\fP\fIx\fP\fB**11+\fP\fIx\fP\fB**10+\fP\fIx\fP\fB**8+\fP\fIx\fP\fB**7+\fP\fIx\fP\fB**5+\fP\fIx\fP\fB**4+\fP\fIx\fP\fB**2+\fP\fIx\fP\fB+1 +\fP +.fi +.RE +.LP +Mathematically, the CRC value corresponding to a given file shall +be defined by the following procedure: +.IP " 1." 4 +The \fIn\fP bits to be evaluated are considered to be the coefficients +of a mod 2 polynomial \fIM\fP( \fIx\fP) of degree +\fIn\fP-1. These \fIn\fP bits are the bits from the file, with the +most significant bit being the most significant bit of the +first octet of the file and the last bit being the least significant +bit of the last octet, padded with zero bits (if necessary) to +achieve an integral number of octets, followed by one or more octets +representing the length of the file as a binary value, least +significant octet first. The smallest number of octets capable of +representing this integer shall be used. +.LP +.IP " 2." 4 +\fIM\fP( \fIx\fP) is multiplied by \fIx\fP**32 (that is, shifted left +32 bits) and divided by +\fIG\fP( \fIx\fP) using mod 2 division, producing a remainder \fIR\fP( +\fIx\fP) of degree <= 31. +.LP +.IP " 3." 4 +The coefficients of \fIR\fP( \fIx\fP) are considered to be a 32-bit +sequence. +.LP +.IP " 4." 4 +The bit sequence is complemented and the result is the CRC. +.LP +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be checked. If no \fIfile\fP operands are +specified, the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files can be any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcksum\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +For each file processed successfully, the \fIcksum\fP utility shall +write in the following format: +.sp +.RS +.nf + +\fB"%u %d %s\\n", <\fP\fIchecksum\fP\fB>, <\fP\fI# of octets\fP\fB>, <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +If no \fIfile\fP operand was specified, the pathname and its leading +<space> shall be omitted. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All files were processed successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIcksum\fP utility is typically used to quickly compare a suspect +file against a trusted version of the same, such as to +ensure that files transmitted over noisy media arrive intact. However, +this comparison cannot be considered cryptographically +secure. The chances of a damaged file producing the same CRC as the +original are small; deliberate deception is difficult, but +probably not impossible. +.LP +Although input files to \fIcksum\fP can be any type, the results need +not be what would be expected on character special device +files or on file types not described by the System Interfaces volume +of IEEE\ Std\ 1003.1-2001. Since this volume of +IEEE\ Std\ 1003.1-2001 does not specify the block size used when doing +input, checksums of character special files need not +process all of the data in those files. +.LP +The algorithm is expressed in terms of a bitstream divided into octets. +If a file is transmitted between two systems and +undergoes any data transformation (such as changing little-endian +byte ordering to big-endian), identical CRC values cannot be +expected. Implementations performing such transformations may extend +\fIcksum\fP to handle such situations. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The following C-language program can be used as a model to describe +the algorithm. It assumes that a \fBchar\fP is one octet. +It also assumes that the entire file is available for one pass through +the function. This was done for simplicity in demonstrating +the algorithm, rather than as an implementation model. +.sp +.RS +.nf + +\fBstatic unsigned long crctab[] = { +0x00000000, +0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, +0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, +0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, +0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, +0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f, +0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, +0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, +0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, +0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, +0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe, +0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, +0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, +0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, +0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, +0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, +0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07, +0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, +0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, +0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, +0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, +0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, +0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, +0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, +0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f, +0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, +0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, +0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, +0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, +0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629, +0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, +0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, +0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, +0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, +0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8, +0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, +0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, +0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, +0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, +0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, +0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21, +0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, +0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087, +0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, +0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, +0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, +0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, +0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, +0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09, +0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, +0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, +0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 +}; +.sp + +unsigned long memcrc(const unsigned char *b, size_t n) +{ +/* Input arguments: + * const char* b == byte sequence to checksum + * size_t n == length of sequence + */ +.sp + + register unsigned i, c, s = 0; +.sp + + for (i = n; i > 0; --i) { + c = (unsigned)(*b++); + s = (s << 8) ^ crctab[(s >> 24) ^ c]; + } +.sp + + /* Extend with the length of the string. */ + while (n != 0) { + c = n & 0377; + n >>= 8; + s = (s << 8) ^ crctab[(s >> 24) ^ c]; + } +.sp + + return ~s; +} +\fP +.fi +.RE +.LP +The historical practice of writing the number of "blocks" has been +changed to writing the number of octets, since the latter +is not only more useful, but also since historical implementations +have not been consistent in defining what a "block" meant. +Octets are used instead of bytes because bytes can differ in size +between systems. +.LP +The algorithm used was selected to increase the operational robustness +of \fIcksum\fP. Neither the System V nor BSD \fIsum\fP +algorithm was selected. Since each of these was different and each +was the default behavior on those systems, no realistic +compromise was available if either were selected-some set of historical +applications would break. Therefore, the name was changed +to \fIcksum\fP. Although the historical \fIsum\fP commands will probably +continue to be provided for many years, programs +designed for portability across systems should use the new name. +.LP +The algorithm selected is based on that used by the ISO/IEC\ 8802-3:1996 +standard (Ethernet) for the frame check sequence +field. The algorithm used does not match the technical definition +of a \fIchecksum\fP; the term is used for historical reasons. +The length of the file is included in the CRC calculation because +this parallels inclusion of a length field by Ethernet in its +CRC, but also because it guards against inadvertent collisions between +files that begin with different series of zero octets. The +chance that two different files produce identical CRCs is much greater +when their lengths are not considered. Keeping the length +and the checksum of the file itself separate would yield a slightly +more robust algorithm, but historical usage has always been +that a single number (the checksum as printed) represents the signature +of the file. It was decided that historical usage was the +more important consideration. +.LP +Early proposals contained modifications to the Ethernet algorithm +that involved extracting table values whenever an intermediate +result became zero. This was demonstrated to be less robust than the +current method and mathematically difficult to describe or +justify. +.LP +The calculation used is identical to that given in pseudo-code in +the referenced Sarwate article. The pseudo-code rendition +is: +.sp +.RS +.nf + +\fBX <- 0; Y <- 0; +for i <- m -1 step -1 until 0 do + begin + T <- X(1) ^ A[i]; + X(1) <- X(0); X(0) <- Y(1); Y(1) <- Y(0); Y(0) <- 0; + comment: f[T] and f'[T] denote the T-th words in the + table f and f' ; + X <- X ^ f[T]; Y <- Y ^ f'[T]; + end +\fP +.fi +.RE +.LP +The pseudo-code is reproduced exactly as given; however, note that +in the case of \fIcksum\fP, \fBA[i]\fP represents a byte of +the file, the words \fBX\fP and \fBY\fP are treated as a single 32-bit +value, and the tables \fBf\fP and \fBf'\fP are a single +table containing 32-bit values. +.LP +The referenced Sarwate article also discusses generating the table. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +None. +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cmp.1p b/man1p/cmp.1p new file mode 100644 index 000000000..89003c13b --- /dev/null +++ b/man1p/cmp.1p @@ -0,0 +1,241 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CMP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cmp +.SH NAME +cmp \- compare two files +.SH SYNOPSIS +.LP +\fBcmp\fP \fB[\fP \fB-l | -s\fP \fB]\fP \fIfile1 file2\fP +.SH DESCRIPTION +.LP +The \fIcmp\fP utility shall compare two files. The \fIcmp\fP utility +shall write no output if the files are the same. Under +default options, if they differ, it shall write to standard output +the byte and line number at which the first difference occurred. +Bytes and lines shall be numbered beginning with 1. +.SH OPTIONS +.LP +The \fIcmp\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-l\fP +(Lowercase ell.) Write the byte number (decimal) and the differing +bytes (octal) for each difference. +.TP 7 +\fB-s\fP +Write nothing for differing files; return exit status only. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile1\fP +A pathname of the first file to be compared. If \fIfile1\fP is \fB'-'\fP +, the standard input shall be used. +.TP 7 +\fIfile2\fP +A pathname of the second file to be compared. If \fIfile2\fP is \fB'-'\fP +, the standard input shall be used. +.sp +.LP +If both \fIfile1\fP and \fIfile2\fP refer to standard input or refer +to the same FIFO special, block special, or character +special file, the results are undefined. +.SH STDIN +.LP +The standard input shall be used only if the \fIfile1\fP or \fIfile2\fP +operand refers to standard input. See the INPUT FILES +section. +.SH INPUT FILES +.LP +The input files can be any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcmp\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +In the POSIX locale, results of the comparison shall be written to +standard output. When no options are used, the format shall +be: +.sp +.RS +.nf + +\fB"%s %s differ: char %d, line %d\\n",\fP \fIfile1\fP\fB,\fP \fIfile2\fP\fB, + <\fP\fIbyte number\fP\fB>, <\fP\fIline number\fP\fB> +\fP +.fi +.RE +.LP +When the \fB-l\fP option is used, the format shall be: +.sp +.RS +.nf + +\fB"%d %o %o\\n", <\fP\fIbyte number\fP\fB>, <\fP\fIdiffering byte\fP\fB>, + <\fP\fIdiffering byte\fP\fB> +\fP +.fi +.RE +.LP +for each byte that differs. The first <\fIdiffering\ byte\fP> number +is from \fIfile1\fP while the second is from +\fIfile2\fP. In both cases, <\fIbyte\ number\fP> shall be relative +to the beginning of the file, beginning with 1. +.LP +No output shall be written to standard output when the \fB-s\fP option +is used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. If +\fIfile1\fP and \fIfile2\fP are identical for the entire +length of the shorter file, in the POSIX locale the following diagnostic +message shall be written, unless the \fB-s\fP option is +specified: +.sp +.RS +.nf + +\fB"cmp: EOF on %s%s\\n", <\fP\fIname of shorter file\fP\fB>, <\fP\fIadditional info\fP\fB> +\fP +.fi +.RE +.LP +The <\fIadditional\ info\fP> field shall either be null or a string +that starts with a <blank> and contains no +<newline>s. Some implementations report on the number of lines in +this case. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The files are identical. +.TP 7 +\ 1 +The files are different; this includes the case where one file is +identical to the first part of the other. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Although input files to \fIcmp\fP can be any type, the results might +not be what would be expected on character special device +files or on file types not described by the System Interfaces volume +of IEEE\ Std\ 1003.1-2001. Since this volume of +IEEE\ Std\ 1003.1-2001 does not specify the block size used when doing +input, comparisons of character special files need +not compare all of the data in those files. +.LP +For files which are not text files, line numbers simply reflect the +presence of a <newline>, without any implication that +the file is organized into lines. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The global language in \fIUtility Description Defaults\fP indicates +that using two +mutually-exclusive options together produces unspecified results. +Some System V implementations consider the option usage: +.sp +.RS +.nf + +\fBcmp -l -s ... +\fP +.fi +.RE +.LP +to be an error. They also treat: +.sp +.RS +.nf + +\fBcmp -s -l ... +\fP +.fi +.RE +.LP +as if no options were specified. Both of these behaviors are considered +bugs, but are allowed. +.LP +The word \fBchar\fP in the standard output format comes from historical +usage, even though it is actually a byte number. When +\fIcmp\fP is supported in other locales, implementations are encouraged +to use the word \fIbyte\fP or its equivalent in another +language. Users should not interpret this difference to indicate that +the functionality of the utility changed between locales. +.LP +Some implementations report on the number of lines in the identical-but-shorter +file case. This is allowed by the inclusion of +the <\fIadditional\ info\fP> fields in the output format. The restriction +on having a leading <blank> and no +<newline>s is to make parsing for the filename easier. It is recognized +that some filenames containing white-space characters +make parsing difficult anyway, but the restriction does aid programs +used on systems where the names are predominantly well +behaved. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcomm\fP , \fIdiff\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/colon.1p b/man1p/colon.1p new file mode 100644 index 000000000..cb3f9f2ee --- /dev/null +++ b/man1p/colon.1p @@ -0,0 +1,102 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "COLON" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" colon +.SH NAME +colon \- null utility +.SH SYNOPSIS +.LP +\fB:\fP \fB[\fP\fIargument\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +This utility shall only expand command \fIargument\fPs. It is used +when a command is needed, as in the \fBthen\fP condition of +an \fBif\fP command, but nothing is to be done by the command. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +Zero. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fB: ${X=abc} +if false +then : +else echo $X +fi +\fP\fBabc\fP +.fi +.RE +.LP +As with any of the special built-ins, the null utility can also have +variable assignments and redirections associated with it, +such as: +.sp +.RS +.nf + +\fBx=y : > z +\fP +.fi +.RE +.LP +which sets variable \fIx\fP to the value \fIy\fP (so that it persists +after the null utility completes) and creates or +truncates file \fBz\fP. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/comm.1p b/man1p/comm.1p new file mode 100644 index 000000000..77848a4da --- /dev/null +++ b/man1p/comm.1p @@ -0,0 +1,252 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "COMM" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" comm +.SH NAME +comm \- select or reject lines common to two files +.SH SYNOPSIS +.LP +\fBcomm\fP \fB[\fP\fB-123\fP\fB]\fP \fIfile1 file2\fP +.SH DESCRIPTION +.LP +The \fIcomm\fP utility shall read \fIfile1\fP and \fIfile2\fP, which +should be ordered in the current collating sequence, and +produce three text columns as output: lines only in \fIfile1\fP, lines +only in \fIfile2\fP, and lines in both files. +.LP +If the lines in both files are not ordered according to the collating +sequence of the current locale, the results are +unspecified. +.SH OPTIONS +.LP +The \fIcomm\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-1\fP +Suppress the output column of lines unique to \fIfile1\fP. +.TP 7 +\fB-2\fP +Suppress the output column of lines unique to \fIfile2\fP. +.TP 7 +\fB-3\fP +Suppress the output column of lines duplicated in \fIfile1\fP and +\fIfile2\fP. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile1\fP +A pathname of the first file to be compared. If \fIfile1\fP is \fB'-'\fP +, the standard input shall be used. +.TP 7 +\fIfile2\fP +A pathname of the second file to be compared. If \fIfile2\fP is \fB'-'\fP +, the standard input shall be used. +.sp +.LP +If both \fIfile1\fP and \fIfile2\fP refer to standard input or to +the same FIFO special, block special, or character special +file, the results are undefined. +.SH STDIN +.LP +The standard input shall be used only if one of the \fIfile1\fP or +\fIfile2\fP operands refers to standard input. See the +INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcomm\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the collating sequence \fIcomm\fP expects +to have been used when the input files were sorted. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIcomm\fP utility shall produce output depending on the options +selected. If the \fB-1\fP, \fB-2\fP, and \fB-3\fP +options are all selected, \fIcomm\fP shall write nothing to standard +output. +.LP +If the \fB-1\fP option is not selected, lines contained only in \fIfile1\fP +shall be written using the format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIline in file1\fP\fB> +\fP +.fi +.RE +.LP +If the \fB-2\fP option is not selected, lines contained only in \fIfile2\fP +are written using the format: +.sp +.RS +.nf + +\fB"%s%s\\n", <\fP\fIlead\fP\fB>, <\fP\fIline in file2\fP\fB> +\fP +.fi +.RE +.LP +where the string <\fIlead\fP> is as follows: +.TP 7 +<tab> +The \fB-1\fP option is not selected. +.TP 7 +null\ string +The \fB-1\fP option is selected. +.sp +.LP +If the \fB-3\fP option is not selected, lines contained in both files +shall be written using the format: +.sp +.RS +.nf + +\fB"%s%s\\n", <\fP\fIlead\fP\fB>, <\fP\fIline in both\fP\fB> +\fP +.fi +.RE +.LP +where the string <\fIlead\fP> is as follows: +.TP 7 +<tab><tab> +Neither the \fB-1\fP nor the \fB-2\fP option is selected. +.TP 7 +<tab> +Exactly one of the \fB-1\fP and \fB-2\fP options is selected. +.TP 7 +null\ string +Both the \fB-1\fP and \fB-2\fP options are selected. +.sp +.LP +If the input files were ordered according to the collating sequence +of the current locale, the lines written shall be in the +collating sequence of the original lines. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were successfully output as specified. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +If the input files are not properly presorted, the output of \fIcomm\fP +might not be useful. +.SH EXAMPLES +.LP +If a file named \fBxcu\fP contains a sorted list of the utilities +in this volume of IEEE\ Std\ 1003.1-2001, a file +named \fBxpg3\fP contains a sorted list of the utilities specified +in the X/Open Portability Guide, Issue 3, and a file named +\fBsvid89\fP contains a sorted list of the utilities in the System +V Interface Definition Third Edition: +.sp +.RS +.nf + +\fBcomm -23 xcu xpg3 | comm -23 - svid89 +\fP +.fi +.RE +.LP +would print a list of utilities in this volume of IEEE\ Std\ 1003.1-2001 +not specified by either of the other +documents: +.sp +.RS +.nf + +\fBcomm -12 xcu xpg3 | comm -12 - svid89 +\fP +.fi +.RE +.LP +would print a list of utilities specified by all three documents, +and: +.sp +.RS +.nf + +\fBcomm -12 xpg3 svid89 | comm -23 - xcu +\fP +.fi +.RE +.LP +would print a list of utilities specified by both XPG3 and the SVID, +but not specified in this volume of +IEEE\ Std\ 1003.1-2001. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcmp\fP , \fIdiff\fP , \fIsort\fP , \fIuniq\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/command.1p b/man1p/command.1p new file mode 100644 index 000000000..7b33799b7 --- /dev/null +++ b/man1p/command.1p @@ -0,0 +1,484 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "COMMAND" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" command +.SH NAME +command \- execute a simple command +.SH SYNOPSIS +.LP +\fBcommand\fP \fB[\fP\fB-p\fP\fB]\fP \fIcommand_name\fP \fB[\fP\fIargument\fP +\fB\&...\fP\fB]\fP\fB +.br +.sp +\fP +.LP +\fBcommand\fP \fB[\fP \fB-v | -V\fP \fB]\fP \fIcommand_name\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIcommand\fP utility shall cause the shell to treat the arguments +as a simple command, suppressing the shell function +lookup that is described in \fICommand Search and Execution\fP , item +1b. +.LP +If the \fIcommand_name\fP is the same as the name of one of the special +built-in utilities, the special properties in the +enumerated list at the beginning of \fISpecial Built-In Utilities\fP +shall not occur. In +every other respect, if \fIcommand_name\fP is not the name of a function, +the effect of \fIcommand\fP (with no options) shall be +the same as omitting \fIcommand\fP. +.LP +On systems supporting the User Portability Utilities option, the \fIcommand\fP +utility also shall provide information +concerning how a command name is interpreted by the shell; see \fB-v\fP +and \fB-V\fP. +.SH OPTIONS +.LP +The \fIcommand\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-p\fP +Perform the command search using a default value for \fIPATH\fP that +is guaranteed to find all of the standard utilities. +.TP 7 +\fB-v\fP +(On systems supporting the User Portability Utilities option.) Write +a string to standard output that indicates the pathname or +command that will be used by the shell, in the current shell execution +environment (see \fIShell Execution Environment\fP ), to invoke \fIcommand_name\fP, +but do not invoke +\fIcommand_name\fP. +.RS +.IP " *" 3 +Utilities, regular built-in utilities, \fIcommand_name\fPs including +a slash character, and any implementation-defined +functions that are found using the \fIPATH\fP variable (as described +in \fICommand +Search and Execution\fP ), shall be written as absolute pathnames. +.LP +.IP " *" 3 +Shell functions, special built-in utilities, regular built-in utilities +not associated with a \fIPATH\fP search, and shell +reserved words shall be written as just their names. +.LP +.IP " *" 3 +An alias shall be written as a command line that represents its alias +definition. +.LP +.IP " *" 3 +Otherwise, no output shall be written and the exit status shall reflect +that the name was not found. +.LP +.RE +.TP 7 +\fB-V\fP +(On systems supporting the User Portability Utilities option.) Write +a string to standard output that indicates how the name +given in the \fIcommand_name\fP operand will be interpreted by the +shell, in the current shell execution environment (see \fIShell Execution +Environment\fP ), but do not invoke \fIcommand_name\fP. Although the +format of +this string is unspecified, it shall indicate in which of the following +categories \fIcommand_name\fP falls and shall include the +information stated: +.RS +.IP " *" 3 +Utilities, regular built-in utilities, and any implementation-defined +functions that are found using the \fIPATH\fP variable +(as described in \fICommand Search and Execution\fP ), shall be identified +as such +and include the absolute pathname in the string. +.LP +.IP " *" 3 +Other shell functions shall be identified as functions. +.LP +.IP " *" 3 +Aliases shall be identified as aliases and their definitions included +in the string. +.LP +.IP " *" 3 +Special built-in utilities shall be identified as special built-in +utilities. +.LP +.IP " *" 3 +Regular built-in utilities not associated with a \fIPATH\fP search +shall be identified as regular built-in utilities. (The term +"regular" need not be used.) +.LP +.IP " *" 3 +Shell reserved words shall be identified as reserved words. +.LP +.RE +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIargument\fP +One of the strings treated as an argument to \fIcommand_name\fP. +.TP 7 +\fIcommand_name\fP +.sp +The name of a utility or a special built-in utility. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcommand\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the search path used during the command search described +in \fICommand +Search and Execution\fP , except as described under the \fB-p\fP option. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When the \fB-v\fP option is specified, standard output shall be formatted +as: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIpathname or command\fP\fB> +\fP +.fi +.RE +.LP +When the \fB-V\fP option is specified, standard output shall be formatted +as: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIunspecified\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +When the \fB-v\fP or \fB-V\fP options are specified, the following +exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +The \fIcommand_name\fP could not be found or an error occurred. +.sp +.LP +Otherwise, the following exit values shall be returned: +.TP 7 +126 +The utility specified by \fIcommand_name\fP was found but could not +be invoked. +.TP 7 +127 +An error occurred in the \fIcommand\fP utility or the utility specified +by \fIcommand_name\fP could not be found. +.sp +.LP +Otherwise, the exit status of \fIcommand\fP shall be that of the simple +command specified by the arguments to +\fIcommand\fP. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The order for command search allows functions to override regular +built-ins and path searches. This utility is necessary to +allow functions that have the same name as a utility to call the utility +(instead of a recursive call to the function). +.LP +The system default path is available using \fIgetconf\fP; however, +since \fIgetconf\fP may need to have the \fIPATH\fP set up before +it can be called itself, the +following can be used: +.sp +.RS +.nf + +\fBcommand -p getconf _CS_PATH +\fP +.fi +.RE +.LP +There are some advantages to suppressing the special characteristics +of special built-ins on occasion. For example: +.sp +.RS +.nf + +\fBcommand exec >\fP \fIunwritable-file\fP +.fi +.RE +.LP +does not cause a non-interactive script to abort, so that the output +status can be checked by the script. +.LP +The \fIcommand\fP, \fIenv\fP, \fInohup\fP, \fItime\fP, and \fIxargs\fP +utilities have been specified to +use exit code 127 if an error occurs so that applications can distinguish +"failure to find a utility" from "invoked utility +exited with an error indication". The value 127 was chosen because +it is not commonly used for other meanings; most utilities use +small values for "normal error conditions" and the values above 128 +can be confused with termination due to receipt of a signal. +The value 126 was chosen in a similar manner to indicate that the +utility could be found, but not invoked. Some scripts produce +meaningful error messages differentiating the 126 and 127 cases. The +distinction between exit codes 126 and 127 is based on +KornShell practice that uses 127 when all attempts to \fIexec\fP the +utility fail with [ENOENT], and uses 126 when any attempt to +\fIexec\fP the utility fails for any other reason. +.LP +Since the \fB-v\fP and \fB-V\fP options of \fIcommand\fP produce output +in relation to the current shell execution +environment, \fIcommand\fP is generally provided as a shell regular +built-in. If it is called in a subshell or separate utility +execution environment, such as one of the following: +.sp +.RS +.nf + +\fB(PATH=foo command -v) + nohup command -v +\fP +.fi +.RE +.LP +it does not necessarily produce correct results. For example, when +called with \fInohup\fP or an \fIexec\fP function, in a separate utility +execution environment, most +implementations are not able to identify aliases, functions, or special +built-ins. +.LP +Two types of regular built-ins could be encountered on a system and +these are described separately by \fIcommand\fP. The +description of command search in \fICommand Search and Execution\fP +allows for a +standard utility to be implemented as a regular built-in as long as +it is found in the appropriate place in a \fIPATH\fP search. +So, for example, \fIcommand\fP \fB-v\fP \fItrue\fP might yield \fB/bin/true\fP +or some similar pathname. Other +implementation-defined utilities that are not defined by this volume +of IEEE\ Std\ 1003.1-2001 might exist only as +built-ins and have no pathname associated with them. These produce +output identified as (regular) built-ins. Applications +encountering these are not able to count on \fIexec\fPing them, using +them with \fInohup\fP, overriding them with a different \fIPATH ,\fP +and so on. +.SH EXAMPLES +.IP " 1." 4 +Make a version of \fIcd\fP that always prints out the new working +directory exactly +once: +.sp +.RS +.nf + +\fBcd() { + command cd "$@" >/dev/null + pwd +} +\fP +.fi +.RE +.LP +.IP " 2." 4 +Start off a "secure shell script" in which the script avoids being +spoofed by its parent: +.sp +.RS +.nf + +\fBIFS=' +' +# The preceding value should be <space><tab><newline>. +# Set IFS to its default value. +.sp + +\\unalias -a +# Unset all possible aliases. +# Note that unalias is escaped to prevent an alias +# being used for unalias. +.sp + +unset -f command +# Ensure command is not a user function. +.sp + +PATH="$(command -p getconf _CS_PATH):$PATH" +# Put on a reliable PATH prefix. +.sp + +# ... +\fP +.fi +.RE +.LP +At this point, given correct permissions on the directories called +by \fIPATH ,\fP the script has the ability to ensure that +any utility it calls is the intended one. It is being very cautious +because it assumes that implementation extensions may be +present that would allow user functions to exist when it is invoked; +this capability is not specified by this volume of +IEEE\ Std\ 1003.1-2001, but it is not prohibited as an extension. +For example, the \fIENV\fP variable precedes the +invocation of the script with a user start-up script. Such a script +could define functions to spoof the application. +.LP +.SH RATIONALE +.LP +Since \fIcommand\fP is a regular built-in utility it is always found +prior to the \fIPATH\fP search. +.LP +There is nothing in the description of \fIcommand\fP that implies +the command line is parsed any differently from that of any +other simple command. For example: +.sp +.RS +.nf + +\fBcommand a | b ; c +\fP +.fi +.RE +.LP +is not parsed in any special way that causes \fB'|'\fP or \fB';'\fP +to be treated other than a pipe operator or semicolon +or that prevents function lookup on \fBb\fP or \fBc\fP. +.LP +The \fIcommand\fP utility is somewhat similar to the Eighth Edition +shell \fIbuiltin\fP command, but since \fIcommand\fP also +goes to the file system to search for utilities, the name \fIbuiltin\fP +would not be intuitive. +.LP +The \fIcommand\fP utility is most likely to be provided as a regular +built-in. It is not listed as a special built-in for the +following reasons: +.IP " *" 3 +The removal of exportable functions made the special precedence of +a special built-in unnecessary. +.LP +.IP " *" 3 +A special built-in has special properties (see \fISpecial Built-In +Utilities\fP ) that +were inappropriate for invoking other utilities. For example, two +commands such as: +.sp +.RS +.nf + +\fBdate >\fP \fIunwritable-file\fP\fB +.br + +command date >\fP \fIunwritable-file\fP +.fi +.RE +.LP +would have entirely different results; in a non-interactive script, +the former would continue to execute the next command, the +latter would abort. Introducing this semantic difference along with +suppressing functions was seen to be non-intuitive. +.LP +.LP +The \fB-p\fP option is present because it is useful to be able to +ensure a safe path search that finds all the standard +utilities. This search might not be identical to the one that occurs +through one of the \fIexec\fP functions (as defined in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001) when \fIPATH\fP +is unset. At the very least, this feature is required +to allow the script to access the correct version of \fIgetconf\fP +so that the value of +the default path can be accurately retrieved. +.LP +The \fIcommand\fP \fB-v\fP and \fB-V\fP options were added to satisfy +requirements from users that are currently accomplished +by three different historical utilities: \fItype\fP in the System +V shell, \fIwhence\fP in +the KornShell, and \fIwhich\fP in the C shell. Since there is no historical +agreement on how and what to accomplish here, the +POSIX \fIcommand\fP utility was enhanced and the historical utilities +were left unmodified. The C shell \fIwhich\fP merely +conducts a path search. The KornShell \fIwhence\fP is more elaborate-in +addition to the categories required by POSIX, it also +reports on tracked aliases, exported aliases, and undefined functions. +.LP +The output format of \fB-V\fP was left mostly unspecified because +human users are its only audience. Applications should not be +written to care about this information; they can use the output of +\fB-v\fP to differentiate between various types of commands, +but the additional information that may be emitted by the more verbose +\fB-V\fP is not needed and should not be arbitrarily +constrained in its verbosity or localization for application parsing +reasons. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fICommand Search and Execution\fP , \fIShell +Execution Environment\fP , \fISpecial Built-In Utilities\fP , \fIsh\fP +, \fItype\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIexec\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/compress.1p b/man1p/compress.1p new file mode 100644 index 000000000..ed7f5d231 --- /dev/null +++ b/man1p/compress.1p @@ -0,0 +1,216 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "COMPRESS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" compress +.SH NAME +compress \- compress data +.SH SYNOPSIS +.LP +\fBcompress\fP \fB[\fP\fB-fv\fP\fB][\fP\fB-b\fP \fIbits\fP\fB][\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +.sp +compress\fP \fB[\fP\fB-cfv\fP\fB][\fP\fB-b\fP \fIbits\fP\fB][\fP\fIfile\fP\fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIcompress\fP utility shall attempt to reduce the size of the +named files by using adaptive Lempel-Ziv coding algorithm. +.TP 7 +\fBNote:\fP +Lempel-Ziv is US Patent 4464650, issued to William Eastman, Abraham +Lempel, Jacob Ziv, Martin Cohn on August 7th, 1984, and +assigned to Sperry Corporation. +.LP +Lempel-Ziv-Welch compression is covered by US Patent 4558302, issued +to Terry A. Welch on December 10th, 1985, and assigned to +Sperry Corporation. +.sp +On systems not supporting adaptive Lempel-Ziv coding algorithm, the +input files shall not be changed and an +error value greater than two shall be returned. Except when the output +is to the standard output, each file shall be replaced by +one with the extension \fB.Z\fP. If the invoking process has appropriate +privileges, the ownership, modes, access time, and +modification time of the original file are preserved. If appending +the \fB.Z\fP to the filename would make the name exceed +{NAME_MAX} bytes, the command shall fail. If no files are specified, +the standard input shall be compressed to the standard +output. +.SH OPTIONS +.LP +The \fIcompress\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-b\ \fP \fIbits\fP +Specify the maximum number of bits to use in a code. For a conforming +application, the \fIbits\fP argument shall be: +.sp +.RS +.nf + +\fB9 <=\fP \fIbits\fP \fB<= 14 +\fP +.fi +.RE +.LP +The implementation may allow \fIbits\fP values of greater than 14. +The default is 14, 15, or 16. +.TP 7 +\fB-c\fP +Cause \fIcompress\fP to write to the standard output; the input file +is not changed, and no \fB.Z\fP files are created. +.TP 7 +\fB-f\fP +Force compression of \fIfile\fP, even if it does not actually reduce +the size of the file, or if the corresponding \fIfile\fP +\fB\&.Z\fP file already exists. If the \fB-f\fP option is not given, +and the process is not running in the background, the user is +prompted as to whether an existing \fIfile\fP \fB.Z\fP file should +be overwritten. +.TP 7 +\fB-v\fP +Write the percentage reduction of each file to standard error. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be compressed. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP +\&. +.SH INPUT FILES +.LP +If \fIfile\fP operands are specified, the input files contain the +data to be compressed. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcompress\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If no \fIfile\fP operands are specified, or if a \fIfile\fP operand +is \fB'-'\fP , or if the \fB-c\fP option is specified, +the standard output contains the compressed output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic and prompt messages +and the output from \fB-v\fP. +.SH OUTPUT FILES +.LP +The output files shall contain the compressed output. The format of +compressed files is unspecified and interchange of such +files between implementations (including access via unspecified file +sharing mechanisms) is not required by +IEEE\ Std\ 1003.1-2001. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +\ 1 +An error occurred. +.TP 7 +\ 2 +One or more files were not compressed because they would have increased +in size (and the \fB-f\fP option was not +specified). +.TP 7 +>2 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The input file shall remain unmodified. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The amount of compression obtained depends on the size of the input, +the number of \fIbits\fP per code, and the distribution of +common substrings. Typically, text such as source code or English +is reduced by 50-60%. Compression is generally much better than +that achieved by Huffman coding or adaptive Huffman coding ( \fIcompact\fP), +and takes less time to compute. +.LP +Although \fIcompress\fP strictly follows the default actions upon +receipt of a signal or when an error occurs, some unexpected +results may occur. In some implementations it is likely that a partially +compressed file is left in place, alongside its +uncompressed input file. Since the general operation of \fIcompress\fP +is to delete the uncompressed file only after the \fB.Z\fP +file has been successfully filled, an application should always carefully +check the exit status of \fIcompress\fP before +arbitrarily deleting files that have like-named neighbors with \fB.Z\fP +suffixes. +.LP +The limit of 14 on the \fIbits\fP option-argument is to achieve portability +to all systems (within the restrictions imposed by +the lack of an explicit published file format). Some implementations +based on 16-bit architectures cannot support 15 or 16-bit +uncompression. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIuncompress\fP , \fIzcat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/continue.1p b/man1p/continue.1p new file mode 100644 index 000000000..b9fa7cd35 --- /dev/null +++ b/man1p/continue.1p @@ -0,0 +1,102 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CONTINUE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" continue +.SH NAME +continue \- continue for, while, or until loop +.SH SYNOPSIS +.LP +\fBcontinue\fP \fB[\fP\fIn\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIcontinue\fP utility shall return to the top of the smallest +enclosing \fBfor\fP, \fBwhile\fP, or \fBuntil\fP loop, or +to the top of the \fIn\fPth enclosing loop, if \fIn\fP is specified. +This involves repeating the condition list of a \fBwhile\fP +or \fBuntil\fP loop or performing the next assignment of a \fBfor\fP +loop, and re-executing the loop if appropriate. +.LP +The value of \fIn\fP is a decimal integer greater than or equal to +1. The default shall be equivalent to \fIn\fP=1. If +\fIn\fP is greater than the number of enclosing loops, the outermost +enclosing loop shall be used. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +The \fIn\fP value was not an unsigned decimal integer greater than +or equal to 1. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fBfor i in * +do + if test -d "$i" + then continue + fi + echo "\\"$i\\"" is not a directory. +done +\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cp.1p b/man1p/cp.1p new file mode 100644 index 000000000..2cb597da9 --- /dev/null +++ b/man1p/cp.1p @@ -0,0 +1,634 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cp +.SH NAME +cp \- copy files +.SH SYNOPSIS +.LP +\fBcp\fP \fB[\fP\fB-fip\fP\fB]\fP \fIsource_file target_file\fP\fB +.br +.sp +cp\fP \fB[\fP\fB-fip\fP\fB]\fP \fIsource_file\fP \fB...\fP \fItarget\fP\fB +.br +.sp +cp -R\fP \fB[\fP\fB-H | -L | -P\fP\fB][\fP\fB-fip\fP\fB]\fP \fIsource_file\fP +\fB\&...\fP \fItarget\fP\fB +.br +.sp +cp -r\fP \fB[\fP\fB-H | -L | -P\fP\fB][\fP\fB-fip\fP\fB]\fP \fIsource_file\fP +\fB\&...\fP \fItarget\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The first synopsis form is denoted by two operands, neither of which +are existing files of type directory. The \fIcp\fP utility +shall copy the contents of \fIsource_file\fP (or, if \fIsource_file\fP +is a file of type symbolic link, the contents of the file +referenced by \fIsource_file\fP) to the destination path named by +\fItarget_file.\fP +.LP +The second synopsis form is denoted by two or more operands where +the \fB-R\fP or \fB-r\fP options are not specified and the +first synopsis form is not applicable. It shall be an error if any +\fIsource_file\fP is a file of type directory, if \fItarget\fP +does not exist, or if \fItarget\fP is a file of a type defined by +the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +but is not a file of type directory. The \fIcp\fP utility shall copy +the contents of each \fIsource_file\fP (or, if +\fIsource_file\fP is a file of type symbolic link, the contents of +the file referenced by \fIsource_file\fP) to the destination +path named by the concatenation of \fItarget\fP, a slash character, +and the last component of \fIsource_file\fP. +.LP +The third and fourth synopsis forms are denoted by two or more operands +where the \fB-R\fP or \fB-r\fP options are specified. +The \fIcp\fP utility shall copy each file in the file hierarchy rooted +in each \fIsource_file\fP to a destination path named as +follows: +.IP " *" 3 +If \fItarget\fP exists and is a file of type directory, the name of +the corresponding destination path for each file in the +file hierarchy shall be the concatenation of \fItarget\fP, a slash +character, and the pathname of the file relative to the +directory containing \fIsource_file\fP. +.LP +.IP " *" 3 +If \fItarget\fP does not exist and two operands are specified, the +name of the corresponding destination path for +\fIsource_file\fP shall be \fItarget\fP; the name of the corresponding +destination path for all other files in the file hierarchy +shall be the concatenation of \fItarget\fP, a slash character, and +the pathname of the file relative to \fIsource_file\fP. +.LP +.LP +It shall be an error if \fItarget\fP does not exist and more than +two operands are specified, or if \fItarget\fP exists and is +a file of a type defined by the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +but is not a file of type +directory. +.LP +In the following description, the term \fIdest_file\fP refers to the +file named by the destination path. The term +\fIsource_file\fP refers to the file that is being copied, whether +specified as an operand or a file in a file hierarchy rooted in +a \fIsource_file\fP operand. If \fIsource_file\fP is a file of type +symbolic link: +.IP " *" 3 +If neither the \fB-R\fP nor \fB-r\fP options were specified, \fIcp\fP +shall take actions based on the type and contents of +the file referenced by the symbolic link, and not by the symbolic +link itself. +.LP +.IP " *" 3 +If the \fB-R\fP option was specified: +.RS +.IP " *" 3 +If none of the options \fB-H\fP, \fB-L\fP, nor \fB-P\fP were specified, +it is unspecified which of \fB-H\fP, \fB-L\fP, or +\fB-P\fP will be used as a default. +.LP +.IP " *" 3 +If the \fB-H\fP option was specified, \fIcp\fP shall take actions +based on the type and contents of the file referenced by any +symbolic link specified as a \fIsource_file\fP operand. +.LP +.IP " *" 3 +If the \fB-L\fP option was specified, \fIcp\fP shall take actions +based on the type and contents of the file referenced by any +symbolic link specified as a \fIsource_file\fP operand or any symbolic +links encountered during traversal of a file hierarchy. +.LP +.IP " *" 3 +If the \fB-P\fP option was specified, \fIcp\fP shall copy any symbolic +link specified as a \fIsource_file\fP operand and any +symbolic links encountered during traversal of a file hierarchy, and +shall not follow any symbolic links. +.LP +.RE +.LP +.IP " *" 3 +If the \fB-r\fP option was specified, the behavior is implementation-defined. +.LP +.LP +For each \fIsource_file\fP, the following steps shall be taken: +.IP " 1." 4 +If \fIsource_file\fP references the same file as \fIdest_file\fP, +\fIcp\fP may write a diagnostic message to standard error; +it shall do nothing more with \fIsource_file\fP and shall go on to +any remaining files. +.LP +.IP " 2." 4 +If \fIsource_file\fP is of type directory, the following steps shall +be taken: +.RS +.IP " a." 4 +If neither the \fB-R\fP or \fB-r\fP options were specified, \fIcp\fP +shall write a diagnostic message to standard error, do +nothing more with \fIsource_file\fP, and go on to any remaining files. +.LP +.IP " b." 4 +If \fIsource_file\fP was not specified as an operand and \fIsource_file\fP +is dot or dot-dot, \fIcp\fP shall do nothing more +with \fIsource_file\fP and go on to any remaining files. +.LP +.IP " c." 4 +If \fIdest_file\fP exists and it is a file type not specified by the +System Interfaces volume of +IEEE\ Std\ 1003.1-2001, the behavior is implementation-defined. +.LP +.IP " d." 4 +If \fIdest_file\fP exists and it is not of type directory, \fIcp\fP +shall write a diagnostic message to standard error, do +nothing more with \fIsource_file\fP or any files below \fIsource_file\fP +in the file hierarchy, and go on to any remaining +files. +.LP +.IP " e." 4 +If the directory \fIdest_file\fP does not exist, it shall be created +with file permission bits set to the same value as those +of \fIsource_file\fP, modified by the file creation mask of the user +if the \fB-p\fP option was not specified, and then +bitwise-inclusively OR'ed with S_IRWXU. If \fIdest_file\fP cannot +be created, \fIcp\fP shall write a diagnostic message to +standard error, do nothing more with \fIsource_file\fP, and go on +to any remaining files. It is unspecified if \fIcp\fP attempts +to copy files in the file hierarchy rooted in \fIsource_file\fP. +.LP +.IP " f." 4 +The files in the directory \fIsource_file\fP shall be copied to the +directory \fIdest_file\fP, taking the four steps (1 to 4) +listed here with the files as \fIsource_file\fPs. +.LP +.IP " g." 4 +If \fIdest_file\fP was created, its file permission bits shall be +changed (if necessary) to be the same as those of +\fIsource_file\fP, modified by the file creation mask of the user +if the \fB-p\fP option was not specified. +.LP +.IP " h." 4 +The \fIcp\fP utility shall do nothing more with \fIsource_file\fP +and go on to any remaining files. +.LP +.RE +.LP +.IP " 3." 4 +If \fIsource_file\fP is of type regular file, the following steps +shall be taken: +.RS +.IP " a." 4 +If \fIdest_file\fP exists, the following steps shall be taken: +.RS +.IP "i. " 5 +If the \fB-i\fP option is in effect, the \fIcp\fP utility shall write +a prompt to the standard error and read a line from the +standard input. If the response is not affirmative, \fIcp\fP shall +do nothing more with \fIsource_file\fP and go on to any +remaining files. +.LP +.IP "ii." 5 +A file descriptor for \fIdest_file\fP shall be obtained by performing +actions equivalent to the \fIopen\fP() function defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001 +called using \fIdest_file\fP as the \fIpath\fP argument, and the bitwise-inclusive +OR of O_WRONLY and O_TRUNC as the \fIoflag\fP +argument. +.LP +.IP "iii." 5 +If the attempt to obtain a file descriptor fails and the \fB-f\fP +option is in effect, \fIcp\fP shall attempt to remove the +file by performing actions equivalent to the \fIunlink\fP() function +defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001 called using \fIdest_file\fP +as the \fIpath\fP argument. If this attempt +succeeds, \fIcp\fP shall continue with step 3b. +.LP +.RE +.LP +.IP " b." 4 +If \fIdest_file\fP does not exist, a file descriptor shall be obtained +by performing actions equivalent to the \fIopen\fP() function defined +in the System Interfaces volume of IEEE\ Std\ 1003.1-2001 +called using \fIdest_file\fP as the \fIpath\fP argument, and the bitwise-inclusive +OR of O_WRONLY and O_CREAT as the \fIoflag\fP +argument. The file permission bits of \fIsource_file\fP shall be the +\fImode\fP argument. +.LP +.IP " c." 4 +If the attempt to obtain a file descriptor fails, \fIcp\fP shall write +a diagnostic message to standard error, do nothing more +with \fIsource_file\fP, and go on to any remaining files. +.LP +.IP " d." 4 +The contents of \fIsource_file\fP shall be written to the file descriptor. +Any write errors shall cause \fIcp\fP to write a +diagnostic message to standard error and continue to step 3e. +.LP +.IP " e." 4 +The file descriptor shall be closed. +.LP +.IP " f." 4 +The \fIcp\fP utility shall do nothing more with \fIsource_file\fP. +If a write error occurred in step 3d, it is unspecified if +\fIcp\fP continues with any remaining files. If no write error occurred +in step 3d, \fIcp\fP shall go on to any remaining +files. +.LP +.RE +.LP +.IP " 4." 4 +Otherwise, the following steps shall be taken: +.RS +.IP " a." 4 +If the \fB-r\fP option was specified, the behavior is implementation-defined. +.LP +.IP " b." 4 +If the \fB-R\fP option was specified, the following steps shall be +taken: +.RS +.IP "i. " 5 +The \fIdest_file\fP shall be created with the same file type as \fIsource_file\fP. +.LP +.IP "ii." 5 +If \fIsource_file\fP is a file of type FIFO, the file permission bits +shall be the same as those of \fIsource_file,\fP +modified by the file creation mask of the user if the \fB-p\fP option +was not specified. Otherwise, the permissions, owner ID, and +group ID of \fIdest_file\fP are implementation-defined. +.LP +If this creation fails for any reason, \fIcp\fP shall write a diagnostic +message to standard error, do nothing more with +\fIsource_file\fP, and go on to any remaining files. +.LP +.IP "iii." 5 +If \fIsource_file\fP is a file of type symbolic link, the pathname +contained in \fIdest_file\fP shall be the same as the +pathname contained in \fIsource_file\fP. +.LP +If this fails for any reason, \fIcp\fP shall write a diagnostic message +to standard error, do nothing more with +\fIsource_file\fP, and go on to any remaining files. +.LP +.RE +.LP +.RE +.LP +.LP +If the implementation provides additional or alternate access control +mechanisms (see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 4.4, File Access Permissions), their +effect on copies of files is implementation-defined. +.SH OPTIONS +.LP +The \fIcp\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-f\fP +If a file descriptor for a destination file cannot be obtained, as +described in step 3.a.ii., attempt to unlink the destination +file and proceed. +.TP 7 +\fB-H\fP +Take actions based on the type and contents of the file referenced +by any symbolic link specified as a \fIsource_file\fP +operand. +.TP 7 +\fB-i\fP +Write a prompt to standard error before copying to any existing destination +file. If the response from the standard input is +affirmative, the copy shall be attempted; otherwise, it shall not. +.TP 7 +\fB-L\fP +Take actions based on the type and contents of the file referenced +by any symbolic link specified as a \fIsource_file\fP +operand or any symbolic links encountered during traversal of a file +hierarchy. +.TP 7 +\fB-P\fP +Take actions on any symbolic link specified as a \fIsource_file\fP +operand or any symbolic link encountered during traversal +of a file hierarchy. +.TP 7 +\fB-p\fP +Duplicate the following characteristics of each source file in the +corresponding destination file: +.RS +.IP " 1." 4 +The time of last data modification and time of last access. If this +duplication fails for any reason, \fIcp\fP shall write a +diagnostic message to standard error. +.LP +.IP " 2." 4 +The user ID and group ID. If this duplication fails for any reason, +it is unspecified whether \fIcp\fP writes a diagnostic +message to standard error. +.LP +.IP " 3." 4 +The file permission bits and the S_ISUID and S_ISGID bits. Other, +implementation-defined, bits may be duplicated as well. If +this duplication fails for any reason, \fIcp\fP shall write a diagnostic +message to standard error. +.LP +.RE +.LP +If the user ID or the group ID cannot be duplicated, the file permission +bits S_ISUID and S_ISGID shall be cleared. If these +bits are present in the source file but are not duplicated in the +destination file, it is unspecified whether \fIcp\fP writes a +diagnostic message to standard error. +.LP +The order in which the preceding characteristics are duplicated is +unspecified. The \fIdest_file\fP shall not be deleted if +these characteristics cannot be preserved. +.TP 7 +\fB-R\fP +Copy file hierarchies. +.TP 7 +\fB-r\fP +Copy file hierarchies. The treatment of special files is implementation-defined. +.sp +.LP +Specifying more than one of the mutually-exclusive options \fB-H\fP, +\fB-L\fP, and \fB-P\fP shall not be considered an error. +The last option specified shall determine the behavior of the utility. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIsource_file\fP +A pathname of a file to be copied. +.TP 7 +\fItarget_file\fP +A pathname of an existing or nonexistent file, used for the output +when a single file is copied. +.TP 7 +\fItarget\fP +A pathname of a directory to contain the copied files. +.sp +.SH STDIN +.LP +The standard input shall be used to read an input line in response +to each prompt specified in the STDERR section. Otherwise, +the standard input shall not be used. +.SH INPUT FILES +.LP +The input files specified as operands may be of any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcp\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements used in the extended +regular expression defined for the \fByesexpr\fP locale keyword in +the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classes used in the extended regular +expression defined for the \fByesexpr\fP locale keyword in the \fILC_MESSAGES\fP +category. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale for the processing of affirmative responses that +should be used to affect the format and contents of +diagnostic messages written to standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +A prompt shall be written to standard error under the conditions specified +in the DESCRIPTION section. The prompt shall contain +the destination pathname, but its format is otherwise unspecified. +Otherwise, the standard error shall be used only for diagnostic +messages. +.SH OUTPUT FILES +.LP +The output files may be of any type. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All files were copied successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If \fIcp\fP is prematurely terminated by a signal or error, files +or file hierarchies may be only partially copied and files +and directories may have incorrect permissions or access and modification +times. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The difference between \fB-R\fP and \fB-r\fP is in the treatment by +\fIcp\fP of file types other than regular and directory. +The original \fB-r\fP flag, for historic reasons, does not handle +special files any differently from regular files, but always +reads the file and copies its contents. This has obvious problems +in the presence of special file types; for example, character +devices, FIFOs, and sockets. The \fB-R\fP option is intended to recreate +the file hierarchy and the \fB-r\fP option supports +historical practice. It was anticipated that a future version of this +volume of IEEE\ Std\ 1003.1-2001 would deprecate the +\fB-r\fP option, and for that reason, there has been no attempt to +fix its behavior with respect to FIFOs or other file types +where copying the file is clearly wrong. However, some implementations +support \fB-r\fP with the same abilities as the \fB-R\fP +defined in this volume of IEEE\ Std\ 1003.1-2001. To accommodate them +as well as systems that do not, the differences +between \fB-r\fP and \fB-R\fP are implementation-defined. Implementations +may make them identical. The \fB-r\fP option is marked +obsolescent. +.LP +The set-user-ID and set-group-ID bits are explicitly cleared when +files are created. This is to prevent users from creating +programs that are set-user-ID or set-group-ID to them when copying +files or to make set-user-ID or set-group-ID files accessible to +new groups of users. For example, if a file is set-user-ID and the +copy has a different group ID than the source, a new group of +users has execute permission to a set-user-ID program than did previously. +In particular, this is a problem for superusers copying +users' trees. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fB-i\fP option exists on BSD systems, giving applications and +users a way to avoid accidentally removing files when +copying. Although the 4.3 BSD version does not prompt if the standard +input is not a terminal, the standard developers decided that +use of \fB-i\fP is a request for interaction, so when the destination +path exists, the utility takes instructions from whatever +responds on standard input. +.LP +The exact format of the interactive prompts is unspecified. Only the +general nature of the contents of prompts are specified +because implementations may desire more descriptive prompts than those +used on historical implementations. Therefore, an +application using the \fB-i\fP option relies on the system to provide +the most suitable dialog directly with the user, based on +the behavior specified. +.LP +The \fB-p\fP option is historical practice on BSD systems, duplicating +the time of last data modification and time of last +access. This volume of IEEE\ Std\ 1003.1-2001 extends it to preserve +the user and group IDs, as well as the file +permissions. This requirement has obvious problems in that the directories +are almost certainly modified after being copied. This +volume of IEEE\ Std\ 1003.1-2001 requires that the modification times +be preserved. The statement that the order in which +the characteristics are duplicated is unspecified is to permit implementations +to provide the maximum amount of security for the +user. Implementations should take into account the obvious security +issues involved in setting the owner, group, and mode in the +wrong order or creating files with an owner, group, or mode different +from the final value. +.LP +It is unspecified whether \fIcp\fP writes diagnostic messages when +the user and group IDs cannot be set due to the widespread +practice of users using \fB-p\fP to duplicate some portion of the +file characteristics, indifferent to the duplication of others. +Historic implementations only write diagnostic messages on errors +other than [EPERM]. +.LP +The \fB-r\fP option is historical practice on BSD and BSD-derived +systems, copying file hierarchies as opposed to single files. +This functionality is used heavily in historical applications, and +its loss would significantly decrease consensus. The \fB-R\fP +option was added as a close synonym to the \fB-r\fP option, selected +for consistency with all other options in this volume of +IEEE\ Std\ 1003.1-2001 that do recursive directory descent. +.LP +When a failure occurs during the copying of a file hierarchy, \fIcp\fP +is required to attempt to copy files that are on the +same level in the hierarchy or above the file where the failure occurred. +It is unspecified if \fIcp\fP shall attempt to copy +files below the file where the failure occurred (which cannot succeed +in any case). +.LP +Permissions, owners, and groups of created special file types have +been deliberately left as implementation-defined. This is to +allow systems to satisfy special requirements (for example, allowing +users to create character special devices, but requiring them +to be owned by a certain group). In general, it is strongly suggested +that the permissions, owner, and group be the same as if the +user had run the historical \fImknod\fP, \fIln\fP, or other utility +to create the file. It is +also probable that additional privileges are required to create block, +character, or other implementation-defined special file +types. +.LP +Additionally, the \fB-p\fP option explicitly requires that all set-user-ID +and set-group-ID permissions be discarded if any of +the owner or group IDs cannot be set. This is to keep users from unintentionally +giving away special privilege when copying +programs. +.LP +When creating regular files, historical versions of \fIcp\fP use the +mode of the source file as modified by the file mode +creation mask. Other choices would have been to use the mode of the +source file unmodified by the creation mask or to use the same +mode as would be given to a new file created by the user (plus the +execution bits of the source file) and then modify it by the +file mode creation mask. In the absence of any strong reason to change +historic practice, it was in large part retained. +.LP +When creating directories, historical versions of \fIcp\fP use the +mode of the source directory, plus read, write, and search +bits for the owner, as modified by the file mode creation mask. This +is done so that \fIcp\fP can copy trees where the user has +read permission, but the owner does not. A side effect is that if +the file creation mask denies the owner permissions, \fIcp\fP +fails. Also, once the copy is done, historical versions of \fIcp\fP +set the permissions on the created directory to be the same as +the source directory, unmodified by the file creation mask. +.LP +This behavior has been modified so that \fIcp\fP is always able to +create the contents of the directory, regardless of the file +creation mask. After the copy is done, the permissions are set to +be the same as the source directory, as modified by the file +creation mask. This latter change from historical behavior is to prevent +users from accidentally creating directories with +permissions beyond those they would normally set and for consistency +with the behavior of \fIcp\fP in creating files. +.LP +It is not a requirement that \fIcp\fP detect attempts to copy a file +to itself; however, implementations are strongly +encouraged to do so. Historical implementations have detected the +attempt in most cases. +.LP +There are two methods of copying subtrees in this volume of IEEE\ Std\ 1003.1-2001. +The other method is described as +part of the \fIpax\fP utility (see \fIpax\fP ). Both methods are +historical practice. The \fIcp\fP utility provides a simpler, more +intuitive interface, while \fIpax\fP offers a finer granularity of +control. Each provides additional functionality to the other; +in particular, \fIpax\fP maintains the hard-link structure of the +hierarchy, while \fIcp\fP +does not. It is the intention of the standard developers that the +results be similar (using appropriate option combinations in both +utilities). The results are not required to be identical; there seemed +insufficient gain to applications to balance the difficulty +of implementations having to guarantee that the results would be exactly +identical. +.LP +The wording allowing \fIcp\fP to copy a directory to implementation-defined +file types not specified by the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 is provided so that implementations +supporting symbolic links are not required to prohibit +copying directories to symbolic links. Other extensions to the System +Interfaces volume of IEEE\ Std\ 1003.1-2001 file +types may need to use this loophole as well. +.SH FUTURE DIRECTIONS +.LP +The \fB-r\fP option may be removed; use \fB-R\fP instead. +.SH SEE ALSO +.LP +\fImv\fP , \fIfind\fP , \fIln\fP , \fIpax\fP , the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, \fIopen\fP(), \fIunlink\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/crontab.1p b/man1p/crontab.1p new file mode 100644 index 000000000..49353d7c6 --- /dev/null +++ b/man1p/crontab.1p @@ -0,0 +1,321 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CRONTAB" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" crontab +.SH NAME +crontab \- schedule periodic background work +.SH SYNOPSIS +.LP +\fBcrontab\fP \fB[\fP\fIfile\fP\fB]\fP\fB +.br +.sp +crontab\fP \fB[\fP \fB-e | -l | -r\fP \fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIcrontab\fP utility shall create, replace, or edit a user's +crontab entry; a crontab entry is a list of commands and the +times at which they shall be executed. The new crontab entry can be +input by specifying \fIfile\fP or input from standard input if +no \fIfile\fP operand is specified, or by using an editor, if \fB-e\fP +is specified. +.LP +Upon execution of a command from a crontab entry, the implementation +shall supply a default environment, defining at least the +following environment variables: +.TP 7 +\fIHOME\fP +A pathname of the user's home directory. +.TP 7 +\fILOGNAME\fP +The user's login name. +.TP 7 +\fIPATH\fP +A string representing a search path guaranteed to find all of the +standard utilities. +.TP 7 +\fISHELL\fP +A pathname of the command interpreter. When \fIcrontab\fP is invoked +as specified by this volume of +IEEE\ Std\ 1003.1-2001, the value shall be a pathname for \fIsh\fP. +.sp +.LP +The values of these variables when \fIcrontab\fP is invoked as specified +by this volume of IEEE\ Std\ 1003.1-2001 shall +not affect the default values provided when the scheduled command +is run. +.LP +If standard output and standard error are not redirected by commands +executed from the crontab entry, any generated output or +errors shall be mailed, via an implementation-defined method, to the +user. +.LP +Users shall be permitted to use \fIcrontab\fP if their names appear +in the file \fB/usr/lib/cron/cron.allow\fP. If that file does +not exist, the file \fB/usr/lib/cron/cron.deny\fP shall be checked +to determine whether the user shall be denied access to +\fIcrontab\fP. If neither file exists, only a process with appropriate +privileges shall be allowed to submit a job. If only +\fBcron.deny\fP exists and is empty, global usage shall be permitted. +The \fBcron.allow\fP and \fBcron.deny\fP files shall +consist of one user name per line. +.SH OPTIONS +.LP +The \fIcrontab\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-e\fP +Edit a copy of the invoking user's crontab entry, or create an empty +entry to edit if the crontab entry does not exist. When +editing is complete, the entry shall be installed as the user's crontab +entry. +.TP 7 +\fB-l\fP +(The letter ell.) List the invoking user's crontab entry. +.TP 7 +\fB-r\fP +Remove the invoking user's crontab entry. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +The pathname of a file that contains specifications, in the format +defined in the INPUT FILES section, for crontab +entries. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +In the POSIX locale, the user or application shall ensure that a crontab +entry is a text file consisting of lines of six fields +each. The fields shall be separated by <blank>s. The first five fields +shall be integer patterns that specify the +following: +.IP " 1." 4 +Minute [0,59] +.LP +.IP " 2." 4 +Hour [0,23] +.LP +.IP " 3." 4 +Day of the month [1,31] +.LP +.IP " 4." 4 +Month of the year [1,12] +.LP +.IP " 5." 4 +Day of the week ([0,6] with 0=Sunday) +.LP +.LP +Each of these patterns can be either an asterisk (meaning all valid +values), an element, or a list of elements separated by +commas. An element shall be either a number or two numbers separated +by a hyphen (meaning an inclusive range). The specification of +days can be made by two fields (day of the month and day of the week). +If month, day of month, and day of week are all asterisks, +every day shall be matched. If either the month or day of month is +specified as an element or list, but the day of week is an +asterisk, the month and day of month fields shall specify the days +that match. If both month and day of month are specified as an +asterisk, but day of week is an element or list, then only the specified +days of the week match. Finally, if either the month or +day of month is specified as an element or list, and the day of week +is also specified as an element or list, then any day matching +either the month and day of month, or the day of week, shall be matched. +.LP +The sixth field of a line in a crontab entry is a string that shall +be executed by \fIsh\fP +at the specified times. A percent sign character in this field shall +be translated to a <newline>. Any character preceded by +a backslash (including the \fB'%'\fP ) shall cause that character +to be treated literally. Only the first line (up to a +\fB'%'\fP or end-of-line) of the command field shall be executed by +the command interpreter. The other lines shall be made +available to the command as standard input. +.LP +Blank lines and those whose first non- <blank> is \fB'#'\fP shall +be ignored. +.LP +The text files \fB/usr/lib/cron/cron.allow\fP and \fB/usr/lib/cron/cron.deny\fP +shall contain zero or more user names, one per +line, of users who are, respectively, authorized or denied access +to the service underlying the \fIcrontab\fP utility. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcrontab\fP: +.TP 7 +\fIEDITOR\fP +Determine the editor to be invoked when the \fB-e\fP option is specified. +The default editor shall be \fIvi\fP. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If the \fB-l\fP option is specified, the crontab entry shall be written +to the standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The user's crontab entry is not submitted, removed, edited, or listed. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The format of the crontab entry shown here is guaranteed only for +the POSIX locale. Other cultures may be supported with +substantially different interfaces, although implementations are encouraged +to provide comparable levels of functionality. +.LP +The default settings of the \fIHOME ,\fP \fILOGNAME ,\fP \fIPATH ,\fP +and \fISHELL\fP variables that are given to the +scheduled job are not affected by the settings of those variables +when \fIcrontab\fP is run; as stated, they are defaults. The +text about "invoked as specified by this volume of IEEE\ Std\ 1003.1-2001" +means that the implementation may provide +extensions that allow these variables to be affected at runtime, but +that the user has to take explicit action in order to access +the extension, such as give a new option flag or modify the format +of the crontab entry. +.LP +A typical user error is to type only \fIcrontab\fP; this causes the +system to wait for the new crontab entry on standard input. +If end-of-file is typed (generally <control>-D), the crontab entry +is replaced by an empty file. In this case, the user +should type the interrupt character, which prevents the crontab entry +from being replaced. +.SH EXAMPLES +.IP " 1." 4 +Clean up \fBcore\fP files every weekday morning at 3:15 am: +.sp +.RS +.nf + +\fB15 3 * * 1-5 find $HOME -name core 2>/dev/null | xargs rm -f +\fP +.fi +.RE +.LP +.IP " 2." 4 +Mail a birthday greeting: +.sp +.RS +.nf + +\fB0 12 14 2 * mailx john%Happy Birthday!%Time for lunch. +\fP +.fi +.RE +.LP +.IP " 3." 4 +As an example of specifying the two types of days: +.sp +.RS +.nf + +\fB0 0 1,15 * 1 +\fP +.fi +.RE +.LP +would run a command on the first and fifteenth of each month, as well +as on every Monday. To specify days by only one field, the +other field should be set to \fB'*'\fP ; for example: +.sp +.RS +.nf + +\fB0 0 * * 1 +\fP +.fi +.RE +.LP +would run a command only on Mondays. +.LP +.SH RATIONALE +.LP +All references to a \fIcron\fP daemon and to \fIcron\fP \fIfiles\fP +have been omitted. Although historical implementations +have used this arrangement, there is no reason to limit future implementations. +.LP +This description of \fIcrontab\fP is designed to support only users +with normal privileges. The format of the input is based on +the System V \fIcrontab\fP; however, there is no requirement here +that the actual system database used by the \fIcron\fP daemon +(or a similar mechanism) use this format internally. For example, +systems derived from BSD are likely to have an additional field +appended that indicates the user identity to be used when the job +is submitted. +.LP +The \fB-e\fP option was adopted from the SVID as a user convenience, +although it does not exist in all historical +implementations. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/csplit.1p b/man1p/csplit.1p new file mode 100644 index 000000000..b80d6bfb9 --- /dev/null +++ b/man1p/csplit.1p @@ -0,0 +1,269 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CSPLIT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" csplit +.SH NAME +csplit \- split files based on context +.SH SYNOPSIS +.LP +\fBcsplit\fP \fB[\fP\fB-ks\fP\fB][\fP\fB-f\fP \fIprefix\fP\fB][\fP\fB-n\fP +\fInumber\fP\fB]\fP \fIfile arg1\fP \fB...\fP\fIargn\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIcsplit\fP utility shall read the file named by the \fIfile\fP +operand, write all or part of that file into other files +as directed by the \fIarg\fP operands, and write the sizes of the +files. +.SH OPTIONS +.LP +The \fIcsplit\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-f\ \fP \fIprefix\fP +Name the created files \fIprefix\fP \fB00\fP, \fIprefix\fP \fB01\fP, +\&..., \fIprefixn\fP. The default is \fBxx00\fP ... +\fBxx\fP \fIn\fP. If the \fIprefix\fP argument would create a filename +exceeding {NAME_MAX} bytes, an error shall result, +\fIcsplit\fP shall exit with a diagnostic message, and no files shall +be created. +.TP 7 +\fB-k\fP +Leave previously created files intact. By default, \fIcsplit\fP shall +remove created files if an error occurs. +.TP 7 +\fB-n\ \fP \fInumber\fP +Use \fInumber\fP decimal digits to form filenames for the file pieces. +The default shall be 2. +.TP 7 +\fB-s\fP +Suppress the output of file size messages. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +The pathname of a text file to be split. If \fIfile\fP is \fB'-'\fP +, the standard input shall be used. +.sp +.LP +The operands \fIarg1\fP ... \fIargn\fP can be a combination of the +following: +.TP 7 +/\fIrexp\fP/\fB[\fP\fIoffset\fP\fB]\fP +.sp +A file shall be created using the content of the lines from the current +line up to, but not including, the line that results from +the evaluation of the regular expression with \fIoffset\fP, if any, +applied. The regular expression \fIrexp\fP shall follow the +rules for basic regular expressions described in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 9.3, Basic Regular Expressions. +The application shall use the sequence +\fB"\\/"\fP to specify a slash character within the \fIrexp\fP. The +optional offset shall be a positive or negative integer +value representing a number of lines. A positive integer value can +be preceded by \fB'+'\fP . If the selection of lines from an +\fIoffset\fP expression of this type would create a file with zero +lines, or one with greater than the number of lines left in the +input file, the results are unspecified. After the section is created, +the current line shall be set to the line that results from +the evaluation of the regular expression with any offset applied. +If the current line is the first line in the file and a regular +expression operation has not yet been performed, the pattern match +of \fIrexp\fP shall be applied from the current line to the end +of the file. Otherwise, the pattern match of \fIrexp\fP shall be applied +from the line following the current line to the end of +the file. +.TP 7 +%\fIrexp\fP%\fB[\fP\fIoffset\fP\fB]\fP +.sp +Equivalent to /\fIrexp\fP/\fB[\fP\fIoffset\fP\fB]\fP, except that +no file shall be created for the selected section of the +input file. The application shall use the sequence \fB"\\%"\fP to +specify a percent-sign character within the \fIrexp\fP. +.TP 7 +\fIline_no\fP +Create a file from the current line up to (but not including) the +line number \fIline_no\fP. Lines in the file shall be +numbered starting at one. The current line becomes \fIline_no\fP. +.TP 7 +{\fInum\fP} +Repeat operand. This operand can follow any of the operands described +previously. If it follows a \fIrexp\fP type operand, +that operand shall be applied \fInum\fP more times. If it follows +a \fIline_no\fP operand, the file shall be split every +\fIline_no\fP lines, \fInum\fP times, from that point. +.sp +.LP +An error shall be reported if an operand does not reference a line +between the current position and the end of the file. +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input file shall be a text file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcsplit\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classes within regular +expressions. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +If the \fB-k\fP option is specified, created files shall be retained. +Otherwise, the default action occurs. +.SH STDOUT +.LP +Unless the \fB-s\fP option is used, the standard output shall consist +of one line per file created, with a format as +follows: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fIfile size in bytes\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output files shall contain portions of the original input file; +otherwise, unchanged. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +By default, created files shall be removed if an error occurs. When +the \fB-k\fP option is specified, created files shall not +be removed if an error occurs. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.IP " 1." 4 +This example creates four files, \fBcobol00\fP ... \fBcobol03\fP: +.sp +.RS +.nf + +\fBcsplit -f cobol file '/procedure division/' /par5./ /par16./ +\fP +.fi +.RE +.LP +After editing the split files, they can be recombined as follows: +.sp +.RS +.nf + +\fBcat cobol0[0-3] > file +\fP +.fi +.RE +.LP +Note that this example overwrites the original file. +.LP +.IP " 2." 4 +This example would split the file after the first 99 lines, and every +100 lines thereafter, up to 9999 lines; this is because +lines in the file are numbered from 1 rather than zero, for historical +reasons: +.sp +.RS +.nf + +\fBcsplit -k file 100 {99} +\fP +.fi +.RE +.LP +.IP " 3." 4 +Assuming that \fBprog.c\fP follows the C-language coding convention +of ending routines with a \fB'}'\fP at the beginning of +the line, this example creates a file containing each separate C routine +(up to 21) in \fBprog.c\fP: +.sp +.RS +.nf + +\fBcsplit -k prog.c '%main(%' '/^}/+1' {20} +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fB-n\fP option was added to extend the range of filenames that +could be handled. +.LP +Consideration was given to adding a \fB-a\fP flag to use the alphabetic +filename generation used by the historical \fIsplit\fP utility, but +the functionality added by the \fB-n\fP option was deemed to make +alphabetic naming unnecessary. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIsed\fP , \fIsplit\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ctags.1p b/man1p/ctags.1p new file mode 100644 index 000000000..14526c528 --- /dev/null +++ b/man1p/ctags.1p @@ -0,0 +1,414 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CTAGS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ctags +.SH NAME +ctags \- create a tags file (\fBDEVELOPMENT\fP, \fBFORTRAN\fP) +.SH SYNOPSIS +.LP +\fBctags\fP \fB[\fP\fB-a\fP\fB][\fP\fB-f\fP \fItagsfile\fP\fB]\fP +\fIpathname\fP \fB... +.br +.sp +ctags -x\fP \fIpathname\fP \fB... \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIctags\fP utility shall be provided on systems that support +the User Portability Utilities option, the Software +Development Utilities option, and either or both of the C-Language +Development Utilities option and FORTRAN Development Utilities +option. On other systems, it is optional. +.LP +The \fIctags\fP utility shall write a \fItagsfile\fP or an index of +objects from C-language or FORTRAN source files specified +by the \fIpathname\fP operands. The \fItagsfile\fP shall list the +locators of language-specific objects within the source files. +A locator consists of a name, pathname, and either a search pattern +or a line number that can be used in searching for the object +definition. The objects that shall be recognized are specified in +the EXTENDED DESCRIPTION section. +.SH OPTIONS +.LP +The \fIctags\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Append to \fItagsfile\fP. +.TP 7 +\fB-f\ \fP \fItagsfile\fP +Write the object locator lists into \fItagsfile\fP instead of the +default file named \fBtags\fP in the current +directory. +.TP 7 +\fB-x\fP +Produce a list of object names, the line number, and filename in which +each is defined, as well as the text of that line, and +write this to the standard output. A \fItagsfile\fP shall not be created +when \fB-x\fP is specified. +.sp +.SH OPERANDS +.LP +The following \fIpathname\fP operands are supported: +.TP 7 +\fIfile\fP\fB.c\fP +Files with basenames ending with the \fB.c\fP suffix shall be treated +as C-language source code. Such files that are not valid +input to \fIc99\fP produce unspecified results. +.TP 7 +\fIfile\fP\fB.h\fP +Files with basenames ending with the \fB.h\fP suffix shall be treated +as C-language source code. Such files that are not valid +input to \fIc99\fP produce unspecified results. +.TP 7 +\fIfile\fP\fB.f\fP +Files with basenames ending with the \fB.f\fP suffix shall be treated +as FORTRAN-language source code. Such files that are not +valid input to \fIfort77\fP produce unspecified results. +.sp +.LP +The handling of other files is implementation-defined. +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files containing source code in the +language indicated by the operand filename suffixes. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIctags\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the order in which output is sorted for the \fB-x\fP option. +The POSIX locale determines the order in which the +\fItagsfile\fP is written. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). When +processing C-language source code, if the locale is not +compatible with the C locale described by the ISO\ C standard, the +results are unspecified. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The list of object name information produced by the \fB-x\fP option +shall be written to standard output in the following +format: +.sp +.RS +.nf + +\fB"%s %d %s %s", <\fP\fIobject-name\fP\fB>, <\fP\fIline-number\fP\fB>, <\fP\fIfilename\fP\fB>, <\fP\fItext\fP\fB> +\fP +.fi +.RE +.LP +where <\fItext\fP> is the text of line <\fIline-number\fP> of file +<\fIfilename\fP>. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +When the \fB-x\fP option is not specified, the format of the output +file shall be: +.sp +.RS +.nf + +\fB"%s\\t%s\\t/%s/\\n", <\fP\fIidentifier\fP\fB>, <\fP\fIfilename\fP\fB>, <\fP\fIpattern\fP\fB> +\fP +.fi +.RE +.LP +where <\fIpattern\fP> is a search pattern that could be used by an +editor to find the defining instance of +<\fIidentifier\fP> in <\fIfilename\fP> (where \fIdefining instance\fP +is indicated by the declarations listed in the +EXTENDED DESCRIPTION). +.LP +An optional circumflex ( \fB'^'\fP ) can be added as a prefix to <\fIpattern\fP>, +and an optional dollar sign can be +appended to <\fIpattern\fP> to indicate that the pattern is anchored +to the beginning (end) of a line of text. Any slash or +backslash characters in <\fIpattern\fP> shall be preceded by a backslash +character. The anchoring circumflex, dollar sign, +and escaping backslash characters shall not be considered part of +the search pattern. All other characters in the search pattern +shall be considered literal characters. +.br +.LP +An alternative format is: +.sp +.RS +.nf + +\fB"%s\\t%s\\t?%s?\\n", <\fP\fIidentifier\fP\fB>, <\fP\fIfilename\fP\fB>, <\fP\fIpattern\fP\fB> +\fP +.fi +.RE +.LP +which is identical to the first format except that slashes in <\fIpattern\fP> +shall not be preceded by escaping backslash +characters, and question mark characters in <\fIpattern\fP> shall +be preceded by backslash characters. +.LP +A second alternative format is: +.sp +.RS +.nf + +\fB"%s\\t%s\\t%d\\n", <\fP\fIidentifier\fP\fB>, <\fP\fIfilename\fP\fB>, <\fP\fIlineno\fP\fB> +\fP +.fi +.RE +.LP +where <\fIlineno\fP> is a decimal line number that could be used by +an editor to find <\fIidentifier\fP> in +<\fIfilename\fP>. +.LP +Neither alternative format shall be produced by \fIctags\fP when it +is used as described by IEEE\ Std\ 1003.1-2001, but +the standard utilities that process tags files shall be able to process +those formats as well as the first format. +.LP +In any of these formats, the file shall be sorted by identifier, based +on the collation sequence in the POSIX locale. +.SH EXTENDED DESCRIPTION +.LP +If the operand identifies C-language source, the \fIctags\fP utility +shall attempt to produce an output line for each of the +following objects: +.IP " *" 3 +Function definitions +.LP +.IP " *" 3 +Type definitions +.LP +.IP " *" 3 +Macros with arguments +.LP +.LP +It may also produce output for any of the following objects: +.IP " *" 3 +Function prototypes +.LP +.IP " *" 3 +Structures +.LP +.IP " *" 3 +Unions +.LP +.IP " *" 3 +Global variable definitions +.LP +.IP " *" 3 +Enumeration types +.LP +.IP " *" 3 +Macros without arguments +.LP +.IP " *" 3 +\fB#define\fP statements +.LP +.IP " *" 3 +\fB#line\fP statements +.LP +.LP +Any \fB#if\fP and \fB#ifdef\fP statements shall produce no output. +The tag \fBmain\fP is treated specially in C programs. The +tag formed shall be created by prefixing \fBM\fP to the name of the +file, with the trailing \fB.c\fP, and leading pathname +components (if any) removed. +.LP +On systems that do not support the C-Language Development Utilities +option, \fIctags\fP produces unspecified results for +C-language source code files. It should write to standard error a +message identifying this condition and cause a non-zero exit +status to be produced. +.LP +If the operand identifies FORTRAN source, the \fIctags\fP utility +shall produce an output line for each function definition. It +may also produce output for any of the following objects: +.IP " *" 3 +Subroutine definitions +.LP +.IP " *" 3 +COMMON statements +.LP +.IP " *" 3 +PARAMETER statements +.LP +.IP " *" 3 +DATA and BLOCK DATA statements +.LP +.IP " *" 3 +Statement numbers +.LP +.LP +On systems that do not support the FORTRAN Development Utilities option, +\fIctags\fP produces unspecified results for FORTRAN +source code files. It should write to standard error a message identifying +this condition and cause a non-zero exit status to be +produced. +.LP +It is implementation-defined what other objects (including duplicate +identifiers) produce output. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The output with \fB-x\fP is meant to be a simple index that can be +written out as an off-line readable function index. If the +input files to \fIctags\fP (such as \fB.c\fP files) were not created +using the same locale as that in effect when \fIctags\fP +\fB-x\fP is run, results might not be as expected. +.LP +The description of C-language processing says "attempts to" because +the C language can be greatly confused, especially through +the use of \fB#define\fPs, and this utility would be of no use if +the real C preprocessor were run to identify them. The output +from \fIctags\fP may be fooled and incorrect for various constructs. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The option list was significantly reduced from that provided by historical +implementations. The \fB-F\fP option was omitted as +redundant, since it is the default. The \fB-B\fP option was omitted +as being of very limited usefulness. The \fB-t\fP option was +omitted since the recognition of \fBtypedef\fPs is now required for +C source files. The \fB-u\fP option was omitted because the +update function was judged to be not only inefficient, but also rarely +needed. +.LP +An early proposal included a \fB-w\fP option to suppress warning diagnostics. +Since the types of such diagnostics could not be +described, the option was omitted as being not useful. +.LP +The text for \fILC_CTYPE\fP about compatibility with the C locale +acknowledges that the ISO\ C standard imposes +requirements on the locale used to process C source. This could easily +be a superset of that known as "the C locale" by way of +implementation extensions, or one of a few alternative locales for +systems supporting different codesets. No statement is made for +FORTRAN because the ANSI\ X3.9-1978 standard (FORTRAN 77) does not +(yet) define a similar locale concept. However, a general +rule in this volume of IEEE\ Std\ 1003.1-2001 is that any time that +locales do not match (preparing a file for one locale +and processing it in another), the results are suspect. +.LP +The collation sequence of the tags file is not affected by \fILC_COLLATE\fP +because it is typically not used by human readers, +but only by programs such as \fIvi\fP to locate the tag within the +source files. Using the +POSIX locale eliminates some of the problems of coordinating locales +between the \fIctags\fP file creator and the \fIvi\fP file reader. +.LP +Historically, the tags file has been used only by \fIex\fP and \fIvi\fP. +However, the format of the tags file has been published to encourage +other programs to use +the tags in new ways. The format allows either patterns or line numbers +to find the identifiers because the historical \fIvi\fP recognizes +either. The \fIctags\fP utility does not produce the format using +line numbers +because it is not useful following any source file changes that add +or delete lines. The documented search patterns match +historical practice. It should be noted that literal leading circumflex +or trailing dollar-sign characters in the search pattern +will only behave correctly if anchored to the beginning of the line +or end of the line by an additional circumflex or dollar-sign +character. +.LP +Historical implementations also understand the objects used by the +languages Pascal and sometimes LISP, and they understand the +C source output by \fIlex\fP and \fIyacc\fP. The +\fIctags\fP utility is not required to accommodate these languages, +although implementors are encouraged to do so. +.LP +The following historical option was not specified, as \fIvgrind\fP +is not included in this volume of +IEEE\ Std\ 1003.1-2001: +.TP 7 +\fB-v\fP +If the \fB-v\fP flag is given, an index of the form expected by \fIvgrind\fP +is produced on the standard output. This listing +contains the function name, filename, and page number (assuming 64-line +pages). Since the output is sorted into lexicographic +order, it may be desired to run the output through \fIsort\fP \fB-f\fP. +Sample use: +.sp +.RS +.nf + +\fBctags -v files | sort -f > index vgrind -x index +\fP +.fi +.RE +.sp +.LP +The special treatment of the tag \fBmain\fP makes the use of \fIctags\fP +practical in directories with more than one +program. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP , \fIfort77\fP , \fIvi\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cut.1p b/man1p/cut.1p new file mode 100644 index 000000000..61ed475a3 --- /dev/null +++ b/man1p/cut.1p @@ -0,0 +1,362 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CUT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cut +.SH NAME +cut \- cut out selected fields of each line of a file +.SH SYNOPSIS +.LP +\fBcut -b\fP \fIlist\fP \fB[\fP\fB-n\fP\fB] [\fP\fIfile\fP \fB...\fP\fB]\fP\fB +.br +.sp +cut -c\fP \fIlist\fP \fB[\fP\fIfile\fP \fB...\fP\fB]\fP\fB +.br +.sp +cut -f\fP \fIlist\fP \fB[\fP\fB-d\fP \fIdelim\fP\fB][\fP\fB-s\fP\fB][\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIcut\fP utility shall cut out bytes ( \fB-b\fP option), characters +( \fB-c\fP option), or character-delimited fields ( +\fB-f\fP option) from each line in one or more files, concatenate +them, and write them to standard output. +.SH OPTIONS +.LP +The \fIcut\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The application shall ensure that the option-argument \fIlist\fP (see +options \fB-b\fP, \fB-c\fP, and \fB-f\fP below) is a +comma-separated list or <blank>-separated list of positive numbers +and ranges. Ranges can be in three forms. The first is two +positive numbers separated by a hyphen ( \fIlow\fP- \fIhigh\fP), which +represents all fields from the first number to the second +number. The second is a positive number preceded by a hyphen (- \fIhigh\fP), +which represents all fields from field number 1 to +that number. The third is a positive number followed by a hyphen ( +\fIlow\fP-), which represents that number to the last field, +inclusive. The elements in \fIlist\fP can be repeated, can overlap, +and can be specified in any order, but the bytes, characters, +or fields selected shall be written in the order of the input data. +If an element appears in the selection list more than once, it +shall be written exactly once. +.LP +The following options shall be supported: +.TP 7 +\fB-b\ \fP \fIlist\fP +Cut based on a \fIlist\fP of bytes. Each selected byte shall be output +unless the \fB-n\fP option is also specified. It shall +not be an error to select bytes not present in the input line. +.TP 7 +\fB-c\ \fP \fIlist\fP +Cut based on a \fIlist\fP of characters. Each selected character shall +be output. It shall not be an error to select +characters not present in the input line. +.TP 7 +\fB-d\ \fP \fIdelim\fP +Set the field delimiter to the character \fIdelim\fP. The default +is the <tab>. +.TP 7 +\fB-f\ \fP \fIlist\fP +Cut based on a \fIlist\fP of fields, assumed to be separated in the +file by a delimiter character (see \fB-d\fP). Each +selected field shall be output. Output fields shall be separated by +a single occurrence of the field delimiter character. Lines +with no field delimiters shall be passed through intact, unless \fB-s\fP +is specified. It shall not be an error to select fields +not present in the input line. +.TP 7 +\fB-n\fP +Do not split characters. When specified with the \fB-b\fP option, +each element in \fIlist\fP of the form \fIlow\fP- +\fIhigh\fP (hyphen-separated numbers) shall be modified as follows: +.RS +.IP " *" 3 +If the byte selected by \fIlow\fP is not the first byte of a character, +\fIlow\fP shall be decremented to select the first +byte of the character originally selected by \fIlow\fP. If the byte +selected by \fIhigh\fP is not the last byte of a character, +\fIhigh\fP shall be decremented to select the last byte of the character +prior to the character originally selected by +\fIhigh\fP, or zero if there is no prior character. If the resulting +range element has \fIhigh\fP equal to zero or \fIlow\fP +greater than \fIhigh\fP, the list element shall be dropped from \fIlist\fP +for that input line without causing an error. +.LP +.RE +.LP +Each element in \fIlist\fP of the form \fIlow\fP- shall be treated +as above with \fIhigh\fP set to the number of bytes in the +current line, not including the terminating <newline>. Each element +in \fIlist\fP of the form - \fIhigh\fP shall be treated +as above with \fIlow\fP set to 1. Each element in \fIlist\fP of the +form \fInum\fP (a single number) shall be treated as above +with \fIlow\fP set to \fInum\fP and \fIhigh\fP set to \fInum\fP. +.TP 7 +\fB-s\fP +Suppress lines with no delimiter characters, when used with the \fB-f\fP +option. Unless specified, lines with no delimiters +shall be passed through untouched. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If no \fIfile\fP operands are specified, +or if a \fIfile\fP operand is \fB'-'\fP , the +standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP . +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files, except that line lengths shall +be unlimited. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcut\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIcut\fP utility output shall be a concatenation of the selected +bytes, characters, or fields (one of the following): +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIconcatenation of bytes\fP\fB> +.sp + +"%s\\n", <\fP\fIconcatenation of characters\fP\fB> +.sp + +"%s\\n", <\fP\fIconcatenation of fields and field delimiters\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were output successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Earlier versions of the \fIcut\fP utility worked in an environment +where bytes and characters were considered equivalent +(modulo <backspace> and <tab> processing in some implementations). +In the extended world of multi-byte characters, the +new \fB-b\fP option has been added. The \fB-n\fP option (used with +\fB-b\fP) allows it to be used to act on bytes rounded to +character boundaries. The algorithm specified for \fB-n\fP guarantees +that: +.sp +.RS +.nf + +\fBcut -b 1-500 -n file > file1 +cut -b 501- -n file > file2 +\fP +.fi +.RE +.LP +ends up with all the characters in \fBfile\fP appearing exactly once +in \fBfile1\fP or \fBfile2\fP. (There is, however, a +<newline> in both \fBfile1\fP and \fBfile2\fP for each <newline> in +\fBfile\fP.) +.SH EXAMPLES +.LP +Examples of the option qualifier list: +.TP 7 +1,4,7 +Select the first, fourth, and seventh bytes, characters, or fields +and field delimiters. +.TP 7 +1-3,8 +Equivalent to 1,2,3,8. +.TP 7 +-5,10 +Equivalent to 1,2,3,4,5,10. +.TP 7 +3- +Equivalent to third to last, inclusive. +.sp +.LP +The \fIlow\fP- \fIhigh\fP forms are not always equivalent when used +with \fB-b\fP and \fB-n\fP and multi-byte characters; +see the description of \fB-n\fP. +.LP +The following command: +.sp +.RS +.nf + +\fBcut -d : -f 1,6 /etc/passwd +\fP +.fi +.RE +.LP +reads the System V password file (user database) and produces lines +of the form: +.sp +.RS +.nf + +\fB<\fP\fIuser ID\fP\fB>:<\fP\fIhome directory\fP\fB> +\fP +.fi +.RE +.LP +Most utilities in this volume of IEEE\ Std\ 1003.1-2001 work on text +files. The \fIcut\fP utility can be used to turn +files with arbitrary line lengths into a set of text files containing +the same data. The \fIpaste\fP utility can be used to create (or recreate) +files with arbitrary line lengths. For +example, if \fBfile\fP contains long lines: +.sp +.RS +.nf + +\fBcut -b 1-500 -n file > file1 +cut -b 501- -n file > file2 +\fP +.fi +.RE +.LP +creates \fBfile1\fP (a text file) with lines no longer than 500 bytes +(plus the <newline>) and \fBfile2\fP that contains +the remainder of the data from \fBfile\fP. (Note that \fBfile2\fP +is not a text file if there are lines in \fBfile\fP that are +longer than 500 + {LINE_MAX} bytes.) The original file can be recreated +from \fBfile1\fP and \fBfile2\fP using the command: +.sp +.RS +.nf + +\fBpaste -d "\\0" file1 file2 > file +\fP +.fi +.RE +.SH RATIONALE +.LP +Some historical implementations do not count <backspace>s in determining +character counts with the \fB-c\fP option. This +may be useful for using \fIcut\fP for processing \fInroff\fP output. +It was deliberately decided not to have the \fB-c\fP option +treat either <backspace>s or <tab>s in any special fashion. The \fIfold\fP +utility does treat these characters specially. +.LP +Unlike other utilities, some historical implementations of \fIcut\fP +exit after not finding an input file, rather than +continuing to process the remaining \fIfile\fP operands. This behavior +is prohibited by this volume of +IEEE\ Std\ 1003.1-2001, where only the exit status is affected by +this problem. +.LP +The behavior of \fIcut\fP when provided with either mutually-exclusive +options or options that do not work logically together +has been deliberately left unspecified in favor of global wording +in \fIUtility Description +Defaults\fP . +.LP +The OPTIONS section was changed in response to IEEE PASC Interpretation +1003.2 #149. The change represents historical practice +on all known systems. The original standard was ambiguous on the nature +of the output. +.LP +The \fIlist\fP option-arguments are historically used to select the +portions of the line to be written, but do not affect the +order of the data. For example: +.sp +.RS +.nf + +\fBecho abcdefghi | cut -c6,2,4-7,1 +\fP +.fi +.RE +.LP +yields \fB"abdefg"\fP . +.LP +A proposal to enhance \fIcut\fP with the following option: +.TP 7 +\fB-o\fP +Preserve the selected field order. When this option is specified, +each byte, character, or field (or ranges of such) shall be +written in the order specified by the \fIlist\fP option-argument, +even if this requires multiple outputs of the same bytes, +characters, or fields. +.sp +.LP +was rejected because this type of enhancement is outside the scope +of the IEEE\ P1003.2b draft standard. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIgrep\fP , \fIpaste\fP , \fIParameters +and Variables\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/cxref.1p b/man1p/cxref.1p new file mode 100644 index 000000000..49e1b79cc --- /dev/null +++ b/man1p/cxref.1p @@ -0,0 +1,181 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "CXREF" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" cxref +.SH NAME +cxref \- generate a C-language program cross-reference table (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBcxref\fP \fB[\fP\fB-cs\fP\fB][\fP\fB-o\fP \fIfile\fP\fB][\fP\fB-w\fP +\fInum\fP\fB] +[\fP\fB-D\fP \fIname\fP\fB[\fP\fB=\fP\fIdef\fP\fB]]\fP\fB...\fP\fB[\fP\fB-I\fP +\fIdir\fP\fB]\fP\fB... +.br +\ \ \ \ \ \ \fP \fB[\fP\fB-U\fP \fIname\fP\fB]\fP\fB...\fP \fIfile\fP +\fB\&... \fP +.SH DESCRIPTION +.LP +The \fIcxref\fP utility shall analyze a collection of C-language \fIfile\fPs +and attempt to build a cross-reference table. +Information from \fB#define\fP lines shall be included in the symbol +table. A sorted listing shall be written to standard output +of all symbols (auto, static, and global) in each \fIfile\fP separately, +or with the \fB-c\fP option, in combination. Each symbol +shall contain an asterisk before the declaring reference. +.SH OPTIONS +.LP +The \fIcxref\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the order of the \fB-D\fP, +\fB-I\fP, and \fB-U\fP options (which are identical to their interpretation +by \fIc99\fP) is +significant. The following options shall be supported: +.TP 7 +\fB-c\fP +Write a combined cross-reference of all input files. +.TP 7 +\fB-s\fP +Operate silently; do not print input filenames. +.TP 7 +\fB-o\ \fP \fIfile\fP +Direct output to named \fIfile\fP. +.TP 7 +\fB-w\ \fP \fInum\fP +Format output no wider than \fInum\fP (decimal) columns. This option +defaults to 80 if \fInum\fP is not specified or is less +than 51. +.TP 7 +\fB-D\fP +Equivalent to \fIc99\fP. +.TP 7 +\fB-I\fP +Equivalent to \fIc99\fP. +.TP 7 +\fB-U\fP +Equivalent to \fIc99\fP. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a C-language source file. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The input files are C-language source files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIcxref\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the ordering of the output. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be used for the cross-reference listing, +unless the \fB-o\fP option is used to select a different +output file. +.LP +The format of standard output is unspecified, except that the following +information shall be included: +.IP " *" 3 +If the \fB-c\fP option is not specified, each portion of the listing +shall start with the name of the input file on a separate +line. +.LP +.IP " *" 3 +The name line shall be followed by a sorted list of symbols, each +with its associated location pathname, the name of the +function in which it appears (if it is not a function name itself), +and line number references. +.LP +.IP " *" 3 +Each line number may be preceded by an asterisk ( \fB'*'\fP ) flag, +meaning that this is the declaring reference. Other +single-character flags, with implementation-defined meanings, may +be included. +.LP +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output file named by the \fB-o\fP option shall be used instead +of standard output. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/date.1p b/man1p/date.1p new file mode 100644 index 000000000..0fa9828a5 --- /dev/null +++ b/man1p/date.1p @@ -0,0 +1,572 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DATE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" date +.SH NAME +date \- write the date and time +.SH SYNOPSIS +.LP +\fBdate\fP \fB[\fP\fB-u\fP\fB] [\fP\fB+\fP\fIformat\fP\fB]\fP\fB +.br +.sp +\fP +.LP +\fBdate\fP \fB[\fP\fB-u\fP\fB]\fP +\fImmddhhmm\fP\fB[[\fP\fIcc\fP\fB]\fP\fIyy\fP\fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIdate\fP utility shall write the date and time to standard output +\ or attempt +to set the system date and time. By default, the current date and +time shall be written. If an operand beginning with \fB'+'\fP is specified, +the output format of \fIdate\fP shall be controlled +by the conversion specifications and other text in the operand. +.SH OPTIONS +.LP +The \fIdate\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-u\fP +Perform operations as if the \fITZ\fP environment variable was set +to the string \fB"UTC0"\fP , or its equivalent +historical value of \fB"GMT0"\fP . Otherwise, \fIdate\fP shall use +the timezone indicated by the \fITZ\fP environment variable +or the system default if that variable is unset or null. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 ++\fIformat\fP +When the format is specified, each conversion specifier shall be replaced +in the standard output by its corresponding value. +All other characters shall be copied to the output without change. +The output shall always be terminated with a +<newline>. +.sp +.SS Conversion Specifications +.TP 7 +\fB%a\fP +Locale's abbreviated weekday name. +.TP 7 +\fB%A\fP +Locale's full weekday name. +.TP 7 +\fB%b\fP +Locale's abbreviated month name. +.TP 7 +\fB%B\fP +Locale's full month name. +.TP 7 +\fB%c\fP +Locale's appropriate date and time representation. +.TP 7 +\fB%C\fP +Century (a year divided by 100 and truncated to an integer) as a decimal +number [00,99]. +.TP 7 +\fB%d\fP +Day of the month as a decimal number [01,31]. +.TP 7 +\fB%D\fP +Date in the format \fImm\fP/\fIdd\fP/\fIyy\fP. +.TP 7 +\fB%e\fP +Day of the month as a decimal number [1,31] in a two-digit field with +leading space character fill. +.TP 7 +\fB%h\fP +A synonym for \fB%b\fP . +.TP 7 +\fB%H\fP +Hour (24-hour clock) as a decimal number [00,23]. +.TP 7 +\fB%I\fP +Hour (12-hour clock) as a decimal number [01,12]. +.TP 7 +\fB%j\fP +Day of the year as a decimal number [001,366]. +.TP 7 +\fB%m\fP +Month as a decimal number [01,12]. +.TP 7 +\fB%M\fP +Minute as a decimal number [00,59]. +.TP 7 +\fB%n\fP +A <newline>. +.TP 7 +\fB%p\fP +Locale's equivalent of either AM or PM. +.TP 7 +\fB%r\fP +12-hour clock time [01,12] using the AM/PM notation; in the POSIX +locale, this shall be equivalent to \fB%I\fP : \fB%M\fP +: \fB%S\fP \fB%p\fP . +.TP 7 +\fB%S\fP +Seconds as a decimal number [00,60]. +.TP 7 +\fB%t\fP +A <tab>. +.TP 7 +\fB%T\fP +24-hour clock time [00,23] in the format \fIHH\fP:\fIMM\fP:\fISS\fP. +.TP 7 +\fB%u\fP +Weekday as a decimal number [1,7] (1=Monday). +.TP 7 +\fB%U\fP +Week of the year (Sunday as the first day of the week) as a decimal +number [00,53]. All days in a new year preceding the first +Sunday shall be considered to be in week 0. +.TP 7 +\fB%V\fP +Week of the year (Monday as the first day of the week) as a decimal +number [01,53]. If the week containing January 1 has four +or more days in the new year, then it shall be considered week 1; +otherwise, it shall be the last week of the previous year, and +the next week shall be week 1. +.TP 7 +\fB%w\fP +Weekday as a decimal number [0,6] (0=Sunday). +.TP 7 +\fB%W\fP +Week of the year (Monday as the first day of the week) as a decimal +number [00,53]. All days in a new year preceding the first +Monday shall be considered to be in week 0. +.TP 7 +\fB%x\fP +Locale's appropriate date representation. +.TP 7 +\fB%X\fP +Locale's appropriate time representation. +.TP 7 +\fB%y\fP +Year within century [00,99]. +.TP 7 +\fB%Y\fP +Year with century as a decimal number. +.TP 7 +\fB%Z\fP +Timezone name, or no characters if no timezone is determinable. +.TP 7 +\fB%%\fP +A percent sign character. +.sp +.LP +See the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section +7.3.5, LC_TIME for the conversion specifier values in the POSIX locale. +.SS Modified Conversion Specifications +.LP +Some conversion specifiers can be modified by the \fBE\fP and \fBO\fP +modifier characters to indicate a different format +or specification as specified in the \fILC_TIME\fP locale description +(see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 7.3.5, LC_TIME). If the +corresponding keyword (see \fBera\fP, \fBera_year\fP, \fBera_d_fmt\fP, +and \fBalt_digits\fP in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 7.3.5, LC_TIME) is not specified or +not supported for the current locale, the unmodified conversion specifier +value shall be used. +.TP 7 +\fB%Ec\fP +Locale's alternative appropriate date and time representation. +.TP 7 +\fB%EC\fP +The name of the base year (period) in the locale's alternative representation. +.TP 7 +\fB%Ex\fP +Locale's alternative date representation. +.TP 7 +\fB%EX\fP +Locale's alternative time representation. +.TP 7 +\fB%Ey\fP +Offset from \fB%EC\fP (year only) in the locale's alternative representation. +.TP 7 +\fB%EY\fP +Full alternative year representation. +.TP 7 +\fB%Od\fP +Day of month using the locale's alternative numeric symbols. +.TP 7 +\fB%Oe\fP +Day of month using the locale's alternative numeric symbols. +.TP 7 +\fB%OH\fP +Hour (24-hour clock) using the locale's alternative numeric symbols. +.TP 7 +\fB%OI\fP +Hour (12-hour clock) using the locale's alternative numeric symbols. +.TP 7 +\fB%Om\fP +Month using the locale's alternative numeric symbols. +.TP 7 +\fB%OM\fP +Minutes using the locale's alternative numeric symbols. +.TP 7 +\fB%OS\fP +Seconds using the locale's alternative numeric symbols. +.TP 7 +\fB%Ou\fP +Weekday as a number in the locale's alternative representation (Monday += 1). +.TP 7 +\fB%OU\fP +Week number of the year (Sunday as the first day of the week) using +the locale's alternative numeric symbols. +.TP 7 +\fB%OV\fP +Week number of the year (Monday as the first day of the week, rules +corresponding to \fB%V\fP ), using the locale's +alternative numeric symbols. +.TP 7 +\fB%Ow\fP +Weekday as a number in the locale's alternative representation (Sunday += 0). +.TP 7 +\fB%OW\fP +Week number of the year (Monday as the first day of the week) using +the locale's alternative numeric symbols. +.TP 7 +\fB%Oy\fP +Year (offset from \fB%C\fP ) in alternative representation. +.sp +.sp +.TP 7 +\fImmddhhmm\fP\fB[[\fP\fIcc\fP\fB]\fP\fIyy\fP\fB]\fP +.sp +Attempt to set the system date and time from the value given in the +operand. This is only possible if the user has appropriate +privileges and the system permits the setting of the system date and +time. The first \fImm\fP is the month (number); \fIdd\fP is +the day (number); \fIhh\fP is the hour (number, 24-hour system); the +second \fImm\fP is the minute (number); \fIcc\fP is the +century and is the first two digits of the year (this is optional); +\fIyy\fP is the last two digits of the year and is optional. +If century is not specified, then values in the range [69,99] shall +refer to years 1969 to 1999 inclusive, and values in the range +[00,68] shall refer to years 2000 to 2068 inclusive. The current year +is the default if \fIyy\fP is omitted. +.TP 7 +\fBNote:\fP +.RS +It is expected that in a future version of IEEE\ Std\ 1003.1-2001 +the default century inferred from a 2-digit year will +change. (This would apply to all commands accepting a 2-digit year +as input.) +.RE +.sp +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIdate\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_TIME\fP +Determine the format and contents of date and time strings written +by \fIdate\fP. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone in which the time and date are written, unless +the \fB-u\fP option is specified. If the \fITZ\fP +variable is unset or null and \fB-u\fP is not specified, an unspecified +system default timezone is used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When no formatting operand is specified, the output in the POSIX locale +shall be equivalent to specifying: +.sp +.RS +.nf + +\fBdate "+%a %b %e %H:%M:%S %Z %Y" +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The date was written successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Conversion specifiers are of unspecified format when not in the POSIX +locale. Some of them can contain <newline>s in some +locales, so it may be difficult to use the format shown in standard +output for parsing the output of \fIdate\fP in those +locales. +.LP +The range of values for \fB%S\fP extends from 0 to 60 seconds to accommodate +the occasional leap second. +.LP +Although certain of the conversion specifiers in the POSIX locale +(such as the name of the month) are shown with initial capital +letters, this need not be the case in other locales. Programs using +these fields may need to adjust the capitalization if the +output is going to be used at the beginning of a sentence. +.LP +The date string formatting capabilities are intended for use in Gregorian-style +calendars, possibly with a different starting +year (or years). The \fB%x\fP and \fB%c\fP conversion specifications, +however, are intended for local representation; these +may be based on a different, non-Gregorian calendar. +.LP +The \fB%C\fP conversion specification was introduced to allow a fallback +for the \fB%EC\fP (alternative year format base +year); it can be viewed as the base of the current subdivision in +the Gregorian calendar. The century number is calculated as the +year divided by 100 and truncated to an integer; it should not be +confused with the use of ordinal numbers for centuries (for +example, "twenty-first century".) Both the \fB%Ey\fP and \fB%y\fP +can then be viewed as the offset from \fB%EC\fP and +\fB%C\fP , respectively. +.LP +The \fBE\fP and \fBO\fP modifiers modify the traditional conversion +specifiers, so that they can always be used, even if +the implementation (or the current locale) does not support the modifier. +.LP +The \fBE\fP modifier supports alternative date formats, such as the +Japanese Emperor's Era, as long as these are based on the +Gregorian calendar system. Extending the \fBE\fP modifiers to other +date elements may provide an implementation-defined +extension capable of supporting other calendar systems, especially +in combination with the \fBO\fP modifier. +.LP +The \fBO\fP modifier supports time and date formats using the locale's +alternative numerical symbols, such as Kanji or Hindi +digits or ordinal number representation. +.LP +Non-European locales, whether they use Latin digits in computational +items or not, often have local forms of the digits for use +in date formats. This is not totally unknown even in Europe; a variant +of dates uses Roman numerals for the months: the third day +of September 1991 would be written as 3.IX.1991. In Japan, Kanji digits +are regularly used for dates; in Arabic-speaking countries, +Hindi digits are used. The \fB%d\fP , \fB%e\fP , \fB%H\fP , \fB%I\fP +, \fB%m\fP , \fB%S\fP , \fB%U\fP , +\fB%w\fP , \fB%W\fP , and \fB%y\fP conversion specifications always +return the date and time field in Latin digits (that +is, 0 to 9). The \fB%O\fP modifier was introduced to support the use +for display purposes of non-Latin digits. In the +\fILC_TIME\fP category in \fIlocaledef\fP, the optional \fBalt_digits\fP +keyword is +intended for this purpose. As an example, assume the following (partial) +\fIlocaledef\fP +source: +.sp +.RS +.nf + +\fBalt_digits "";"I";"II";"III";"IV";"V";"VI";"VII";"VIII" \\ + "IX";"X";"XI";"XII" +d_fmt "%e.%Om.%Y" +\fP +.fi +.RE +.LP +With the above date, the command: +.sp +.RS +.nf + +\fBdate "+%x" +\fP +.fi +.RE +.LP +would yield 3.IX.1991. With the same \fBd_fmt\fP, but without the +\fBalt_digits\fP, the command would yield 3.9.1991. +.SH EXAMPLES +.IP " 1." 4 +The following are input/output examples of \fIdate\fP used at arbitrary +times in the POSIX locale: +.sp +.RS +.nf + +\fB$\fP \fBdate +\fP\fBTue Jun 26 09:58:10 PDT 1990 +.sp + +$\fP \fBdate "+DATE: %m/%d/%y%nTIME: %H:%M:%S" +\fP\fBDATE: 11/02/91 +TIME: 13:36:16 +.sp + +$\fP \fBdate "+TIME: %r" +\fP\fBTIME: 01:36:32 PM\fP +.fi +.RE +.LP +.IP " 2." 4 +Examples for Denmark, where the default date and time format is \fB%a\fP +\fB%d\fP \fB%b\fP \fB%Y\fP \fB%T\fP +\fB%Z\fP : +.sp +.RS +.nf + +\fB$\fP \fBLANG=da_DK.iso_8859-1 date +\fP\fBons 02 okt 1991 15:03:32 CET +.sp + +$\fP \fBLANG=da_DK.iso_8859-1 \\ + date "+DATO: %A den %e. %B %Y%nKLOKKEN: %H:%M:%S" +\fP\fBDATO: onsdag den 2. oktober 1991 +KLOKKEN: 15:03:56\fP +.fi +.RE +.LP +.IP " 3." 4 +Examples for Germany, where the default date and time format is \fB%a\fP +\fB%d\fP . \fB%h\fP . \fB%Y\fP , +\fB%T\fP \fB%Z\fP : +.sp +.RS +.nf + +\fB$\fP \fBLANG=De_DE.88591 date +\fP\fBMi 02.Okt.1991, 15:01:21 MEZ +.sp + +$\fP \fBLANG=De_DE.88591 date "+DATUM: %A, %d. %B %Y%nZEIT: %H:%M:%S" +\fP\fBDATUM: Mittwoch, 02. Oktober 1991 +ZEIT: 15:02:02\fP +.fi +.RE +.LP +.IP " 4." 4 +Examples for France, where the default date and time format is \fB%a\fP +\fB%d\fP \fB%h\fP \fB%Y\fP \fB%Z\fP +\fB%T\fP : +.sp +.RS +.nf + +\fB$\fP \fBLANG=Fr_FR.88591 date +\fP\fBMer 02 oct 1991 MET 15:03:32 +.sp + +$\fP \fBLANG=Fr_FR.88591 date "+JOUR: %A %d %B %Y%nHEURE: %H:%M:%S" +\fP\fBJOUR: Mercredi 02 octobre 1991 +HEURE: 15:03:56\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +Some of the new options for formatting are from the ISO\ C standard. +The \fB-u\fP option was introduced to allow portable +access to Coordinated Universal Time (UTC). The string \fB"GMT0"\fP +is allowed as an equivalent \fITZ\fP value to be compatible +with all of the systems using the BSD implementation, where this option +originated. +.LP +The \fB%e\fP format conversion specification (adopted from System +V) was added because the ISO\ C standard conversion +specifications did not provide any way to produce the historical default +\fIdate\fP output during the first nine days of any +month. +.LP +There are two varieties of day and week numbering supported (in addition +to any others created with the locale-dependent +\fB%E\fP and \fB%O\fP modifier characters): +.IP " *" 3 +The historical variety in which Sunday is the first day of the week +and the weekdays preceding the first Sunday of the year are +considered week 0. These are represented by \fB%w\fP and \fB%U\fP +\&. A variant of this is \fB%W\fP , using Monday as the +first day of the week, but still referring to week 0. This view of +the calendar was retained because so many historical +applications depend on it and the ISO\ C standard \fIstrftime\fP() +function, on which +many \fIdate\fP implementations are based, was defined in this way. +.LP +.IP " *" 3 +The international standard, based on the ISO\ 8601:2000 standard where +Monday is the first weekday and the algorithm for the +first week number is more complex: If the week (Monday to Sunday) +containing January 1 has four or more days in the new year, then +it is week 1; otherwise, it is week 53 of the previous year, and the +next week is week 1. These are represented by the new +conversion specifications \fB%u\fP and \fB%V\fP , added as a result +of international comments. +.LP +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIprintf\fP(), +\fIstrftime\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/dd.1p b/man1p/dd.1p new file mode 100644 index 000000000..3a40d4682 --- /dev/null +++ b/man1p/dd.1p @@ -0,0 +1,588 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" dd +.SH NAME +dd \- convert and copy a file +.SH SYNOPSIS +.LP +\fBdd\fP \fB[\fP\fIoperand\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIdd\fP utility shall copy the specified input file to the specified +output file with possible conversions using specific +input and output block sizes. It shall read the input one block at +a time, using the specified input block size; it shall then +process the block of data actually returned, which could be smaller +than the requested block size. It shall apply any conversions +that have been specified and write the resulting data to the output +in blocks of the specified output block size. If the \fBbs\fP= +\fIexpr\fP operand is specified and no conversions other than \fBsync\fP, +\fBnoerror\fP, or \fBnotrunc\fP are requested, the +data returned from each input block shall be written as a separate +output block; if the read returns less than a full block and the +\fBsync\fP conversion is not specified, the resulting output block +shall be the same size as the input block. If the \fBbs\fP= +\fIexpr\fP operand is not specified, or a conversion other than \fBsync\fP, +\fBnoerror\fP, or \fBnotrunc\fP is requested, the +input shall be processed and collected into full-sized output blocks +until the end of the input is reached. +.LP +The processing order shall be as follows: +.IP " 1." 4 +An input block is read. +.LP +.IP " 2." 4 +If the input block is shorter than the specified input block size +and the \fBsync\fP conversion is specified, null bytes shall +be appended to the input data up to the specified size. (If either +\fBblock\fP or \fBunblock\fP is also specified, <space>s +shall be appended instead of null bytes.) The remaining conversions +and output shall include the pad characters as if they had been +read from the input. +.LP +.IP " 3." 4 +If the \fBbs\fP= \fIexpr\fP operand is specified and no conversion +other than \fBsync\fP or \fBnoerror\fP is requested, the +resulting data shall be written to the output as a single block, and +the remaining steps are omitted. +.LP +.IP " 4." 4 +If the \fBswab\fP conversion is specified, each pair of input data +bytes shall be swapped. If there is an odd number of bytes +in the input block, the last byte in the input record shall not be +swapped. +.LP +.IP " 5." 4 +Any remaining conversions ( \fBblock\fP, \fBunblock\fP, \fBlcase\fP, +and \fBucase\fP) shall be performed. These conversions +shall operate on the input data independently of the input blocking; +an input or output fixed-length record may span block +boundaries. +.LP +.IP " 6." 4 +The data resulting from input or conversion or both shall be aggregated +into output blocks of the specified size. After the end +of input is reached, any remaining output shall be written as a block +without padding if \fBconv\fP= \fBsync\fP is not specified; +thus, the final output block may be shorter than the output block +size. +.LP +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +All of the operands shall be processed before any input is read. The +following operands shall be supported: +.TP 7 +\fBif\fP=\fIfile\fP +Specify the input pathname; the default is standard input. +.TP 7 +\fBof\fP=\fIfile\fP +Specify the output pathname; the default is standard output. If the +\fBseek\fP= \fIexpr\fP conversion is not also specified, +the output file shall be truncated before the copy begins if an explicit +\fBof\fP= \fIfile\fP operand is specified, unless +\fBconv\fP= \fBnotrunc\fP is specified. If \fBseek\fP= \fIexpr\fP +is specified, but \fBconv\fP= \fBnotrunc\fP is not, the +effect of the copy shall be to preserve the blocks in the output file +over which \fIdd\fP seeks, but no other portion of the +output file shall be preserved. (If the size of the seek plus the +size of the input file is less than the previous size of the +output file, the output file shall be shortened by the copy.) +.TP 7 +\fBibs\fP=\fIexpr\fP +Specify the input block size, in bytes, by \fIexpr\fP (default is +512). +.TP 7 +\fBobs\fP=\fIexpr\fP +Specify the output block size, in bytes, by \fIexpr\fP (default is +512). +.TP 7 +\fBbs\fP=\fIexpr\fP +Set both input and output block sizes to \fIexpr\fP bytes, superseding +\fBibs\fP= and \fBobs\fP=. If no conversion other +than \fBsync\fP, \fBnoerror\fP, and \fBnotrunc\fP is specified, each +input block shall be copied to the output as a single block +without aggregating short blocks. +.TP 7 +\fBcbs\fP=\fIexpr\fP +Specify the conversion block size for \fBblock\fP and \fBunblock\fP +in bytes by \fIexpr\fP (default is zero). If \fBcbs\fP= +is omitted or given a value of zero, using \fBblock\fP or \fBunblock\fP +produces unspecified results. +.LP +The application shall ensure that this operand is also specified if +the \fBconv\fP= operand is specified with a value of +\fBascii\fP, \fBebcdic\fP, or \fBibm\fP. For a \fBconv\fP= operand +with an \fBascii\fP value, the input is handled as +described for the \fBunblock\fP value, except that characters are +converted to ASCII before any trailing <space>s are +deleted. For \fBconv\fP= operands with \fBebcdic\fP or \fBibm\fP values, +the input is handled as described for the \fBblock\fP +value except that the characters are converted to EBCDIC or IBM EBCDIC, +respectively, after any trailing <space>s are added. +.TP 7 +\fBskip\fP=\fIn\fP +Skip \fIn\fP input blocks (using the specified input block size) before +starting to copy. On seekable files, the +implementation shall read the blocks or seek past them; on non-seekable +files, the blocks shall be read and the data shall be +discarded. +.TP 7 +\fBseek\fP=\fIn\fP +Skip \fIn\fP blocks (using the specified output block size) from the +beginning of the output file before copying. On +non-seekable files, existing blocks shall be read and space from the +current end-of-file to the specified offset, if any, filled +with null bytes; on seekable files, the implementation shall seek +to the specified offset or read the blocks as described for +non-seekable files. +.TP 7 +\fBcount\fP=\fIn\fP +Copy only \fIn\fP input blocks. +.TP 7 +\fBconv\fP=\fIvalue\fP\fB[\fP,\fIvalue\fP\ ...\fB]\fP +.sp +Where \fIvalue\fPs are comma-separated symbols from the following +list: +.TP 7 +\fBascii\fP +.RS +Convert EBCDIC to ASCII; see ASCII to EBCDIC Conversion . +.RE +.TP 7 +\fBebcdic\fP +.RS +Convert ASCII to EBCDIC; see ASCII to EBCDIC Conversion . +.RE +.TP 7 +\fBibm\fP +.RS +Convert ASCII to a different EBCDIC set; see ASCII to IBM EBCDIC Conversion +\&. +.RE +.sp +.LP +The \fBascii\fP, \fBebcdic\fP, and \fBibm\fP values are mutually-exclusive. +.TP 7 +\fBblock\fP +.RS +Treat the input as a sequence of <newline>-terminated or end-of-file-terminated +variable-length records independent of +the input block boundaries. Each record shall be converted to a record +with a fixed length specified by the conversion block size. +Any <newline> shall be removed from the input line; <space>s shall +be appended to lines that are shorter than their +conversion block size to fill the block. Lines that are longer than +the conversion block size shall be truncated to the largest +number of characters that fit into that size; the number of truncated +lines shall be reported (see the STDERR section). +.LP +The \fBblock\fP and \fBunblock\fP values are mutually-exclusive. +.RE +.TP 7 +\fBunblock\fP +.RS +Convert fixed-length records to variable length. Read a number of +bytes equal to the conversion block size (or the number of +bytes remaining in the input, if less than the conversion block size), +delete all trailing <space>s, and append a +<newline>. +.RE +.TP 7 +\fBlcase\fP +.RS +Map uppercase characters specified by the \fILC_CTYPE\fP keyword \fBtolower\fP +to the corresponding lowercase character. +Characters for which no mapping is specified shall not be modified +by this conversion. +.LP +The \fBlcase\fP and \fBucase\fP symbols are mutually-exclusive. +.RE +.TP 7 +\fBucase\fP +.RS +Map lowercase characters specified by the \fILC_CTYPE\fP keyword \fBtoupper\fP +to the corresponding uppercase character. +Characters for which no mapping is specified shall not be modified +by this conversion. +.RE +.TP 7 +\fBswab\fP +.RS +Swap every pair of input bytes. +.RE +.TP 7 +\fBnoerror\fP +.RS +Do not stop processing on an input error. When an input error occurs, +a diagnostic message shall be written on standard error, +followed by the current input and output block counts in the same +format as used at completion (see the STDERR section). If the +\fBsync\fP conversion is specified, the missing input shall be replaced +with null bytes and processed normally; otherwise, the +input block shall be omitted from the output. +.RE +.TP 7 +\fBnotrunc\fP +.RS +Do not truncate the output file. Preserve blocks in the output file +not explicitly written by this invocation of the \fIdd\fP +utility. (See also the preceding \fBof\fP= \fIfile\fP operand.) +.RE +.TP 7 +\fBsync\fP +.RS +Pad every input block to the size of the \fBibs\fP= buffer, appending +null bytes. (If either \fBblock\fP or \fBunblock\fP is +also specified, append <space>s, rather than null bytes.) +.RE +.sp +.sp +.LP +The behavior is unspecified if operands other than \fBconv\fP= are +specified more than once. +.LP +For the \fBbs\fP=, \fBcbs\fP=, \fBibs\fP=, and \fBobs\fP= operands, +the application shall supply an expression specifying a +size in bytes. The expression, \fIexpr\fP, can be: +.IP " 1." 4 +A positive decimal number +.LP +.IP " 2." 4 +A positive decimal number followed by \fIk\fP, specifying multiplication +by 1024 +.LP +.IP " 3." 4 +A positive decimal number followed by \fIb\fP, specifying multiplication +by 512 +.LP +.IP " 4." 4 +Two or more positive decimal numbers (with or without \fIk\fP or \fIb\fP) +separated by \fIx\fP, specifying the product of the +indicated values +.LP +.LP +All of the operands are processed before any input is read. +.LP +The following two tables display the octal number character values +used for the \fBascii\fP and \fBebcdic\fP conversions (first +table) and for the \fBibm\fP conversion (second table). In both tables, +the ASCII values are the row and column headers and the +EBCDIC values are found at their intersections. For example, ASCII +0012 (LF) is the second row, third column, yielding 0045 in +EBCDIC. The inverted tables (for EBCDIC to ASCII conversion) are not +shown, but are in one-to-one correspondence with these tables. +The differences between the two tables are highlighted by small boxes +drawn around five entries. +.br +.sp +.ce 1 +\fBTable: ASCII to EBCDIC Conversion\fP +.sp +.sp +.ce 1 +\fBTable: ASCII to IBM EBCDIC Conversion\fP +.SH STDIN +.LP +If no \fBif\fP= operand is specified, the standard input shall be +used. See the INPUT FILES section. +.SH INPUT FILES +.LP +The input file can be any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIdd\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +classification of characters as uppercase or lowercase, and the +mapping of characters from one case to the other. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +For SIGINT, the \fIdd\fP utility shall interrupt its current processing, +write status information to standard error, and exit +as though terminated by SIGINT. It shall take the standard action +for all other signals; see the ASYNCHRONOUS EVENTS section in \fIUtility +Description Defaults\fP . +.SH STDOUT +.LP +If no \fBof\fP= operand is specified, the standard output shall be +used. The nature of the output depends on the operands +selected. +.SH STDERR +.LP +On completion, \fIdd\fP shall write the number of input and output +blocks to standard error. In the POSIX locale the following +formats shall be used: +.sp +.RS +.nf + +\fB"%u+%u records in\\n", <\fP\fInumber of whole input blocks\fP\fB>, + <\fP\fInumber of partial input blocks\fP\fB> +.sp + +"%u+%u records out\\n", <\fP\fInumber of whole output blocks\fP\fB>, + <\fP\fInumber of partial output blocks\fP\fB> +\fP +.fi +.RE +.LP +A partial input block is one for which \fIread\fP() returned less +than the input block +size. A partial output block is one that was written with fewer bytes +than specified by the output block size. +.LP +In addition, when there is at least one truncated block, the number +of truncated blocks shall be written to standard error. In +the POSIX locale, the format shall be: +.sp +.RS +.nf + +\fB"%u truncated %s\\n", <\fP\fInumber of truncated blocks\fP\fB>, "record" (if + <\fP\fInumber of truncated blocks\fP\fB> is one) "records" (otherwise) +\fP +.fi +.RE +.LP +Diagnostic messages may also be written to standard error. +.SH OUTPUT FILES +.LP +If the \fBof\fP= operand is used, the output shall be the same as +described in the STDOUT section. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The input file was copied successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If an input error is detected and the \fBnoerror\fP conversion has +not been specified, any partial output block shall be +written to the output file, a diagnostic message shall be written, +and the copy operation shall be discontinued. If some other +error is detected, a diagnostic message shall be written and the copy +operation shall be discontinued. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The input and output block size can be specified to take advantage +of raw physical I/O. +.LP +There are many different versions of the EBCDIC codesets. The ASCII +and EBCDIC conversions specified for the \fIdd\fP utility +perform conversions for the version specified by the tables. +.SH EXAMPLES +.LP +The following command: +.sp +.RS +.nf + +\fBdd if=/dev/rmt0h of=/dev/rmt1h +\fP +.fi +.RE +.LP +copies from tape drive 0 to tape drive 1, using a common historical +device naming convention. +.LP +The following command: +.sp +.RS +.nf + +\fBdd ibs=10 skip=1 +\fP +.fi +.RE +.LP +strips the first 10 bytes from standard input. +.LP +This example reads an EBCDIC tape blocked ten 80-byte EBCDIC card +images per block into the ASCII file \fBx\fP: +.sp +.RS +.nf + +\fBdd if=/dev/tape of=x ibs=800 cbs=80 conv=ascii,lcase +\fP +.fi +.RE +.SH RATIONALE +.LP +The OPTIONS section is listed as "None" because there are no options +recognized by historical \fIdd\fP utilities. Certainly, +many of the operands could have been designed to use the Utility Syntax +Guidelines, which would have resulted in the classic +hyphenated option letters. In this version of this volume of IEEE\ Std\ 1003.1-2001, +\fIdd\fP retains its curious JCL-like +syntax due to the large number of applications that depend on the +historical implementation. +.LP +A suggested implementation technique for \fBconv\fP= \fBnoerror\fP, +\fBsync\fP is to zero (or <space>-fill, if +\fBblock\fPing or \fBunblock\fPing) the input buffer before each read +and to write the contents of the input buffer to the output +even after an error. In this manner, any data transferred to the input +buffer before the error was detected is preserved. Another +point is that a failed read on a regular file or a disk generally +does not increment the file offset, and \fIdd\fP must then seek +past the block on which the error occurred; otherwise, the input error +occurs repetitively. When the input is a magnetic tape, +however, the tape normally has passed the block containing the error +when the error is reported, and thus no seek is necessary. +.LP +The default \fBibs\fP= and \fBobs\fP= sizes are specified as 512 bytes +because there are historical (largely portable) scripts +that assume these values. If they were left unspecified, unusual results +could occur if an implementation chose an odd block +size. +.LP +Historical implementations of \fIdd\fP used \fIcreat\fP() when processing +\fBof\fP= +\fIfile\fP. This makes the \fBseek\fP= operand unusable except on +special files. The \fBconv\fP= \fBnotrunc\fP feature was +added because more recent BSD-based implementations use \fIopen\fP() +(without O_TRUNC) +instead of \fIcreat\fP(), but they fail to delete output file contents +after the data +copied. +.LP +The \fIw\fP multiplier (historically meaning \fIword\fP), is used +in System V to mean 2 and in 4.2 BSD to mean 4. Since +\fIword\fP is inherently non-portable, its use is not supported by +this volume of IEEE\ Std\ 1003.1-2001. +.LP +Standard EBCDIC does not have the characters \fB'['\fP and \fB']'\fP +\&. The values used in the table are taken from a +common print train that does contain them. Other than those characters, +the print train values are not filled in, but appear to +provide some of the motivation for the historical choice of translations +reflected here. +.LP +The Standard EBCDIC table provides a 1:1 translation for all 256 bytes. +.LP +The IBM EBCDIC table does not provide such a translation. The marked +cells in the tables differ in such a way that: +.IP " 1." 4 +EBCDIC 0112 ( \fB'cent'\fP ) and 0152 (broken pipe) do not appear +in the table. +.LP +.IP " 2." 4 +EBCDIC 0137 ( \fB'not'\fP ) translates to/from ASCII 0236 ( \fB'^'\fP +). In the standard table, EBCDIC 0232 (no graphic) +is used. +.LP +.IP " 3." 4 +EBCDIC 0241 ( \fB'~'\fP ) translates to/from ASCII 0176 ( \fB'~'\fP +). In the standard table, EBCDIC 0137 ( +\fB'not'\fP ) is used. +.LP +.IP " 4." 4 +0255 ( \fB'['\fP ) and 0275 ( \fB']'\fP ) appear twice, once in the +same place as for the standard table and once in place +of 0112 ( \fB'cent'\fP ) and 0241 ( \fB'~'\fP ). +.LP +.LP +In net result: +EBCDIC 0275 ( \fB']'\fP ) displaced EBCDIC 0241 ( \fB'~'\fP ) in cell +0345. +.LP +\ \ \ \ That displaced EBCDIC 0137 ( \fB'not'\fP ) in cell 0176. +.LP +\ \ \ \ That displaced EBCDIC 0232 (no graphic) in cell 0136. +.LP +\ \ \ \ That replaced EBCDIC 0152 (broken pipe) in cell 0313. +.LP +EBCDIC 0255 ( \fB'['\fP ) replaced EBCDIC 0112 ( \fB'cent'\fP ). +.LP +This translation, however, reflects historical practice that (ASCII) +\fB'~'\fP and \fB'not'\fP were often mapped to +each other, as were \fB'['\fP and \fB'cent'\fP ; and \fB']'\fP and +(EBCDIC) \fB'~'\fP . +.LP +The \fBcbs\fP operand is required if any of the \fBascii\fP, \fBebcdic\fP, +or \fBibm\fP operands are specified. For the +\fBascii\fP operand, the input is handled as described for the \fBunblock\fP +operand except that characters are converted to +ASCII before the trailing <space>s are deleted. For the \fBebcdic\fP +and \fBibm\fP operands, the input is handled as +described for the \fBblock\fP operand except that the characters are +converted to EBCDIC or IBM EBCDIC after the trailing +<space>s are added. +.LP +The \fBblock\fP and \fBunblock\fP keywords are from historical BSD +practice. +.LP +The consistent use of the word \fBrecord\fP in standard error messages +matches most historical practice. An earlier version of +System V used \fBblock\fP, but this has been updated in more recent +releases. +.LP +Early proposals only allowed two numbers separated by \fBx\fP to be +used in a product when specifying \fBbs\fP=, \fBcbs\fP=, +\fBibs\fP=, and \fBobs\fP= sizes. This was changed to reflect the +historical practice of allowing multiple numbers in the product +as provided by Version 7 and all releases of System V and BSD. +.LP +A change to the \fBswab\fP conversion is required to match historical +practice and is the result of IEEE PASC Interpretations +1003.2 #03 and #04, submitted for the ISO\ POSIX-2:1993 standard. +.LP +A change to the handling of SIGINT is required to match historical +practice and is the result of IEEE PASC Interpretation 1003.2 +#06 submitted for the ISO\ POSIX-2:1993 standard. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIUtility Description Defaults\fP , \fIsed\fP , \fItr\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/delta.1p b/man1p/delta.1p new file mode 100644 index 000000000..3863f282b --- /dev/null +++ b/man1p/delta.1p @@ -0,0 +1,272 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DELTA" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" delta +.SH NAME +delta \- make a delta (change) to an SCCS file (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBdelta\fP \fB[\fP\fB-nps\fP\fB][\fP\fB-g\fP \fIlist\fP\fB][\fP\fB-m\fP +\fImrlist\fP\fB][\fP\fB-r\fP \fISID\fP\fB][\fP\fB-y\fP\fB[\fP\fIcomment\fP\fB]]\fP +\fIfile\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIdelta\fP utility shall be used to permanently introduce into +the named SCCS files changes that were made to the files +retrieved by \fIget\fP (called the \fIg-files\fP, or generated files). +.SH OPTIONS +.LP +The \fIdelta\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the \fB-y\fP option has an +optional option-argument. This optional option-argument shall not +be presented as a separate argument. +.LP +The following options shall be supported: +.TP 7 +\fB-r\ \fP \fISID\fP +Uniquely identify which delta is to be made to the SCCS file. The +use of this option shall be necessary only if two or more +outstanding \fIget\fP commands for editing ( \fIget\fP +\fB-e\fP) on the same SCCS file were done by the same person (login +name). The SID value specified with the \fB-r\fP option can +be either the SID specified on the \fIget\fP command line or the SID +to be made as reported by +the \fIget\fP utility; see \fIget\fP . +.TP 7 +\fB-s\fP +Suppress the report to standard output of the activity associated +with each \fIfile\fP. See the STDOUT section. +.TP 7 +\fB-n\fP +Specify retention of the edited \fIg-file\fP (normally removed at +completion of delta processing). +.TP 7 +\fB-g\ \fP \fIlist\fP +Specify a \fIlist\fP (see \fIget\fP for the definition of \fIlist\fP) +of deltas that shall be ignored +when the file is accessed at the change level (SID) created by this +delta. +.TP 7 +\fB-m\ \fP \fImrlist\fP +Specify a modification request (MR) number that the application shall +supply as the reason for creating the new delta. This +shall be used if the SCCS file has the \fBv\fP flag set; see \fIadmin\fP +\&. +.LP +If \fB-m\fP is not used and \fB'-'\fP is not specified as a file argument, +and the standard input is a terminal, the prompt +described in the STDOUT section shall be written to standard output +before the standard input is read; if the standard input is not +a terminal, no prompt shall be issued. +.LP +MRs in a list shall be separated by <blank>s or escaped <newline>s. +An unescaped <newline> shall terminate the +MR list. The escape character is <backslash>. +.LP +If the \fBv\fP flag has a value, it shall be taken to be the name +of a program which validates the correctness of the MR +numbers. If a non-zero exit status is returned from the MR number +validation program, the \fIdelta\fP utility shall terminate. (It +is assumed that the MR numbers were not all valid.) +.TP 7 +\fB-y[\fP\fIcomment\fP\fB]\fP +Describe the reason for making the delta. The \fIcomment\fP shall +be an arbitrary group of lines that would meet the +definition of a text file. Implementations shall support \fIcomment\fPs +from zero to 512 bytes and may support longer values. A +null string (specified as either \fB-y\fP, \fB-y\fP \fB""\fP , or +in response to a prompt for a comment) shall be considered a +valid \fIcomment\fP. +.LP +If \fB-y\fP is not specified and \fB'-'\fP is not specified as a file +argument, and the standard input is a terminal, the +prompt described in the STDOUT section shall be written to standard +output before the standard input is read; if the standard input +is not a terminal, no prompt shall be issued. An unescaped <newline> +shall terminate the comment text. The escape character +is <backslash>. +.LP +The \fB-y\fP option shall be required if the \fIfile\fP operand is +specified as \fB'-'\fP . +.TP 7 +\fB-p\fP +Write (to standard output) the SCCS file differences before and after +the delta is applied in \fIdiff\fP format; see \fIdiff\fP . +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file or a directory. If \fIfile\fP +is a directory, the \fIdelta\fP utility shall behave as +though each file in the directory were specified as a named file, +except that non-SCCS files (last component of the pathname does +not begin with \fBs.\fP) and unreadable files shall be silently ignored. +.LP +If exactly one \fIfile\fP operand appears, and it is \fB'-'\fP , the +standard input shall be read; each line of the standard +input shall be taken to be the name of an SCCS file to be processed. +Non-SCCS files and unreadable files shall be silently +ignored. +.sp +.SH STDIN +.LP +The standard input shall be a text file used only in the following +cases: +.IP " *" 3 +To read an \fImrlist\fP or a \fIcomment\fP (see the \fB-m\fP and \fB-y\fP +options). +.LP +.IP " *" 3 +A \fIfile\fP operand shall be specified as \fB'-'\fP . In this case, +the \fB-y\fP option must be used to specify the +comment, and if the SCCS file has the \fBv\fP flag set, the \fB-m\fP +option must also be used to specify the MR list. +.LP +.SH INPUT FILES +.LP +Input files shall be text files whose data is to be included in the +SCCS files. If the first character of any line of an input +file is <SOH> in the POSIX locale, the results are unspecified. If +this file contains more than 99999 lines, the number of +lines recorded in the header for this file shall be 99999 for this +delta. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIdelta\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error, +and informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone in which the time and date are written in the +SCCS file. If the \fITZ\fP variable is unset or NULL, an +unspecified system default timezone is used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +If SIGINT is caught, temporary files shall be cleaned up and \fIdelta\fP +shall exit with a non-zero exit code. The standard +action shall be taken for all other signals; see \fIUtility Description +Defaults\fP . +.SH STDOUT +.LP +The standard output shall be used only for the following messages +in the POSIX locale: +.IP " *" 3 +Prompts (see the \fB-m\fP and \fB-y\fP options) in the following formats: +.sp +.RS +.nf + +\fB"MRs? " +.sp + +"comments? " +\fP +.fi +.RE +.LP +The MR prompt, if written, shall always precede the comments prompt. +.LP +.IP " *" 3 +A report of each file's activities (unless the \fB-s\fP option is +specified) in the following format: +.sp +.RS +.nf + +\fB"%s\\n%d inserted\\n%d deleted\\n%d unchanged\\n", <\fP\fINew SID\fP\fB>, + <\fP\fInumber of lines inserted\fP\fB>, <\fP\fInumber of lines deleted\fP\fB>, + <\fP\fInumber of lines unchanged\fP\fB> +\fP +.fi +.RE +.LP +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Any SCCS files updated shall be files of an unspecified format. +.SH EXTENDED DESCRIPTION +.SS System Date and Time +.LP +When a delta is added to an SCCS file, the system date and time shall +be recorded for the new delta. If a \fIget\fP is performed using an +SCCS file with a date recorded apparently in the future, the behavior +is unspecified. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Problems can arise if the system date and time have been modified +(for example, put forward and then back again, or +unsynchronized clocks across a network) and can also arise when different +values of the \fITZ\fP environment variable are +used. +.LP +Problems of a similar nature can also arise for the operation of the +\fIget\fP utility, +which records the date and time in the file body. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIUtility Description Defaults\fP , \fIadmin\fP , \fIdiff\fP , \fIget\fP +, \fIprs\fP , \fIrmdel\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/df.1p b/man1p/df.1p new file mode 100644 index 000000000..fb283d0c3 --- /dev/null +++ b/man1p/df.1p @@ -0,0 +1,296 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DF" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" df +.SH NAME +df \- report free disk space +.SH SYNOPSIS +.LP +\fBdf\fP \fB[\fP\fB-k\fP\fB][\fP\fB-P|-t\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIdf\fP utility shall write the amount of available space \ and +file slots for file systems on which the invoking user has appropriate +read access. File systems shall be specified +by the \fIfile\fP operands; when none are specified, information shall +be written for all file systems. The format of the default +output from \fIdf\fP is unspecified, but all space figures are reported +in 512-byte units, unless the \fB-k\fP option is +specified. This output shall contain at least the file system names, +amount of available space on each of these file systems, +\ and the number of free file slots, or \fIinodes\fP, available; when +\fB-t\fP is specified, the output shall contain the +total allocated space as well. +.SH OPTIONS +.LP +The \fIdf\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-k\fP +Use 1024-byte units, instead of the default 512-byte units, when writing +space figures. +.TP 7 +\fB-P\fP +Produce output in the format described in the STDOUT section. +.TP 7 +\fB-t\fP +Include total allocated-space figures in the output. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file within the hierarchy of the desired file system. +If a file other than a FIFO, a regular file, a directory, +\ or a special file representing the device containing the file system +(for example, \fB/dev/dsk/0s1\fP) is specified, the results are unspecified. +Otherwise, \fIdf\fP shall write +the amount of free space in the file system containing the specified +\fIfile\fP operand. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIdf\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When both the \fB-k\fP and \fB-P\fP options are specified, the following +header line shall be written (in the POSIX +locale): +.sp +.RS +.nf + +\fB"Filesystem 1024-blocks Used Available Capacity Mounted on\\n" +\fP +.fi +.RE +.LP +When the \fB-P\fP option is specified without the \fB-k\fP option, +the following header line shall be written (in the POSIX +locale): +.sp +.RS +.nf + +\fB"Filesystem 512-blocks Used Available Capacity Mounted on\\n" +\fP +.fi +.RE +.LP +The implementation may adjust the spacing of the header line and the +individual data lines so that the information is presented +in orderly columns. +.LP +The remaining output with \fB-P\fP shall consist of one line of information +for each specified file system. These lines shall +be formatted as follows: +.sp +.RS +.nf + +\fB"%s %d %d %d %d%% %s\\n", <\fP\fIfile system name\fP\fB>, <\fP\fItotal space\fP\fB>, + <\fP\fIspace used\fP\fB>, <\fP\fIspace free\fP\fB>, <\fP\fIpercentage used\fP\fB>, + <\fP\fIfile system root\fP\fB> +\fP +.fi +.RE +.LP +In the following list, all quantities expressed in 512-byte units +(1024-byte when \fB-k\fP is specified) shall be rounded up to +the next higher unit. The fields are: +.TP 7 +<\fIfile\ system\ name\fP> +.sp +The name of the file system, in an implementation-defined format. +.TP 7 +<\fItotal\ space\fP> +The total size of the file system in 512-byte units. The exact meaning +of this figure is implementation-defined, but should +include <\fIspace\ used\fP>, <\fIspace\ free\fP>, plus any space reserved +by the system not normally +available to a user. +.TP 7 +<\fIspace\ used\fP> +The total amount of space allocated to existing files in the file +system, in 512-byte units. +.TP 7 +<\fIspace\ free\fP> +The total amount of space available within the file system for the +creation of new files by unprivileged users, in 512-byte +units. When this figure is less than or equal to zero, it shall not +be possible to create any new files on the file system without +first deleting others, unless the process has appropriate privileges. +The figure written may be less than zero. +.TP 7 +<\fIpercentage\ used\fP> +.sp +The percentage of the normally available space that is currently allocated +to all files on the file system. This shall be +calculated using the fraction: +.sp +.RS +.nf + +\fB<\fP\fIspace used\fP\fB>/( <\fP\fIspace used\fP\fB>+ <\fP\fIspace free\fP\fB>) +\fP +.fi +.RE +.LP +expressed as a percentage. This percentage may be greater than 100 +if <\fIspace\ free\fP> is less than zero. The +percentage value shall be expressed as a positive integer, with any +fractional result causing it to be rounded to the next highest +integer. +.TP 7 +<\fIfile\ system\ root\fP> +.sp +The directory below which the file system hierarchy appears. +.sp +.LP +The output format is unspecified when \fB-t\fP is used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +On most systems, the "name of the file system, in an implementation-defined +format" is the special file on which the file +system is mounted. +.LP +On large file systems, the calculation specified for percentage used +can create huge rounding errors. +.SH EXAMPLES +.IP " 1." 4 +The following example writes portable information about the \fB/usr\fP +file system: +.sp +.RS +.nf + +\fBdf -P /usr +\fP +.fi +.RE +.LP +.IP " 2." 4 +Assuming that \fB/usr/src\fP is part of the \fB/usr\fP file system, +the following produces the same output as the previous +example: +.sp +.RS +.nf + +\fBdf -P /usr/src +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The behavior of \fIdf\fP with the \fB-P\fP option is the default action +of the 4.2 BSD \fIdf\fP utility. The uppercase +\fB-P\fP was selected to avoid collision with a known industry extension +using \fB-p\fP. +.LP +Historical \fIdf\fP implementations vary considerably in their default +output. It was therefore necessary to describe the +default output in a loose manner to accommodate all known historical +implementations and to add a portable option ( \fB-P\fP) to +provide information in a portable format. +.LP +The use of 512-byte units is historical practice and maintains compatibility +with \fIls\fP +and other utilities in this volume of IEEE\ Std\ 1003.1-2001. This +does not mandate that the file system itself be based on +512-byte blocks. The \fB-k\fP option was added as a compromise measure. +It was agreed by the standard developers that 512 bytes +was the best default unit because of its complete historical consistency +on System V (\fIversus\fP the mixed 512/1024-byte usage +on BSD systems), and that a \fB-k\fP option to switch to 1024-byte +units was a good compromise. Users who prefer the more logical +1024-byte quantity can easily alias \fIdf\fP to \fIdf\fP \fB-k\fP +without breaking many historical scripts relying on the +512-byte units. +.LP +It was suggested that \fIdf\fP and the various related utilities be +modified to access a \fIBLOCKSIZE\fP environment variable +to achieve consistency and user acceptance. Since this is not historical +practice on any system, it is left as a possible area for +system extensions and will be re-evaluated in a future version if +it is widely implemented. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIfind\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/diff.1p b/man1p/diff.1p new file mode 100644 index 000000000..27598b9ab --- /dev/null +++ b/man1p/diff.1p @@ -0,0 +1,646 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DIFF" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" diff +.SH NAME +diff \- compare two files +.SH SYNOPSIS +.LP +\fBdiff\fP \fB[\fP\fB-c| -e| -f| -C\fP \fIn\fP\fB][\fP\fB-br\fP\fB]\fP +\fIfile1 file2\fP +.SH DESCRIPTION +.LP +The \fIdiff\fP utility shall compare the contents of \fIfile1\fP and +\fIfile2\fP and write to standard output a list of +changes necessary to convert \fIfile1\fP into \fIfile2\fP. This list +should be minimal. No output shall be produced if the files +are identical. +.SH OPTIONS +.LP +The \fIdiff\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-b\fP +Cause any amount of white space at the end of a line to be treated +as a single <newline> (that is, the white-space +characters preceding the <newline> are ignored) and other strings +of white-space characters, not including <newline>s, +to compare equal. +.TP 7 +\fB-c\fP +Produce output in a form that provides three lines of context. +.TP 7 +\fB-C\ n\fP +Produce output in a form that provides \fIn\fP lines of context (where +\fIn\fP shall be interpreted as a positive decimal +integer). +.TP 7 +\fB-e\fP +Produce output in a form suitable as input for the \fIed\fP utility, +which can then be used +to convert \fIfile1\fP into \fIfile2\fP. +.TP 7 +\fB-f\fP +Produce output in an alternative form, similar in format to \fB-e\fP, +but not intended to be suitable as input for the \fIed\fP utility, +and in the opposite order. +.TP 7 +\fB-r\fP +Apply \fIdiff\fP recursively to files and directories of the same +name when \fIfile1\fP and \fIfile2\fP are both +directories. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile1\fP,\ \fIfile2\fP +A pathname of a file to be compared. If either the \fIfile1\fP or +\fIfile2\fP operand is \fB'-'\fP , the standard input +shall be used in its place. +.sp +.LP +If both \fIfile1\fP and \fIfile2\fP are directories, \fIdiff\fP shall +not compare block special files, character special +files, or FIFO special files to any files and shall not compare regular +files to directories. Further details are as specified in +Diff Directory Comparison Format . The behavior of \fIdiff\fP on other +file types is +implementation-defined when found in directories. +.LP +If only one of \fIfile1\fP and \fIfile2\fP is a directory, \fIdiff\fP +shall be applied to the non-directory file and the file +contained in the directory file with a filename that is the same as +the last component of the non-directory file. +.SH STDIN +.LP +The standard input shall be used only if one of the \fIfile1\fP or +\fIfile2\fP operands references standard input. See the +INPUT FILES section. +.SH INPUT FILES +.LP +The input files may be of any type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIdiff\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fILC_TIME\fP +Determine the locale for affecting the format of file timestamps written +with the \fB-C\fP and \fB-c\fP options. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone used for calculating file timestamps written +with the \fB-C\fP and \fB-c\fP options. If \fITZ\fP is +unset or null, an unspecified default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.SS Diff Directory Comparison Format +.LP +If both \fIfile1\fP and \fIfile2\fP are directories, the following +output formats shall be used. +.LP +In the POSIX locale, each file that is present in only one directory +shall be reported using the following format: +.sp +.RS +.nf + +\fB"Only in %s: %s\\n", <\fP\fIdirectory pathname\fP\fB>, <\fP\fIfilename\fP\fB> +\fP +.fi +.RE +.LP +In the POSIX locale, subdirectories that are common to the two directories +may be reported with the following format: +.sp +.RS +.nf + +\fB"Common subdirectories: %s and %s\\n", <\fP\fIdirectory1 pathname\fP\fB>, + <\fP\fIdirectory2 pathname\fP\fB> +\fP +.fi +.RE +.LP +For each file common to the two directories if the two files are not +to be compared, the following format shall be used in the +POSIX locale: +.sp +.RS +.nf + +\fB"File %s is a %s while file %s is a %s\\n", <\fP\fIdirectory1 pathname\fP\fB>, + <\fP\fIfile type of directory1 pathname\fP\fB>, <\fP\fIdirectory2 pathname\fP\fB>, + <\fP\fIfile type of directory2 pathname\fP\fB> +\fP +.fi +.RE +.LP +For each file common to the two directories, if the files are compared +and are identical, no output shall be written. If the two +files differ, the following format is written: +.sp +.RS +.nf + +\fB"diff %s %s %s\\n", <\fP\fIdiff_options\fP\fB>, <\fP\fIfilename1\fP\fB>, <\fP\fIfilename2\fP\fB> +\fP +.fi +.RE +.LP +where <\fIdiff_options\fP> are the options as specified on the command +line. +.LP +All directory pathnames listed in this section shall be relative to +the original command line arguments. All other names of +files listed in this section shall be filenames (pathname components). +.SS Diff Binary Output Format +.LP +In the POSIX locale, if one or both of the files being compared are +not text files, an unspecified format shall be used that +contains the pathnames of two files being compared and the string +\fB"differ"\fP . +.LP +If both files being compared are text files, depending on the options +specified, one of the following formats shall be used to +write the differences. +.SS Diff Default Output Format +.LP +The default (without \fB-e\fP, \fB-f\fP, \fB-c\fP, or \fB-C\fP options) +\fIdiff\fP utility output shall contain lines of +these forms: +.sp +.RS +.nf + +\fB"%da%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB> +.sp + +"%da%d,%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB>, <\fP\fInum3\fP\fB> +.sp + +"%dd%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB> +.sp + +"%d,%dd%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB>, <\fP\fInum3\fP\fB> +.sp + +"%dc%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB> +.sp + +"%d,%dc%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB>, <\fP\fInum3\fP\fB> +.sp + +"%dc%d,%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB>, <\fP\fInum3\fP\fB> +.sp + +"%d,%dc%d,%d\\n", <\fP\fInum1\fP\fB>, <\fP\fInum2\fP\fB>, <\fP\fInum3\fP\fB>, <\fP\fInum4\fP\fB> +\fP +.fi +.RE +.LP +These lines resemble \fIed\fP subcommands to convert \fIfile1\fP into +\fIfile2\fP. The +line numbers before the action letters shall pertain to \fIfile1\fP; +those after shall pertain to \fIfile2\fP. Thus, by +exchanging \fIa\fP for \fId\fP and reading the line in reverse order, +one can also determine how to convert \fIfile2\fP into +\fIfile1\fP. As in \fIed\fP, identical pairs (where \fInum1\fP= \fInum2\fP) +are abbreviated +as a single number. +.LP +Following each of these lines, \fIdiff\fP shall write to standard +output all lines affected in the first file using the +format: +.sp +.RS +.nf + +\fB"< %s", <\fP\fIline\fP\fB> +\fP +.fi +.RE +.LP +and all lines affected in the second file using the format: +.sp +.RS +.nf + +\fB"> %s", <\fP\fIline\fP\fB> +\fP +.fi +.RE +.LP +If there are lines affected in both \fIfile1\fP and \fIfile2\fP (as +with the \fBc\fP subcommand), the changes are separated +with a line consisting of three hyphens: +.sp +.RS +.nf + +\fB"---\\n" +\fP +.fi +.RE +.SS Diff -e Output Format +.LP +With the \fB-e\fP option, a script shall be produced that shall, when +provided as input to \fIed\fP, along with an appended \fBw\fP (write) +command, convert \fIfile1\fP into \fIfile2\fP. Only +the \fBa\fP (append), \fBc\fP (change), \fBd\fP (delete), \fBi\fP +(insert), and \fBs\fP (substitute) commands of \fIed\fP shall be used +in this script. Text lines, except those consisting of the single +character +period ( \fB'.'\fP ), shall be output as they appear in the file. +.SS Diff -f Output Format +.LP +With the \fB-f\fP option, an alternative format of script shall be +produced. It is similar to that produced by \fB-e\fP, with +the following differences: +.IP " 1." 4 +It is expressed in reverse sequence; the output of \fB-e\fP orders +changes from the end of the file to the beginning; the +\fB-f\fP from beginning to end. +.LP +.IP " 2." 4 +The command form <\fIlines\fP> <\fIcommand-letter\fP> used by \fB-e\fP +is reversed. For example, 10\fIc\fP with +\fB-e\fP would be \fIc\fP10 with \fB-f\fP. +.LP +.IP " 3." 4 +The form used for ranges of line numbers is <space>-separated, rather +than comma-separated. +.LP +.SS Diff -c or -C Output Format +.LP +With the \fB-c\fP or \fB-C\fP option, the output format shall consist +of affected lines along with surrounding lines of +context. The affected lines shall show which ones need to be deleted +or changed in \fIfile1\fP, and those added from \fIfile2\fP. +With the \fB-c\fP option, three lines of context, if available, shall +be written before and after the affected lines. With the +\fB-C\fP option, the user can specify how many lines of context are +written. The exact format follows. +.LP +The name and last modification time of each file shall be output in +the following format: +.sp +.RS +.nf + +\fB"*** %s %s\\n",\fP \fIfile1\fP\fB, <\fP\fIfile1 timestamp\fP\fB> +"--- %s %s\\n",\fP \fIfile2\fP\fB, <\fP\fIfile2 timestamp\fP\fB> +\fP +.fi +.RE +.LP +Each <\fIfile\fP> field shall be the pathname of the corresponding +file being compared. The pathname written for standard +input is unspecified. +.LP +In the POSIX locale, each <\fItimestamp\fP> field shall be equivalent +to the output from the following command: +.sp +.RS +.nf + +\fBdate "+%a %b %e %T %Y" +\fP +.fi +.RE +.LP +without the trailing <newline>, executed at the time of last modification +of the corresponding file (or the current time, +if the file is standard input). +.LP +Then, the following output formats shall be applied for every set +of changes. +.LP +First, a line shall be written in the following format: +.sp +.RS +.nf + +\fB"***************\\n" +\fP +.fi +.RE +.LP +Next, the range of lines in \fIfile1\fP shall be written in the following +format if the range contains two or more lines: +.sp +.RS +.nf + +\fB"*** %d,%d ****\\n", <\fP\fIbeginning line number\fP\fB>, <\fP\fIending line number\fP\fB> +\fP +.fi +.RE +.LP +and the following format otherwise: +.sp +.RS +.nf + +\fB"*** %d ****\\n", <\fP\fIending line number\fP\fB> +\fP +.fi +.RE +.LP +The ending line number of an empty range shall be the number of the +preceding line, or 0 if the range is at the start of the +file. +.LP +Next, the affected lines along with lines of context (unaffected lines) +shall be written. Unaffected lines shall be written in +the following format: +.sp +.RS +.nf + +\fB" %s", <\fP\fIunaffected_line\fP\fB> +\fP +.fi +.RE +.LP +Deleted lines shall be written as: +.sp +.RS +.nf + +\fB"- %s", <\fP\fIdeleted_line\fP\fB> +\fP +.fi +.RE +.LP +Changed lines shall be written as: +.sp +.RS +.nf + +\fB"! %s", <\fP\fIchanged_line\fP\fB> +\fP +.fi +.RE +.LP +Next, the range of lines in \fIfile2\fP shall be written in the following +format if the range contains two or more lines: +.sp +.RS +.nf + +\fB"--- %d,%d ----\\n", <\fP\fIbeginning line number\fP\fB>, <\fP\fIending line number\fP\fB> +\fP +.fi +.RE +.LP +and the following format otherwise: +.sp +.RS +.nf + +\fB"--- %d ----\\n", <\fP\fIending line number\fP\fB> +\fP +.fi +.RE +.LP +Then, lines of context and changed lines shall be written as described +in the previous formats. Lines added from \fIfile2\fP +shall be written in the following format: +.sp +.RS +.nf + +\fB"+ %s", <\fP\fIadded_line\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +No differences were found. +.TP 7 +\ 1 +Differences were found. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +If lines at the end of a file are changed and other lines are added, +\fIdiff\fP output may show this as a delete and add, as a +change, or as a change and add; \fIdiff\fP is not expected to know +which happened and users should not care about the difference +in output as long as it clearly shows the differences between the +files. +.SH EXAMPLES +.LP +If \fBdir1\fP is a directory containing a directory named \fBx\fP, +\fBdir2\fP is a directory containing a directory named +\fBx\fP, \fBdir1/x\fP and \fBdir2/x\fP both contain files named \fBdate.out\fP, +and \fBdir2/x\fP contains a file named +\fBy\fP, the command: +.sp +.RS +.nf + +\fBdiff -r dir1 dir2 +\fP +.fi +.RE +.LP +could produce output similar to: +.sp +.RS +.nf + +\fBCommon subdirectories: dir1/x and dir2/x +Only in dir2/x: y +diff -r dir1/x/date.out dir2/x/date.out +1c1 +< Mon Jul 2 13:12:16 PDT 1990 +--- +> Tue Jun 19 21:41:39 PDT 1990 +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fB-h\fP option was omitted because it was insufficiently specified +and does not add to applications portability. +.LP +Historical implementations employ algorithms that do not always produce +a minimum list of differences; the current language +about making every effort is the best this volume of IEEE\ Std\ 1003.1-2001 +can do, as there is no metric that could be +employed to judge the quality of implementations against any and all +file contents. The statement "This list should be minimal'' +clearly implies that implementations are not expected to provide the +following output when comparing two 100-line files that differ +in only one character on a single line: +.sp +.RS +.nf + +\fB1,100c1,100 +all 100 lines from file1 preceded with "< " +--- +all 100 lines from file2 preceded with "> " +\fP +.fi +.RE +.LP +The "Only in" messages required when the \fB-r\fP option is specified +are not used by most historical implementations if the +\fB-e\fP option is also specified. It is required here because it +provides useful information that must be provided to update a +target directory hierarchy to match a source hierarchy. The "Common +subdirectories" messages are written by System V and 4.3 BSD +when the \fB-r\fP option is specified. They are allowed here but are +not required because they are reporting on something that is +the same, not reporting a difference, and are not needed to update +a target hierarchy. +.LP +The \fB-c\fP option, which writes output in a format using lines of +context, has been included. The format is useful for a +variety of reasons, among them being much improved readability and +the ability to understand difference changes when the target +file has line numbers that differ from another similar, but slightly +different, copy. The \fIpatch\fP utility is most valuable when working +with difference listings using the context format. +The BSD version of \fB-c\fP takes an optional argument specifying +the amount of context. Rather than overloading \fB-c\fP and +breaking the Utility Syntax Guidelines for \fIdiff\fP, the standard +developers decided to add a separate option for specifying a +context diff with a specified amount of context ( \fB-C\fP). Also, +the format for context \fIdiff\fPs was extended slightly in +4.3 BSD to allow multiple changes that are within context lines from +each other to be merged together. The output format contains +an additional four asterisks after the range of affected lines in +the first filename. This was to provide a flag for old programs +(like old versions of \fIpatch\fP) that only understand the old context +format. The version +of context described here does not require that multiple changes within +context lines be merged, but it does not prohibit it +either. The extension is upwards-compatible, so any vendors that wish +to retain the old version of \fIdiff\fP can do so by adding +the extra four asterisks (that is, utilities that currently use \fIdiff\fP +and understand the new merged format will also +understand the old unmerged format, but not \fIvice versa\fP). +.LP +The substitute command was added as an additional format for the \fB-e\fP +option. This was added to provide implementations +with a way to fix the classic "dot alone on a line" bug present in +many versions of \fIdiff\fP. Since many implementations have +fixed this bug, the standard developers decided not to standardize +broken behavior, but rather to provide the necessary tool for +fixing the bug. One way to fix this bug is to output two periods whenever +a lone period is needed, then terminate the append +command with a period, and then use the substitute command to convert +the two periods into one period. +.LP +The BSD-derived \fB-r\fP option was added to provide a mechanism for +using \fIdiff\fP to compare two file system trees. This +behavior is useful, is standard practice on all BSD-derived systems, +and is not easily reproducible with the \fIfind\fP utility. +.LP +The requirement that \fIdiff\fP not compare files in some circumstances, +even though they have the same name, is based on the +actual output of historical implementations. The message specified +here is already in use when a directory is being compared to a +non-directory. It is extended here to preclude the problems arising +from running into FIFOs and other files that would cause +\fIdiff\fP to hang waiting for input with no indication to the user +that \fIdiff\fP was hung. In most common usage, \fIdiff\fP +\fB-r\fP should indicate differences in the file hierarchies, not +the difference of contents of devices pointed to by the +hierarchies. +.LP +Many early implementations of \fIdiff\fP require seekable files. Since +the System Interfaces volume of +IEEE\ Std\ 1003.1-2001 supports named pipes, the standard developers +decided that such a restriction was unreasonable. Note +also that the allowed filename \fB-\fP almost always refers to a pipe. +.LP +No directory search order is specified for \fIdiff\fP. The historical +ordering is, in fact, not optimal, in that it prints out +all of the differences at the current level, including the statements +about all common subdirectories before recursing into those +subdirectories. +.LP +The message: +.sp +.RS +.nf + +\fB"diff %s %s %s\\n", <\fP\fIdiff_options\fP\fB>, <\fP\fIfilename1\fP\fB>, <\fP\fIfilename2\fP\fB> +\fP +.fi +.RE +.LP +does not vary by locale because it is the representation of a command, +not an English sentence. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcmp\fP , \fIcomm\fP , \fIed\fP , \fIfind\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/dirname.1p b/man1p/dirname.1p new file mode 100644 index 000000000..3b4b292ce --- /dev/null +++ b/man1p/dirname.1p @@ -0,0 +1,214 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DIRNAME" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" dirname +.SH NAME +dirname \- return the directory portion of a pathname +.SH SYNOPSIS +.LP +\fBdirname\fP \fIstring\fP +.SH DESCRIPTION +.LP +The \fIstring\fP operand shall be treated as a pathname, as defined +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 3.266, Pathname. The string +\fIstring\fP shall be converted to the name of the directory containing +the filename corresponding to the last pathname component +in \fIstring\fP, performing actions equivalent to the following steps +in order: +.IP " 1." 4 +If \fIstring\fP is \fB//\fP, skip steps 2 to 5. +.LP +.IP " 2." 4 +If \fIstring\fP consists entirely of slash characters, \fIstring\fP +shall be set to a single slash character. In this case, +skip steps 3 to 8. +.LP +.IP " 3." 4 +If there are any trailing slash characters in \fIstring\fP, they shall +be removed. +.LP +.IP " 4." 4 +If there are no slash characters remaining in \fIstring\fP, \fIstring\fP +shall be set to a single period character. In this +case, skip steps 5 to 8. +.LP +.IP " 5." 4 +If there are any trailing non-slash characters in \fIstring\fP, they +shall be removed. +.LP +.IP " 6." 4 +If the remaining \fIstring\fP is \fB//\fP, it is implementation-defined +whether steps 7 and 8 are skipped or processed. +.LP +.IP " 7." 4 +If there are any trailing slash characters in \fIstring\fP, they shall +be removed. +.LP +.IP " 8." 4 +If the remaining \fIstring\fP is empty, \fIstring\fP shall be set +to a single slash character. +.LP +.LP +The resulting string shall be written to standard output. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIstring\fP +A string. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIdirname\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIdirname\fP utility shall write a line to the standard output +in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIresulting string\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The definition of \fIpathname\fP specifies implementation-defined +behavior for pathnames starting with two slash characters. +Therefore, applications shall not arbitrarily add slashes to the beginning +of a pathname unless they can ensure that there are more +or less than two or are prepared to deal with the implementation-defined +consequences. +.SH EXAMPLES +.TS C +center; l l. +\fBCommand\fP \fBResults\fP +\fIdirname\fP / / +\fIdirname\fP // / or // +\fIdirname\fP /\fIa\fP/\fIb\fP/ /\fIa\fP +\fIdirname\fP //\fIa\fP//\fIb\fP// //\fIa\fP +\fIdirname\fP Unspecified +\fIdirname a\fP . ($? = 0) +\fIdirname\fP "" . ($? = 0) +\fIdirname\fP /\fIa\fP / +\fIdirname\fP /\fIa\fP/\fIb\fP /\fIa\fP +\fIdirname\fP \fIa\fP/\fIb\fP \fIa\fP +.TE +.SH RATIONALE +.LP +The \fIdirname\fP utility originated in System III. It has evolved +through the System V releases to a version that matches the +requirements specified in this description in System V Release 3. +4.3 BSD and earlier versions did not include \fIdirname\fP. +.LP +The behaviors of \fIbasename\fP and \fIdirname\fP in this volume of +IEEE\ Std\ 1003.1-2001 have been coordinated so that when \fIstring\fP +is a valid pathname: +.sp +.RS +.nf + +\fB$(basename "\fP\fIstring\fP\fB") +\fP +.fi +.RE +.LP +would be a valid filename for the file in the directory: +.sp +.RS +.nf + +\fB$(dirname "\fP\fIstring\fP\fB") +\fP +.fi +.RE +.LP +This would not work for the versions of these utilities in early proposals +due to the way processing of trailing slashes was +specified. Consideration was given to leaving processing unspecified +if there were trailing slashes, but this cannot be done; the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 3.266, +Pathname allows trailing slashes. The \fIbasename\fP and \fIdirname\fP +utilities +have to specify consistent handling for all valid pathnames. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIbasename\fP() , \fIParameters and Variables\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/dot.1p b/man1p/dot.1p new file mode 100644 index 000000000..2c790bb82 --- /dev/null +++ b/man1p/dot.1p @@ -0,0 +1,103 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DOT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" dot +.SH NAME +dot \- execute commands in the current environment +.SH SYNOPSIS +.LP +\fB\&.\fP \fIfile\fP +.SH DESCRIPTION +.LP +The shell shall execute commands from the \fIfile\fP in the current +environment. +.LP +If \fIfile\fP does not contain a slash, the shell shall use the search +path specified by \fIPATH\fP to find the directory +containing \fIfile\fP. Unlike normal command search, however, the +file searched for by the \fIdot\fP utility need not be +executable. If no readable file is found, a non-interactive shell +shall abort; an interactive shell shall write a diagnostic +message to standard error, but this condition shall not be considered +a syntax error. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +See the DESCRIPTION. +.SH ENVIRONMENT VARIABLES +.LP +See the DESCRIPTION. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +Returns the value of the last command executed, or a zero exit status +if no command is executed. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fBcat foobar +\fP\fBfoo=hello bar=world\fP\fB. foobar +echo $foo $bar +\fP\fBhello world\fP +.fi +.RE +.SH RATIONALE +.LP +Some older implementations searched the current directory for the +\fIfile\fP, even if the value of \fIPATH\fP disallowed it. +This behavior was omitted from this volume of IEEE\ Std\ 1003.1-2001 +due to concerns about introducing the susceptibility +to trojan horses that the user might be trying to avoid by leaving +\fBdot\fP out of \fIPATH .\fP +.LP +The KornShell version of \fIdot\fP takes optional arguments that are +set to the positional parameters. This is a valid +extension that allows a \fIdot\fP script to behave identically to +a function. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/du.1p b/man1p/du.1p new file mode 100644 index 000000000..3f34004f8 --- /dev/null +++ b/man1p/du.1p @@ -0,0 +1,244 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "DU" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" du +.SH NAME +du \- estimate file space usage +.SH SYNOPSIS +.LP +\fBdu\fP \fB[\fP\fB-a | -s\fP\fB][\fP\fB-kx\fP\fB][\fP\fB-H | -L\fP\fB][\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +By default, the \fIdu\fP utility shall write to standard output the +size of the file space allocated to, and the size of the +file space allocated to each subdirectory of, the file hierarchy rooted +in each of the specified files. By default, when a symbolic +link is encountered on the command line or in the file hierarchy, +\fIdu\fP shall count the size of the symbolic link (rather than +the file referenced by the link), and shall not follow the link to +another portion of the file hierarchy. The size of the file +space allocated to a file of type directory shall be defined as the +sum total of space allocated to all files in the file hierarchy +rooted in the directory plus the space allocated to the directory +itself. +.LP +When \fIdu\fP cannot \fIstat\fP() files or \fIstat\fP() or read directories, +it shall report an error condition and the final exit status is +affected. Files with multiple links shall be counted and written for +only one entry. The directory entry that is selected in the +report is unspecified. By default, file sizes shall be written in +512-byte units, rounded up to the next 512-byte unit. +.SH OPTIONS +.LP +The \fIdu\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +In addition to the default output, report the size of each file not +of type directory in the file hierarchy rooted in the +specified file. Regardless of the presence of the \fB-a\fP option, +non-directories given as \fIfile\fP operands shall always be +listed. +.TP 7 +\fB-H\fP +If a symbolic link is specified on the command line, \fIdu\fP shall +count the size of the file or file hierarchy referenced by +the link. +.TP 7 +\fB-k\fP +Write the files sizes in units of 1024 bytes, rather than the default +512-byte units. +.TP 7 +\fB-L\fP +If a symbolic link is specified on the command line or encountered +during the traversal of a file hierarchy, \fIdu\fP shall +count the size of the file or file hierarchy referenced by the link. +.TP 7 +\fB-s\fP +Instead of the default output, report only the total sum for each +of the specified files. +.TP 7 +\fB-x\fP +When evaluating file sizes, evaluate only those files that have the +same device as the file specified by the \fIfile\fP +operand. +.sp +.LP +Specifying more than one of the mutually-exclusive options \fB-H\fP +and \fB-L\fP shall not be considered an error. The last +option specified shall determine the behavior of the utility. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +The pathname of a file whose size is to be written. If no \fIfile\fP +is specified, the current directory shall be used. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIdu\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The output from \fIdu\fP shall consist of the amount of space allocated +to a file and the name of the file, in the following +format: +.sp +.RS +.nf + +\fB"%d %s\\n", <\fP\fIsize\fP\fB>, <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The use of 512-byte units is historical practice and maintains compatibility +with \fIls\fP +and other utilities in this volume of IEEE\ Std\ 1003.1-2001. This +does not mandate that the file system itself be based on +512-byte blocks. The \fB-k\fP option was added as a compromise measure. +It was agreed by the standard developers that 512 bytes +was the best default unit because of its complete historical consistency +on System V (\fIversus\fP the mixed 512/1024-byte usage +on BSD systems), and that a \fB-k\fP option to switch to 1024-byte +units was a good compromise. Users who prefer the 1024-byte +quantity can easily alias \fIdu\fP to \fIdu\fP \fB-k\fP without breaking +the many historical scripts relying on the 512-byte +units. +.LP +The \fB-b\fP option was added to an early proposal to provide a resolution +to the situation where System V and BSD systems give +figures for file sizes in \fIblocks\fP, which is an implementation-defined +concept. (In common usage, the block size is 512 bytes +for System V and 1024 bytes for BSD systems.) However, \fB-b\fP was +later deleted, since the default was eventually decided as +512-byte units. +.LP +Historical file systems provided no way to obtain exact figures for +the space allocation given to files. There are two known +areas of inaccuracies in historical file systems: cases of \fIindirect +blocks\fP being used by the file system or \fIsparse\fP +files yielding incorrectly high values. An indirect block is space +used by the file system in the storage of the file, but that +need not be counted in the space allocated to the file. A \fIsparse\fP +file is one in which an \fIlseek\fP() call has been made to a position +beyond the end of the file and data has subsequently +been written at that point. A file system need not allocate all the +intervening zero-filled blocks to such a file. It is up to the +implementation to define exactly how accurate its methods are. +.LP +The \fB-a\fP and \fB-s\fP options were mutually-exclusive in the original +version of \fIdu\fP. The POSIX Shell and Utilities +description is implied by the language in the SVID where \fB-s\fP +is described as causing "only the grand total" to be reported. +Some systems may produce output for \fB-sa\fP, but a Strictly Conforming +POSIX Shell and Utilities Application cannot use that +combination. +.LP +The \fB-a\fP and \fB-s\fP options were adopted from the SVID except +that the System V behavior of not listing non-directories +explicitly given as operands, unless the \fB-a\fP option is specified, +was considered a bug; the BSD-based behavior (report for +all operands) is mandated. The default behavior of \fIdu\fP in the +SVID with regard to reporting the failure to read files (it +produces no messages) was considered counter-intuitive, and thus it +was specified that the POSIX Shell and Utilities default +behavior shall be to produce such messages. These messages can be +turned off with shell redirection to achieve the System V +behavior. +.LP +The \fB-x\fP option is historical practice on recent BSD systems. +It has been adopted by this volume of +IEEE\ Std\ 1003.1-2001 because there was no other historical method +of limiting the \fIdu\fP search to a single file +hierarchy. This limitation of the search is necessary to make it possible +to obtain file space usage information about a file +system on which other file systems are mounted, without having to +resort to a lengthy \fIfind\fP and \fIawk\fP script. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIls\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIstat\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/echo.1p b/man1p/echo.1p new file mode 100644 index 000000000..4a371bf1b --- /dev/null +++ b/man1p/echo.1p @@ -0,0 +1,246 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ECHO" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" echo +.SH NAME +echo \- write arguments to standard output +.SH SYNOPSIS +.LP +\fBecho\fP \fB[\fP\fIstring\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIecho\fP utility writes its arguments to standard output, followed +by a <newline>. If there are no arguments, only +the <newline> is written. +.SH OPTIONS +.LP +The \fIecho\fP utility shall not recognize the \fB"--"\fP argument +in the manner specified by Guideline 10 of the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility +Syntax +Guidelines; \fB"--"\fP shall be recognized as a string operand. +.LP +Implementations shall not support any options. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIstring\fP +A string to be written to standard output. If the first operand is +\fB-n\fP, or if any of the operands contain a backslash ( +\fB'\\'\fP ) character, the results are implementation-defined. +.LP +On XSI-conformant systems, if the first operand is \fB-n\fP, it shall +be treated as a string, not an option. The following +character sequences shall be recognized on XSI-conformant systems +within any of the arguments: +.TP 7 +\fB\\a\fP +.RS +Write an <alert>. +.RE +.TP 7 +\fB\\b\fP +.RS +Write a <backspace>. +.RE +.TP 7 +\fB\\c\fP +.RS +Suppress the <newline> that otherwise follows the final argument in +the output. All characters following the +\fB'\\c'\fP in the arguments shall be ignored. +.RE +.TP 7 +\fB\\f\fP +.RS +Write a <form-feed>. +.RE +.TP 7 +\fB\\n\fP +.RS +Write a <newline>. +.RE +.TP 7 +\fB\\r\fP +.RS +Write a <carriage-return>. +.RE +.TP 7 +\fB\\t\fP +.RS +Write a <tab>. +.RE +.TP 7 +\fB\\v\fP +.RS +Write a <vertical-tab>. +.RE +.TP 7 +\fB\\\\\fP +.RS +Write a backslash character. +.RE +.TP 7 +\fB\\0\fP\fInum\fP +.RS +Write an 8-bit value that is the zero, one, two, or three-digit octal +number \fInum\fP. +.RE +.sp +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIecho\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as opposed +to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIecho\fP utility arguments shall be separated by single <space>s +and a <newline> shall follow the last +argument. \ Output transformations shall occur based on the escape +sequences in the input. See the OPERANDS section. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +It is not possible to use \fIecho\fP portably across all POSIX systems +unless both \fB-n\fP (as the first argument) and escape +sequences are omitted. +.LP +The \fIprintf\fP utility can be used portably to emulate any of the +traditional +behaviors of the \fIecho\fP utility as follows (assuming that \fIIFS\fP +has its standard value or is unset): +.IP " *" 3 +The historic System V \fIecho\fP and the requirements on XSI implementations +in this volume of IEEE\ Std\ 1003.1-2001 +are equivalent to: +.sp +.RS +.nf + +\fBprintf "%b\\n" "$*" +\fP +.fi +.RE +.LP +.IP " *" 3 +The BSD \fIecho\fP is equivalent to: +.sp +.RS +.nf + +\fBif [ "X$1" = "X-n" ] +then + shift + printf "%s" "$*" +else + printf "%s\\n" "$*" +fi +\fP +.fi +.RE +.LP +.LP +New applications are encouraged to use \fIprintf\fP instead of \fIecho\fP. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIecho\fP utility has not been made obsolescent because of its +extremely widespread use in historical applications. +Conforming applications that wish to do prompting without <newline>s +or that could possibly be expecting to echo a \fB-n\fP, +should use the \fIprintf\fP utility derived from the Ninth Edition +system. +.LP +As specified, \fIecho\fP writes its arguments in the simplest of ways. +The two different historical versions of \fIecho\fP +vary in fatally incompatible ways. +.LP +The BSD \fIecho\fP checks the first argument for the string \fB-n\fP +which causes it to suppress the <newline> that +would otherwise follow the final argument in the output. +.LP +The System V \fIecho\fP does not support any options, but allows escape +sequences within its operands, as described for XSI +implementations in the OPERANDS section. +.LP +The \fIecho\fP utility does not support Utility Syntax Guideline 10 +because historical applications depend on \fIecho\fP to +echo \fIall\fP of its arguments, except for the \fB-n\fP option in +the BSD version. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIprintf\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ed.1p b/man1p/ed.1p new file mode 100644 index 000000000..b7817a257 --- /dev/null +++ b/man1p/ed.1p @@ -0,0 +1,1462 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ED" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ed +.SH NAME +ed \- edit text +.SH SYNOPSIS +.LP +\fBed\fP \fB[\fP\fB-p\fP \fIstring\fP\fB][\fP\fB-s\fP\fB][\fP\fIfile\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIed\fP utility is a line-oriented text editor that uses two +modes: \fIcommand mode\fP and \fIinput mode\fP. In command +mode the input characters shall be interpreted as commands, and in +input mode they shall be interpreted as text. See the EXTENDED +DESCRIPTION section. +.SH OPTIONS +.LP +The \fIed\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-p\ \fP \fIstring\fP +Use \fIstring\fP as the prompt string when in command mode. By default, +there shall be no prompt string. +.TP 7 +\fB-s\fP +Suppress the writing of byte counts by \fBe\fP, \fBE\fP, \fBr\fP, +and \fBw\fP commands and of the \fB'!'\fP prompt after +a !\fIcommand\fP. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +If the \fIfile\fP argument is given, \fIed\fP shall simulate an \fBe\fP +command on the file named by the pathname, +\fIfile\fP, before accepting commands from the standard input. If +the \fIfile\fP operand is \fB'-'\fP , the results are +unspecified. +.sp +.SH STDIN +.LP +The standard input shall be a text file consisting of commands, as +described in the EXTENDED DESCRIPTION section. +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIed\fP: +.TP 7 +\fIHOME\fP +Determine the pathname of the user's home directory. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classes within regular +expressions. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +The \fIed\fP utility shall take the standard action for all signals +(see the ASYNCHRONOUS EVENTS section in \fIUtility Description Defaults\fP +) with the following exceptions: +.TP 7 +SIGINT +The \fIed\fP utility shall interrupt its current activity, write the +string \fB"?\\n"\fP to standard output, and return to +command mode (see the EXTENDED DESCRIPTION section). +.TP 7 +SIGHUP +If the buffer is not empty and has changed since the last write, the +\fIed\fP utility shall attempt to write a copy of the +buffer in a file. First, the file named \fBed.hup\fP in the current +directory shall be used; if that fails, the file named +\fBed.hup\fP in the directory named by the \fIHOME\fP environment +variable shall be used. In any case, the \fIed\fP utility +shall exit without returning to command mode. +.TP 7 +SIGQUIT +The \fIed\fP utility shall ignore this event. +.sp +.SH STDOUT +.LP +Various editing commands and the prompting feature (see \fB-p\fP) +write to standard output, as described in the EXTENDED +DESCRIPTION section. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output files shall be text files whose formats are dependent on +the editing commands given. +.SH EXTENDED DESCRIPTION +.LP +The \fIed\fP utility shall operate on a copy of the file it is editing; +changes made to the copy shall have no effect on the +file until a \fBw\fP (write) command is given. The copy of the text +is called the \fIbuffer\fP. +.LP +Commands to \fIed\fP have a simple and regular structure: zero, one, +or two \fIaddresses\fP followed by a single-character +\fIcommand\fP, possibly followed by parameters to that command. These +addresses specify one or more lines in the buffer. Every +command that requires addresses has default addresses, so that the +addresses very often can be omitted. If the \fB-p\fP option is +specified, the prompt string shall be written to standard output before +each command is read. +.LP +In general, only one command can appear on a line. Certain commands +allow text to be input. This text is placed in the +appropriate place in the buffer. While \fIed\fP is accepting text, +it is said to be in \fIinput mode\fP. In this mode, no +commands shall be recognized; all input is merely collected. Input +mode is terminated by entering a line consisting of two +characters: a period ( \fB'.'\fP ) followed by a <newline>. This line +is not considered part of the input text. +.SS Regular Expressions in ed +.LP +The \fIed\fP utility shall support basic regular expressions, as described +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 9.3, Basic Regular Expressions. Since +regular expressions in \fIed\fP are always matched against single +lines (excluding the terminating <newline>s), never +against any larger section of text, there is no way for a regular +expression to match a <newline>. +.LP +A null RE shall be equivalent to the last RE encountered. +.LP +Regular expressions are used in addresses to specify lines, and in +some commands (for example, the \fBs\fP substitute command) +to specify portions of a line to be substituted. +.SS Addresses in ed +.LP +Addressing in \fIed\fP relates to the current line. Generally, the +current line is the last line affected by a command. The +current line number is the address of the current line. If the edit +buffer is not empty, the initial value for the current line +shall be the last line in the edit buffer; otherwise, zero. +.LP +Addresses shall be constructed as follows: +.IP " 1." 4 +The period character ( \fB'.'\fP ) shall address the current line. +.LP +.IP " 2." 4 +The dollar sign character ( \fB'$'\fP ) shall address the last line +of the edit buffer. +.LP +.IP " 3." 4 +The positive decimal number \fIn\fP shall address the \fIn\fPth line +of the edit buffer. +.LP +.IP " 4." 4 +The apostrophe-x character pair ( \fB"'x"\fP ) shall address the line +marked with the mark name character \fIx\fP, which +shall be a lowercase letter from the portable character set. It shall +be an error if the character has not been set to mark a line +or if the line that was marked is not currently present in the edit +buffer. +.LP +.IP " 5." 4 +A BRE enclosed by slash characters ( \fB'/'\fP ) shall address the +first line found by searching forwards from the line +following the current line toward the end of the edit buffer and stopping +at the first line for which the line excluding the +terminating <newline> matches the BRE. The BRE consisting of a null +BRE delimited by a pair of slash characters shall address +the next line for which the line excluding the terminating <newline> +matches the last BRE encountered. In addition, the +second slash can be omitted at the end of a command line. Within the +BRE, a backslash-slash pair ( \fB"\\/"\fP ) shall represent +a literal slash instead of the BRE delimiter. If necessary, the search +shall wrap around to the beginning of the buffer and +continue up to and including the current line, so that the entire +buffer is searched. +.LP +.IP " 6." 4 +A BRE enclosed by question-mark characters ( \fB'?'\fP ) shall address +the first line found by searching backwards from the +line preceding the current line toward the beginning of the edit buffer +and stopping at the first line for which the line excluding +the terminating <newline> matches the BRE. The BRE consisting of a +null BRE delimited by a pair of question-mark characters ( +\fB"??"\fP ) shall address the previous line for which the line excluding +the terminating <newline> matches the last BRE +encountered. In addition, the second question-mark can be omitted +at the end of a command line. Within the BRE, a +backslash-question-mark pair ( \fB"\\?"\fP ) shall represent a literal +question mark instead of the BRE delimiter. If necessary, +the search shall wrap around to the end of the buffer and continue +up to and including the current line, so that the entire buffer +is searched. +.LP +.IP " 7." 4 +A plus-sign ( \fB'+'\fP ) or hyphen character ( \fB'-'\fP ) followed +by a decimal number shall address the current line +plus or minus the number. A plus-sign or hyphen character not followed +by a decimal number shall address the current line plus or +minus 1. +.LP +.LP +Addresses can be followed by zero or more address offsets, optionally +<blank>-separated. Address offsets are constructed +as follows: +.IP " *" 3 +A plus-sign or hyphen character followed by a decimal number shall +add or subtract, respectively, the indicated number of lines +to or from the address. A plus-sign or hyphen character not followed +by a decimal number shall add or subtract 1 to or from the +address. +.LP +.IP " *" 3 +A decimal number shall add the indicated number of lines to the address. +.LP +.LP +It shall not be an error for an intermediate address value to be less +than zero or greater than the last line in the edit +buffer. It shall be an error for the final address value to be less +than zero or greater than the last line in the edit buffer. It +shall be an error if a search for a BRE fails to find a matching line. +.LP +Commands accept zero, one, or two addresses. If more than the required +number of addresses are provided to a command that +requires zero addresses, it shall be an error. Otherwise, if more +than the required number of addresses are provided to a command, +the addresses specified first shall be evaluated and then discarded +until the maximum number of valid addresses remain, for the +specified command. +.LP +Addresses shall be separated from each other by a comma ( \fB','\fP +) or semicolon character ( \fB';'\fP ). In the case of +a semicolon separator, the current line ( \fB'.'\fP ) shall be set +to the first address, and only then will the second address +be calculated. This feature can be used to determine the starting +line for forwards and backwards searches; see rules 5. and 6. +.LP +Addresses can be omitted on either side of the comma or semicolon +separator, in which case the resulting address pairs shall be +as follows: +.TS C +center; l l. +\fBSpecified\fP \fBResulting\fP +, 1 , $ +, addr 1 , addr +addr , addr , addr +; . ; $ +; addr . ; addr +addr ; addr ; addr +.TE +.LP +Any <blank>s included between addresses, address separators, or address +offsets shall be ignored. +.SS Commands in ed +.LP +In the following list of \fIed\fP commands, the default addresses +are shown in parentheses. The number of addresses shown in +the default shall be the number expected by the command. The parentheses +are not part of the address; they show that the given +addresses are the default. +.LP +It is generally invalid for more than one command to appear on a line. +However, any command (except \fBe\fP, \fBE\fP, +\fBf\fP, \fBq\fP, \fBQ\fP, \fBr\fP, \fBw\fP, and \fB!\fP) can be suffixed +by the letter \fBl\fP, \fBn\fP, or \fBp\fP; in +which case, except for the \fBl\fP, \fBn\fP, and \fBp\fP commands, +the command shall be executed and then the new current line +shall be written as described below under the \fBl\fP, \fBn\fP, and +\fBp\fP commands. When an \fBl\fP, \fBn\fP, or \fBp\fP +suffix is used with an \fBl\fP, \fBn\fP, or \fBp\fP command, the command +shall write to standard output as described below, but +it is unspecified whether the suffix writes the current line again +in the requested format or whether the suffix has no effect. For +example, the \fBpl\fP command (base \fBp\fP command with an \fBl\fP +suffix) shall either write just the current line or write it +twice-once as specified for \fBp\fP and once as specified for \fBl\fP. +Also, the \fBg\fP, \fBG\fP, \fBv\fP, and \fBV\fP +commands shall take a command as a parameter. +.LP +Each address component can be preceded by zero or more <blank>s. The +command letter can be preceded by zero or more +<blank>s. If a suffix letter ( \fBl\fP, \fBn\fP, or \fBp\fP) is given, +the application shall ensure that it immediately +follows the command. +.LP +The \fBe\fP, \fBE\fP, \fBf\fP, \fBr\fP, and \fBw\fP commands shall +take an optional \fIfile\fP parameter, separated from +the command letter by one or more <blank>s. +.LP +If changes have been made in the buffer since the last \fBw\fP command +that wrote the entire buffer, \fIed\fP shall warn the +user if an attempt is made to destroy the editor buffer via the \fBe\fP +or \fBq\fP commands. The \fIed\fP utility shall write +the string: +.sp +.RS +.nf + +\fB"?\\n" +\fP +.fi +.RE +.LP +(followed by an explanatory message if \fIhelp mode\fP has been enabled +via the \fBH\fP command) to standard output and shall +continue in command mode with the current line number unchanged. If +the \fBe\fP or \fBq\fP command is repeated with no +intervening command, it shall take effect. +.LP +If a terminal disconnect is detected: +.IP " *" 3 +If the buffer is not empty and has changed since the last write, the +\fIed\fP utility shall attempt to write a copy of the +buffer to a file named \fBed.hup\fP in the current directory. If this +write fails, \fIed\fP shall attempt to write a copy of the +buffer to a filename \fBed.hup\fP in the directory named by the \fIHOME\fP +environment variable. If both these attempts fail, +\fIed\fP shall exit without saving the buffer. +.LP +.IP " *" 3 +The \fIed\fP utility shall not write the file to the currently remembered +pathname or return to command mode, and shall +terminate with a non-zero exit status. +.LP +.LP +If an end-of-file is detected on standard input: +.IP " *" 3 +If the \fIed\fP utility is in input mode, \fIed\fP shall terminate +input mode and return to command mode. It is unspecified if +any partially entered lines (that is, input text without a terminating +<newline>) are discarded from the input text. +.LP +.IP " *" 3 +If the \fIed\fP utility is in command mode, it shall act as if a \fBq\fP +command had been entered. +.LP +.LP +If the closing delimiter of an RE or of a replacement string (for +example, \fB'/'\fP ) in a \fBg\fP, \fBG\fP, \fBs\fP, +\fBv\fP, or \fBV\fP command would be the last character before a <newline>, +that delimiter can be omitted, in which case +the addressed line shall be written. For example, the following pairs +of commands are equivalent: +.sp +.RS +.nf + +\fBs/s1/s2 s/s1/s2/p +g/s1 g/s1/p +?s1 ?s1? +\fP +.fi +.RE +.LP +If an invalid command is entered, \fIed\fP shall write the string: +.sp +.RS +.nf + +\fB"?\\n" +\fP +.fi +.RE +.LP +(followed by an explanatory message if \fIhelp mode\fP has been enabled +via the \fBH\fP command) to standard output and shall +continue in command mode with the current line number unchanged. +.SS Append Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.)a +<\fP\fItext\fP\fB> +\&. +\fP +.fi +.RE +.sp +.LP +The \fBa\fP command shall read the given text and append it after +the addressed line; the current line number shall become the +address of the last inserted line or, if there were none, the addressed +line. Address 0 shall be valid for this command; it shall +cause the appended text to be placed at the beginning of the buffer. +.SS Change Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)c +<\fP\fItext\fP\fB> +\&. +\fP +.fi +.RE +.sp +.LP +The \fBc\fP command shall delete the addressed lines, then accept +input text that replaces these lines; the current line shall +be set to the address of the last line input; or, if there were none, +at the line after the last line deleted; if the lines deleted +were originally at the end of the buffer, the current line number +shall be set to the address of the new last line; if no lines +remain in the buffer, the current line number shall be set to zero. +Address 0 shall be valid for this command; it shall be +interpreted as if address 1 were specified. +.SS Delete Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)d +\fP +.fi +.RE +.sp +.LP +The \fBd\fP command shall delete the addressed lines from the buffer. +The address of the line after the last line deleted shall +become the current line number; if the lines deleted were originally +at the end of the buffer, the current line number shall be set +to the address of the new last line; if no lines remain in the buffer, +the current line number shall be set to zero. +.SS Edit Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBe\fP \fB[\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +The \fBe\fP command shall delete the entire contents of the buffer +and then read in the file named by the pathname \fIfile\fP. +The current line number shall be set to the address of the last line +of the buffer. If no pathname is given, the currently +remembered pathname, if any, shall be used (see the \fBf\fP command). +The number of bytes read shall be written to standard +output, unless the \fB-s\fP option was specified, in the following +format: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fInumber of bytes read\fP\fB> +\fP +.fi +.RE +.LP +The name \fIfile\fP shall be remembered for possible use as a default +pathname in subsequent \fBe\fP, \fBE\fP, \fBr\fP, and +\fBw\fP commands. If \fIfile\fP is replaced by \fB'!'\fP , the rest +of the line shall be taken to be a shell command line +whose output is to be read. Such a shell command line shall not be +remembered as the current \fIfile\fP. All marks shall be +discarded upon the completion of a successful \fBe\fP command. If +the buffer has changed since the last time the entire buffer was +written, the user shall be warned, as described previously. +.SS Edit Without Checking Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBE\fP \fB[\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +The \fBE\fP command shall possess all properties and restrictions +of the \fBe\fP command except that the editor shall not +check to see whether any changes have been made to the buffer since +the last \fBw\fP command. +.SS Filename Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBf\fP \fB[\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +If \fIfile\fP is given, the \fBf\fP command shall change the currently +remembered pathname to \fIfile\fP; whether the name is +changed or not, it shall then write the (possibly new) currently remembered +pathname to the standard output in the following +format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +The current line number shall be unchanged. +.SS Global Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(1,$)g/\fP\fIRE\fP\fB/\fP\fIcommand list\fP +.fi +.RE +.sp +.LP +In the \fBg\fP command, the first step shall be to mark every line +for which the line excluding the terminating <newline> +matches the given RE. Then, going sequentially from the beginning +of the file to the end of the file, the given \fIcommand list\fP +shall be executed for each marked line, with the current line number +set to the address of that line. Any line modified by the +\fIcommand list\fP shall be unmarked. When the \fBg\fP command completes, +the current line number shall have the value assigned +by the last command in the \fIcommand list\fP. If there were no matching +lines, the current line number shall not be changed. A +single command or the first of a list of commands shall appear on +the same line as the global command. All lines of a multi-line +list except the last line shall be ended with a backslash preceding +the terminating <newline>; the \fBa\fP, \fBi\fP, and +\fBc\fP commands and associated input are permitted. The \fB'.'\fP +terminating input mode can be omitted if it would be the +last line of the \fIcommand list\fP. An empty \fIcommand list\fP shall +be equivalent to the \fBp\fP command. The use of the +\fBg\fP, \fBG\fP, \fBv\fP, \fBV\fP, and \fB!\fP commands in the \fIcommand +list\fP produces undefined results. Any character +other than <space> or <newline> can be used instead of a slash to +delimit the RE. Within the RE, the RE delimiter +itself can be used as a literal character if it is preceded by a backslash. +.SS Interactive Global Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(1,$)G/\fP\fIRE\fP\fB/ +\fP +.fi +.RE +.sp +.LP +In the \fBG\fP command, the first step shall be to mark every line +for which the line excluding the terminating <newline> +matches the given RE. Then, for every such line, that line shall be +written, the current line number shall be set to the address of +that line, and any one command (other than one of the \fBa\fP, \fBc\fP, +\fBi\fP, \fBg\fP, \fBG\fP, \fBv\fP, and \fBV\fP +commands) shall be read and executed. A <newline> shall act as a null +command (causing no action to be taken on the current +line); an \fB'&'\fP shall cause the re-execution of the most recent +non-null command executed within the current invocation +of \fBG\fP. Note that the commands input as part of the execution +of the \fBG\fP command can address and affect any lines in the +buffer. Any line modified by the command shall be unmarked. The final +value of the current line number shall be the value set by +the last command successfully executed. (Note that the last command +successfully executed shall be the \fBG\fP command itself if a +command fails or the null command is specified.) If there were no +matching lines, the current line number shall not be changed. The +\fBG\fP command can be terminated by a SIGINT signal. Any character +other than <space> or <newline> can be used +instead of a slash to delimit the RE and the replacement. Within the +RE, the RE delimiter itself can be used as a literal character +if it is preceded by a backslash. +.SS Help Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBh +\fP +.fi +.RE +.sp +.LP +The \fBh\fP command shall write a short message to standard output +that explains the reason for the most recent \fB'?'\fP +notification. The current line number shall be unchanged. +.SS Help-Mode Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBH +\fP +.fi +.RE +.sp +.LP +The \fBH\fP command shall cause \fIed\fP to enter a mode in which +help messages (see the \fBh\fP command) shall be written to +standard output for all subsequent \fB'?'\fP notifications. The \fBH\fP +command alternately shall turn this mode on and off; it +is initially off. If the help-mode is being turned on, the \fBH\fP +command also explains the previous \fB'?'\fP notification, +if there was one. The current line number shall be unchanged. +.SS Insert Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.)i +<\fP\fItext\fP\fB> +\&. +\fP +.fi +.RE +.sp +.LP +The \fBi\fP command shall insert the given text before the addressed +line; the current line is set to the last inserted line +or, if there was none, to the addressed line. This command differs +from the \fBa\fP command only in the placement of the input +text. Address 0 shall be valid for this command; it shall be interpreted +as if address 1 were specified. +.SS Join Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.+1)j +\fP +.fi +.RE +.sp +.LP +The \fBj\fP command shall join contiguous lines by removing the appropriate +<newline>s. If exactly one address is given, +this command shall do nothing. If lines are joined, the current line +number shall be set to the address of the joined line; +otherwise, the current line number shall be unchanged. +.SS Mark Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.)k\fP\fIx\fP +.fi +.RE +.sp +.LP +The \fBk\fP command shall mark the addressed line with name \fIx\fP, +which the application shall ensure is a lowercase letter +from the portable character set. The address \fB"'x"\fP shall then +refer to this line; the current line number shall be +unchanged. +.SS List Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)l +\fP +.fi +.RE +.sp +.LP +The \fBl\fP command shall write to standard output the addressed lines +in a visually unambiguous form. The characters listed in +the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Table 5-1, +Escape Sequences and Associated Actions ( \fB'\\\\'\fP , +\fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , \fB'\\r'\fP , \fB'\\t'\fP +, \fB'\\v'\fP ) shall be written as the +corresponding escape sequence; the \fB'\\n'\fP in that table is not +applicable. Non-printable characters not in the table shall +be written as one three-digit octal number (with a preceding backslash +character) for each byte in the character (most significant +byte first). If the size of a byte on the system is greater than nine +bits, the format used for non-printable characters is +implementation-defined. +.LP +Long lines shall be folded, with the point of folding indicated by +<newline> preceded by a backslash; the length at which +folding occurs is unspecified, but should be appropriate for the output +device. The end of each line shall be marked with a +\fB'$'\fP , and \fB'$'\fP characters within the text shall be written +with a preceding backslash. An \fBl\fP command can be +appended to any other command other than \fBe\fP, \fBE\fP, \fBf\fP, +\fBq\fP, \fBQ\fP, \fBr\fP, \fBw\fP, or \fB!\fP. The +current line number shall be set to the address of the last line written. +.SS Move Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)m\fP\fIaddress\fP +.fi +.RE +.sp +.LP +The \fBm\fP command shall reposition the addressed lines after the +line addressed by \fIaddress\fP. Address 0 shall be valid +for \fIaddress\fP and cause the addressed lines to be moved to the +beginning of the buffer. It shall be an error if address +\fIaddress\fP falls within the range of moved lines. The current line +number shall be set to the address of the last line +moved. +.SS Number Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)n +\fP +.fi +.RE +.sp +.LP +The \fBn\fP command shall write to standard output the addressed lines, +preceding each line by its line number and a +<tab>; the current line number shall be set to the address of the +last line written. The \fBn\fP command can be appended to +any command other than \fBe\fP, \fBE\fP, \fBf\fP, \fBq\fP, \fBQ\fP, +\fBr\fP, \fBw\fP, or \fB!\fP. +.SS Print Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)p +\fP +.fi +.RE +.sp +.LP +The \fBp\fP command shall write to standard output the addressed lines; +the current line number shall be set to the address of +the last line written. The \fBp\fP command can be appended to any +command other than \fBe\fP, \fBE\fP, \fBf\fP, \fBq\fP, +\fBQ\fP, \fBr\fP, \fBw\fP, or \fB!\fP. +.SS Prompt Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBP +\fP +.fi +.RE +.sp +.LP +The \fBP\fP command shall cause \fIed\fP to prompt with an asterisk +( \fB'*'\fP ) (or \fIstring\fP, if \fB-p\fP is +specified) for all subsequent commands. The \fBP\fP command alternatively +shall turn this mode on and off; it shall be initially +on if the \fB-p\fP option is specified; otherwise, off. The current +line number shall be unchanged. +.SS Quit Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBq +\fP +.fi +.RE +.sp +.LP +The \fBq\fP command shall cause \fIed\fP to exit. If the buffer has +changed since the last time the entire buffer was written, +the user shall be warned, as described previously. +.SS Quit Without Checking Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBQ +\fP +.fi +.RE +.sp +.LP +The \fBQ\fP command shall cause \fIed\fP to exit without checking +whether changes have been made in the buffer since the last +\fBw\fP command. +.SS Read Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB($)r\fP \fB[\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +The \fBr\fP command shall read in the file named by the pathname \fIfile\fP +and append it after the addressed line. If no +\fIfile\fP argument is given, the currently remembered pathname, if +any, shall be used (see the \fBe\fP and \fBf\fP commands). +The currently remembered pathname shall not be changed unless there +is no remembered pathname. Address 0 shall be valid for +\fBr\fP and shall cause the file to be read at the beginning of the +buffer. If the read is successful, and \fB-s\fP was not +specified, the number of bytes read shall be written to standard output +in the following format: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fInumber of bytes read\fP\fB> +\fP +.fi +.RE +.LP +The current line number shall be set to the address of the last line +read in. If \fIfile\fP is replaced by \fB'!'\fP , the +rest of the line shall be taken to be a shell command line whose output +is to be read. Such a shell command line shall not be +remembered as the current pathname. +.SS Substitute Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)s/\fP\fIRE\fP\fB/\fP\fIreplacement\fP\fB/\fP\fIflags\fP +.fi +.RE +.sp +.LP +The \fBs\fP command shall search each addressed line for an occurrence +of the specified RE and replace either the first or all +(non-overlapped) matched strings with the \fIreplacement\fP; see the +following description of the \fBg\fP suffix. It is an error +if the substitution fails on every addressed line. Any character other +than <space> or <newline> can be used instead of +a slash to delimit the RE and the replacement. Within the RE, the +RE delimiter itself can be used as a literal character if it is +preceded by a backslash. The current line shall be set to the address +of the last line on which a substitution occurred. +.LP +An ampersand ( \fB'&'\fP ) appearing in the \fIreplacement\fP shall +be replaced by the string matching the RE on the +current line. The special meaning of \fB'&'\fP in this context can +be suppressed by preceding it by backslash. As a more +general feature, the characters \fB'\\n'\fP , where \fIn\fP is a digit, +shall be replaced by the text matched by the +corresponding back-reference expression. When the character \fB'%'\fP +is the only character in the \fIreplacement\fP, the +\fIreplacement\fP used in the most recent substitute command shall +be used as the \fIreplacement\fP in the current substitute +command; if there was no previous substitute command, the use of \fB'%'\fP +in this manner shall be an error. The \fB'%'\fP +shall lose its special meaning when it is in a replacement string +of more than one character or is preceded by a backslash. For +each backslash ( \fB'\\'\fP ) encountered in scanning \fIreplacement\fP +from beginning to end, the following character shall +lose its special meaning (if any). It is unspecified what special +meaning is given to any character other than \fB'&'\fP , +\fB'\\'\fP , \fB'%'\fP , or digits. +.LP +A line can be split by substituting a <newline> into it. The application +shall ensure it escapes the <newline> in +the \fIreplacement\fP by preceding it by backslash. Such substitution +cannot be done as part of a \fBg\fP or \fBv\fP \fIcommand +list\fP. The current line number shall be set to the address of the +last line on which a substitution is performed. If no +substitution is performed, the current line number shall be unchanged. +If a line is split, a substitution shall be considered to +have been performed on each of the new lines for the purpose of determining +the new current line number. A substitution shall be +considered to have been performed even if the replacement string is +identical to the string that it replaces. +.LP +The application shall ensure that the value of \fIflags\fP is zero +or more of: +.TP 7 +\fIcount\fP +Substitute for the \fIcount\fPth occurrence only of the RE found on +each addressed line. +.TP 7 +\fBg\fP +Globally substitute for all non-overlapping instances of the RE rather +than just the first one. If both \fBg\fP and +\fIcount\fP are specified, the results are unspecified. +.TP 7 +\fBl\fP +Write to standard output the final line in which a substitution was +made. The line shall be written in the format specified for +the \fBl\fP command. +.TP 7 +\fBn\fP +Write to standard output the final line in which a substitution was +made. The line shall be written in the format specified for +the \fBn\fP command. +.TP 7 +\fBp\fP +Write to standard output the final line in which a substitution was +made. The line shall be written in the format specified for +the \fBp\fP command. +.sp +.SS Copy Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.,.)t\fP\fIaddress\fP +.fi +.RE +.sp +.LP +The \fBt\fP command shall be equivalent to the \fBm\fP command, except +that a copy of the addressed lines shall be placed +after address \fIaddress\fP (which can be 0); the current line number +shall be set to the address of the last line added. +.SS Undo Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBu +\fP +.fi +.RE +.sp +.LP +The \fBu\fP command shall nullify the effect of the most recent command +that modified anything in the buffer, namely the most +recent \fBa\fP, \fBc\fP, \fBd\fP, \fBg\fP, \fBi\fP, \fBj\fP, \fBm\fP, +\fBr\fP, \fBs\fP, \fBt\fP, \fBu\fP, \fBv\fP, +\fBG\fP, or \fBV\fP command. All changes made to the buffer by a \fBg\fP, +\fBG\fP, \fBv\fP, or \fBV\fP global command shall +be undone as a single change; if no changes were made by the global +command (such as with \fBg\fP/RE/ \fBp\fP), the \fBu\fP +command shall have no effect. The current line number shall be set +to the value it had immediately before the command being undone +started. +.SS Global Non-Matched Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(1,$)v/\fP\fIRE\fP\fB/\fP\fIcommand list\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the global command \fBg\fP except +that the lines that are marked during the first step +shall be those for which the line excluding the terminating <newline> +does not match the RE. +.SS Interactive Global Not-Matched Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(1,$)V/\fP\fIRE\fP\fB/ +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the interactive global command +\fBG\fP except that the lines that are marked during the +first step shall be those for which the line excluding the terminating +<newline> does not match the RE. +.SS Write Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(1,$)w\fP \fB[\fP\fIfile\fP\fB] +\fP +.fi +.RE +.sp +.LP +The \fBw\fP command shall write the addressed lines into the file +named by the pathname \fIfile\fP. The command shall create +the file, if it does not exist, or shall replace the contents of the +existing file. The currently remembered pathname shall not be +changed unless there is no remembered pathname. If no pathname is +given, the currently remembered pathname, if any, shall be used +(see the \fBe\fP and \fBf\fP commands); the current line number shall +be unchanged. If the command is successful, the number of +bytes written shall be written to standard output, unless the \fB-s\fP +option was specified, in the following format: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fInumber of bytes written\fP\fB> +\fP +.fi +.RE +.LP +If \fIfile\fP begins with \fB'!'\fP , the rest of the line shall be +taken to be a shell command line whose standard input +shall be the addressed lines. Such a shell command line shall not +be remembered as the current pathname. This usage of the write +command with \fB'!'\fP shall not be considered as a "last \fBw\fP +command that wrote the entire buffer", as described +previously; thus, this alone shall not prevent the warning to the +user if an attempt is made to destroy the editor buffer via the +\fBe\fP or \fBq\fP commands. +.SS Line Number Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB($)= +\fP +.fi +.RE +.sp +.LP +The line number of the addressed line shall be written to standard +output in the following format: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fIline number\fP\fB> +\fP +.fi +.RE +.LP +The current line number shall be unchanged by this command. +.SS Shell Escape Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB!\fP\fIcommand\fP +.fi +.RE +.sp +.LP +The remainder of the line after the \fB'!'\fP shall be sent to the +command interpreter to be interpreted as a shell command +line. Within the text of that shell command line, the unescaped character +\fB'%'\fP shall be replaced with the remembered +pathname; if a \fB'!'\fP appears as the first character of the command, +it shall be replaced with the text of the previous shell +command executed via \fB'!'\fP . Thus, \fB"!!"\fP shall repeat the +previous !\fIcommand\fP. If any replacements of +\fB'%'\fP or \fB'!'\fP are performed, the modified line shall be written +to the standard output before \fIcommand\fP is +executed. The \fB!\fP command shall write: +.sp +.RS +.nf + +\fB"!\\n" +\fP +.fi +.RE +.LP +to standard output upon completion, unless the \fB-s\fP option is +specified. The current line number shall be unchanged. +.SS Null Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB(.+1) +\fP +.fi +.RE +.sp +.LP +An address alone on a line shall cause the addressed line to be written. +A <newline> alone shall be equivalent to +\fB"+1p"\fP . The current line number shall be set to the address +of the written line. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion without any file or command errors. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +When an error in the input script is encountered, or when an error +is detected that is a consequence of the data (not) present +in the file or due to an external condition such as a read or write +error: +.IP " *" 3 +If the standard input is a terminal device file, all input shall be +flushed, and a new command read. +.LP +.IP " *" 3 +If the standard input is a regular file, \fIed\fP shall terminate +with a non-zero exit status. +.LP +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Because of the extremely terse nature of the default error messages, +the prudent script writer begins the \fIed\fP input +commands with an \fBH\fP command, so that if any errors do occur at +least some clue as to the cause is made available. +.LP +In previous versions, an obsolescent \fB-\fP option was described. +This is no longer specified. Applications should use the +\fB-s\fP option. Using \fB-\fP as a \fIfile\fP operand now produces +unspecified results. This allows implementations to continue +to support the former required behavior. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The initial description of this utility was adapted from the SVID. +It contains some features not found in Version 7 or +BSD-derived systems. Some of the differences between the POSIX and +BSD \fIed\fP utilities include, but need not be limited to: +.IP " *" 3 +The BSD \fB-\fP option does not suppress the \fB'!'\fP prompt after +a \fB!\fP command. +.LP +.IP " *" 3 +BSD does not support the special meanings of the \fB'%'\fP and \fB'!'\fP +characters within a \fB!\fP command. +.LP +.IP " *" 3 +BSD does not support the \fIaddresses\fP \fB';'\fP and \fB','\fP . +.LP +.IP " *" 3 +BSD allows the command/suffix pairs \fBpp\fP, \fBll\fP, and so on, +which are unspecified in this volume of +IEEE\ Std\ 1003.1-2001. +.LP +.IP " *" 3 +BSD does not support the \fB'!'\fP character part of the \fBe\fP, +\fBr\fP, or \fBw\fP commands. +.LP +.IP " *" 3 +A failed \fBg\fP command in BSD sets the line number to the last line +searched if there are no matches. +.LP +.IP " *" 3 +BSD does not default the \fIcommand list\fP to the \fBp\fP command. +.LP +.IP " *" 3 +BSD does not support the \fBG\fP, \fBh\fP, \fBH\fP, \fBn\fP, or \fBV\fP +commands. +.LP +.IP " *" 3 +On BSD, if there is no inserted text, the insert command changes the +current line to the referenced line -1; that is, the line +before the specified line. +.LP +.IP " *" 3 +On BSD, the \fIjoin\fP command with only a single address changes +the current line to that +address. +.LP +.IP " *" 3 +BSD does not support the \fBP\fP command; moreover, in BSD it is synonymous +with the \fBp\fP command. +.LP +.IP " *" 3 +BSD does not support the \fIundo\fP of the commands \fBj\fP, \fBm\fP, +\fBr\fP, \fBs\fP, or \fBt\fP. +.LP +.IP " *" 3 +The Version 7 \fIed\fP command \fBW\fP, and the BSD \fIed\fP commands +\fBW\fP, \fBwq\fP, and \fBz\fP are not present in +this volume of IEEE\ Std\ 1003.1-2001. +.LP +.LP +The \fB-s\fP option was added to allow the functionality of the now +withdrawn \fB-\fP option in a manner compatible with the +Utility Syntax Guidelines. +.LP +In early proposals there was a limit, {ED_FILE_MAX}, that described +the historical limitations of some \fIed\fP utilities in +their handling of large files; some of these have had problems with +files larger than 100000 bytes. It was this limitation that +prompted much of the desire to include a \fIsplit\fP command in this +volume of +IEEE\ Std\ 1003.1-2001. Since this limit was removed, this volume +of IEEE\ Std\ 1003.1-2001 requires that +implementations document the file size limits imposed by \fIed\fP +in the conformance document. The limit {ED_LINE_MAX} was also +removed; therefore, the global limit {LINE_MAX} is used for input +and output lines. +.LP +The manner in which the \fBl\fP command writes non-printable characters +was changed to avoid the historical +backspace-overstrike method. On video display terminals, the overstrike +is ambiguous because most terminals simply replace +overstruck characters, making the \fBl\fP format not useful for its +intended purpose of unambiguously understanding the content of +the line. The historical backslash escapes were also ambiguous. (The +string \fB"a\\0011"\fP could represent a line containing +those six characters or a line containing the three characters \fB'a'\fP +, a byte with a binary value of 1, and a 1.) In the +format required here, a backslash appearing in the line is written +as \fB"\\\\"\fP so that the output is truly unambiguous. The +method of marking the ends of lines was adopted from the \fIex\fP +editor and is required for +any line ending in <space>s; the \fB'$'\fP is placed on all lines +so that a real \fB'$'\fP at the end of a line cannot +be misinterpreted. +.LP +Systems with bytes too large to fit into three octal digits must devise +other means of displaying non-printable characters. +Consideration was given to requiring that the number of octal digits +be large enough to hold a byte, but this seemed to be too +confusing for applications on the vast majority of systems where three +digits are adequate. It would be theoretically possible for +the application to use the \fIgetconf\fP utility to find out the CHAR_BIT +value and deal +with such an algorithm; however, there is really no portable way that +an application can use the octal values of the bytes across +various coded character sets, so the additional specification was +not worthwhile. +.LP +The description of how a NUL is written was removed. The NUL character +cannot be in text files, and this volume of +IEEE\ Std\ 1003.1-2001 should not dictate behavior in the case of +undefined, erroneous input. +.LP +Unlike some of the other editing utilities, the filenames accepted +by the \fBE\fP, \fBe\fP, \fBR\fP, and \fBr\fP commands +are not patterns. +.LP +Early proposals stated that the \fB-p\fP option worked only when standard +input was associated with a terminal device. This has +been changed to conform to historical implementations, thereby allowing +applications to interpose themselves between a user and the +\fIed\fP utility. +.LP +The form of the substitute command that uses the \fBn\fP suffix was +limited in some historical documentation (where this was +described incorrectly as "backreferencing"). This limit has been omitted +because there is no reason why an editor processing +lines of {LINE_MAX} length should have this restriction. The command +\fBs/x/X/2047\fP should be able to substitute the 2047th +occurrence of \fB'x'\fP on a line. +.LP +The use of printing commands with printing suffixes (such as \fBpn\fP, +\fBlp\fP, and so on) was made unspecified because +BSD-based systems allow this, whereas System V does not. +.LP +Some BSD-based systems exit immediately upon receipt of end-of-file +if all of the lines in the file have been deleted. Since +this volume of IEEE\ Std\ 1003.1-2001 refers to the \fBq\fP command +in this instance, such behavior is not allowed. +.LP +Some historical implementations returned exit status zero even if +command errors had occurred; this is not allowed by this +volume of IEEE\ Std\ 1003.1-2001. +.LP +Some historical implementations contained a bug that allowed a single +period to be entered in input mode as <backslash> +<period> <newline>. This is not allowed by \fIed\fP because there +is no description of escaping any of the characters +in input mode; backslashes are entered into the buffer exactly as +typed. The typical method of entering a single period has been to +precede it with another character and then use the substitute command +to delete that character. +.LP +It is difficult under some modes of some versions of historical operating +system terminal drivers to distinguish between an +end-of-file condition and terminal disconnect. IEEE\ Std\ 1003.1-2001 +does not require implementations to distinguish +between the two situations, which permits historical implementations +of the \fIed\fP utility on historical platforms to conform. +Implementations are encouraged to distinguish between the two, if +possible, and take appropriate action on terminal disconnect. +.LP +Historically, \fIed\fP accepted a zero address for the \fBa\fP and +\fBr\fP commands in order to insert text at the start of +the edit buffer. When the buffer was empty the command \fB.=\fP returned +zero. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. +.LP +For consistency with the \fBa\fP and \fBr\fP commands and better user +functionality, the \fBi\fP and \fBc\fP commands must +also accept an address of 0, in which case 0\fIi\fP is treated as +1\fIi\fP and likewise for the \fBc\fP command. +.LP +All of the following are valid addresses: +.TP 7 +\fB+++\fP +Three lines after the current line. +.TP 7 +\fB/\fP\fIpattern\fP\fB/-\fP +One line before the next occurrence of pattern. +.TP 7 +\fB-2\fP +Two lines before the current line. +.TP 7 +\fB3\ ----\ 2\fP +Line one (note the intermediate negative address). +.TP 7 +\fB1\ 2\ 3\fP +Line six. +.sp +.LP +Any number of addresses can be provided to commands taking addresses; +for example, \fB"1,2,3,4,5p"\fP prints lines 4 and 5, +because two is the greatest valid number of addresses accepted by +the \fBprint\fP command. This, in combination with the semicolon +delimiter, permits users to create commands based on ordered patterns +in the file. For example, the command \fB"3;/foo/;+2p"\fP +will display the first line after line 3 that contains the pattern +\fIfoo\fP, plus the next two lines. Note that the address +\fB"3;"\fP must still be evaluated before being discarded, because +the search origin for the \fB"/foo/"\fP command depends on +this. +.LP +Historically, \fIed\fP disallowed address chains, as discussed above, +consisting solely of comma or semicolon separators; for +example, \fB",,,"\fP or \fB";;;"\fP were considered an error. For +consistency of address specification, this restriction is +removed. The following table lists some of the address forms now possible: +.TS C +center; l2 l2 l2 l2 l. +\fBAddress\fP \fBAddr1\fP \fBAddr2\fP \fBStatus\fP \fBComment\fP +7, 7 7 Historical \ +7,5, 5 5 Historical \ +7,5,9 5 9 Historical \ +7,9 7 9 Historical \ +7,+ 7 8 Historical \ +, 1 $ Historical \ +,7 1 7 Extension \ +,, $ $ Extension \ +,; $ $ Extension \ +7; 7 7 Historical \ +7;5; 5 5 Historical \ +7;5;9 5 9 Historical \ +7;5,9 5 9 Historical \ +7;$;4 $ 4 Historical Valid, but erroneous. +7;9 7 9 Historical \ +7;+ 7 8 Historical \ +; . $ Historical \ +;7 . 7 Extension \ +;; $ $ Extension \ +;, $ $ Extension \ +.TE +.LP +Historically, values could be added to addresses by including them +after one or more <blank>s; for example, +\fB"3\ -\ 5p"\fP wrote the seventh line of the file, and \fB"/foo/\ 5"\fP +was the same as \fB"5\ /foo/"\fP +\&. However, only absolute values could be added; for example, \fB"5\ /foo/"\fP +was an error. IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice. +.LP +Historically, \fIed\fP accepted the \fB'^'\fP character as an address, +in which case it was identical to the hyphen +character. IEEE\ Std\ 1003.1-2001 does not require or prohibit this +behavior. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIUtility Description Defaults\fP , \fIex\fP , \fIsed\fP , \fIsh\fP +, \fIvi\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/env.1p b/man1p/env.1p new file mode 100644 index 000000000..96a833213 --- /dev/null +++ b/man1p/env.1p @@ -0,0 +1,233 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ENV" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" env +.SH NAME +env \- set the environment for command invocation +.SH SYNOPSIS +.LP +\fBenv\fP \fB[\fP\fB-i\fP\fB][\fP\fIname\fP\fB=\fP\fIvalue\fP\fB]\fP\fB...\fP +\fB[\fP\fIutility\fP +\fB[\fP\fIargument\fP\fB...\fP\fB]]\fP +.SH DESCRIPTION +.LP +The \fIenv\fP utility shall obtain the current environment, modify +it according to its arguments, then invoke the utility named +by the \fIutility\fP operand with the modified environment. +.LP +Optional arguments shall be passed to \fIutility\fP. +.LP +If no \fIutility\fP operand is specified, the resulting environment +shall be written to the standard output, with one +\fIname\fP= \fIvalue\fP pair per line. +.SH OPTIONS +.LP +The \fIenv\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-i\fP +Invoke \fIutility\fP with exactly the environment specified by the +arguments; the inherited environment shall be ignored +completely. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIname\fP=\fIvalue\fP +Arguments of the form \fIname\fP= \fIvalue\fP shall modify the execution +environment, and shall be placed into the inherited +environment before the \fIutility\fP is invoked. +.TP 7 +\fIutility\fP +The name of the utility to be invoked. If the \fIutility\fP operand +names any of the special built-in utilities in \fISpecial Built-In +Utilities\fP , the results are undefined. +.TP 7 +\fIargument\fP +A string to pass as an argument for the invoked utility. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIenv\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the location of the \fIutility\fP, as described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables. If \fIPATH\fP is specified as a \fIname\fP= \fIvalue\fP +operand to \fIenv\fP, the \fIvalue\fP given shall be used in the search +for \fIutility\fP. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If no \fIutility\fP operand is specified, each \fIname\fP= \fIvalue\fP +pair in the resulting environment shall be written in +the form: +.sp +.RS +.nf + +\fB"%s=%s\\n", <\fP\fIname\fP\fB>, <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +If the \fIutility\fP operand is specified, the \fIenv\fP utility shall +not write to standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If \fIutility\fP is invoked, the exit status of \fIenv\fP shall be +the exit status of \fIutility\fP; otherwise, the +\fIenv\fP utility shall exit with one of the following values: +.TP 7 +\ \ \ \ 0 +The \fIenv\fP utility completed successfully. +.TP 7 +1-125 +An error occurred in the \fIenv\fP utility. +.TP 7 +\ \ 126 +The utility specified by \fIutility\fP was found but could not be +invoked. +.TP 7 +\ \ 127 +The utility specified by \fIutility\fP could not be found. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIcommand\fP, \fIenv\fP, \fInice\fP, \fInohup\fP, \fItime\fP, +and \fIxargs\fP utilities have been specified to use exit code 127 +if an error occurs so that +applications can distinguish "failure to find a utility" from "invoked +utility exited with an error indication". The value 127 +was chosen because it is not commonly used for other meanings; most +utilities use small values for "normal error conditions" and +the values above 128 can be confused with termination due to receipt +of a signal. The value 126 was chosen in a similar manner to +indicate that the utility could be found, but not invoked. Some scripts +produce meaningful error messages differentiating the 126 +and 127 cases. The distinction between exit codes 126 and 127 is based +on KornShell practice that uses 127 when all attempts to +\fIexec\fP the utility fail with [ENOENT], and uses 126 when any attempt +to \fIexec\fP the utility fails for any other +reason. +.LP +Historical implementations of the \fIenv\fP utility use the \fIexecvp\fP() +or \fIexeclp\fP() functions defined in the System Interfaces volume +of IEEE\ Std\ 1003.1-2001 +to invoke the specified utility; this provides better performance +and keeps users from having to escape characters with special +meaning to the shell. Therefore, shell functions, special built-ins, +and built-ins that are only provided by the shell are not +found. +.SH EXAMPLES +.LP +The following command: +.sp +.RS +.nf + +\fBenv -i PATH=/mybin mygrep xyz myfile +\fP +.fi +.RE +.LP +invokes the command \fImygrep\fP with a new \fIPATH\fP value as the +only entry in its environment. In this case, \fIPATH\fP +is used to locate \fImygrep\fP, which then must reside in \fB/mybin\fP. +.SH RATIONALE +.LP +As with all other utilities that invoke other utilities, this volume +of IEEE\ Std\ 1003.1-2001 only specifies what +\fIenv\fP does with standard input, standard output, standard error, +input files, and output files. If a utility is executed, it +is not constrained by the specification of input and output by \fIenv\fP. +.LP +The \fB-i\fP option was added to allow the functionality of the withdrawn +\fB-\fP option in a manner compatible with the +Utility Syntax Guidelines. +.LP +Some have suggested that \fIenv\fP is redundant since the same effect +is achieved by: +.sp +.RS +.nf + +\fBname=value ... utility\fP \fB[\fP \fBargument ...\fP \fB]\fP +.fi +.RE +.LP +The example is equivalent to \fIenv\fP when an environment variable +is being added to the environment of the command, but not +when the environment is being set to the given value. The \fIenv\fP +utility also writes out the current environment if invoked +without arguments. There is sufficient functionality beyond what the +example provides to justify inclusion of \fIenv\fP. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIParameters and Variables\fP , \fISpecial +Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/eval.1p b/man1p/eval.1p new file mode 100644 index 000000000..c38b1b985 --- /dev/null +++ b/man1p/eval.1p @@ -0,0 +1,90 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "EVAL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" eval +.SH NAME +eval \- construct command by concatenating arguments +.SH SYNOPSIS +.LP +\fBeval\fP \fB[\fP\fIargument\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIeval\fP utility shall construct a command by concatenating +\fIargument\fPs together, separating each with a +<space>. The constructed command shall be read and executed by the +shell. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If there are no \fIargument\fPs, or only null arguments, \fIeval\fP +shall return a zero exit status; otherwise, it shall +return the exit status of the command defined by the string of concatenated +\fIargument\fPs separated by <space>s. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fBfoo=10 x=foo +y='$'$x +echo $y +\fP\fB$foo\fP\fBeval y='$'$x +echo $y +\fP\fB10\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ex.1p b/man1p/ex.1p new file mode 100644 index 000000000..9c29dc3f9 --- /dev/null +++ b/man1p/ex.1p @@ -0,0 +1,6056 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "EX" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ex +.SH NAME +ex \- text editor +.SH SYNOPSIS +.LP +\fBex\fP \fB[\fP\fB-rR\fP\fB][\fP\fB-s | -v\fP\fB][\fP\fB-c\fP +\fIcommand\fP\fB][\fP\fB-t\fP \fItagstring\fP\fB][\fP\fB-w\fP \fIsize\fP\fB][\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIex\fP utility is a line-oriented text editor. There are two +other modes of the editor-open and visual-in which +screen-oriented editing is available. This is described more fully +by the \fIex\fP \fBopen\fP and \fBvisual\fP commands and in +\fIvi\fP . +.LP +This section uses the term \fIedit buffer\fP to describe the current +working text. No specific implementation is implied by +this term. All editing changes are performed on the edit buffer, and +no changes to it shall affect any file until an editor command +writes the file. +.LP +Certain terminals do not have all the capabilities necessary to support +the complete \fIex\fP definition, such as the +full-screen editing commands ( \fIvisual mode\fP or \fIopen mode\fP). +When these commands cannot be supported on such terminals, +this condition shall not produce an error message such as "not an +editor command" or report a syntax error. The implementation +may either accept the commands and produce results on the screen that +are the result of an unsuccessful attempt to meet the +requirements of this volume of IEEE\ Std\ 1003.1-2001 or report an +error describing the terminal-related deficiency. +.SH OPTIONS +.LP +The \fIex\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\ \fP \fIcommand\fP +Specify an initial command to be executed in the first edit buffer +loaded from an existing file (see the EXTENDED DESCRIPTION +section). Implementations may support more than a single \fB-c\fP +option. In such implementations, the specified commands shall be +executed in the order specified on the command line. +.TP 7 +\fB-r\fP +Recover the named files (see the EXTENDED DESCRIPTION section). Recovery +information for a file shall be saved during an editor +or system crash (for example, when the editor is terminated by a signal +which the editor can catch), or after the use of an +\fIex\fP \fBpreserve\fP command. +.LP +A \fIcrash\fP in this context is an unexpected failure of the system +or utility that requires restarting the failed system or +utility. A system crash implies that any utilities running at the +time also crash. In the case of an editor or system crash, the +number of changes to the edit buffer (since the most recent \fBpreserve\fP +command) that will be recovered is unspecified. +.LP +If no \fIfile\fP operands are given and the \fB-t\fP option is not +specified, all other options, the \fIEXINIT\fP variable, +and any \fB.exrc\fP files shall be ignored; a list of all recoverable +files available to the invoking user shall be written, and +the editor shall exit normally without further action. +.TP 7 +\fB-R\fP +Set \fBreadonly\fP edit option. +.TP 7 +\fB-s\fP +Prepare \fIex\fP for batch use by taking the following actions: +.RS +.IP " *" 3 +Suppress writing prompts and informational (but not diagnostic) messages. +.LP +.IP " *" 3 +Ignore the value of \fITERM\fP and any implementation default terminal +type and assume the terminal is a type incapable of +supporting open or visual modes; see the \fBvisual\fP command and +the description of \fIvi\fP . +.LP +.IP " *" 3 +Suppress the use of the \fIEXINIT\fP environment variable and the +reading of any \fB.exrc\fP file; see the EXTENDED +DESCRIPTION section. +.LP +.IP " *" 3 +Suppress autoindentation, ignoring the value of the \fBautoindent\fP +edit option. +.LP +.RE +.TP 7 +\fB-t\ \fP \fItagstring\fP +Edit the file containing the specified \fItagstring\fP; see \fIctags\fP +\&. The tags feature +represented by \fB-t\fP \fItagstring\fP and the \fBtag\fP command +is optional. It shall be provided on any system that also +provides a conforming implementation of \fIctags\fP; otherwise, the +use of \fB-t\fP +produces undefined results. On any system, it shall be an error to +specify more than a single \fB-t\fP option. +.TP 7 +\fB-v\fP +Begin in visual mode (see \fIvi\fP ). +.TP 7 +\fB-w\ \fP \fIsize\fP +Set the value of the \fIwindow\fP editor option to \fIsize\fP. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be edited. +.sp +.SH STDIN +.LP +The standard input consists of a series of commands and input text, +as described in the EXTENDED DESCRIPTION section. The +implementation may limit each line of standard input to a length of +{LINE_MAX}. +.LP +If the standard input is not a terminal device, it shall be as if +the \fB-s\fP option had been specified. +.LP +If a read from the standard input returns an error, or if the editor +detects an end-of-file condition from the standard input, +it shall be equivalent to a SIGHUP asynchronous event. +.SH INPUT FILES +.LP +Input files shall be text files or files that would be text files +except for an incomplete last line that is not longer than +{LINE_MAX}-1 bytes in length and contains no NUL characters. By default, +any incomplete last line shall be treated as if it had a +trailing <newline>. The editing of other forms of files may optionally +be allowed by \fIex\fP implementations. +.LP +The \fB.exrc\fP files and source files shall be text files consisting +of \fIex\fP commands; see the EXTENDED DESCRIPTION +section. +.LP +By default, the editor shall read lines from the files to be edited +without interpreting any of those lines as any form of +editor command. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIex\fP: +.TP 7 +\fICOLUMNS\fP +Override the system-selected horizontal screen size. See the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables for valid values and results when it is unset or null. +.TP 7 +\fIEXINIT\fP +Determine a list of \fIex\fP commands that are executed on editor +start-up. See the EXTENDED DESCRIPTION section for more +details of the initialization phase. +.TP 7 +\fIHOME\fP +Determine a pathname of a directory that shall be searched for an +editor start-up file named \fB.exrc\fP; see the EXTENDED +DESCRIPTION section. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +behavior of character classes within regular expressions, the +classification of characters as uppercase or lowercase letters, the +case conversion of letters, and the detection of word +boundaries. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILINES\fP +Override the system-selected vertical screen size, used as the number +of lines in a screenful and the vertical screen size in +visual mode. See the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 8, +Environment Variables for valid values and results when it is unset +or null. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the search path for the shell command specified in the \fIex\fP +editor commands \fB!\fP, \fBshell\fP, \fBread\fP, +and \fBwrite\fP, and the open and visual mode command \fB!\fP; see +the description of command search and execution in \fICommand Search +and Execution\fP . +.TP 7 +\fISHELL\fP +Determine the preferred command line interpreter for use as the default +value of the \fBshell\fP edit option. +.TP 7 +\fITERM\fP +Determine the name of the terminal type. If this variable is unset +or null, an unspecified default terminal type shall be +used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +The following term is used in this and following sections to specify +command and asynchronous event actions: +.TP 7 +\fIcomplete\ write\fP +.sp +A complete write is a write of the entire contents of the edit buffer +to a file of a type other than a terminal device, or the +saving of the edit buffer caused by the user executing the \fIex\fP +\fBpreserve\fP command. Writing the contents of the edit +buffer to a temporary file that will be removed when the editor exits +shall not be considered a complete write. +.sp +.LP +The following actions shall be taken upon receipt of signals: +.TP 7 +SIGINT +If the standard input is not a terminal device, \fIex\fP shall not +write the file or return to command or text input mode, and +shall exit with a non-zero exit status. +.LP +Otherwise, if executing an open or visual text input mode command, +\fIex\fP in receipt of SIGINT shall behave identically to +its receipt of the <ESC> character. +.LP +Otherwise: +.RS +.IP " 1." 4 +If executing an \fIex\fP text input mode command, all input lines +that have been completely entered shall be resolved into the +edit buffer, and any partially entered line shall be discarded. +.LP +.IP " 2." 4 +If there is a currently executing command, it shall be aborted and +a message displayed. Unless otherwise specified by the +\fIex\fP or \fIvi\fP command descriptions, it is unspecified whether +any lines modified by the +executing command appear modified, or as they were before being modified +by the executing command, in the buffer. +.LP +If the currently executing command was a motion command, its associated +command shall be discarded. +.LP +.IP " 3." 4 +If in open or visual command mode, the terminal shall be alerted. +.LP +.IP " 4." 4 +The editor shall then return to command mode. +.LP +.RE +.TP 7 +SIGCONT +The screen shall be refreshed if in open or visual mode. +.TP 7 +SIGHUP +If the edit buffer has been modified since the last complete write, +\fIex\fP shall attempt to save the edit buffer so that it +can be recovered later using the \fB-r\fP option or the \fIex\fP \fBrecover\fP +command. The editor shall not write the file or +return to command or text input mode, and shall terminate with a non-zero +exit status. +.TP 7 +SIGTERM +Refer to SIGHUP. +.sp +.LP +The action taken for all other signals is unspecified. +.SH STDOUT +.LP +The standard output shall be used only for writing prompts to the +user, for informational messages, and for writing lines from +the file. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output from \fIex\fP shall be text files. +.SH EXTENDED DESCRIPTION +.LP +Only the \fIex\fP mode of the editor is described in this section. +See \fIvi\fP for additional editing +capabilities available in \fIex\fP. +.LP +When an error occurs, \fIex\fP shall write a message. If the terminal +supports a standout mode (such as inverse video), the +message shall be written in standout mode. If the terminal does not +support a standout mode, and the edit option \fBerrorbells\fP +is set, an alert action shall precede the error message. +.LP +By default, \fIex\fP shall start in command mode, which shall be indicated +by a \fB:\fP prompt; see the \fBprompt\fP command. +Text input mode can be entered by the \fBappend\fP, \fBinsert\fP, +or \fBchange\fP commands; it can be exited (and command mode +re-entered) by typing a period ( \fB'.'\fP ) alone at the beginning +of a line. +.SS Initialization in ex and vi +.LP +The following symbols are used in this and following sections to specify +locations in the edit buffer: +.TP 7 +\fIalternate\ and\ current\ pathnames\fP +.sp +Two pathnames, named \fIcurrent\fP and \fIalternate\fP, are maintained +by the editor. Any \fIex\fP commands that take filenames +as arguments shall set them as follows: +.RS +.IP " 1." 4 +If a \fIfile\fP argument is specified to the \fIex\fP \fBedit\fP, +\fBex\fP, or \fBrecover\fP commands, or if an \fIex\fP +\fBtag\fP command replaces the contents of the edit buffer. +.RS +.IP " a." 4 +If the command replaces the contents of the edit buffer, the current +pathname shall be set to the \fIfile\fP argument or the +file indicated by the tag, and the alternate pathname shall be set +to the previous value of the current pathname. +.LP +.IP " b." 4 +Otherwise, the alternate pathname shall be set to the \fIfile\fP argument. +.LP +.RE +.LP +.IP " 2." 4 +If a \fIfile\fP argument is specified to the \fIex\fP \fBnext\fP command: +.RS +.IP " a." 4 +If the command replaces the contents of the edit buffer, the current +pathname shall be set to the first \fIfile\fP argument, +and the alternate pathname shall be set to the previous value of the +current pathname. +.LP +.RE +.LP +.IP " 3." 4 +If a \fIfile\fP argument is specified to the \fIex\fP \fBfile\fP command, +the current pathname shall be set to the +\fIfile\fP argument, and the alternate pathname shall be set to the +previous value of the current pathname. +.LP +.IP " 4." 4 +If a \fIfile\fP argument is specified to the \fIex\fP \fBread\fP and +\fBwrite\fP commands (that is, when reading or writing +a file, and not to the program named by the \fBshell\fP edit option), +or a \fIfile\fP argument is specified to the \fIex\fP +\fBxit\fP command: +.RS +.IP " a." 4 +If the current pathname has no value, the current pathname shall be +set to the \fIfile\fP argument. +.LP +.IP " b." 4 +Otherwise, the alternate pathname shall be set to the \fIfile\fP argument. +.LP +.RE +.LP +.RE +.LP +If the alternate pathname is set to the previous value of the current +pathname when the current pathname had no previous value, +then the alternate pathname shall have no value as a result. +.TP 7 +\fIcurrent\ line\fP +.sp +The line of the edit buffer referenced by the cursor. Each command +description specifies the current line after the command has +been executed, as the \fIcurrent line value\fP. When the edit buffer +contains no lines, the current line shall be zero; see Addressing +in ex . +.TP 7 +\fIcurrent\ column\fP +.sp +The current display line column occupied by the cursor. (The columns +shall be numbered beginning at 1.) Each command description +specifies the current column after the command has been executed, +as the \fIcurrent column\fP value. This column is an +\fIideal\fP column that is remembered over the lifetime of the editor. +The actual display line column upon which the cursor rests +may be different from the current column; see the cursor positioning +discussion in \fICommand +Descriptions in vi\fP . +.TP 7 +\fIset\ to\ non-<blank>\fP +.sp +A description for a current column value, meaning that the current +column shall be set to the last display line column on which is +displayed any part of the first non- <blank> of the line. If the line +has no non- <blank> non- <newline>s, the +current column shall be set to the last display line column on which +is displayed any part of the last non- <newline> in the +line. If the line is empty, the current column shall be set to column +position 1. +.sp +.LP +The length of lines in the edit buffer may be limited to {LINE_MAX} +bytes. In open and visual mode, the length of lines in the +edit buffer may be limited to the number of characters that will fit +in the display. If either limit is exceeded during editing, an +error message shall be written. If either limit is exceeded by a line +read in from a file, an error message shall be written and +the edit session may be terminated. +.LP +If the editor stops running due to any reason other than a user command, +and the edit buffer has been modified since the last +complete write, it shall be equivalent to a SIGHUP asynchronous event. +If the system crashes, it shall be equivalent to a SIGHUP +asynchronous event. +.LP +During initialization (before the first file is copied into the edit +buffer or any user commands from the terminal are +processed) the following shall occur: +.IP " 1." 4 +If the environment variable \fIEXINIT\fP is set, the editor shall +execute the \fIex\fP commands contained in that +variable. +.LP +.IP " 2." 4 +If the \fIEXINIT\fP variable is not set, and all of the following +are true: +.RS +.IP " a." 4 +The \fIHOME\fP environment variable is not null and not empty. +.LP +.IP " b." 4 +The file \fB.exrc\fP in the directory referred to by the \fIHOME\fP +environment variable: +.RS +.IP " 1." 4 +Exists +.LP +.IP " 2." 4 +Is owned by the same user ID as the real user ID of the process or +the process has appropriate privileges +.LP +.IP " 3." 4 +Is not writable by anyone other than the owner +.LP +.RE +.LP +.RE +.LP +the editor shall execute the \fIex\fP commands contained in that file. +.LP +.IP " 3." 4 +If and only if all of the following are true: +.RS +.IP " a." 4 +The current directory is not referred to by the \fIHOME\fP environment +variable. +.LP +.IP " b." 4 +A command in the \fIEXINIT\fP environment variable or a command in +the \fB.exrc\fP file in the directory referred to by the +\fIHOME\fP environment variable sets the editor option \fBexrc\fP. +.LP +.IP " c." 4 +The \fB.exrc\fP file in the current directory: +.RS +.IP " 1." 4 +Exists +.LP +.IP " 2." 4 +Is owned by the same user ID as the real user ID of the process, or +by one of a set of implementation-defined user IDs +.LP +.IP " 3." 4 +Is not writable by anyone other than the owner +.LP +.RE +.LP +.RE +.LP +the editor shall attempt to execute the \fIex\fP commands contained +in that file. +.LP +.LP +Lines in any \fB.exrc\fP file that are blank lines shall be ignored. +If any \fB.exrc\fP file exists, but is not read for +ownership or permission reasons, it shall be an error. +.LP +After the \fIEXINIT\fP variable and any \fB.exrc\fP files are processed, +the first file specified by the user shall be edited, +as follows: +.IP " 1." 4 +If the user specified the \fB-t\fP option, the effect shall be as +if the \fIex\fP \fBtag\fP command was entered with the +specified argument, with the exception that if tag processing does +not result in a file to edit, the effect shall be as described +in step 3. below. +.LP +.IP " 2." 4 +Otherwise, if the user specified any command line \fIfile\fP arguments, +the effect shall be as if the \fIex\fP \fBedit\fP +command was entered with the first of those arguments as its \fIfile\fP +argument. +.LP +.IP " 3." 4 +Otherwise, the effect shall be as if the \fIex\fP \fBedit\fP command +was entered with a nonexistent filename as its +\fIfile\fP argument. It is unspecified whether this action shall set +the current pathname. In an implementation where this action +does not set the current pathname, any editor command using the current +pathname shall fail until an editor command sets the +current pathname. +.LP +.LP +If the \fB-r\fP option was specified, the first time a file in the +initial argument list or a file specified by the \fB-t\fP +option is edited, if recovery information has previously been saved +about it, that information shall be recovered and the editor +shall behave as if the contents of the edit buffer have already been +modified. If there are multiple instances of the file to be +recovered, the one most recently saved shall be recovered, and an +informational message that there are previous versions of the +file that can be recovered shall be written. If no recovery information +about a file is available, an informational message to this +effect shall be written, and the edit shall proceed as usual. +.LP +If the \fB-c\fP option was specified, the first time a file that already +exists (including a file that might not exist but for +which recovery information is available, when the \fB-r\fP option +is specified) replaces or initializes the contents of the edit +buffer, the current line shall be set to the last line of the edit +buffer, the current column shall be set to non- <blank>, +and the \fIex\fP commands specified with the \fB-c\fP option shall +be executed. In this case, the current line and current column +shall not be set as described for the command associated with the +replacement or initialization of the edit buffer contents. +However, if the \fB-t\fP option or a \fBtag\fP command is associated +with this action, the \fB-c\fP option commands shall be +executed and then the movement to the tag shall be performed. +.LP +The current argument list shall initially be set to the filenames +specified by the user on the command line. If no filenames are +specified by the user, the current argument list shall be empty. If +the \fB-t\fP option was specified, it is unspecified whether +any filename resulting from tag processing shall be prepended to the +current argument list. In the case where the filename is added +as a prefix to the current argument list, the current argument list +reference shall be set to that filename. In the case where the +filename is not added as a prefix to the current argument list, the +current argument list reference shall logically be located +before the first of the filenames specified on the command line (for +example, a subsequent \fIex\fP \fBnext\fP command shall edit +the first filename from the command line). If the \fB-t\fP option +was not specified, the current argument list reference shall be +to the first of the filenames on the command line. +.SS Addressing in ex +.LP +Addressing in \fIex\fP relates to the current line and the current +column; the address of a line is its 1-based line number, +the address of a column is its 1-based count from the beginning of +the line. Generally, the current line is the last line affected +by a command. The current line number is the address of the current +line. In each command description, the effect of the command on +the current line number and the current column is described. +.LP +Addresses are constructed as follows: +.IP " 1." 4 +The character \fB'.'\fP (period) shall address the current line. +.LP +.IP " 2." 4 +The character \fB'$'\fP shall address the last line of the edit buffer. +.LP +.IP " 3." 4 +The positive decimal number \fIn\fP shall address the \fIn\fPth line +of the edit buffer. +.LP +.IP " 4." 4 +The address \fB"'x"\fP refers to the line marked with the mark name +character \fB'x'\fP , which shall be a lowercase +letter from the portable character set or one of the characters \fB'`'\fP +or \fB'"\fP . It shall be an error if the line +that was marked is not currently present in the edit buffer or the +mark has not been set. Lines can be marked with the \fIex\fP +\fBmark\fP or \fBk\fP commands, or the \fIvi\fP \fBm\fP command. +.LP +.IP " 5." 4 +A regular expression enclosed by slashes ( \fB'/'\fP ) shall address +the first line found by searching forwards from the line +following the current line toward the end of the edit buffer and stopping +at the first line for which the line excluding the +terminating <newline> matches the regular expression. As stated in +Regular Expressions in ex , +an address consisting of a null regular expression delimited by slashes +\fB"//"\fP shall address the next line for which the +line excluding the terminating <newline> matches the last regular +expression encountered. In addition, the second slash can +be omitted at the end of a command line. If the \fBwrapscan\fP edit +option is set, the search shall wrap around to the beginning +of the edit buffer and continue up to and including the current line, +so that the entire edit buffer is searched. Within the +regular expression, the sequence \fB"\\/"\fP shall represent a literal +slash instead of the regular expression delimiter. +.LP +.IP " 6." 4 +A regular expression enclosed in question marks ( \fB'?'\fP ) shall +address the first line found by searching backwards from +the line preceding the current line toward the beginning of the edit +buffer and stopping at the first line for which the line +excluding the terminating <newline> matches the regular expression. +An address consisting of a null regular expression +delimited by question marks \fB"??"\fP shall address the previous +line for which the line excluding the terminating +<newline> matches the last regular expression encountered. In addition, +the second question mark can be omitted at the end of +a command line. If the \fBwrapscan\fP edit option is set, the search +shall wrap around from the beginning of the edit buffer to +the end of the edit buffer and continue up to and including the current +line, so that the entire edit buffer is searched. Within +the regular expression, the sequence \fB"\\?"\fP shall represent a +literal question mark instead of the RE delimiter. +.LP +.IP " 7." 4 +A plus sign ( \fB'+'\fP ) or a minus sign ( \fB'-'\fP ) followed by +a decimal number shall address the current line plus +or minus the number. A \fB'+'\fP or \fB'-'\fP not followed by a decimal +number shall address the current line plus or minus +1. +.LP +.LP +Addresses can be followed by zero or more address offsets, optionally +<blank>-separated. Address offsets are constructed +as follows: +.IP " 1." 4 +A \fB'+'\fP or \fB'-'\fP immediately followed by a decimal number +shall add (subtract) the indicated number of lines to +(from) the address. A \fB'+'\fP or \fB'-'\fP not followed by a decimal +number shall add (subtract) 1 to (from) the +address. +.LP +.IP " 2." 4 +A decimal number shall add the indicated number of lines to the address. +.LP +.LP +It shall not be an error for an intermediate address value to be less +than zero or greater than the last line in the edit +buffer. It shall be an error for the final address value to be less +than zero or greater than the last line in the edit buffer. +.LP +Commands take zero, one, or two addresses; see the descriptions of +\fI1addr\fP and \fI2addr\fP in Command Descriptions in ex . If more +than the required number of addresses are provided to a command that +requires zero addresses, it shall be an error. Otherwise, if more +than the required number of addresses are provided to a command, +the addresses specified first shall be evaluated and then discarded +until the maximum number of valid addresses remain. +.LP +Addresses shall be separated from each other by a comma ( \fB','\fP +) or a semicolon ( \fB';'\fP ). If no address is +specified before or after a comma or semicolon separator, it shall +be as if the address of the current line was specified before or +after the separator. In the case of a semicolon separator, the current +line ( \fB'.'\fP ) shall be set to the first address, and +only then will the next address be calculated. This feature can be +used to determine the starting line for forwards and backwards +searches (see rules 5. and 6.). +.LP +A percent sign ( \fB'%'\fP ) shall be equivalent to entering the two +addresses \fB"1,$"\fP . +.LP +Any delimiting <blank>s between addresses, address separators, or +address offsets shall be discarded. +.SS Command Line Parsing in ex +.LP +The following symbol is used in this and following sections to describe +parsing behavior: +.TP 7 +\fIescape\fP +If a character is referred to as "backslash-escaped" or " <control>-V-escaped," +it shall mean that the character +acquired or lost a special meaning by virtue of being preceded, respectively, +by a backslash or <control>-V character. Unless +otherwise specified, the escaping character shall be discarded at +that time and shall not be further considered for any +purpose. +.sp +.LP +Command-line parsing shall be done in the following steps. For each +step, characters already evaluated shall be ignored; that +is, the phrase "leading character" refers to the next character that +has not yet been evaluated. +.IP " 1." 4 +Leading colon characters shall be skipped. +.LP +.IP " 2." 4 +Leading <blank>s shall be skipped. +.LP +.IP " 3." 4 +If the leading character is a double-quote character, the characters +up to and including the next non-backslash-escaped +<newline> shall be discarded, and any subsequent characters shall +be parsed as a separate command. +.LP +.IP " 4." 4 +Leading characters that can be interpreted as addresses shall be evaluated; +see Addressing in ex +\&. +.LP +.IP " 5." 4 +Leading <blank>s shall be skipped. +.LP +.IP " 6." 4 +If the next character is a vertical-line character or a <newline>: +.RS +.IP " a." 4 +If the next character is a <newline>: +.RS +.IP " 1." 4 +If \fIex\fP is in open or visual mode, the current line shall be set +to the last address specified, if any. +.LP +.IP " 2." 4 +Otherwise, if the last command was terminated by a vertical-line character, +no action shall be taken; for example, the command +\fB"||<newline>"\fP shall execute two implied commands, not three. +.LP +.IP " 3." 4 +Otherwise, step 6.b. shall apply. +.LP +.RE +.LP +.IP " b." 4 +Otherwise, the implied command shall be the \fBprint\fP command. The +last \fB#\fP, \fBp\fP, and \fBl\fP flags specified to +any \fIex\fP command shall be remembered and shall apply to this implied +command. Executing the \fIex\fP \fBnumber\fP, +\fBprint\fP, or \fBlist\fP command shall set the remembered flags +to \fB#\fP, nothing, and \fBl\fP, respectively, plus any +other flags specified for that execution of the \fBnumber\fP, \fBprint\fP, +or \fBlist\fP command. +.LP +If \fIex\fP is not currently performing a \fBglobal\fP or \fBv\fP +command, and no address or count is specified, the current +line shall be incremented by 1 before the command is executed. If +incrementing the current line would result in an address past the +last line in the edit buffer, the command shall fail, and the increment +shall not happen. +.LP +.IP " c." 4 +The <newline> or vertical-line character shall be discarded and any +subsequent characters shall be parsed as a separate +command. +.LP +.RE +.LP +.IP " 7." 4 +The command name shall be comprised of the next character (if the +character is not alphabetic), or the next character and any +subsequent alphabetic characters (if the character is alphabetic), +with the following exceptions: +.RS +.IP " a." 4 +Commands that consist of any prefix of the characters in the command +name \fBdelete\fP, followed immediately by any of the +characters \fB'l'\fP , \fB'p'\fP , \fB'+'\fP , \fB'-'\fP , or \fB'#'\fP +shall be interpreted as a \fBdelete\fP +command, followed by a <blank>, followed by the characters that were +not part of the prefix of the \fBdelete\fP command. The +maximum number of characters shall be matched to the command name +\fBdelete\fP; for example, \fB"del"\fP shall not be treated +as \fB"de"\fP followed by the flag \fBl\fP. +.LP +.IP " b." 4 +Commands that consist of the character \fB'k'\fP , followed by a character +that can be used as the name of a mark, shall be +equivalent to the mark command followed by a <blank>, followed by +the character that followed the \fB'k'\fP . +.LP +.IP " c." 4 +Commands that consist of the character \fB's'\fP , followed by characters +that could be interpreted as valid options to the +\fBs\fP command, shall be the equivalent of the \fBs\fP command, without +any pattern or replacement values, followed by a +<blank>, followed by the characters after the \fB's'\fP . +.LP +.RE +.LP +.IP " 8." 4 +The command name shall be matched against the possible command names, +and a command name that contains a prefix matching the +characters specified by the user shall be the executed command. In +the case of commands where the characters specified by the user +could be ambiguous, the executed command shall be as follows: +.TS C +center; l l l l l l l l. +\fBa\fP \fBappend\fP n \fBnext\fP \fBt\fP t \fB\ \fP \fB\ \fP +\fBc\fP \fBchange\fP p \fBprint\fP \fBu\fP undo \fB\ \fP \fB\ \fP +\fBch\fP \fBchange\fP pr \fBprint\fP \fBun\fP undo \fB\ \fP \fB\ \fP +\fBe\fP \fBedit\fP r \fBread\fP \fBv\fP v \fB\ \fP \fB\ \fP +\fBm\fP \fBmove\fP re \fBread\fP \fBw\fP write \fB\ \fP \fB\ \fP +\fBma\fP \fBmark\fP s \fBs\fP \fB\ \fP \ \fB\ \fP \fB\ \fP +.TE +.LP +Implementation extensions with names causing similar ambiguities shall +not be checked for a match until all possible matches for +commands specified by IEEE\ Std\ 1003.1-2001 have been checked. +.LP +.IP " 9." 4 +If the command is a \fB!\fP command, or if the command is a \fBread\fP +command followed by zero or more <blank>s and a +\fB!\fP, or if the command is a \fBwrite\fP command followed by one +or more <blank>s and a \fB!\fP, the rest of the +command shall include all characters up to a non-backslash-escaped +<newline>. The <newline> shall be discarded and any +subsequent characters shall be parsed as a separate \fIex\fP command. +.LP +.IP "10." 4 +Otherwise, if the command is an \fBedit\fP, \fBex\fP, or \fBnext\fP +command, or a \fBvisual\fP command while in open or +visual mode, the next part of the command shall be parsed as follows: +.RS +.IP " a." 4 +Any \fB'!'\fP character immediately following the command shall be +skipped and be part of the command. +.LP +.IP " b." 4 +Any leading <blank>s shall be skipped and be part of the command. +.LP +.IP " c." 4 +If the next character is a \fB'+'\fP , characters up to the first +non-backslash-escaped <newline> or +non-backslash-escaped <blank> shall be skipped and be part of the +command. +.LP +.IP " d." 4 +The rest of the command shall be determined by the steps specified +in paragraph 12. +.LP +.RE +.LP +.IP "11." 4 +Otherwise, if the command is a \fBglobal\fP, \fBopen\fP, \fBs\fP, +or \fBv\fP command, the next part of the command shall be +parsed as follows: +.RS +.IP " a." 4 +Any leading <blank>s shall be skipped and be part of the command. +.LP +.IP " b." 4 +If the next character is not an alphanumeric, double-quote, <newline>, +backslash, or vertical-line character: +.RS +.IP " 1." 4 +The next character shall be used as a command delimiter. +.LP +.IP " 2." 4 +If the command is a \fBglobal\fP, \fBopen\fP, or \fBv\fP command, +characters up to the first non-backslash-escaped +<newline>, or first non-backslash-escaped delimiter character, shall +be skipped and be part of the command. +.LP +.IP " 3." 4 +If the command is an \fBs\fP command, characters up to the first non-backslash-escaped +<newline>, or second +non-backslash-escaped delimiter character, shall be skipped and be +part of the command. +.LP +.RE +.LP +.IP " c." 4 +If the command is a \fBglobal\fP or \fBv\fP command, characters up +to the first non-backslash-escaped <newline> shall be +skipped and be part of the command. +.LP +.IP " d." 4 +Otherwise, the rest of the command shall be determined by the steps +specified in paragraph 12. +.LP +.RE +.LP +.IP "12." 4 +Otherwise: +.RS +.IP " a." 4 +If the command was a \fBmap\fP, \fBunmap\fP, \fBabbreviate\fP, or +\fBunabbreviate\fP command, characters up to the first +non- <control>-V-escaped <newline>, vertical-line, or double-quote +character shall be skipped and be part of the +command. +.LP +.IP " b." 4 +Otherwise, characters up to the first non-backslash-escaped <newline>, +vertical-line, or double-quote character shall be +skipped and be part of the command. +.LP +.IP " c." 4 +If the command was an \fBappend\fP, \fBchange\fP, or \fBinsert\fP +command, and the step 12.b. ended at a vertical-line +character, any subsequent characters, up to the next non-backslash-escaped +<newline> shall be used as input text to the +command. +.LP +.IP " d." 4 +If the command was ended by a double-quote character, all subsequent +characters, up to the next non-backslash-escaped +<newline>, shall be discarded. +.LP +.IP " e." 4 +The terminating <newline> or vertical-line character shall be discarded +and any subsequent characters shall be parsed as a +separate \fIex\fP command. +.LP +.RE +.LP +.LP +Command arguments shall be parsed as described by the Synopsis and +Description of each individual \fIex\fP command. This +parsing shall not be <blank>-sensitive, except for the \fB!\fP argument, +which must follow the command name without +intervening <blank>s, and where it would otherwise be ambiguous. For +example, \fIcount\fP and \fIflag\fP arguments need not +be <blank>-separated because \fB"d22p"\fP is not ambiguous, but \fIfile\fP +arguments to the \fIex\fP \fBnext\fP command +must be separated by one or more <blank>s. Any <blank> in command +arguments for the \fBabbreviate\fP, +\fBunabbreviate\fP, \fBmap\fP, and \fBunmap\fP commands can be <control>-V-escaped, +in which case the <blank> shall +not be used as an argument delimiter. Any <blank> in the command argument +for any other command can be backslash-escaped, in +which case that <blank> shall not be used as an argument delimiter. +.LP +Within command arguments for the \fBabbreviate\fP, \fBunabbreviate\fP, +\fBmap\fP, and \fBunmap\fP commands, any character +can be <control>-V-escaped. All such escaped characters shall be treated +literally and shall have no special meaning. Within +command arguments for all other \fIex\fP commands that are not regular +expressions or replacement strings, any character that +would otherwise have a special meaning can be backslash-escaped. Escaped +characters shall be treated literally, without special +meaning as shell expansion characters or \fB'!'\fP , \fB'%'\fP , and +\fB'#'\fP expansion characters. See Regular Expressions in ex and +Replacement Strings in ex for descriptions of +command arguments that are regular expressions or replacement strings. +.LP +Non-backslash-escaped \fB'%'\fP characters appearing in \fIfile\fP +arguments to any \fIex\fP command shall be replaced by +the current pathname; unescaped \fB'#'\fP characters shall be replaced +by the alternate pathname. It shall be an error if +\fB'%'\fP or \fB'#'\fP characters appear unescaped in an argument +and their corresponding values are not set. +.LP +Non-backslash-escaped \fB'!'\fP characters in the arguments to either +the \fIex\fP \fB!\fP command or the open and visual +mode \fB!\fP command, or in the arguments to the \fIex\fP \fBread\fP +command, where the first non- <blank> after the +command name is a \fB'!'\fP character, or in the arguments to the +\fIex\fP \fBwrite\fP command where the command name is +followed by one or more <blank>s and the first non- <blank> after +the command name is a \fB'!'\fP character, shall +be replaced with the arguments to the last of those three commands +as they appeared after all unescaped \fB'%'\fP , \fB'#'\fP +, and \fB'!'\fP characters were replaced. It shall be an error if +\fB'!'\fP characters appear unescaped in one of these +commands and there has been no previous execution of one of these +commands. +.LP +If an error occurs during the parsing or execution of an \fIex\fP +command: +.IP " *" 3 +An informational message to this effect shall be written. Execution +of the \fIex\fP command shall stop, and the cursor (for +example, the current line and column) shall not be further modified. +.LP +.IP " *" 3 +If the \fIex\fP command resulted from a map expansion, all characters +from that map expansion shall be discarded, except as +otherwise specified by the \fBmap\fP command. +.LP +.IP " *" 3 +Otherwise, if the \fIex\fP command resulted from the processing of +an \fIEXINIT\fP environment variable, a \fB.exrc\fP file, +a \fB:source\fP command, a \fB-c\fP option, or a \fB+\fP \fIcommand\fP +specified to an \fIex\fP \fBedit\fP, \fBex\fP, +\fBnext\fP, or \fBvisual\fP command, no further commands from the +source of the commands shall be executed. +.LP +.IP " *" 3 +Otherwise, if the \fIex\fP command resulted from the execution of +a buffer or a \fBglobal\fP or \fBv\fP command, no further +commands caused by the execution of the buffer or the \fBglobal\fP +or \fBv\fP command shall be executed. +.LP +.IP " *" 3 +Otherwise, if the \fIex\fP command was not terminated by a <newline>, +all characters up to and including the next +non-backslash-escaped <newline> shall be discarded. +.LP +.SS Input Editing in ex +.LP +The following symbol is used in this and the following sections to +specify command actions: +.TP 7 +\fIword\fP +In the POSIX locale, a word consists of a maximal sequence of letters, +digits, and underscores, delimited at both ends by +characters other than letters, digits, or underscores, or by the beginning +or end of a line or the edit buffer. +.sp +.LP +When accepting input characters from the user, in either \fIex\fP +command mode or \fIex\fP text input mode, \fIex\fP shall +enable canonical mode input processing, as defined in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001. +.LP +If in \fIex\fP text input mode: +.IP " 1." 4 +If the \fBnumber\fP edit option is set, \fIex\fP shall prompt for +input using the line number that would be assigned to the +line if it is entered, in the format specified for the \fIex\fP \fBnumber\fP +command. +.LP +.IP " 2." 4 +If the \fBautoindent\fP edit option is set, \fIex\fP shall prompt +for input using \fBautoindent\fP characters, as described +by the \fBautoindent\fP edit option. \fBautoindent\fP characters shall +follow the line number, if any. +.LP +.LP +If in \fIex\fP command mode: +.IP " 1." 4 +If the \fBprompt\fP edit option is set, input shall be prompted for +using a single \fB':'\fP character; otherwise, there +shall be no prompt. +.LP +.LP +The input characters in the following sections shall have the following +effects on the input line. +.SS Scroll +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBeof +\fP +.fi +.RE +.sp +.LP +See the description of the \fIstty\fP \fIeof\fP character in \fIstty\fP +\&. +.LP +If in \fIex\fP command mode: +If the \fIeof\fP character is the first character entered on the line, +the line shall be evaluated as if it contained +two characters: a <control>-D and a <newline>. +.LP +Otherwise, the \fIeof\fP character shall have no special meaning. +.sp +.LP +If in \fIex\fP text input mode: +If the cursor follows an \fBautoindent\fP character, the \fBautoindent\fP +characters in the line shall be modified so +that a part of the next text input character will be displayed on +the first column in the line after the previous \fBshiftwidth\fP +edit option column boundary, and the user shall be prompted again +for input for the same line. +.LP +Otherwise, if the cursor follows a \fB'0'\fP , which follows an \fBautoindent\fP +character, and the \fB'0'\fP was the +previous text input character, the \fB'0'\fP and all \fBautoindent\fP +characters in the line shall be discarded, and the user +shall be prompted again for input for the same line. +.LP +Otherwise, if the cursor follows a \fB'^'\fP , which follows an \fBautoindent\fP +character, and the \fB'^'\fP was the +previous text input character, the \fB'^'\fP and all \fBautoindent\fP +characters in the line shall be discarded, and the user +shall be prompted again for input for the same line. In addition, +the \fBautoindent\fP level for the next input line shall be +derived from the same line from which the \fBautoindent\fP level for +the current input line was derived. +.LP +Otherwise, if there are no \fBautoindent\fP or text input characters +in the line, the \fIeof\fP character shall be +discarded. +.LP +Otherwise, the \fIeof\fP character shall have no special meaning. +.SS <newline> +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<newline> +.sp + +<control>-J +\fP +.fi +.RE +.sp +.LP +If in \fIex\fP command mode: +Cause the command line to be parsed; <control>-J shall be mapped to +the <newline> for this +purpose. +.LP +If in \fIex\fP text input mode: +Terminate the current line. If there are no characters other than +\fBautoindent\fP characters on the line, all +characters on the line shall be discarded. +.LP +Prompt for text input on a new line after the current line. If the +\fBautoindent\fP edit option is set, an appropriate number +of \fBautoindent\fP characters shall be added as a prefix to the line +as described by the \fIex\fP \fBautoindent\fP edit +option. +.SS <backslash> +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<backslash> +\fP +.fi +.RE +.sp +.LP +Allow the entry of a subsequent <newline> or <control>-J as a literal +character, removing any special meaning that +it may have to the editor during text input mode. The backslash character +shall be retained and evaluated when the command line is +parsed, or retained and included when the input text becomes part +of the edit buffer. +.SS <control>-V +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-V +\fP +.fi +.RE +.sp +.LP +Allow the entry of any subsequent character as a literal character, +removing any special meaning that it may have to the editor +during text input mode. The <control>-V character shall be discarded +before the command line is parsed or the input text +becomes part of the edit buffer. +.LP +If the "literal next" functionality is performed by the underlying +system, it is implementation-defined whether a character +other than <control>-V performs this function. +.SS <control>-W +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-W +\fP +.fi +.RE +.sp +.LP +Discard the <control>-W, and the word previous to it in the input +line, including any <blank>s following the word +and preceding the <control>-W. If the "word erase" functionality is +performed by the underlying system, it is +implementation-defined whether a character other than <control>-W +performs this function. +.SS Command Descriptions in ex +.LP +The following symbols are used in this section to represent command +modifiers. Some of these modifiers can be omitted, in which +case the specified defaults shall be used. +.TP 7 +\fI1addr\fP +A single line address, given in any of the forms described in Addressing +in ex ; the default +shall be the current line ( \fB'.'\fP ), unless otherwise specified. +.LP +If the line address is zero, it shall be an error, unless otherwise +specified in the following command descriptions. +.LP +If the edit buffer is empty, and the address is specified with a command +other than \fB=\fP, \fBappend\fP, \fBinsert\fP, +\fBopen\fP, \fBput\fP, \fBread\fP, or \fBvisual\fP, or the address +is not zero, it shall be an error. +.TP 7 +\fI2addr\fP +Two addresses specifying an inclusive range of lines. If no addresses +are specified, the default for \fI2addr\fP shall be the +current line only ( \fB".,."\fP ), unless otherwise specified in the +following command descriptions. If one address is +specified, \fI2addr\fP shall specify that line only, unless otherwise +specified in the following command descriptions. +.LP +It shall be an error if the first address is greater than the second +address. +.LP +If the edit buffer is empty, and the two addresses are specified with +a command other than the \fB!\fP, \fBwrite\fP, +\fBwq\fP, or \fBxit\fP commands, or either address is not zero, it +shall be an error. +.TP 7 +\fIcount\fP +A positive decimal number. If \fIcount\fP is specified, it shall be +equivalent to specifying an additional address to the +command, unless otherwise specified by the following command descriptions. +The additional address shall be equal to the last +address specified to the command (either explicitly or by default) +plus \fIcount\fP-1. +.LP +If this would result in an address greater than the last line of the +edit buffer, it shall be corrected to equal the last line +of the edit buffer. +.TP 7 +\fIflags\fP +One or more of the characters \fB'+'\fP , \fB'-'\fP , \fB'#'\fP , +\fB'p'\fP , or \fB'l'\fP (ell). The flag +characters can be <blank>-separated, and in any order or combination. +The characters \fB'#'\fP , \fB'p'\fP , and +\fB'l'\fP shall cause lines to be written in the format specified +by the \fBprint\fP command with the specified \fIflags\fP. +.LP +The lines to be written are as follows: +.RS +.IP " 1." 4 +All edit buffer lines written during the execution of the \fIex\fP +\fB&\fP, \fB~\fP, \fBlist\fP, \fBnumber\fP, +\fBopen\fP, \fBprint\fP, \fBs\fP, \fBvisual\fP, and \fBz\fP commands +shall be written as specified by \fIflags\fP. +.LP +.IP " 2." 4 +After the completion of an \fIex\fP command with a flag as an argument, +the current line shall be written as specified by +\fIflags\fP, unless the current line was the last line written by +the command. +.LP +.RE +.LP +The characters \fB'+'\fP and \fB'-'\fP cause the value of the current +line after the execution of the \fIex\fP command to +be adjusted by the offset address as described in Addressing in ex +\&. This adjustment shall occur +before the current line is written as described in 2. above. +.LP +The default for \fIflags\fP shall be none. +.TP 7 +\fIbuffer\fP +One of a number of named areas for holding text. The named buffers +are specified by the alphanumeric characters of the POSIX +locale. There shall also be one "unnamed" buffer. When no buffer is +specified for editor commands that use a buffer, the unnamed +buffer shall be used. Commands that store text into buffers shall +store the text as it was before the command took effect, and +shall store text occurring earlier in the file before text occurring +later in the file, regardless of how the text region was +specified. Commands that store text into buffers shall store the text +into the unnamed buffer as well as any specified buffer. +.LP +In \fIex\fP commands, buffer names are specified as the name by itself. +In open or visual mode commands the name is preceded by +a double quote ( \fB' )'\fP character. +.LP +If the specified buffer name is an uppercase character, and the buffer +contents are to be modified, the buffer shall be appended +to rather than being overwritten. If the buffer is not being modified, +specifying the buffer name in lowercase and uppercase shall +have identical results. +.LP +There shall also be buffers named by the numbers 1 through 9. In open +and visual mode, if a region of text including characters +from more than a single line is being modified by the \fIvi\fP \fBc\fP +or \fBd\fP commands, +the motion character associated with the \fBc\fP or \fBd\fP commands +specifies that the buffer text shall be in line mode, or the +commands \fB%\fP, \fB`\fP, \fB/\fP, \fB?\fP, \fB(\fP, \fB)\fP, \fBN\fP, +\fBn\fP, \fB{\fP, or \fB}\fP are used to define a +region of text for the \fBc\fP or \fBd\fP commands, the contents of +buffers 1 through 8 shall be moved into the buffer named by +the next numerically greater value, the contents of buffer 9 shall +be discarded, and the region of text shall be copied into buffer +1. This shall be in addition to copying the text into a user-specified +buffer or unnamed buffer, or both. Numeric buffers can be +specified as a source buffer for open and visual mode commands; however, +specifying a numeric buffer as the write target of an open +or visual mode command shall have unspecified results. +.LP +The text of each buffer shall have the characteristic of being in +either line or character mode. Appending text to a non-empty +buffer shall set the mode to match the characteristic of the text +being appended. Appending text to a buffer shall cause the +creation of at least one additional line in the buffer. All text stored +into buffers by \fIex\fP commands shall be in line mode. +The \fIex\fP commands that use buffers as the source of text specify +individually how buffers of different modes are handled. Each +open or visual mode command that uses buffers for any purpose specifies +individually the mode of the text stored into the buffer +and how buffers of different modes are handled. +.TP 7 +\fIfile\fP +Command text used to derive a pathname. The default shall be the current +pathname, as defined previously, in which case, if no +current pathname has yet been established it shall be an error, except +where specifically noted in the individual command +descriptions that follow. If the command text contains any of the +characters \fB'~'\fP , \fB'{'\fP , \fB'['\fP , +\fB'*'\fP , \fB'?'\fP , \fB'$'\fP , \fB'`'\fP , \fB'"\fP , \fB' ,'\fP +and \fB'\\'\fP , it shall be subjected +to the process of "shell expansions", as described below; if more +than a single pathname results and the command expects only +one, it shall be an error. +.LP +The process of shell expansions in the editor shall be done as follows. +The \fIex\fP utility shall pass two arguments to the +program named by the shell edit option; the first shall be \fB-c\fP, +and the second shall be the string \fB"echo"\fP and the +command text as a single argument. The standard output and standard +error of that command shall replace the command text. +.TP 7 +\fB!\fP +A character that can be appended to the command name to modify its +operation, as detailed in the individual command +descriptions. With the exception of the \fIex\fP \fBread\fP, \fBwrite\fP, +and \fB!\fP commands, the \fB'!'\fP character +shall only act as a modifier if there are no <blank>s between it and +the command name. +.TP 7 +\fIremembered\ search\ direction\fP +.sp +The \fIvi\fP commands \fBN\fP and \fBn\fP begin searching in a forwards +or backwards +direction in the edit buffer based on a remembered search direction, +which is initially unset, and is set by the \fIex\fP +\fBglobal\fP, \fBv\fP, \fBs\fP, and \fBtag\fP commands, and the \fIvi\fP +\fB/\fP and +\fB?\fP commands. +.sp +.SS Abbreviate +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBab\fP\fB[\fP\fIbreviate\fP\fB][\fP\fIlhs rhs\fP\fB]\fP +.fi +.RE +.sp +.LP +If \fIlhs\fP and \fIrhs\fP are not specified, write the current list +of abbreviations and do nothing more. +.LP +Implementations may restrict the set of characters accepted in \fIlhs\fP +or \fIrh\fP, except that printable characters and +<blank>s shall not be restricted. Additional restrictions shall be +implementation-defined. +.LP +In both \fIlhs\fP and \fIrhs\fP, any character may be escaped with +a <control>-V, in which case the character shall not +be used to delimit \fIlhs\fP from \fIrhs\fP, and the escaping <control>-V +shall be discarded. +.LP +In open and visual text input mode, if a non-word or <ESC> character +that is not escaped by a <control>-V character +is entered after a word character, a check shall be made for a set +of characters matching \fIlhs\fP, in the text input entered +during this command. If it is found, the effect shall be as if \fIrhs\fP +was entered instead of \fIlhs\fP. +.LP +The set of characters that are checked is defined as follows: +.IP " 1." 4 +If there are no characters inserted before the word and non-word or +<ESC> characters that triggered the check, the set of +characters shall consist of the word character. +.LP +.IP " 2." 4 +If the character inserted before the word and non-word or <ESC> characters +that triggered the check is a word character, +the set of characters shall consist of the characters inserted immediately +before the triggering characters that are word +characters, plus the triggering word character. +.LP +.IP " 3." 4 +If the character inserted before the word and non-word or <ESC> characters +that triggered the check is not a word +character, the set of characters shall consist of the characters that +were inserted before the triggering characters that are +neither <blank>s nor word characters, plus the triggering word character. +.LP +.LP +It is unspecified whether the \fIlhs\fP argument entered for the \fIex\fP +\fBabbreviate\fP and \fBunabbreviate\fP commands +is replaced in this fashion. Regardless of whether or not the replacement +occurs, the effect of the command shall be as if the +replacement had not occurred. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Append +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBa\fP\fB[\fP\fBppend\fP\fB][\fP\fB!\fP\fB]\fP +.fi +.RE +.sp +.LP +Enter \fIex\fP text input mode; the input text shall be placed after +the specified line. If line zero is specified, the text +shall be placed at the beginning of the edit buffer. +.LP +This command shall be affected by the \fBnumber\fP and \fBautoindent\fP +edit options; following the command name with +\fB'!'\fP shall cause the \fBautoindent\fP edit option setting to +be toggled for the duration of this command only. +.LP +\fICurrent line\fP: Set to the last input line; if no lines were input, +set to the specified line, or to the first line of the +edit buffer if a line of zero was specified, or zero if the edit buffer +is empty. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Arguments +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBar\fP\fB[\fP\fIgs\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the current argument list, with the current argument-list entry, +if any, between \fB'['\fP and \fB']'\fP +characters. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Change +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBc\fP\fB[\fP\fBhange\fP\fB][\fP\fB!\fP\fB][\fP\fIcount\fP\fB]\fP +.fi +.RE +.sp +.LP +Enter \fIex\fP text input mode; the input text shall replace the specified +lines. The specified lines shall be copied into the +unnamed buffer, which shall become a line mode buffer. +.LP +This command shall be affected by the \fBnumber\fP and \fBautoindent\fP +edit options; following the command name with +\fB'!'\fP shall cause the \fBautoindent\fP edit option setting to +be toggled for the duration of this command only. +.LP +\fICurrent line\fP: Set to the last input line; if no lines were input, +set to the line before the first address, or to the +first line of the edit buffer if there are no lines preceding the +first address, or to zero if the edit buffer is empty. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Change Directory +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBchd\fP\fB[\fP\fBir\fP\fB][\fP\fB!\fP\fB][\fP\fIdirectory\fP\fB]\fP\fBcd\fP\fB[\fP\fB!\fP\fB][\fP\fIdirectory\fP\fB]\fP +.fi +.RE +.sp +.LP +Change the current working directory to \fIdirectory\fP. +.LP +If no \fIdirectory\fP argument is specified, and the \fIHOME\fP environment +variable is set to a non-null and non-empty value, +\fIdirectory\fP shall default to the value named in the \fIHOME\fP +environment variable. If the \fIHOME\fP environment variable +is empty or is undefined, the default value of \fIdirectory\fP is +implementation-defined. +.LP +If no \fB'!'\fP is appended to the command name, and the edit buffer +has been modified since the last complete write, and the +current pathname does not begin with a \fB'/'\fP , it shall be an +error. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Copy +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBco\fP\fB[\fP\fBpy\fP\fB]\fP \fI1addr\fP \fB[\fP\fIflags\fP\fB] +[\fP\fI2addr\fP\fB]\fP \fBt\fP \fI1addr\fP \fB[\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +Copy the specified lines after the specified destination line; line +zero specifies that the lines shall be placed at the +beginning of the edit buffer. +.LP +\fICurrent line\fP: Set to the last line copied. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Delete +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBd\fP\fB[\fP\fBelete\fP\fB][\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +Delete the specified lines into a buffer (defaulting to the unnamed +buffer), which shall become a line-mode buffer. +.LP +Flags can immediately follow the command name; see Command Line Parsing +in ex . +.LP +\fICurrent line\fP: Set to the line following the deleted lines, or +to the last line in the edit buffer if that line is past +the end of the edit buffer, or to zero if the edit buffer is empty. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Edit +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBe\fP\fB[\fP\fBdit\fP\fB][\fP\fB!\fP\fB][\fP\fB+\fP\fIcommand\fP\fB][\fP\fIfile\fP\fB]\fP\fBex\fP\fB[\fP\fB!\fP\fB][\fP\fB+\fP\fIcommand\fP\fB][\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +If no \fB'!'\fP is appended to the command name, and the edit buffer +has been modified since the last complete write, it +shall be an error. +.LP +If \fIfile\fP is specified, replace the current contents of the edit +buffer with the current contents of \fIfile\fP, and set +the current pathname to \fIfile\fP. If \fIfile\fP is not specified, +replace the current contents of the edit buffer with the +current contents of the file named by the current pathname. If for +any reason the current contents of the file cannot be accessed, +the edit buffer shall be empty. +.LP +The \fB+\fP \fIcommand\fP option shall be <blank>-delimited; <blank>s +within \fB+\fP \fIcommand\fP can be +escaped by preceding them with a backslash character. The \fB+\fP +\fIcommand\fP shall be interpreted as an \fIex\fP command +immediately after the contents of the edit buffer have been replaced +and the current line and column have been set. +.LP +If the edit buffer is empty: +.LP +\fICurrent line\fP: Set to 0. +.LP +\fICurrent column\fP: Set to 1. +.LP +Otherwise, if executed while in \fIex\fP command mode or if the \fB+\fP +\fIcommand\fP argument is specified: +.LP +\fICurrent line\fP: Set to the last line of the edit buffer. +.LP +\fICurrent column\fP: Set to non- <blank>. +.LP +Otherwise, if \fIfile\fP is omitted or results in the current pathname: +.LP +\fICurrent line\fP: Set to the first line of the edit buffer. +.LP +\fICurrent column\fP: Set to non- <blank>. +.LP +Otherwise, if \fIfile\fP is the same as the last file edited, the +line and column shall be set as follows; if the file was +previously edited, the line and column may be set as follows: +.LP +\fICurrent line\fP: Set to the last value held when that file was +last edited. If this value is not a valid line in the new +edit buffer, set to the first line of the edit buffer. +.LP +\fICurrent column\fP: If the current line was set to the last value +held when the file was last edited, set to the last value +held when the file was last edited. Otherwise, or if the last value +is not a valid column in the new edit buffer, set to non- +<blank>. +.LP +Otherwise: +.LP +\fICurrent line\fP: Set to the first line of the edit buffer. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBf\fP\fB[\fP\fBile\fP\fB][\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +If a \fIfile\fP argument is specified, the alternate pathname shall +be set to the current pathname, and the current pathname +shall be set to \fIfile\fP. +.LP +Write an informational message. If the file has a current pathname, +it shall be included in this message; otherwise, the message +shall indicate that there is no current pathname. If the edit buffer +contains lines, the current line number and the number of +lines in the edit buffer shall be included in this message; otherwise, +the message shall indicate that the edit buffer is empty. If +the edit buffer has been modified since the last complete write, this +fact shall be included in this message. If the +\fBreadonly\fP edit option is set, this fact shall be included in +this message. The message may contain other unspecified +information. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Global +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBg\fP\fB[\fP\fBlobal\fP\fB]\fP \fB/\fP\fIpattern\fP\fB/\fP \fB[\fP\fIcommands\fP\fB] +[\fP\fI2addr\fP\fB]\fP \fBv /\fP\fIpattern\fP\fB/\fP \fB[\fP\fIcommands\fP\fB]\fP +.fi +.RE +.sp +.LP +The optional \fB'!'\fP character after the \fBglobal\fP command shall +be the same as executing the \fBv\fP command. +.LP +If \fIpattern\fP is empty (for example, \fB"//"\fP ) or not specified, +the last regular expression used in the editor +command shall be used as the \fIpattern\fP. The \fIpattern\fP can +be delimited by slashes (shown in the Synopsis), as well as any +non-alphanumeric or non- <blank> other than backslash, vertical line, +double quote, or <newline>. +.LP +If no lines are specified, the lines shall default to the entire file. +.LP +The \fBglobal\fP and \fBv\fP commands are logically two-pass operations. +First, mark the lines within the specified lines for +which the line excluding the terminating <newline> matches ( \fBglobal\fP) +or does not match ( \fBv\fP or \fBglobal!\fP) +the specified pattern. Second, execute the \fIex\fP commands given +by \fIcommands\fP, with the current line ( \fB'.'\fP ) set +to each marked line. If an error occurs during this process, or the +contents of the edit buffer are replaced (for example, by the +\fIex\fP \fB:edit\fP command) an error message shall be written and +no more commands resulting from the execution of this command +shall be processed. +.LP +Multiple \fIex\fP commands can be specified by entering multiple commands +on a single line using a vertical line to delimit +them, or one per line, by escaping each <newline> with a backslash. +.LP +If no commands are specified: +.IP " 1." 4 +If in \fIex\fP command mode, it shall be as if the \fBprint\fP command +were specified. +.LP +.IP " 2." 4 +Otherwise, no command shall be executed. +.LP +.LP +For the \fBappend\fP, \fBchange\fP, and \fBinsert\fP commands, the +input text shall be included as part of the command, and +the terminating period can be omitted if the command ends the list +of commands. The \fBopen\fP and \fBvisual\fP commands can be +specified as one of the commands, in which case each marked line shall +cause the editor to enter open or visual mode. If open or +visual mode is exited using the \fIvi\fP \fBQ\fP command, the current +line shall be set to the +next marked line, and open or visual mode reentered, until the list +of marked lines is exhausted. +.LP +The \fBglobal\fP, \fBv\fP, and \fBundo\fP commands cannot be used +in \fIcommands\fP. Marked lines may be deleted by commands +executed for lines occurring earlier in the file than the marked lines. +In this case, no commands shall be executed for the deleted +lines. +.LP +If the remembered search direction is not set, the \fBglobal\fP and +\fBv\fP commands shall set it to forward. +.LP +The \fBautoprint\fP and \fBautoindent\fP edit options shall be inhibited +for the duration of the \fBg\fP or \fBv\fP +command. +.LP +\fICurrent line\fP: If no commands executed, set to the last marked +line. Otherwise, as specified for the executed \fIex\fP +commands. +.LP +\fICurrent column\fP: If no commands are executed, set to non- <blank>; +otherwise, as specified for the individual +\fIex\fP commands. +.SS Insert +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBi\fP\fB[\fP\fBnsert\fP\fB][\fP\fB!\fP\fB]\fP +.fi +.RE +.sp +.LP +Enter \fIex\fP text input mode; the input text shall be placed before +the specified line. If the line is zero or 1, the text +shall be placed at the beginning of the edit buffer. +.LP +This command shall be affected by the \fBnumber\fP and \fBautoindent\fP +edit options; following the command name with +\fB'!'\fP shall cause the \fBautoindent\fP edit option setting to +be toggled for the duration of this command only. +.LP +\fICurrent line\fP: Set to the last input line; if no lines were input, +set to the line before the specified line, or to the +first line of the edit buffer if there are no lines preceding the +specified line, or zero if the edit buffer is empty. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Join +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBj\fP\fB[\fP\fBoin\fP\fB][\fP\fB!\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +If \fIcount\fP is specified: +If no address was specified, the \fBjoin\fP command shall behave as +if \fI2addr\fP were the current line and the +current line plus \fIcount\fP (.,. + \fIcount\fP). +.LP +If one address was specified, the \fBjoin\fP command shall behave +as if \fI2addr\fP were the specified address and the +specified address plus \fIcount\fP ( \fIaddr\fP, \fIaddr\fP + \fIcount\fP). +.LP +If two addresses were specified, the \fBjoin\fP command shall behave +as if an additional address, equal to the last address +plus \fIcount\fP -1 ( \fIaddr1\fP, \fIaddr2\fP, \fIaddr2\fP + \fIcount\fP +-1), was specified. +.LP +If this would result in a second address greater than the last line +of the edit buffer, it shall be corrected to be equal to the +last line of the edit buffer. +.LP +If no \fIcount\fP is specified: +If no address was specified, the \fBjoin\fP command shall behave as +if \fI2addr\fP were the current line and the next +line (.,. +1). +.LP +If one address was specified, the \fBjoin\fP command shall behave +as if \fI2addr\fP were the specified address and the next +line ( \fIaddr\fP, \fIaddr\fP +1). +.LP +Join the text from the specified lines together into a single line, +which shall replace the specified lines. +.LP +If a \fB'!'\fP character is appended to the command name, the \fBjoin\fP +shall be without modification of any line, +independent of the current locale. +.LP +Otherwise, in the POSIX locale, set the current line to the first +of the specified lines, and then, for each subsequent line, +proceed as follows: +.IP " 1." 4 +Discard leading <space>s from the line to be joined. +.LP +.IP " 2." 4 +If the line to be joined is now empty, delete it, and skip steps 3 +through 5. +.LP +.IP " 3." 4 +If the current line ends in a <blank>, or the first character of the +line to be joined is a \fB')'\fP character, join +the lines without further modification. +.LP +.IP " 4." 4 +If the last character of the current line is a \fB'.'\fP , join the +lines with two <space>s between them. +.LP +.IP " 5." 4 +Otherwise, join the lines with a single <space> between them. +.LP +.LP +\fICurrent line\fP: Set to the first line specified. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS List +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBl\fP\fB[\fP\fBist\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIex\fP command: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBp\fP\fB[\fP\fBrint\fP\fB][\fP\fIcount\fP\fB]\fP \fBl\fP\fB[\fP\fIflags\fP\fB]\fP +.fi +.RE +.LP +See Print . +.SS Map +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBmap\fP\fB[\fP\fB!\fP\fB][\fP\fIlhs rhs\fP\fB]\fP +.fi +.RE +.sp +.LP +If \fIlhs\fP and \fIrhs\fP are not specified: +.IP " 1." 4 +If \fB'!'\fP is specified, write the current list of text input mode +maps. +.LP +.IP " 2." 4 +Otherwise, write the current list of command mode maps. +.LP +.IP " 3." 4 +Do nothing more. +.LP +.LP +Implementations may restrict the set of characters accepted in \fIlhs\fP +or \fIrhs\fP, except that printable characters and +<blank>s shall not be restricted. Additional restrictions shall be +implementation-defined. In both \fIlhs\fP and \fIrhs\fP, +any character can be escaped with a <control>-V, in which case the +character shall not be used to delimit \fIlhs\fP from +\fIrhs\fP, and the escaping <control>-V shall be discarded. +.LP +If the character \fB'!'\fP is appended to the \fBmap\fP command name, +the mapping shall be effective during open or visual +text input mode rather than \fBopen\fP or \fBvisual\fP command mode. +This allows \fIlhs\fP to have two different \fBmap\fP +definitions at the same time: one for command mode and one for text +input mode. +.LP +For command mode mappings: +When the \fIlhs\fP is entered as any part of a \fIvi\fP command in +open or visual +mode (but not as part of the arguments to the command), the action +shall be as if the corresponding \fIrhs\fP had been entered. +.LP +If any character in the command, other than the first, is escaped +using a <control>-V character, that character shall not +be part of a match to an \fIlhs\fP. +.LP +It is unspecified whether implementations shall support \fBmap\fP +commands where the \fIlhs\fP is more than a single character +in length, where the first character of the \fIlhs\fP is printable. +.LP +If \fIlhs\fP contains more than one character and the first character +is \fB'#'\fP , followed by a sequence of digits +corresponding to a numbered function key, then when this function +key is typed it shall be mapped to \fIrhs\fP. Characters other +than digits following a \fB'#'\fP character also represent the function +key named by the characters in the \fIlhs\fP following +the \fB'#'\fP and may be mapped to \fIrhs\fP. It is unspecified how +function keys are named or what function keys are +supported. +.LP +For text input mode mappings: +When the \fIlhs\fP is entered as any part of text entered in open +or visual text input modes, the action shall be as +if the corresponding \fIrhs\fP had been entered. +.LP +If any character in the input text is escaped using a <control>-V +character, that character shall not be part of a match +to an \fIlhs\fP. +.LP +It is unspecified whether the \fIlhs\fP text entered for subsequent +\fBmap\fP or \fBunmap\fP commands is replaced with the +\fIrhs\fP text for the purposes of the screen display; regardless +of whether or not the display appears as if the corresponding +\fIrhs\fP text was entered, the effect of the command shall be as +if the \fIlhs\fP text was entered. +.LP +If only part of the \fIlhs\fP is entered, it is unspecified how long +the editor will wait for additional, possibly matching +characters before treating the already entered characters as not matching +the \fIlhs\fP. +.LP +The \fIrhs\fP characters shall themselves be subject to remapping, +unless otherwise specified by the \fBremap\fP edit option, +except that if the characters in \fIlhs\fP occur as prefix characters +in \fIrhs\fP, those characters shall not be remapped. +.LP +On block-mode terminals, the mapping need not occur immediately (for +example, it may occur after the terminal transmits a group +of characters to the system), but it shall achieve the same results +as if it occurred immediately. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Mark +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBma\fP\fB[\fP\fBrk\fP\fB]\fP \fIcharacter +\fP\fB[\fP\fI1addr\fP\fB]\fP \fBk\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +Implementations shall support \fIcharacter\fP values of a single lowercase +letter of the POSIX locale and the characters +\fB'`'\fP and \fB'"\fP ; support of other characters is implementation-defined. +.LP +If executing the \fIvi\fP \fBm\fP command, set the specified mark +to the current line and +1-based numbered character referenced by the current column, if any; +otherwise, column position 1. +.LP +Otherwise, set the specified mark to the specified line and 1-based +numbered first non- <blank> non- <newline> in +the line, if any; otherwise, the last non- <newline> in the line, +if any; otherwise, column position 1. +.LP +The mark shall remain associated with the line until the mark is reset +or the line is deleted. If a deleted line is restored by +a subsequent \fBundo\fP command, any marks previously associated with +the line, which have not been reset, shall be restored as +well. Any use of a mark not associated with a current line in the +edit buffer shall be an error. +.LP +The marks \fB`\fP and \fB'\fP shall be set as described previously, +immediately before the following events occur in the +editor: +.IP " 1." 4 +The use of \fB'$'\fP as an \fIex\fP address +.LP +.IP " 2." 4 +The use of a positive decimal number as an \fIex\fP address +.LP +.IP " 3." 4 +The use of a search command as an \fIex\fP address +.LP +.IP " 4." 4 +The use of a mark reference as an \fIex\fP address +.LP +.IP " 5." 4 +The use of the following open and visual mode commands: <control>-], +\fB%\fP, \fB(\fP, \fB)\fP, \fB[\fP, \fB]\fP, +\fB{\fP, \fB}\fP +.LP +.IP " 6." 4 +The use of the following open and visual mode commands: \fB'\fP, \fBG\fP, +\fBH\fP, \fBL\fP, \fBM\fP, \fBz\fP if the +current line will change as a result of the command +.LP +.IP " 7." 4 +The use of the open and visual mode commands: \fB/\fP, \fB?\fP, \fBN\fP, +\fB`\fP, \fBn\fP if the current line or column +will change as a result of the command +.LP +.IP " 8." 4 +The use of the \fIex\fP mode commands: \fBz\fP, \fBundo\fP, \fBglobal\fP, +\fBv\fP +.LP +.LP +For rules 1., 2., 3., and 4., the \fB`\fP and \fB'\fP marks shall +not be set if the \fIex\fP command is parsed as specified +by rule 6.a. in Command Line Parsing in ex . +.LP +For rules 5., 6., and 7., the \fB`\fP and \fB'\fP marks shall not +be set if the commands are used as motion commands in open +and visual mode. +.LP +For rules 1., 2., 3., 4., 5., 6., 7., and 8., the \fB`\fP and \fB'\fP +marks shall not be set if the command fails. +.LP +The \fB`\fP and \fB'\fP marks shall be set as described previously, +each time the contents of the edit buffer are replaced +(including the editing of the initial buffer), if in open or visual +mode, or if in \fBex\fP mode and the edit buffer is not empty, +before any commands or movements (including commands or movements +specified by the \fB-c\fP or \fB-t\fP options or the \fB+\fP +\fIcommand\fP argument) are executed on the edit buffer. If in open +or visual mode, the marks shall be set as if executing the \fIvi\fP +\fBm\fP command; otherwise, as if executing the \fIex\fP \fBmark\fP +command. +.LP +When changing from \fBex\fP mode to open or visual mode, if the \fB`\fP +and \fB'\fP marks are not already set, the \fB`\fP +and \fB'\fP marks shall be set as described previously. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Move +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBm\fP\fB[\fP\fBove\fP\fB]\fP \fI1addr\fP \fB\fP\fB[\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +Move the specified lines after the specified destination line. A destination +of line zero specifies that the lines shall be +placed at the beginning of the edit buffer. It shall be an error if +the destination line is within the range of lines to be +moved. +.LP +\fICurrent line\fP: Set to the last of the moved lines. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Next +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBn\fP\fB[\fP\fBext\fP\fB][\fP\fB!\fP\fB][\fP\fB+\fP\fIcommand\fP\fB][\fP\fIfile\fP \fB...\fP\fB]\fP +.fi +.RE +.sp +.LP +If no \fB'!'\fP is appended to the command name, and the edit buffer +has been modified since the last complete write, it +shall be an error, unless the file is successfully written as specified +by the \fBautowrite\fP option. +.LP +If one or more files is specified: +.IP " 1." 4 +Set the argument list to the specified filenames. +.LP +.IP " 2." 4 +Set the current argument list reference to be the first entry in the +argument list. +.LP +.IP " 3." 4 +Set the current pathname to the first filename specified. +.LP +.LP +Otherwise: +.IP " 1." 4 +It shall be an error if there are no more filenames in the argument +list after the filename currently referenced. +.LP +.IP " 2." 4 +Set the current pathname and the current argument list reference to +the filename after the filename currently referenced in the +argument list. +.LP +.LP +Replace the contents of the edit buffer with the contents of the file +named by the current pathname. If for any reason the +contents of the file cannot be accessed, the edit buffer shall be +empty. +.LP +This command shall be affected by the \fBautowrite\fP and \fBwriteany\fP +edit options. +.LP +The \fB+\fP \fIcommand\fP option shall be <blank>-delimited; <blank>s +can be escaped by preceding them with a +backslash character. The \fB+\fP \fIcommand\fP shall be interpreted +as an \fIex\fP command immediately after the contents of the +edit buffer have been replaced and the current line and column have +been set. +.LP +\fICurrent line\fP: Set as described for the \fBedit\fP command. +.LP +\fICurrent column\fP: Set as described for the \fBedit\fP command. +.SS Number +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBnu\fP\fB[\fP\fBmber\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB] +[\fP\fI2addr\fP\fB]\fP \fB#\fP\fB[\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +These commands shall be equivalent to the \fIex\fP command: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBp\fP\fB[\fP\fBrint\fP\fB][\fP\fIcount\fP\fB]\fP \fB#\fP\fB[\fP\fIflags\fP\fB]\fP +.fi +.RE +.LP +See Print . +.SS Open +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBo\fP\fB[\fP\fBpen\fP\fB]\fP \fB/\fP\fIpattern\fP\fB/\fP \fB[\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +This command need not be supported on block-mode terminals or terminals +with insufficient capabilities. If standard input, +standard output, or standard error are not terminal devices, the results +are unspecified. +.LP +Enter open mode. +.LP +The trailing delimiter can be omitted from \fIpattern\fP at the end +of the command line. If \fIpattern\fP is empty (for +example, \fB"//"\fP ) or not specified, the last regular expression +used in the editor shall be used as the pattern. The pattern +can be delimited by slashes (shown in the Synopsis), as well as any +alphanumeric, or non- <blank> other than backslash, +vertical line, double quote, or <newline>. +.LP +\fICurrent line\fP: Set to the specified line. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Preserve +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBpre\fP\fB[\fP\fBserve\fP\fB]\fP +.fi +.RE +.sp +.LP +Save the edit buffer in a form that can later be recovered by using +the \fB-r\fP option or by using the \fIex\fP +\fBrecover\fP command. After the file has been preserved, a mail message +shall be sent to the user. This message shall be readable +by invoking the \fImailx\fP utility. The message shall contain the +name of the file, the +time of preservation, and an \fIex\fP command that could be used to +recover the file. Additional information may be included in +the mail message. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Print +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBp\fP\fB[\fP\fBrint\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the addressed lines. The behavior is unspecified if the number +of columns on the display is less than the number of +columns required to write any single character in the lines being +written. +.LP +Non-printable characters, except for the <tab>, shall be written as +implementation-defined multi-character sequences. +.LP +If the \fB#\fP flag is specified or the \fBnumber\fP edit option is +set, each line shall be preceded by its line number in the +following format: +.sp +.RS +.nf + +\fB"%6d ", <\fP\fIline number\fP\fB> +\fP +.fi +.RE +.LP +If the \fBl\fP flag is specified or the \fBlist\fP edit option is +set: +.IP " 1." 4 +The characters listed in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Table 5-1, Escape Sequences and +Associated Actions shall be written as the corresponding escape sequence. +.LP +.IP " 2." 4 +Non-printable characters not in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Table 5-1, Escape Sequences and +Associated Actions shall be written as one three-digit octal number +(with a preceding backslash) for each byte in the character +(most significant byte first). If the size of a byte on the system +is greater than 9 bits, the format used for non-printable +characters is implementation-defined. +.LP +.IP " 3." 4 +The end of each line shall be marked with a \fB'$'\fP , and literal +\fB'$'\fP characters within the line shall be written +with a preceding backslash. +.LP +.LP +Long lines shall be folded; the length at which folding occurs is +unspecified, but should be appropriate for the output +terminal, considering the number of columns of the terminal. +.LP +If a line is folded, and the \fBl\fP flag is not specified and the +\fBlist\fP edit option is not set, it is unspecified +whether a multi-column character at the folding position is separated; +it shall not be discarded. +.LP +\fICurrent line\fP: Set to the last written line. +.LP +\fICurrent column\fP: Unchanged if the current line is unchanged; +otherwise, set to non- <blank>. +.SS Put +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBpu\fP\fB[\fP\fBt\fP\fB][\fP\fIbuffer\fP\fB]\fP +.fi +.RE +.sp +.LP +Append text from the specified buffer (by default, the unnamed buffer) +to the specified line; line zero specifies that the text +shall be placed at the beginning of the edit buffer. Each portion +of a line in the buffer shall become a new line in the edit +buffer, regardless of the mode of the buffer. +.LP +\fICurrent line\fP: Set to the last line entered into the edit buffer. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Quit +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBq\fP\fB[\fP\fBuit\fP\fB][\fP\fB!\fP\fB]\fP +.fi +.RE +.sp +.LP +If no \fB'!'\fP is appended to the command name: +.IP " 1." 4 +If the edit buffer has been modified since the last complete write, +it shall be an error. +.LP +.IP " 2." 4 +If there are filenames in the argument list after the filename currently +referenced, and the last command was not a \fBquit\fP, +\fBwq\fP, \fBxit\fP, or \fBZZ\fP (see \fIExit\fP ) command, it shall +be an error. +.LP +.LP +Otherwise, terminate the editing session. +.SS Read +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBr\fP\fB[\fP\fBead\fP\fB][\fP\fB!\fP\fB][\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +If \fB'!'\fP is not the first non- <blank> to follow the command name, +a copy of the specified file shall be appended +into the edit buffer after the specified line; line zero specifies +that the copy shall be placed at the beginning of the edit +buffer. The number of lines and bytes read shall be written. If no +\fIfile\fP is named, the current pathname shall be the default. +If there is no current pathname, then \fIfile\fP shall become the +current pathname. If there is no current pathname or \fIfile\fP +operand, it shall be an error. Specifying a \fIfile\fP that is not +of type regular shall have unspecified results. +.LP +Otherwise, if \fIfile\fP is preceded by \fB'!'\fP , the rest of the +line after the \fB'!'\fP shall have \fB'%'\fP , +\fB'#'\fP , and \fB'!'\fP characters expanded as described in Command +Line Parsing in ex . +.LP +The \fIex\fP utility shall then pass two arguments to the program +named by the shell edit option; the first shall be \fB-c\fP +and the second shall be the expanded arguments to the \fBread\fP command +as a single argument. The standard input of the program +shall be set to the standard input of the \fIex\fP program when it +was invoked. The standard error and standard output of the +program shall be appended into the edit buffer after the specified +line. +.LP +Each line in the copied file or program output (as delimited by <newline>s +or the end of the file or output if it is not +immediately preceded by a <newline>), shall be a separate line in +the edit buffer. Any occurrences of <carriage-return> +and <newline> pairs in the output shall be treated as single <newline>s. +.LP +The special meaning of the \fB'!'\fP following the \fBread\fP command +can be overridden by escaping it with a backslash +character. +.LP +\fICurrent line\fP: If no lines are added to the edit buffer, unchanged. +Otherwise, if in open or visual mode, set to the first +line entered into the edit buffer. Otherwise, set to the last line +entered into the edit buffer. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Recover +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBrec\fP\fB[\fP\fBover\fP\fB][\fP\fB!\fP\fB]\fP \fIfile\fP +.fi +.RE +.sp +.LP +If no \fB'!'\fP is appended to the command name, and the edit buffer +has been modified since the last complete write, it +shall be an error. +.LP +If no \fIfile\fP operand is specified, then the current pathname shall +be used. If there is no current pathname or \fIfile\fP +operand, it shall be an error. +.LP +If no recovery information has previously been saved about \fIfile\fP, +the \fBrecover\fP command shall behave identically to +the \fBedit\fP command, and an informational message to this effect +shall be written. +.LP +Otherwise, set the current pathname to \fIfile\fP, and replace the +current contents of the edit buffer with the recovered +contents of \fIfile\fP. If there are multiple instances of the file +to be recovered, the one most recently saved shall be +recovered, and an informational message that there are previous versions +of the file that can be recovered shall be written. The +editor shall behave as if the contents of the edit buffer have already +been modified. +.LP +\fICurrent file\fP: Set as described for the \fBedit\fP command. +.LP +\fICurrent column\fP: Set as described for the \fBedit\fP command. +.SS Rewind +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBrew\fP\fB[\fP\fBind\fP\fB][\fP\fB!\fP\fB]\fP +.fi +.RE +.sp +.LP +If no \fB'!'\fP is appended to the command name, and the edit buffer +has been modified since the last complete write, it +shall be an error, unless the file is successfully written as specified +by the \fBautowrite\fP option. +.LP +If the argument list is empty, it shall be an error. +.LP +The current argument list reference and the current pathname shall +be set to the first filename in the argument list. +.LP +Replace the contents of the edit buffer with the contents of the file +named by the current pathname. If for any reason the +contents of the file cannot be accessed, the edit buffer shall be +empty. +.LP +This command shall be affected by the \fBautowrite\fP and \fBwriteany\fP +edit options. +.LP +\fICurrent line\fP: Set as described for the \fBedit\fP command. +.LP +\fICurrent column\fP: Set as described for the \fBedit\fP command. +.SS Set +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBse\fP\fB[\fP\fBt\fP\fB][\fP\fIoption\fP\fB[\fP\fB=\fP\fB[\fP\fIvalue\fP\fB]]\fP \fB...\fP\fB][\fP\fBno\fP\fIoption\fP \fB...\fP\fB][\fP\fIoption\fP\fB? ...\fP\fB][\fP\fBall\fP\fB]\fP +.fi +.RE +.sp +.LP +When no arguments are specified, write the value of the \fBterm\fP +edit option and those options whose values have been changed +from the default settings; when the argument \fIall\fP is specified, +write all of the option values. +.LP +Giving an option name followed by the character \fB'?'\fP shall cause +the current value of that option to be written. The +\fB'?'\fP can be separated from the option name by zero or more <blank>s. +The \fB'?'\fP shall be necessary only for +Boolean valued options. Boolean options can be given values by the +form \fBset\fP \fIoption\fP to turn them on or \fBset\fP +\fBno\fP \fIoption\fP to turn them off; string and numeric options +can be assigned by the form \fBset\fP \fIoption\fP= +\fIvalue\fP. Any <blank>s in strings can be included as is by preceding +each <blank> with an escaping backslash. More +than one option can be set or listed by a single set command by specifying +multiple arguments, each separated from the next by one +or more <blank>s. +.LP +See Edit Options in ex for details about specific options. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Shell +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBsh\fP\fB[\fP\fBell\fP\fB]\fP +.fi +.RE +.sp +.LP +Invoke the program named in the \fBshell\fP edit option with the single +argument \fB-i\fP (interactive mode). Editing shall be +resumed when the program exits. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Source +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBso\fP\fB[\fP\fBurce\fP\fB]\fP \fIfile\fP +.fi +.RE +.sp +.LP +Read and execute \fIex\fP commands from \fIfile\fP. Lines in the file +that are blank lines shall be ignored. +.LP +\fICurrent line\fP: As specified for the individual \fIex\fP commands. +.LP +\fICurrent column\fP: As specified for the individual \fIex\fP commands. +.SS Substitute +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBs\fP\fB[\fP\fBubstitute\fP\fB][\fP\fB/\fP\fIpattern\fP\fB/\fP\fIrepl\fP\fB/\fP\fB[\fP\fIoptions\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]]\fP\fB +.br + +\fP\fB[\fP\fI2addr\fP\fB]\fP \fB&\fP\fB[\fP\fIoptions\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]]\fP\fB +.br + +\fP\fB[\fP\fI2addr\fP\fB]\fP \fB~\fP\fB[\fP\fIoptions\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]]\fP +.fi +.RE +.sp +.LP +Replace the first instance of the pattern \fIpattern\fP by the string +\fIrepl\fP on each specified line. (See Regular Expressions in ex +and Replacement Strings in ex .) Any +non-alphabetic, non- <blank> delimiter other than \fB'\\'\fP , \fB'|'\fP +, double quote, or <newline> can be used +instead of \fB'/'\fP . Backslash characters can be used to escape +delimiters, backslash characters, and other special +characters. +.LP +The trailing delimiter can be omitted from \fIpattern\fP or from \fIrepl\fP +at the end of the command line. If both +\fIpattern\fP and \fIrepl\fP are not specified or are empty (for example, +\fB"//"\fP ), the last \fBs\fP command shall be +repeated. If only \fIpattern\fP is not specified or is empty, the +last regular expression used in the editor shall be used as the +pattern. If only \fIrepl\fP is not specified or is empty, the pattern +shall be replaced by nothing. If the entire replacement +pattern is \fB'%'\fP , the last replacement pattern to an \fBs\fP +command shall be used. +.LP +Entering a <carriage-return> in \fIrepl\fP (which requires an escaping +backslash in \fIex\fP mode and an escaping +<control>-V in open or \fIvi\fP mode) shall split the line at that +point, creating a new +line in the edit buffer. The <carriage-return> shall be discarded. +.LP +If \fIoptions\fP includes the letter \fB'g'\fP ( \fBglobal\fP), all +non-overlapping instances of the pattern in the line +shall be replaced. +.LP +If \fIoptions\fP includes the letter \fB'c'\fP ( \fBconfirm\fP), then +before each substitution the line shall be written; +the written line shall reflect all previous substitutions. On the +following line, <space>s shall be written beneath the +characters from the line that are before the \fIpattern\fP to be replaced, +and \fB'^'\fP characters written beneath the +characters included in the \fIpattern\fP to be replaced. The \fIex\fP +utility shall then wait for a response from the user. An +affirmative response shall cause the substitution to be done, while +any other input shall not make the substitution. An affirmative +response shall consist of a line with the affirmative response (as +defined by the current locale) at the beginning of the line. +This line shall be subject to editing in the same way as the \fIex\fP +command line. +.LP +If interrupted (see the ASYNCHRONOUS EVENTS section), any modifications +confirmed by the user shall be preserved in the edit +buffer after the interrupt. +.LP +If the remembered search direction is not set, the \fBs\fP command +shall set it to forward. +.LP +In the second Synopsis, the \fB&\fP command shall repeat the previous +substitution, as if the \fB&\fP command were +replaced by: +.sp +.RS +.nf + +\fBs/\fP\fIpattern\fP\fB/\fP\fIrepl\fP\fB/ +\fP +.fi +.RE +.LP +where \fIpattern\fP and \fIrepl\fP are as specified in the previous +\fBs\fP, \fB&\fP, or \fB~\fP command. +.LP +In the third Synopsis, the \fB~\fP command shall repeat the previous +substitution, as if the \fB'~'\fP were +replaced by: +.sp +.RS +.nf + +\fBs/\fP\fIpattern\fP\fB/\fP\fIrepl\fP\fB/ +\fP +.fi +.RE +.LP +where \fIpattern\fP shall be the last regular expression specified +to the editor, and \fIrepl\fP shall be from the previous +substitution (including \fB&\fP and \fB~\fP) command. +.LP +These commands shall be affected by the \fILC_MESSAGES\fP environment +variable. +.LP +\fICurrent line\fP: Set to the last line in which a substitution occurred, +or, unchanged if no substitution occurred. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Suspend +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBsu\fP\fB[\fP\fBspend\fP\fB][\fP\fB!\fP\fB]\fP\fBst\fP\fB[\fP\fBop\fP\fB][\fP\fB!\fP\fB]\fP +.fi +.RE +.sp +.LP +Allow control to return to the invoking process; \fIex\fP shall suspend +itself as if it had received the SIGTSTP signal. The +suspension shall occur only if job control is enabled in the invoking +shell (see the description of \fIset\fP \fB-m\fP). +.LP +These commands shall be affected by the \fBautowrite\fP and \fBwriteany\fP +edit options. +.LP +The current \fBsusp\fP character (see \fIstty\fP ) shall be equivalent +to the \fBsuspend\fP +command. +.SS Tag +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBta\fP\fB[\fP\fBg\fP\fB][\fP\fB!\fP\fB]\fP \fItagstring\fP +.fi +.RE +.sp +.LP +The results are unspecified if the format of a tags file is not as +specified by the \fIctags\fP utility (see \fIctags\fP ) description. +.LP +The \fBtag\fP command shall search for \fItagstring\fP in the tag +files referred to by the \fBtag\fP edit option, in the +order they are specified, until a reference to \fItagstring\fP is +found. Files shall be searched from beginning to end. If no +reference is found, it shall be an error and an error message to this +effect shall be written. If the reference is not found, or if +an error occurs while processing a file referred to in the \fBtag\fP +edit option, it shall be an error, and an error message shall +be written at the first occurrence of such an error. +.LP +Otherwise, if the tags file contained a pattern, the pattern shall +be treated as a regular expression used in the editor; for +example, for the purposes of the \fBs\fP command. +.LP +If the \fItagstring\fP is in a file with a different name than the +current pathname, set the current pathname to the name of +that file, and replace the contents of the edit buffer with the contents +of that file. In this case, if no \fB'!'\fP is appended +to the command name, and the edit buffer has been modified since the +last complete write, it shall be an error, unless the file is +successfully written as specified by the \fBautowrite\fP option. +.LP +This command shall be affected by the \fBautowrite\fP, \fBtag\fP, +\fBtaglength\fP, and \fBwriteany\fP edit options. +.LP +\fICurrent line\fP: If the tags file contained a line number, set +to that line number. If the line number is larger than the +last line in the edit buffer, an error message shall be written and +the current line shall be set as specified for the \fBedit\fP +command. +.LP +If the tags file contained a pattern, set to the first occurrence +of the pattern in the file. If no matching pattern is found, +an error message shall be written and the current line shall be set +as specified for the \fBedit\fP command. +.LP +\fICurrent column\fP: If the tags file contained a line-number reference +and that line-number was not larger than the last line +in the edit buffer, or if the tags file contained a pattern and that +pattern was found, set to non- <blank>. Otherwise, set +as specified for the \fBedit\fP command. +.SS Unabbreviate +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBuna\fP\fB[\fP\fBbbrev\fP\fB]\fP \fIlhs\fP +.fi +.RE +.sp +.LP +If \fIlhs\fP is not an entry in the current list of abbreviations +(see Abbreviate ), it shall be +an error. Otherwise, delete \fIlhs\fP from the list of abbreviations. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Undo +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBu\fP\fB[\fP\fBndo\fP\fB]\fP +.fi +.RE +.sp +.LP +Reverse the changes made by the last command that modified the contents +of the edit buffer, including \fBundo\fP. For this +purpose, the \fBglobal\fP, \fBv\fP, \fBopen\fP, and \fBvisual\fP commands, +and commands resulting from buffer executions and +mapped character expansions, are considered single commands. +.LP +If no action that can be undone preceded the \fBundo\fP command, it +shall be an error. +.LP +If the \fBundo\fP command restores lines that were marked, the mark +shall also be restored unless it was reset subsequent to +the deletion of the lines. +.LP +\fICurrent line\fP: +.IP " 1." 4 +If lines are added or changed in the file, set to the first line added +or changed. +.LP +.IP " 2." 4 +Set to the line before the first line deleted, if it exists. +.LP +.IP " 3." 4 +Set to 1 if the edit buffer is not empty. +.LP +.IP " 4." 4 +Set to zero. +.LP +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Unmap +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBunm\fP\fB[\fP\fBap\fP\fB][\fP\fB!\fP\fB]\fP \fIlhs\fP +.fi +.RE +.sp +.LP +If \fB'!'\fP is appended to the command name, and if \fIlhs\fP is +not an entry in the list of text input mode map +definitions, it shall be an error. Otherwise, delete \fIlhs\fP from +the list of text input mode map definitions. +.LP +If no \fB'!'\fP is appended to the command name, and if \fIlhs\fP +is not an entry in the list of command mode map +definitions, it shall be an error. Otherwise, delete \fIlhs\fP from +the list of command mode map definitions. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Version +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBve\fP\fB[\fP\fBrsion\fP\fB]\fP +.fi +.RE +.sp +.LP +Write a message containing version information for the editor. The +format of the message is unspecified. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Visual +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBvi\fP\fB[\fP\fBsual\fP\fB][\fP\fItype\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +If \fIex\fP is currently in open or visual mode, the Synopsis and +behavior of the visual command shall be the same as the +\fBedit\fP command, as specified by Edit . +.LP +Otherwise, this command need not be supported on block-mode terminals +or terminals with insufficient capabilities. If standard +input, standard output, or standard error are not terminal devices, +the results are unspecified. +.LP +If \fIcount\fP is specified, the value of the \fBwindow\fP edit option +shall be set to \fIcount\fP (as described in window ). If the \fB'^'\fP +type character was also specified, the \fBwindow\fP edit option shall +be set +before being used by the type character. +.LP +Enter visual mode. If \fItype\fP is not specified, it shall be as +if a \fItype\fP of \fB'+'\fP was specified. The +\fItype\fP shall cause the following effects: +.TP 7 +\fB+\fP +Place the beginning of the specified line at the top of the display. +.TP 7 +\fB-\fP +Place the end of the specified line at the bottom of the display. +.TP 7 +\fB\&.\fP +Place the beginning of the specified line in the middle of the display. +.TP 7 +\fB^\fP +If the specified line is less than or equal to the value of the \fBwindow\fP +edit option, set the line to 1; otherwise, +decrement the line by the value of the \fBwindow\fP edit option minus +1. Place the beginning of this line as close to the bottom +of the displayed lines as possible, while still displaying the value +of the \fBwindow\fP edit option number of lines. +.sp +.LP +\fICurrent line\fP: Set to the specified line. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Write +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBw\fP\fB[\fP\fBrite\fP\fB][\fP\fB!\fP\fB][\fP\fB>>\fP\fB][\fP\fIfile\fP\fB] +[\fP\fI2addr\fP\fB]\fP \fBw\fP\fB[\fP\fBrite\fP\fB][\fP\fB!\fP\fB][\fP\fIfile\fP\fB] +[\fP\fI2addr\fP\fB]\fP \fBwq\fP\fB[\fP\fB!\fP\fB][\fP\fB>>\fP\fB][\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +If no lines are specified, the lines shall default to the entire file. +.LP +The command \fBwq\fP shall be equivalent to a \fBwrite\fP command +followed by a \fBquit\fP command; \fBwq!\fP shall be +equivalent to \fBwrite!\fP followed by \fBquit\fP. In both cases, +if the \fBwrite\fP command fails, the \fBquit\fP shall not be +attempted. +.LP +If the command name is not followed by one or more <blank>s, or \fIfile\fP +is not preceded by a \fB'!'\fP character, +the \fBwrite\fP shall be to a file. +.IP " 1." 4 +If the \fB>>\fP argument is specified, and the file already exists, +the lines shall be appended to the file instead of +replacing its contents. If the \fB>>\fP argument is specified, and +the file does not already exist, it is unspecified +whether the write shall proceed as if the \fB>>\fP argument had not +been specified or if the write shall fail. +.LP +.IP " 2." 4 +If the \fBreadonly\fP edit option is set (see readonly ), the \fBwrite\fP +shall fail. +.LP +.IP " 3." 4 +If \fIfile\fP is specified, and is not the current pathname, and the +file exists, the \fBwrite\fP shall fail. +.LP +.IP " 4." 4 +If \fIfile\fP is not specified, the current pathname shall be used. +If there is no current pathname, the \fBwrite\fP command +shall fail. +.LP +.IP " 5." 4 +If the current pathname is used, and the current pathname has been +changed by the \fBfile\fP or \fBread\fP commands, and the +file exists, the \fBwrite\fP shall fail. If the \fBwrite\fP is successful, +subsequent \fBwrite\fPs shall not fail for this +reason (unless the current pathname is changed again). +.LP +.IP " 6." 4 +If the whole edit buffer is not being written, and the file to be +written exists, the \fBwrite\fP shall fail. +.LP +.LP +For rules 1., 2., 4., and 5., the \fBwrite\fP can be forced by appending +the character \fB'!'\fP to the command name. +.LP +For rules 2., 4., and 5., the \fBwrite\fP can be forced by setting +the \fBwriteany\fP edit option. +.LP +Additional, implementation-defined tests may cause the \fBwrite\fP +to fail. +.LP +If the edit buffer is empty, a file without any contents shall be +written. +.LP +An informational message shall be written noting the number of lines +and bytes written. +.LP +Otherwise, if the command is followed by one or more <blank>s, and +the file is preceded by \fB'!'\fP , the rest of the +line after the \fB'!'\fP shall have \fB'%'\fP , \fB'#'\fP , and \fB'!'\fP +characters expanded as described in Command Line Parsing in ex . +.LP +The \fIex\fP utility shall then pass two arguments to the program +named by the \fBshell\fP edit option; the first shall be +\fB-c\fP and the second shall be the expanded arguments to the \fBwrite\fP +command as a single argument. The specified lines +shall be written to the standard input of the command. The standard +error and standard output of the program, if any, shall be +written as described for the \fBprint\fP command. If the last character +in that output is not a <newline>, a <newline> +shall be written at the end of the output. +.LP +The special meaning of the \fB'!'\fP following the \fBwrite\fP command +can be overridden by escaping it with a backslash +character. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Write and Exit +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBx\fP\fB[\fP\fBit\fP\fB][\fP\fB!\fP\fB][\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +If the edit buffer has not been modified since the last complete \fBwrite\fP, +\fBxit\fP shall be equivalent to the \fBquit\fP +command, or if a \fB'!'\fP is appended to the command name, to \fBquit!\fP. +.LP +Otherwise, \fBxit\fP shall be equivalent to the \fBwq\fP command, +or if a \fB'!'\fP is appended to the command name, to +\fBwq!\fP. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Yank +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fBya\fP\fB[\fP\fBnk\fP\fB][\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP +.fi +.RE +.sp +.LP +Copy the specified lines to the specified buffer (by default, the +unnamed buffer), which shall become a line-mode buffer. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Adjust Window +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fBz\fP\fB[\fP\fB!\fP\fB][\fP\fItype\fP \fB...\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +If no line is specified, the current line shall be the default; if +\fItype\fP is omitted as well, the current line value shall +first be incremented by 1. If incrementing the current line would +cause it to be greater than the last line in the edit buffer, it +shall be an error. +.LP +If there are <blank>s between the \fItype\fP argument and the preceding +\fBz\fP command name or optional \fB'!'\fP +character, it shall be an error. +.LP +If \fIcount\fP is specified, the value of the \fBwindow\fP edit option +shall be set to \fIcount\fP (as described in window ). If \fIcount\fP +is omitted, it shall default to 2 times the value of the \fBscroll\fP +edit +option, or if \fB!\fP was specified, the number of lines in the display +minus 1. +.LP +If \fItype\fP is omitted, then \fIcount\fP lines starting with the +specified line shall be written. Otherwise, \fIcount\fP +lines starting with the line specified by the \fItype\fP argument +shall be written. +.LP +The \fItype\fP argument shall change the lines to be written. The +possible values of \fItype\fP are as follows: +.TP 7 +\fB-\fP +The specified line shall be decremented by the following value: +.sp +.RS +.nf + +\fB(((number of "-" characters) x\fP \fIcount\fP\fB) -1) +\fP +.fi +.RE +.LP +If the calculation would result in a number less than 1, it shall +be an error. Write lines from the edit buffer, starting at the +new value of line, until \fIcount\fP lines or the last line in the +edit buffer has been written. +.TP 7 +\fB+\fP +The specified line shall be incremented by the following value: +.sp +.RS +.nf + +\fB(((number of "+" characters) -1) x\fP \fIcount\fP\fB) +1 +\fP +.fi +.RE +.LP +If the calculation would result in a number greater than the last +line in the edit buffer, it shall be an error. Write lines +from the edit buffer, starting at the new value of line, until \fIcount\fP +lines or the last line in the edit buffer has been +written. +.TP 7 +\fB=\fP,\fB.\fP +If more than a single \fB'.'\fP or \fB'='\fP is specified, it shall +be an error. The following steps shall be taken: +.RS +.IP " 1." 4 +If \fIcount\fP is zero, nothing shall be written. +.LP +.IP " 2." 4 +Write as many of the \fIN\fP lines before the current line in the +edit buffer as exist. If \fIcount\fP or \fB'!'\fP was +specified, \fIN\fP shall be: +.sp +.RS +.nf + +\fB(\fP\fIcount\fP \fB-1) /2 +\fP +.fi +.RE +.LP +Otherwise, \fIN\fP shall be: +.sp +.RS +.nf + +\fB(\fP\fIcount\fP \fB-3) /2 +\fP +.fi +.RE +.LP +If \fIN\fP is a number less than 3, no lines shall be written. +.LP +.IP " 3." 4 +If \fB'='\fP was specified as the type character, write a line consisting +of the smaller of the number of columns in the +display divided by two, or 40 \fB'-'\fP characters. +.LP +.IP " 4." 4 +Write the current line. +.LP +.IP " 5." 4 +Repeat step 3. +.LP +.IP " 6." 4 +Write as many of the \fIN\fP lines after the current line in the edit +buffer as exist. \fIN\fP shall be defined as in step 2. +If \fIN\fP is a number less than 3, no lines shall be written. If +\fIcount\fP is less than 3, no lines shall be written. +.LP +.RE +.TP 7 +\fB^\fP +The specified line shall be decremented by the following value: +.sp +.RS +.nf + +\fB(((number of "^" characters) +1) x\fP \fIcount\fP\fB) -1 +\fP +.fi +.RE +.LP +If the calculation would result in a number less than 1, it shall +be an error. Write lines from the edit buffer, starting at the +new value of line, until \fIcount\fP lines or the last line in the +edit buffer has been written. +.sp +.LP +\fICurrent line\fP: Set to the last line written, unless the type +is \fB=\fP, in which case, set to the specified line. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Escape +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB!\fP \fIcommand +\fP\fB[\fP\fIaddr\fP\fB]\fP\fB!\fP \fIcommand\fP +.fi +.RE +.sp +.LP +The contents of the line after the \fB'!'\fP shall have \fB'%'\fP +, \fB'#'\fP , and \fB'!'\fP characters expanded as +described in Command Line Parsing in ex . If the expansion causes +the text of the line to change, it +shall be redisplayed, preceded by a single \fB'!'\fP character. +.LP +The \fIex\fP utility shall execute the program named by the \fBshell\fP +edit option. It shall pass two arguments to the +program; the first shall be \fB-c\fP, and the second shall be the +expanded arguments to the \fB!\fP command as a single +argument. +.LP +If no lines are specified, the standard input, standard output, and +standard error of the program shall be set to the standard +input, standard output, and standard error of the \fIex\fP program +when it was invoked. In addition, a warning message shall be +written if the edit buffer has been modified since the last complete +write, and the \fBwarn\fP edit option is set. +.LP +If lines are specified, they shall be passed to the program as standard +input, and the standard output and standard error of the +program shall replace those lines in the edit buffer. Each line in +the program output (as delimited by <newline>s or the end +of the output if it is not immediately preceded by a <newline>), shall +be a separate line in the edit buffer. Any occurrences +of <carriage-return> and <newline> pairs in the output shall be treated +as single <newline>s. The specified lines +shall be copied into the unnamed buffer before they are replaced, +and the unnamed buffer shall become a line-mode buffer. +.LP +If in \fIex\fP mode, a single \fB'!'\fP character shall be written +when the program completes. +.LP +This command shall be affected by the \fBshell\fP and \fBwarn\fP edit +options. If no lines are specified, this command shall +be affected by the \fBautowrite\fP and \fBwriteany\fP edit options. +If lines are specified, this command shall be affected by the +\fBautoprint\fP edit option. +.LP +\fICurrent line\fP: +.IP " 1." 4 +If no lines are specified, unchanged. +.LP +.IP " 2." 4 +Otherwise, set to the last line read in, if any lines are read in. +.LP +.IP " 3." 4 +Otherwise, set to the line before the first line of the lines specified, +if that line exists. +.LP +.IP " 4." 4 +Otherwise, set to the first line of the edit buffer if the edit buffer +is not empty. +.LP +.IP " 5." 4 +Otherwise, set to zero. +.LP +.LP +\fICurrent column\fP: If no lines are specified, unchanged. Otherwise, +set to non- <blank>. +.SS Shift Left +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fB<\fP\fB[\fP\fB< ...\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +Shift the specified lines to the start of the line; the number of +column positions to be shifted shall be the number of command +characters times the value of the \fBshiftwidth\fP edit option. Only +leading <blank>s shall be deleted or changed into other +<blank>s in shifting; other characters shall not be affected. +.LP +Lines to be shifted shall be copied into the unnamed buffer, which +shall become a line-mode buffer. +.LP +This command shall be affected by the \fBautoprint\fP edit option. +.LP +\fICurrent line\fP: Set to the last line in the lines specified. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Shift Right +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fB>\fP\fB[\fP\fB> ...\fP\fB][\fP\fIcount\fP\fB][\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +Shift the specified lines away from the start of the line; the number +of column positions to be shifted shall be the number of +command characters times the value of the \fBshiftwidth\fP edit option. +The shift shall be accomplished by adding <blank>s +as a prefix to the line or changing leading <blank>s into other <blank>s. +Empty lines shall not be changed. +.LP +Lines to be shifted shall be copied into the unnamed buffer, which +shall become a line-mode buffer. +.LP +This command shall be affected by the \fBautoprint\fP edit option. +.LP +\fICurrent line\fP: Set to the last line in the lines specified. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS <control>-D +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-D +\fP +.fi +.RE +.sp +.LP +Write the next \fIn\fP lines, where \fIn\fP is the minimum of the +values of the \fBscroll\fP edit option and the number of +lines after the current line in the edit buffer. If the current line +is the last line of the edit buffer it shall be an error. +.LP +\fICurrent line\fP: Set to the last line written. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Write Line Number +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI1addr\fP\fB]\fP \fB=\fP \fB[\fP\fIflags\fP\fB]\fP +.fi +.RE +.sp +.LP +If \fIline\fP is not specified, it shall default to the last line +in the edit buffer. Write the line number of the specified +line. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Execute +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fI2addr\fP\fB]\fP \fB@\fP \fIbuffer\fP\fB[\fP\fI2addr\fP\fB]\fP \fB*\fP \fIbuffer\fP +.fi +.RE +.sp +.LP +If no buffer is specified or is specified as \fB'@'\fP or \fB'*'\fP +, the last buffer executed shall be used. If no +previous buffer has been executed, it shall be an error. +.LP +For each line specified by the addresses, set the current line ( \fB'.'\fP +) to the specified line, and execute the contents +of the named \fIbuffer\fP (as they were at the time the \fB@\fP command +was executed) as \fIex\fP commands. For each line of a +line-mode buffer, and all but the last line of a character-mode buffer, +the \fIex\fP command parser shall behave as if the line +was terminated by a <newline>. +.LP +If an error occurs during this process, or a line specified by the +addresses does not exist when the current line would be set +to it, or more than a single line was specified by the addresses, +and the contents of the edit buffer are replaced (for example, by +the \fIex\fP \fB:edit\fP command) an error message shall be written, +and no more commands resulting from the execution of this +command shall be processed. +.LP +\fICurrent line\fP: As specified for the individual \fIex\fP commands. +.LP +\fICurrent column\fP: As specified for the individual \fIex\fP commands. +.SS Regular Expressions in ex +.LP +The \fIex\fP utility shall support regular expressions that are a +superset of the basic regular expressions described in the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 9.3, Basic +Regular Expressions. A null regular expression ( \fB"//"\fP ) shall +be equivalent to the last regular expression +encountered. +.LP +Regular expressions can be used in addresses to specify lines and, +in some commands (for example, the \fBsubstitute\fP +command), to specify portions of a line to be substituted. +.LP +The following constructs can be used to enhance the basic regular +expressions: +.TP 7 +\fB\\<\fP +Match the beginning of a \fIword\fP. (See the definition of \fIword\fP +at the beginning of Command +Descriptions in ex .) +.TP 7 +\fB\\>\fP +Match the end of a \fIword\fP. +.TP 7 +\fB~\fP +Match the replacement part of the last \fBsubstitute\fP command. The +tilde ( \fB'~'\fP ) character can be escaped in a +regular expression to become a normal character with no special meaning. +The backslash shall be discarded. +.sp +.LP +When the editor option \fBmagic\fP is not set, the only characters +with special meanings shall be \fB'^'\fP at the beginning +of a pattern, \fB'$'\fP at the end of a pattern, and \fB'\\'\fP . +The characters \fB'.'\fP , \fB'*'\fP , \fB'['\fP , +and \fB'~'\fP shall be treated as ordinary characters unless preceded +by a \fB'\\'\fP ; when preceded by a \fB'\\'\fP +they shall regain their special meaning, or in the case of backslash, +be handled as a single backslash. Backslashes used to escape +other characters shall be discarded. +.SS Replacement Strings in ex +.LP +The character \fB'&'\fP ( \fB'\\&'\fP if the editor option \fBmagic\fP +is not set) in the replacement string shall +stand for the text matched by the pattern to be replaced. The character +\fB'~'\fP ( \fB'\\~'\fP if \fBmagic\fP is +not set) shall be replaced by the replacement part of the previous +\fBsubstitute\fP command. The sequence \fB'\\n'\fP , where +\fIn\fP is an integer, shall be replaced by the text matched by the +pattern enclosed in the \fIn\fPth set of parentheses +\fB'\\('\fP and \fB'\\)'\fP . +.LP +The strings \fB'\\l'\fP , \fB'\\u'\fP , \fB'\\L'\fP , and \fB'\\U'\fP +can be used to modify the case of elements in the +replacement string (using the \fB'\\&'\fP or \fB"\\"\fP digit) notation. +The string \fB'\\l'\fP ( \fB'\\u'\fP ) shall +cause the character that follows to be converted to lowercase (uppercase). +The string \fB'\\L'\fP ( \fB'\\U'\fP ) shall cause +all characters subsequent to it to be converted to lowercase (uppercase) +as they are inserted by the substitution until the string +\fB'\\e'\fP or \fB'\\E'\fP , or the end of the replacement string, +is encountered. +.LP +Otherwise, any character following a backslash shall be treated as +that literal character, and the escaping backslash shall be +discarded. +.LP +An example of case conversion with the \fBs\fP command is as follows: +.sp +.RS +.nf + +\fB:\fP\fBp +\fP\fBThe cat sat on the mat. +:\fP\fBs/\\<.at\\>/\\u&/gp +\fP\fBThe Cat Sat on the Mat. +:\fP\fBs/S\\(.*\\)M/S\\U\\1\\eM/p +\fP\fBThe Cat SAT ON THE Mat.\fP +.fi +.RE +.SS Edit Options in ex +.LP +The \fIex\fP utility has a number of options that modify its behavior. +These options have default settings, which can be +changed using the \fBset\fP command. +.LP +Options are Boolean unless otherwise specified. +.SS autoindent, ai +.LP +[Default \fIunset\fP] +.LP +If \fBautoindent\fP is set, each line in input mode shall be indented +(using first as many <tab>s as possible, as +determined by the editor option \fBtabstop\fP, and then using <space>s) +to align with another line, as follows: +.IP " 1." 4 +If in open or visual mode and the text input is part of a line-oriented +command (see the EXTENDED DESCRIPTION in \fIvi\fP ), align to the +first column. +.LP +.IP " 2." 4 +Otherwise, if in open or visual mode, indentation for each line shall +be set as follows: +.RS +.IP " a." 4 +If a line was previously inserted as part of this command, it shall +be set to the indentation of the last inserted line by +default, or as otherwise specified for the <control>-D character in +\fIInput Mode Commands +in vi\fP . +.LP +.IP " b." 4 +Otherwise, it shall be set to the indentation of the previous current +line, if any; otherwise, to the first column. +.LP +.RE +.LP +.IP " 3." 4 +For the \fIex\fP \fBa\fP, \fBi\fP, and \fBc\fP commands, indentation +for each line shall be set as follows: +.RS +.IP " a." 4 +If a line was previously inserted as part of this command, it shall +be set to the indentation of the last inserted line by +default, or as otherwise specified for the \fIeof\fP character in +Scroll . +.LP +.IP " b." 4 +Otherwise, if the command is the \fIex\fP \fBa\fP command, it shall +be set to the line appended after, if any; otherwise to +the first column. +.LP +.IP " c." 4 +Otherwise, if the command is the \fIex\fP \fBi\fP command, it shall +be set to the line inserted before, if any; otherwise to +the first column. +.LP +.IP " d." 4 +Otherwise, if the command is the \fIex\fP \fBc\fP command, it shall +be set to the indentation of the line replaced. +.LP +.RE +.LP +.SS autoprint, ap +.LP +[Default \fIset\fP] +.LP +If \fBautoprint\fP is set, the current line shall be written after +each \fIex\fP command that modifies the contents of the +current edit buffer, and after each \fBtag\fP command for which the +tag search pattern was found or tag line number was valid, +unless: +.IP " 1." 4 +The command was executed while in open or visual mode. +.LP +.IP " 2." 4 +The command was executed as part of a \fBglobal\fP or \fBv\fP command +or \fB@\fP buffer execution. +.LP +.IP " 3." 4 +The command was the form of the \fBread\fP command that reads a file +into the edit buffer. +.LP +.IP " 4." 4 +The command was the \fBappend\fP, \fBchange\fP, or \fBinsert\fP command. +.LP +.IP " 5." 4 +The command was not terminated by a <newline>. +.LP +.IP " 6." 4 +The current line shall be written by a flag specified to the command; +for example, \fBdelete #\fP shall write the current line +as specified for the flag modifier to the \fBdelete\fP command, and +not as specified by the \fBautoprint\fP edit option. +.LP +.SS autowrite, aw +.LP +[Default \fIunset\fP] +.LP +If \fBautowrite\fP is set, and the edit buffer has been modified since +it was last completely written to any file, the contents +of the edit buffer shall be written as if the \fIex\fP \fBwrite\fP +command had been specified without arguments, before each +command affected by the \fBautowrite\fP edit option is executed. Appending +the character \fB'!'\fP to the command name of any +of the \fIex\fP commands except \fB'!'\fP shall prevent the write. +If the write fails, it shall be an error and the command +shall not be executed. +.SS beautify, bf +.LP +[Default \fIunset\fP] +.LP +If \fBbeautify\fP is set, all non-printable characters, other than +<tab>s, <newline>s, and <form-feed>s, +shall be discarded from text read in from files. +.SS directory, dir +.LP +[Default \fIimplementation-defined\fP] +.LP +The value of this option specifies the directory in which the editor +buffer is to be placed. If this directory is not writable +by the user, the editor shall quit. +.SS edcompatible, ed +.LP +[Default \fIunset\fP] +.LP +Causes the presence of \fBg\fP and \fBc\fP suffixes on substitute +commands to be remembered, and toggled by repeating the +suffixes. +.SS errorbells, eb +.LP +[Default \fIunset\fP] +.LP +If the editor is in \fIex\fP mode, and the terminal does not support +a standout mode (such as inverse video), and +\fBerrorbells\fP is set, error messages shall be preceded by alerting +the terminal. +.SS exrc +.LP +[Default \fIunset\fP] +.LP +If \fBexrc\fP is set, \fIex\fP shall access any \fB.exrc\fP file in +the current directory, as described in Initialization in ex and vi +\&. If \fBexrc\fP is not set, \fIex\fP shall ignore any \fB.exrc\fP +file in the +current directory during initialization, unless the current directory +is that named by the \fIHOME\fP environment variable. +.SS ignorecase, ic +.LP +[Default \fIunset\fP] +.LP +If \fBignorecase\fP is set, characters that have uppercase and lowercase +representations shall have those representations +considered as equivalent for purposes of regular expression comparison. +.LP +The \fBignorecase\fP edit option shall affect all remembered regular +expressions; for example, unsetting the \fBignorecase\fP +edit option shall cause a subsequent \fIvi\fP \fBn\fP command to search +for the last basic +regular expression in a case-sensitive fashion. +.SS list +.LP +[Default \fIunset\fP] +.LP +If \fBlist\fP is set, edit buffer lines written while in \fIex\fP +command mode shall be written as specified for the +\fBprint\fP command with the \fBl\fP flag specified. In open or visual +mode, each edit buffer line shall be displayed as +specified for the \fIex\fP \fBprint\fP command with the \fBl\fP flag +specified. In open or visual text input mode, when the +cursor does not rest on any character in the line, it shall rest on +the \fB'$'\fP marking the end of the line. +.SS magic +.LP +[Default \fIset\fP] +.LP +If \fBmagic\fP is set, modify the interpretation of characters in +regular expressions and substitution replacement strings (see +Regular Expressions in ex and Replacement Strings in ex ). +.SS mesg +.LP +[Default \fIset\fP] +.LP +If \fBmesg\fP is set, the permission for others to use the \fBwrite\fP +or \fBtalk\fP commands to write to the terminal shall +be turned on while in open or visual mode. The shell-level command +\fImesg\fP \fBn\fP shall +take precedence over any setting of the \fIex\fP \fBmesg\fP option; +that is, if \fBmesg y\fP was issued before the editor +started (or in a shell escape), such as: +.sp +.RS +.nf + +\fB:!mesg y +\fP +.fi +.RE +.LP +the \fBmesg\fP option in \fIex\fP shall suppress incoming messages, +but the \fBmesg\fP option shall not enable incoming +messages if \fBmesg n\fP was issued. +.SS number, nu +.LP +[Default \fIunset\fP] +.LP +If \fBnumber\fP is set, edit buffer lines written while in \fIex\fP +command mode shall be written with line numbers, in the +format specified by the \fBprint\fP command with the \fB#\fP flag +specified. In \fIex\fP text input mode, each line shall be +preceded by the line number it will have in the file. +.LP +In open or visual mode, each edit buffer line shall be displayed with +a preceding line number, in the format specified by the +\fIex\fP \fBprint\fP command with the \fB#\fP flag specified. This +line number shall not be considered part of the line for the +purposes of evaluating the current column; that is, column position +1 shall be the first column position after the format specified +by the \fBprint\fP command. +.SS paragraphs, para +.LP +[Default in the POSIX locale \fBIPLPPPQPP LIpplpipbp\fP] +.LP +The \fBparagraphs\fP edit option shall define additional paragraph +boundaries for the open and visual mode commands. The +\fBparagraphs\fP edit option can be set to a character string consisting +of zero or more character pairs. It shall be an error to +set it to an odd number of characters. +.SS prompt +.LP +[Default \fIset\fP] +.LP +If \fBprompt\fP is set, \fIex\fP command mode input shall be prompted +for with a colon ( \fB':'\fP ); when unset, no prompt +shall be written. +.SS readonly +.LP +[Default \fIsee text\fP] +.LP +If the \fBreadonly\fP edit option is set, read-only mode shall be +enabled (see Write ). The +\fBreadonly\fP edit option shall be initialized to set if either of +the following conditions are true: +.IP " *" 3 +The command-line option -R was specified. +.LP +.IP " *" 3 +Performing actions equivalent to the \fIaccess\fP() function called +with the following +arguments indicates that the file lacks write permission: +.RS +.IP " 1." 4 +The current pathname is used as the \fIpath\fP argument. +.LP +.IP " 2." 4 +The constant \fBW_OK\fP is used as the \fIamode\fP argument. +.LP +.RE +.LP +.LP +The \fBreadonly\fP edit option may be initialized to set for other, +implementation-defined reasons. The \fBreadonly\fP edit +option shall not be initialized to unset based on any special privileges +of the user or process. The \fBreadonly\fP edit option +shall be reinitialized each time that the contents of the edit buffer +are replaced (for example, by an \fBedit\fP or \fBnext\fP +command) unless the user has explicitly set it, in which case it shall +remain set until the user explicitly unsets it. Once unset, +it shall again be reinitialized each time that the contents of the +edit buffer are replaced. +.SS redraw +.LP +[Default \fIunset\fP] +.LP +The editor simulates an intelligent terminal on a dumb terminal. (Since +this is likely to require a large amount of output to +the terminal, it is useful only at high transmission speeds.) +.SS remap +.LP +[Default \fIset\fP] +.LP +If \fBremap\fP is set, map translation shall allow for maps defined +in terms of other maps; translation shall continue until a +final product is obtained. If unset, only a one-step translation shall +be done. +.SS report +.LP +[Default 5] +.LP +The value of this \fBreport\fP edit option specifies what number of +lines being added, copied, deleted, or modified in the edit +buffer will cause an informational message to be written to the user. +The following conditions shall cause an informational +message. The message shall contain the number of lines added, copied, +deleted, or modified, but is otherwise unspecified. +.IP " *" 3 +An \fIex\fP or \fIvi\fP editor command, other than \fBopen\fP, \fBundo\fP, +or +\fBvisual\fP, that modifies at least the value of the \fBreport\fP +edit option number of lines, and which is not part of an +\fIex\fP \fBglobal\fP or \fBv\fP command, or \fIex\fP or \fIvi\fP +buffer execution, shall +cause an informational message to be written. +.LP +.IP " *" 3 +An \fIex\fP \fByank\fP or \fIvi\fP \fBy\fP or \fBY\fP command, that +copies at least the +value of the \fBreport\fP edit option plus 1 number of lines, and +which is not part of an \fIex\fP \fBglobal\fP or \fBv\fP +command, or \fIex\fP or \fIvi\fP buffer execution, shall cause an +informational message to be +written. +.LP +.IP " *" 3 +An \fIex\fP \fBglobal\fP, \fBv\fP, \fBopen\fP, \fBundo\fP, or \fBvisual\fP +command or \fIex\fP or \fIvi\fP buffer execution, that adds or deletes +a total of at least the value of the \fBreport\fP edit +option number of lines, and which is not part of an \fIex\fP \fBglobal\fP +or \fBv\fP command, or \fIex\fP or \fIvi\fP buffer execution, shall +cause an informational message to be written. (For example, if 3 lines +were added and 8 lines deleted during an \fIex\fP \fBvisual\fP command, +5 would be the number compared against the \fBreport\fP +edit option after the command completed.) +.LP +.SS scroll, scr +.LP +[Default (number of lines in the display -1)/2] +.LP +The value of the \fBscroll\fP edit option shall determine the number +of lines scrolled by the \fIex\fP <control>-D and +\fBz\fP commands. For the \fIvi\fP <control>-D and <control>-U commands, +it shall +be the initial number of lines to scroll when no previous <control>-D +or <control>-U command has been executed. +.SS sections +.LP +[Default in the POSIX locale \fBNHSHH HUnhsh\fP] +.LP +The \fBsections\fP edit option shall define additional section boundaries +for the open and visual mode commands. The +\fBsections\fP edit option can be set to a character string consisting +of zero or more character pairs; it shall be an error to +set it to an odd number of characters. +.SS shell, sh +.LP +[Default from the environment variable \fISHELL ]\fP +.LP +The value of this option shall be a string. The default shall be taken +from the \fISHELL\fP environment variable. If the +\fISHELL\fP environment variable is null or empty, the \fIsh\fP (see +\fIsh\fP ) utility shall be the default. +.SS shiftwidth, sw +.LP +[Default 8] +.LP +The value of this option shall give the width in columns of an indentation +level used during autoindentation and by the shift +commands ( \fB<\fP and \fB>\fP). +.SS showmatch, sm +.LP +[Default \fIunset\fP] +.LP +The functionality described for the \fBshowmatch\fP edit option need +not be supported on block-mode terminals or terminals with +insufficient capabilities. +.LP +If \fBshowmatch\fP is set, in open or visual mode, when a \fB')'\fP +or \fB'}'\fP is typed, if the matching \fB'('\fP +or \fB'{'\fP is currently visible on the display, the matching \fB'('\fP +or \fB'{'\fP shall be flagged moving the cursor +to its location for an unspecified amount of time. +.SS showmode +.LP +[Default \fIunset\fP] +.LP +If \fBshowmode\fP is set, in open or visual mode, the current mode +that the editor is in shall be displayed on the last line of +the display. Command mode and text input mode shall be differentiated; +other unspecified modes and implementation-defined +information may be displayed. +.SS slowopen +.LP +[Default \fIunset\fP] +.LP +If \fBslowopen\fP is set during open and visual text input modes, +the editor shall not update portions of the display other +than those display line columns that display the characters entered +by the user (see \fIInput +Mode Commands in vi\fP ). +.SS tabstop, ts +.LP +[Default 8] +.LP +The value of this edit option shall specify the column boundary used +by a <tab> in the display (see autoprint, ap and \fIInput Mode Commands +in vi\fP ). +.SS taglength, tl +.LP +[Default zero] +.LP +The value of this edit option shall specify the maximum number of +characters that are considered significant in the +user-specified tag name and in the tag name from the tags file. If +the value is zero, all characters in both tag names shall be +significant. +.SS tags +.LP +[Default \fIsee text\fP] +.LP +The value of this edit option shall be a string of <blank>-delimited +pathnames of files used by the \fBtag\fP command. +The default value is unspecified. +.SS term +.LP +[Default from the environment variable \fITERM ]\fP +.LP +The value of this edit option shall be a string. The default shall +be taken from the \fITERM\fP variable in the environment. If +the \fITERM\fP environment variable is empty or null, the default +is unspecified. The editor shall use the value of this edit +option to determine the type of the display device. +.LP +The results are unspecified if the user changes the value of the term +edit option after editor initialization. +.SS terse +.LP +[Default \fIunset\fP] +.LP +If \fBterse\fP is set, error messages may be less verbose. However, +except for this caveat, error messages are unspecified. +Furthermore, not all error messages need change for different settings +of this option. +.SS warn +.LP +[Default \fIset\fP] +.LP +If \fBwarn\fP is set, and the contents of the edit buffer have been +modified since they were last completely written, the +editor shall write a warning message before certain \fB!\fP commands +(see Escape ). +.SS window +.LP +[Default \fIsee text\fP] +.LP +A value used in open and visual mode, by the <control>-B and <control>-F +commands, and, in visual mode, to specify +the number of lines displayed when the screen is repainted. +.LP +If the \fB-w\fP command-line option is not specified, the default +value shall be set to the value of the \fILINES\fP +environment variable. If the \fILINES\fP environment variable is empty +or null, the default shall be the number of lines in the +display minus 1. +.LP +Setting the \fBwindow\fP edit option to zero or to a value greater +than the number of lines in the display minus 1 (either +explicitly or based on the \fB-w\fP option or the \fILINES\fP environment +variable) shall cause the \fBwindow\fP edit option to +be set to the number of lines in the display minus 1. +.LP +The baud rate of the terminal line may change the default in an implementation-defined +manner. +.SS wrapmargin, wm +.LP +[Default 0] +.LP +If the value of this edit option is zero, it shall have no effect. +.LP +If not in the POSIX locale, the effect of this edit option is implementation-defined. +.LP +Otherwise, it shall specify a number of columns from the ending margin +of the terminal. +.LP +During open and visual text input modes, for each character for which +any part of the character is displayed in a column that is +less than \fBwrapmargin\fP columns from the ending margin of the display +line, the editor shall behave as follows: +.IP " 1." 4 +If the character triggering this event is a <blank>, it, and all immediately +preceding <blank>s on the current line +entered during the execution of the current text input command, shall +be discarded, and the editor shall behave as if the user had +entered a single <newline> instead. In addition, if the next user-entered +character is a <space>, it shall be discarded +as well. +.LP +.IP " 2." 4 +Otherwise, if there are one or more <blank>s on the current line immediately +preceding the last group of inserted non- +<blank>s which was entered during the execution of the current text +input command, the <blank>s shall be replaced as if +the user had entered a single <newline> instead. +.LP +.LP +If the \fBautoindent\fP edit option is set, and the events described +in 1. or 2. are performed, any <blank>s at or after +the cursor in the current line shall be discarded. +.LP +The ending margin shall be determined by the system or overridden +by the user, as described for \fICOLUMNS\fP in the +ENVIRONMENT VARIABLES section and the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 8, Environment Variables. +.SS wrapscan, ws +.LP +[Default \fIset\fP] +.LP +If \fBwrapscan\fP is set, searches (the \fIex\fP \fB/\fP or \fB?\fP +addresses, or open and visual mode \fB/\fP, \fB?\fP, +\fBN\fP, and \fBn\fP commands) shall wrap around the beginning or +end of the edit buffer; when unset, searches shall stop at the +beginning or end of the edit buffer. +.SS writeany, wa +.LP +[Default \fIunset\fP] +.LP +If \fBwriteany\fP is set, some of the checks performed when executing +the \fIex\fP \fBwrite\fP commands shall be inhibited, +as described in editor option \fBautowrite\fP. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +When any error is encountered and the standard input is not a terminal +device file, \fIex\fP shall not write the file or return +to command or text input mode, and shall terminate with a non-zero +exit status. +.LP +Otherwise, when an unrecoverable error is encountered, it shall be +equivalent to a SIGHUP asynchronous event. +.LP +Otherwise, when an error is encountered, the editor shall behave as +specified in Command Line Parsing +in ex . +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +If a SIGSEGV signal is received while \fIex\fP is saving a file, the +file might not be successfully saved. +.LP +The \fBnext\fP command can accept more than one file, so usage such +as: +.sp +.RS +.nf + +\fBnext `ls [abc]*` +\fP +.fi +.RE +.LP +is valid; it would not be valid for the \fBedit\fP or \fBread\fP commands, +for example, because they expect only one file and +unspecified results occur. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIex\fP/ \fIvi\fP specification is based on the historical practice +found in the 4 BSD +and System V implementations of \fIex\fP and \fIvi\fP. A freely redistributable +implementation +of \fIex\fP/ \fIvi\fP, which is tracking IEEE\ Std\ 1003.1-2001 fairly +closely, and +demonstrates the intended changes between historical implementations +and IEEE\ Std\ 1003.1-2001, may be obtained by +anonymous FTP from: +.sp +.RS +.nf + +\fBftp://ftp.rdg.opengroup.org/pub/mirrors/nvi +\fP +.fi +.RE +.LP +A \fIrestricted editor\fP (both the historical \fIred\fP utility and +modifications to \fIex\fP) were considered and rejected +for inclusion. Neither option provided the level of security that +users might expect. +.LP +It is recognized that \fIex\fP visual mode and related features would +be difficult, if not impossible, to implement +satisfactorily on a block-mode terminal, or a terminal without any +form of cursor addressing; thus, it is not a mandatory +requirement that such features should work on all terminals. It is +the intention, however, that an \fIex\fP implementation should +provide the full set of capabilities on all terminals capable of supporting +them. +.SS Options +.LP +The \fB-c\fP replacement for \fB+\fP \fIcommand\fP was inspired by +the \fB-e\fP option of \fIsed\fP. Historically, all such commands +(see \fBedit\fP and \fBnext\fP as well) were executed +from the last line of the edit buffer. This meant, for example, that +\fB"+/pattern"\fP would fail unless the \fBwrapscan\fP +option was set. IEEE\ Std\ 1003.1-2001 requires conformance to historical +practice. Historically, some implementations +restricted the \fIex\fP commands that could be listed as part of the +command line arguments. For consistency, +IEEE\ Std\ 1003.1-2001 does not permit these restrictions. +.LP +In historical implementations of the editor, the \fB-R\fP option (and +the \fBreadonly\fP edit option) only prevented +overwriting of files; appending to files was still permitted, mapping +loosely into the \fIcsh\fP \fBnoclobber\fP variable. Some +implementations, however, have not followed this semantic, and \fBreadonly\fP +does not permit appending either. +IEEE\ Std\ 1003.1-2001 follows the latter practice, believing that +it is a more obvious and intuitive meaning of +\fBreadonly\fP. +.LP +The \fB-s\fP option suppresses all interactive user feedback and is +useful for editing scripts in batch jobs. The list of +specific effects is historical practice. The terminal type "incapable +of supporting open and visual modes" has historically been +named "dumb". +.LP +The \fB-t\fP option was required because the \fIctags\fP utility appears +in +IEEE\ Std\ 1003.1-2001 and the option is available in all historical +implementations of \fIex\fP. +.LP +Historically, the \fIex\fP and \fIvi\fP utilities accepted a \fB-x\fP +option, which did +encryption based on the algorithm found in the historical \fIcrypt\fP +utility. The \fB-x\fP option for encryption, and the +associated \fIcrypt\fP utility, were omitted because the algorithm +used was not specifiable and the export control laws of some +nations make it difficult to export cryptographic technology. In addition, +it did not historically provide the level of security +that users might expect. +.SS Standard Input +.LP +An end-of-file condition is not equivalent to an end-of-file character. +A common end-of-file character, <control>-D, is +historically an \fIex\fP command. +.LP +There was no maximum line length in historical implementations of +\fIex\fP. Specifically, as it was parsed in chunks, the +addresses had a different maximum length than the filenames. Further, +the maximum line buffer size was declared as BUFSIZ, which +was different lengths on different systems. This version selected +the value of {LINE_MAX} to impose a reasonable restriction on +portable usage of \fIex\fP and to aid test suite writers in their +development of realistic tests that exercise this limit. +.SS Input Files +.LP +It was an explicit decision by the standard developers that a <newline> +be added to any file lacking one. It was believed +that this feature of \fIex\fP and \fIvi\fP was relied on by users +in order to make text files +lacking a trailing <newline> more portable. It is recognized that +this will require a user-specified option or extension for +implementations that permit \fIex\fP and \fIvi\fP to edit files of +type other than text if +such files are not otherwise identified by the system. It was agreed +that the ability to edit files of arbitrary type can be +useful, but it was not considered necessary to mandate that an \fIex\fP +or \fIvi\fP +implementation be required to handle files other than text files. +.LP +The paragraph in the INPUT FILES section, "By default, ...", is intended +to close a long-standing security problem in +\fIex\fP and \fIvi\fP; that of the "modeline" or "modelines" edit +option. This feature +allows any line in the first or last five lines of the file containing +the strings \fB"ex:"\fP or \fB"vi:"\fP (and, +apparently, \fB"ei:"\fP or \fB"vx:"\fP ) to be a line containing editor +commands, and \fIex\fP interprets all the text up to +the next \fB':'\fP or <newline> as a command. Consider the consequences, +for example, of an unsuspecting user using +\fIex\fP or \fIvi\fP as the editor when replying to a mail message +in which a line such +as: +.sp +.RS +.nf + +\fBex:! rm -rf : +\fP +.fi +.RE +.LP +appeared in the signature lines. The standard developers believed +strongly that an editor should not by default interpret any +lines of a file. Vendors are strongly urged to delete this feature +from their implementations of \fIex\fP and \fIvi\fP. +.SS Asynchronous Events +.LP +The intention of the phrase "complete write" is that the entire edit +buffer be written to stable storage. The note regarding +temporary files is intended for implementations that use temporary +files to back edit buffers unnamed by the user. +.LP +Historically, SIGQUIT was ignored by \fIex\fP, but was the equivalent +of the \fBQ\fP command in visual mode; that is, it +exited visual mode and entered \fIex\fP mode. IEEE\ Std\ 1003.1-2001 +permits, but does not require, this behavior. +Historically, SIGINT was often used by \fIvi\fP users to terminate +text input mode ( +<control>-C is often easier to enter than <ESC>). Some implementations +of \fIvi\fP +alerted the terminal on this event, and some did not. IEEE\ Std\ 1003.1-2001 +requires that SIGINT behave identically to +<ESC>, and that the terminal not be alerted. +.LP +Historically, suspending the \fIex\fP editor during text input mode +was similar to SIGINT, as completed lines were retained, +but any partial line discarded, and the editor returned to command +mode. IEEE\ Std\ 1003.1-2001 is silent on this issue; +implementations are encouraged to follow historical practice, where +possible. +.LP +Historically, the \fIvi\fP editor did not treat SIGTSTP as an asynchronous +event, and it was +therefore impossible to suspend the editor in visual text input mode. +There are two major reasons for this. The first is that +SIGTSTP is a broadcast signal on UNIX systems, and the chain of events +where the shell \fIexec\fPs an application that then \fIexec\fPs \fIvi\fP +usually caused confusion for the +terminal state if SIGTSTP was delivered to the process group in the +default manner. The second was that most implementations of the +UNIX \fIcurses\fP package are not reentrant, and the receipt of SIGTSTP +at the wrong time will cause them to crash. +IEEE\ Std\ 1003.1-2001 is silent on this issue; implementations are +encouraged to treat suspension as an asynchronous event +if possible. +.LP +Historically, modifications to the edit buffer made before SIGINT +interrupted an operation were retained; that is, anywhere from +zero to all of the lines to be modified might have been modified by +the time the SIGINT arrived. These changes were not discarded +by the arrival of SIGINT. IEEE\ Std\ 1003.1-2001 permits this behavior, +noting that the \fBundo\fP command is required to +be able to undo these partially completed commands. +.LP +The action taken for signals other than SIGINT, SIGCONT, SIGHUP, and +SIGTERM is unspecified because some implementations attempt +to save the edit buffer in a useful state when other signals are received. +.SS Standard Error +.LP +For \fIex\fP/ \fIvi\fP, diagnostic messages are those messages reported +as a result of a +failed attempt to invoke \fIex\fP or \fIvi\fP, such as invalid options +or insufficient +resources, or an abnormal termination condition. Diagnostic messages +should not be confused with the error messages generated by +inappropriate or illegal user commands. +.SS Initialization in ex and vi +.LP +If an \fIex\fP command (other than \fBcd\fP, \fBchdir\fP, or \fBsource\fP) +has a filename argument, one or both of the +alternate and current pathnames will be set. Informally, they are +set as follows: +.IP " 1." 4 +If the \fIex\fP command is one that replaces the contents of the edit +buffer, and it succeeds, the current pathname will be set +to the filename argument (the first filename argument in the case +of the \fBnext\fP command) and the alternate pathname will be +set to the previous current pathname, if there was one. +.LP +.IP " 2." 4 +In the case of the file read/write forms of the \fBread\fP and \fBwrite\fP +commands, if there is no current pathname, the +current pathname will be set to the filename argument. +.LP +.IP " 3." 4 +Otherwise, the alternate pathname will be set to the filename argument. +.LP +.LP +For example, \fB:edit foo\fP and \fB:recover foo\fP, when successful, +set the current pathname, and, if there was a previous +current pathname, the alternate pathname. The commands \fB:write\fP, +\fB!command\fP, and \fB:edit\fP set neither the current or +alternate pathnames. If the \fB:edit foo\fP command were to fail for +some reason, the alternate pathname would be set. The +\fBread\fP and \fBwrite\fP commands set the alternate pathname to +their \fIfile\fP argument, unless the current pathname is not +set, in which case they set the current pathname to their \fIfile\fP +arguments. The alternate pathname was not historically set by +the \fB:source\fP command. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. Implementations adding +commands that take filenames as arguments are encouraged to set the +alternate pathname as described here. +.LP +Historically, \fIex\fP and \fIvi\fP read the \fB.exrc\fP file in the +\fI$HOME\fP +directory twice, if the editor was executed in the \fI$HOME\fP directory. +IEEE\ Std\ 1003.1-2001 prohibits this +behavior. +.LP +Historically, the 4 BSD \fIex\fP and \fIvi\fP read the \fI$HOME\fP +and local \fB.exrc\fP +files if they were owned by the real ID of the user, or the \fBsourceany\fP +option was set, regardless of other considerations. +This was a security problem because it is possible to put normal UNIX +system commands inside a \fB.exrc\fP file. +IEEE\ Std\ 1003.1-2001 does not specify the \fBsourceany\fP option, +and historical implementations are encouraged to +delete it. +.LP +The \fB.exrc\fP files must be owned by the real ID of the user, and +not writable by anyone other than the owner. The +appropriate privileges exception is intended to permit users to acquire +special privileges, but continue to use the \fB.exrc\fP +files in their home directories. +.LP +System V Release 3.2 and later \fIvi\fP implementations added the +option \fB[no]exrc\fP. +The behavior is that local \fB.exrc\fP files are read-only if the +\fBexrc\fP option is set. The default for the \fBexrc\fP +option was off, so by default, local \fB.exrc\fP files were not read. +The problem this was intended to solve was that System V +permitted users to give away files, so there is no possible ownership +or writeability test to ensure that the file is safe. This is +still a security problem on systems where users can give away files, +but there is nothing additional that +IEEE\ Std\ 1003.1-2001 can do. The implementation-defined exception +is intended to permit groups to have local \fB.exrc\fP +files that are shared by users, by creating pseudo-users to own the +shared files. +.LP +IEEE\ Std\ 1003.1-2001 does not mention system-wide \fIex\fP and \fIvi\fP +start-up +files. While they exist in several implementations of \fIex\fP and +\fIvi\fP, they are not +present in any implementations considered historical practice by IEEE\ Std\ 1003.1-2001. +Implementations that have such +files should use them only if they are owned by the real user ID or +an appropriate user (for example, root on UNIX systems) and if +they are not writable by any user other than their owner. System-wide +start-up files should be read before the \fIEXINIT\fP +variable, \fB$HOME/.exrc\fP, or local \fB.exrc\fP files are evaluated. +.LP +Historically, any \fIex\fP command could be entered in the \fIEXINIT\fP +variable or the \fB.exrc\fP file, although ones +requiring that the edit buffer already contain lines of text generally +caused historical implementations of the editor to drop +\fBcore\fP. IEEE\ Std\ 1003.1-2001 requires that any \fIex\fP command +be permitted in the \fIEXINIT\fP variable and +\fB\&.exrc\fP files, for simplicity of specification and consistency, +although many of them will obviously fail under many +circumstances. +.LP +The initialization of the contents of the edit buffer uses the phrase +"the effect shall be" with regard to various \fIex\fP +commands. The intent of this phrase is that edit buffer contents loaded +during the initialization phase not be lost; that is, +loading the edit buffer should fail if the \fB.exrc\fP file read in +the contents of a file and did not subsequently write the edit +buffer. An additional intent of this phrase is to specify that the +initial current line and column is set as specified for the +individual \fIex\fP commands. +.LP +Historically, the \fB-t\fP option behaved as if the tag search were +a \fB+\fP \fIcommand\fP; that is, it was executed from +the last line of the file specified by the tag. This resulted in the +search failing if the pattern was a forward search pattern and +the \fBwrapscan\fP edit option was not set. IEEE\ Std\ 1003.1-2001 +does not permit this behavior, requiring that the +search for the tag pattern be performed on the entire file, and, if +not found, that the current line be set to a more reasonable +location in the file. +.LP +Historically, the empty edit buffer presented for editing when a file +was not specified by the user was unnamed. This is +permitted by IEEE\ Std\ 1003.1-2001; however, implementations are +encouraged to provide users a temporary filename for this +buffer because it permits them the use of \fIex\fP commands that use +the current pathname during temporary edit sessions. +.LP +Historically, the file specified using the \fB-t\fP option was not +part of the current argument list. This practice is +permitted by IEEE\ Std\ 1003.1-2001; however, implementations are +encouraged to include its name in the current argument +list for consistency. +.LP +Historically, the \fB-c\fP command was generally not executed until +a file that already exists was edited. +IEEE\ Std\ 1003.1-2001 requires conformance to this historical practice. +Commands that could cause the \fB-c\fP command to +be executed include the \fIex\fP commands \fBedit\fP, \fBnext\fP, +\fBrecover\fP, \fBrewind\fP, and \fBtag\fP, and the \fIvi\fP commands +<control>-^ and <control>-]. Historically, reading a file into an +edit buffer did not cause the \fB-c\fP command to be executed (even +though it might set the current pathname) with the exception +that it did cause the \fB-c\fP command to be executed if: the editor +was in \fIex\fP mode, the edit buffer had no current +pathname, the edit buffer was empty, and no read commands had yet +been attempted. For consistency and simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.LP +Historically, the \fB-r\fP option was the same as a normal edit session +if there was no recovery information available for the +file. This allowed users to enter: +.sp +.RS +.nf + +\fBvi -r *.c +\fP +.fi +.RE +.LP +and recover whatever files were recoverable. In some implementations, +recovery was attempted only on the first file named, and +the file was not entered into the argument list; in others, recovery +was attempted for each file named. In addition, some +historical implementations ignored \fB-r\fP if \fB-t\fP was specified +or did not support command line \fIfile\fP arguments with +the \fB-t\fP option. For consistency and simplicity of specification, +IEEE\ Std\ 1003.1-2001 disallows these special +cases, and requires that recovery be attempted the first time each +file is edited. +.LP +Historically, \fIvi\fP initialized the \fB`\fP and \fB'\fP marks, +but \fIex\fP did not. +This meant that if the first command in \fIex\fP mode was \fBvisual\fP +or if an \fIex\fP command was executed first (for +example, \fIvi\fP +10 \fIfile\fP), \fIvi\fP was entered +without the marks being initialized. Because the standard developers +believed the marks to be generally useful, and for consistency +and simplicity of specification, IEEE\ Std\ 1003.1-2001 requires that +they always be initialized if in open or visual mode, +or if in \fIex\fP mode and the edit buffer is not empty. Not initializing +it in \fIex\fP mode if the edit buffer is empty is +historical practice; however, it has always been possible to set (and +use) marks in empty edit buffers in open and visual mode edit +sessions. +.SS Addressing +.LP +Historically, \fIex\fP and \fIvi\fP accepted the additional addressing +forms \fB'\\/'\fP +and \fB'\\?'\fP . They were equivalent to \fB"//"\fP and \fB"??"\fP +, respectively. They are not required by +IEEE\ Std\ 1003.1-2001, mostly because nobody can remember whether +they ever did anything different historically. +.LP +Historically, \fIex\fP and \fIvi\fP permitted an address of zero for +several commands, and +permitted the \fB%\fP address in empty files for others. For consistency, +IEEE\ Std\ 1003.1-2001 requires support for the +former in the few commands where it makes sense, and disallows it +otherwise. In addition, because IEEE\ Std\ 1003.1-2001 +requires that \fB%\fP be logically equivalent to \fB"1,$"\fP , it +is also supported where it makes sense and disallowed +otherwise. +.LP +Historically, the \fB%\fP address could not be followed by further +addresses. For consistency and simplicity of specification, +IEEE\ Std\ 1003.1-2001 requires that additional addresses be supported. +.LP +All of the following are valid \fIaddresses\fP: +.TP 7 +\fB+++\fP +Three lines after the current line. +.TP 7 +\fB/\fP\fIre\fP\fB/-\fP +One line before the next occurrence of \fIre\fP. +.TP 7 +\fB-2\fP +Two lines before the current line. +.TP 7 +\fB3\ ----\ 2\fP +Line one (note intermediate negative address). +.TP 7 +\fB1\ 2\ 3\fP +Line six. +.sp +.LP +Any number of addresses can be provided to commands taking addresses; +for example, \fB"1,2,3,4,5p"\fP prints lines 4 and 5, +because two is the greatest valid number of addresses accepted by +the \fBprint\fP command. This, in combination with the semicolon +delimiter, permits users to create commands based on ordered patterns +in the file. For example, the command \fB3;/foo/;+2print\fP +will display the first line after line 3 that contains the pattern +\fIfoo\fP, plus the next two lines. Note that the address +\fB3;\fP must be evaluated before being discarded because the search +origin for the \fB/foo/\fP command depends on this. +.LP +Historically, values could be added to addresses by including them +after one or more <blank>s; for example, +\fB3\ -\ 5p\fP wrote the seventh line of the file, and \fB/foo/\ 5\fP +was the same as \fB/foo/+5\fP. However, only +absolute values could be added; for example, \fB5\ /foo/\fP was an +error. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. Address offsets are separately specified from +addresses because they could historically be provided to +visual mode search commands. +.LP +Historically, any missing addresses defaulted to the current line. +This was true for leading and trailing comma-delimited +addresses, and for trailing semicolon-delimited addresses. For consistency, +IEEE\ Std\ 1003.1-2001 requires it for leading +semicolon addresses as well. +.LP +Historically, \fIex\fP and \fIvi\fP accepted the \fB'^'\fP character +as both an address +and as a flag offset for commands. In both cases it was identical +to the \fB'-'\fP character. IEEE\ Std\ 1003.1-2001 +does not require or prohibit this behavior. +.LP +Historically, the enhancements to basic regular expressions could +be used in addressing; for example, \fB'~'\fP , +\fB'\\<'\fP , and \fB'\\>'\fP . IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice; that is, that +regular expression usage be consistent, and that regular expression +enhancements be supported wherever regular expressions are +used. +.SS Command Line Parsing in ex +.LP +Historical \fIex\fP command parsing was even more complex than that +described here. IEEE\ Std\ 1003.1-2001 requires the +subset of the command parsing that the standard developers believed +was documented and that users could reasonably be expected to +use in a portable fashion, and that was historically consistent between +implementations. (The discarded functionality is obscure, +at best.) Historical implementations will require changes in order +to comply with IEEE\ Std\ 1003.1-2001; however, users +are not expected to notice any of these changes. Most of the complexity +in \fIex\fP parsing is to handle three special termination +cases: +.IP " 1." 4 +The \fB!\fP, \fBglobal\fP, \fBv\fP, and the filter versions of the +\fBread\fP and \fBwrite\fP commands are delimited by +<newline>s (they can contain vertical-line characters that are usually +shell pipes). +.LP +.IP " 2." 4 +The \fBex\fP, \fBedit\fP, \fBnext\fP, and \fBvisual\fP in open and +visual mode commands all take \fIex\fP commands, +optionally containing vertical-line characters, as their first arguments. +.LP +.IP " 3." 4 +The \fBs\fP command takes a regular expression as its first argument, +and uses the delimiting characters to delimit the +command. +.LP +.LP +Historically, vertical-line characters in the \fB+\fP \fIcommand\fP +argument of the \fBex\fP, \fBedit\fP, \fBnext\fP, +\fBvi\fP, and \fBvisual\fP commands, and in the \fIpattern\fP and +\fIreplacement\fP parts of the \fBs\fP command, did not +delimit the command, and in the filter cases for \fBread\fP and \fBwrite\fP, +and the \fB!\fP, \fBglobal\fP, and \fBv\fP +commands, they did not delimit the command at all. For example, the +following commands are all valid: +.sp +.RS +.nf + +\fB:\fP\fBedit +25 | s/abc/ABC/ file.c +\fP\fB:\fP\fBs/ | /PIPE/ +\fP\fB:\fP\fBread !spell % | columnate +\fP\fB:\fP\fBglobal/pattern/p | l +\fP\fB:\fP\fBs/a/b/ | s/c/d | set +\fP +.fi +.RE +.LP +Historically, empty or <blank> filled lines in \fB.exrc\fP files and +\fBsource\fPd files (as well as \fIEXINIT\fP +variables and \fIex\fP command scripts) were treated as default commands; +that is, \fBprint\fP commands. +IEEE\ Std\ 1003.1-2001 specifically requires that they be ignored +when encountered in \fB.exrc\fP and \fBsource\fPd files +to eliminate a common source of new user error. +.LP +Historically, \fIex\fP commands with multiple adjacent (or <blank>-separated) +vertical lines were handled oddly when +executed from \fIex\fP mode. For example, the command \fB|||\fP <carriage-return>, +when the cursor was on line 1, displayed +lines 2, 3, and 5 of the file. In addition, the command \fB|\fP would +only display the line after the next line, instead of the +next two lines. The former worked more logically when executed from +\fIvi\fP mode, and +displayed lines 2, 3, and 4. IEEE\ Std\ 1003.1-2001 requires the \fIvi\fP +behavior; +that is, a single default command and line number increment for each +command separator, and trailing <newline>s after +vertical-line separators are discarded. +.LP +Historically, \fIex\fP permitted a single extra colon as a leading +command character; for example, \fB:g/pattern/:p\fP was a +valid command. IEEE\ Std\ 1003.1-2001 generalizes this to require +that any number of leading colon characters be +stripped. +.LP +Historically, any prefix of the \fBdelete\fP command could be followed +without intervening <blank>s by a flag character +because in the command \fBd\ p\fP, \fIp\fP is interpreted as the buffer +\fIp\fP. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice. +.LP +Historically, the \fBk\fP command could be followed by the mark name +without intervening <blank>s. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.LP +Historically, the \fBs\fP command could be immediately followed by +flag and option characters; for example, +\fBs/e/E/|s|sgc3p\fP was a valid command. However, flag characters +could not stand alone; for example, the commands \fBsp\fP and +\fBs\ l\fP would fail, while the command \fBsgp\fP and \fBs\ gl\fP +would succeed. (Obviously, the \fB'#'\fP flag +character was used as a delimiter character if it followed the command.) +Another issue was that option characters had to precede +flag characters even when the command was fully specified; for example, +the command \fBs/e/E/pg\fP would fail, while the command +\fBs/e/E/gp\fP would succeed. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. +.LP +Historically, the first command name that had a prefix matching the +input from the user was the executed command; for example, +\fBve\fP, \fBver\fP, and \fBvers\fP all executed the \fBversion\fP +command. Commands were in a specific order, however, so that +\fBa\fP matched \fBappend\fP, not \fBabbreviate\fP. IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice. +The restriction on command search order for implementations with extensions +is to avoid the addition of commands such that the +historical prefixes would fail to work portably. +.LP +Historical implementations of \fIex\fP and \fIvi\fP did not correctly +handle multiple +\fIex\fP commands, separated by vertical-line characters, that entered +or exited visual mode or the editor. Because +implementations of \fIvi\fP exist that do not exhibit this failure +mode, +IEEE\ Std\ 1003.1-2001 does not permit it. +.LP +The requirement that alphabetic command names consist of all following +alphabetic characters up to the next non-alphabetic +character means that alphabetic command names must be separated from +their arguments by one or more non-alphabetic characters, +normally a <blank> or \fB'!'\fP character, except as specified for +the exceptions, the \fBdelete\fP, \fBk\fP, and +\fBs\fP commands. +.LP +Historically, the repeated execution of the \fIex\fP default \fBprint\fP +commands ( <control>-D, \fIeof\fP, +<newline>, <carriage-return>) erased any prompting character and displayed +the next lines without scrolling the +terminal; that is, immediately below any previously displayed lines. +This provided a cleaner presentation of the lines in the file +for the user. IEEE\ Std\ 1003.1-2001 does not require this behavior +because it may be impossible in some situations; +however, implementations are strongly encouraged to provide this semantic +if possible. +.LP +Historically, it was possible to change files in the middle of a command, +and have the rest of the command executed in the new +file; for example: +.sp +.RS +.nf + +\fB:edit +25 file.c | s/abc/ABC/ | 1 +\fP +.fi +.RE +.LP +was a valid command, and the substitution was attempted in the newly +edited file. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice. The following commands are examples +that exercise the \fIex\fP parser: +.sp +.RS +.nf + +\fBecho 'foo | bar' > file1; echo 'foo/bar' > file2; +vi +:edit +1 | s/|/PIPE/ | w file1 | e file2 | 1 | s/\\//SLASH/ | wq +\fP +.fi +.RE +.LP +Historically, there was no protection in editor implementations to +avoid \fIex\fP \fBglobal\fP, \fBv\fP, \fB@\fP, or +\fB*\fP commands changing edit buffers during execution of their associated +commands. Because this would almost invariably result +in catastrophic failure of the editor, and implementations exist that +do exhibit these problems, IEEE\ Std\ 1003.1-2001 +requires that changing the edit buffer during a \fBglobal\fP or \fBv\fP +command, or during a \fB@\fP or \fB*\fP command for +which there will be more than a single execution, be an error. Implementations +supporting multiple edit buffers simultaneously are +strongly encouraged to apply the same semantics to switching between +buffers as well. +.LP +The \fIex\fP command quoting required by IEEE\ Std\ 1003.1-2001 is +a superset of the quoting in historical +implementations of the editor. For example, it was not historically +possible to escape a <blank> in a filename; for example, +\fB:edit\ foo\\\\\\\ bar\fP would report that too many filenames had +been entered for the edit command, and there was no +method of escaping a <blank> in the first argument of an \fBedit\fP, +\fBex\fP, \fBnext\fP, or \fBvisual\fP command at +all. IEEE\ Std\ 1003.1-2001 extends historical practice, requiring +that quoting behavior be made consistent across all +\fIex\fP commands, except for the \fBmap\fP, \fBunmap\fP, \fBabbreviate\fP, +and \fBunabbreviate\fP commands, which +historically used <control>-V instead of backslashes for quoting. +For those four commands, IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice. +.LP +Backslash quoting in \fIex\fP is non-intuitive. Backslash escapes +are ignored unless they escape a special character; for +example, when performing \fIfile\fP argument expansion, the string +\fB"\\\\%"\fP is equivalent to \fB'\\%'\fP , not +\fB"\\<\fP\fIcurrent\ pathname\fP\fB>"\fP. This can be confusing for +users because backslash is usually one of the +characters that causes shell expansion to be performed, and therefore +shell quoting rules must be taken into consideration. +Generally, quoting characters are only considered if they escape a +special character, and a quoting character must be provided for +each layer of parsing for which the character is special. As another +example, only a single backslash is necessary for the +\fB'\\l'\fP sequence in substitute replacement patterns, because the +character \fB'l'\fP is not special to any parsing layer +above it. +.LP +<control>-V quoting in \fIex\fP is slightly different from backslash +quoting. In the four commands where +<control>-V quoting applies ( \fBabbreviate\fP, \fBunabbreviate\fP, +\fBmap\fP, and \fBunmap\fP), any character may be +escaped by a <control>-V whether it would have a special meaning or +not. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. +.LP +Historical implementations of the editor did not require delimiters +within character classes to be escaped; for example, the +command \fB:s/[/]//\fP on the string \fB"xxx/yyy"\fP would delete +the \fB'/'\fP from the string. +IEEE\ Std\ 1003.1-2001 disallows this historical practice for consistency +and because it places a large burden on +implementations by requiring that knowledge of regular expressions +be built into the editor parser. +.LP +Historically, quoting <newline>s in \fIex\fP commands was handled +inconsistently. In most cases, the <newline> +always terminated the command, regardless of any preceding escape +character, because backslash characters did not escape +<newline>s for most \fIex\fP commands. However, some \fIex\fP commands +(for example, \fBs\fP, \fBmap\fP, and +\fBabbreviation\fP) permitted <newline>s to be escaped (although in +the case of \fBmap\fP and \fBabbreviation\fP, +<control>-V characters escaped them instead of backslashes). This +was true in not only the command line, but also +\fB\&.exrc\fP and \fBsource\fPd files. For example, the command: +.sp +.RS +.nf + +\fBmap = foo<control-V><newline>bar +\fP +.fi +.RE +.LP +would succeed, although it was sometimes difficult to get the <control>-V +and the inserted <newline> passed to the +\fIex\fP parser. For consistency and simplicity of specification, +IEEE\ Std\ 1003.1-2001 requires that it be possible to +escape <newline>s in \fIex\fP commands at all times, using backslashes +for most \fIex\fP commands, and using +<control>-V characters for the \fBmap\fP and \fBabbreviation\fP commands. +For example, the command \fBprint\fP +<newline> \fBlist\fP is required to be parsed as the single command +\fBprint\fP <newline> \fBlist\fP. While this +differs from historical practice, IEEE\ Std\ 1003.1-2001 developers +believed it unlikely that any script or user depended +on the historical behavior. +.LP +Historically, an error in a command specified using the \fB-c\fP option +did not cause the rest of the \fB-c\fP commands to be +discarded. IEEE\ Std\ 1003.1-2001 disallows this for consistency with +mapped keys, the \fB@\fP, \fBglobal\fP, +\fBsource\fP, and \fBv\fP commands, the \fIEXINIT\fP environment variable, +and the \fB.exrc\fP files. +.SS Input Editing in ex +.LP +One of the common uses of the historical \fIex\fP editor is over slow +network connections. Editors that run in canonical mode +can require far less traffic to and from, and far less processing +on, the host machine, as well as more easily supporting +block-mode terminals. For these reasons, IEEE\ Std\ 1003.1-2001 requires +that \fIex\fP be implemented using canonical mode +input processing, as was done historically. +.LP +IEEE\ Std\ 1003.1-2001 does not require the historical 4 BSD input +editing characters "word erase" or "literal +next". For this reason, it is unspecified how they are handled by +\fIex\fP, although they must have the required effect. +Implementations that resolve them after the line has been ended using +a <newline> or <control>-M character, and +implementations that rely on the underlying system terminal support +for this processing, are both conforming. Implementations are +strongly urged to use the underlying system functionality, if at all +possible, for compatibility with other system text input +interfaces. +.LP +Historically, when the \fIeof\fP character was used to decrement the +\fBautoindent\fP level, the cursor moved to display the +new end of the \fBautoindent\fP characters, but did not move the cursor +to a new line, nor did it erase the <control>-D +character from the line. IEEE\ Std\ 1003.1-2001 does not specify that +the cursor remain on the same line or that the rest +of the line is erased; however, implementations are strongly encouraged +to provide the best possible user interface; that is, the +cursor should remain on the same line, and any <control>-D character +on the line should be erased. +.LP +IEEE\ Std\ 1003.1-2001 does not require the historical 4 BSD input +editing character "reprint", traditionally +<control>-R, which redisplayed the current input from the user. For +this reason, and because the functionality cannot be +implemented after the line has been terminated by the user, IEEE\ Std\ 1003.1-2001 +makes no requirements about this +functionality. Implementations are strongly urged to make this historical +functionality available, if possible. +.LP +Historically, <control>-Q did not perform a literal next function +in \fIex\fP, as it did in \fIvi\fP. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice to avoid breaking +historical \fIex\fP scripts and \fB.exrc\fP files. +.SS eof +.LP +Whether the \fIeof\fP character immediately modifies the \fBautoindent\fP +characters in the prompt is left unspecified so that +implementations can conform in the presence of systems that do not +support this functionality. Implementations are encouraged to +modify the line and redisplay it immediately, if possible. +.LP +The specification of the handling of the \fIeof\fP character differs +from historical practice only in that \fIeof\fP +characters are not discarded if they follow normal characters in the +text input. Historically, they were always discarded. +.SS Command Descriptions in ex +.LP +Historically, several commands (for example, \fBglobal\fP, \fBv\fP, +\fBvisual\fP, \fBs\fP, \fBwrite\fP, \fBwq\fP, +\fByank\fP, \fB!\fP, \fB<\fP, \fB>\fP, \fB&\fP, and \fB~\fP) were +executable in empty files (that is, the +default address(es) were 0), or permitted explicit addresses of 0 +(for example, 0 was a valid address, or 0,0 was a valid range). +Addresses of 0, or command execution in an empty file, make sense +only for commands that add new text to the edit buffer or write +commands (because users may wish to write empty files). IEEE\ Std\ 1003.1-2001 +requires this behavior for such commands and +disallows it otherwise, for consistency and simplicity of specification. +.LP +A count to an \fIex\fP command has been historically corrected to +be no greater than the last line in a file; for example, in a +five-line file, the command \fB1,6print\fP would fail, but the command +\fB1print300\fP would succeed. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.LP +Historically, the use of flags in \fIex\fP commands could be obscure. +General historical practice was as described by +IEEE\ Std\ 1003.1-2001, but there were some special cases. For instance, +the \fBlist\fP, \fBnumber\fP, and \fBprint\fP +commands ignored trailing address offsets; for example, \fB3p\ +++#\fP +would display line 3, and 3 would be the current line +after the execution of the command. The \fBopen\fP and \fBvisual\fP +commands ignored both the trailing offsets and the trailing +flags. Also, flags specified to the \fBopen\fP and \fBvisual\fP commands +interacted badly with the \fBlist\fP edit option, and +setting and then unsetting it during the open/visual session would +cause \fIvi\fP to stop +displaying lines in the specified format. For consistency and simplicity +of specification, IEEE\ Std\ 1003.1-2001 does not +permit any of these exceptions to the general rule. +.LP +IEEE\ Std\ 1003.1-2001 uses the word \fIcopy\fP in several places +when discussing buffers. This is not intended to +imply implementation. +.LP +Historically, \fIex\fP users could not specify numeric buffers because +of the ambiguity this would cause; for example, in the +command \fB3\ delete\ 2\fP, it is unclear whether 2 is a buffer name +or a \fIcount\fP. IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice by default, but does not +preclude extensions. +.LP +Historically, the contents of the unnamed buffer were frequently discarded +after commands that did not explicitly affect it; for +example, when using the \fBedit\fP command to switch files. For consistency +and simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.LP +The \fIex\fP utility did not historically have access to the numeric +buffers, and, furthermore, deleting lines in \fIex\fP did +not modify their contents. For example, if, after doing a delete in +\fIvi\fP, the user switched +to \fIex\fP, did another delete, and then switched back to \fIvi\fP, +the contents of the +numeric buffers would not have changed. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice. Numeric buffers +are described in the \fIex\fP utility in order to confine the description +of buffers to a single location in +IEEE\ Std\ 1003.1-2001. +.LP +The metacharacters that trigger shell expansion in \fIfile\fP arguments +match historical practice, as does the method for doing +shell expansion. Implementations wishing to provide users with the +flexibility to alter the set of metacharacters are encouraged to +provide a \fBshellmeta\fP string edit option. +.LP +Historically, \fIex\fP commands executed from \fIvi\fP refreshed the +screen when it did not +strictly need to do so; for example, \fB:!date\ >\ /dev/null\fP does +not require a screen refresh because the output of +the UNIX \fIdate\fP command requires only a single line of the screen. +IEEE\ Std\ 1003.1-2001 requires that the screen be refreshed if it +has been overwritten, but makes no requirements as to +how an implementation should make that determination. Implementations +may prompt and refresh the screen regardless. +.SS Abbreviate +.LP +Historical practice was that characters that were entered as part +of an abbreviation replacement were subject to \fBmap\fP +expansions, the \fBshowmatch\fP edit option, further abbreviation +expansions, and so on; that is, they were logically pushed onto +the terminal input queue, and were not a simple replacement. IEEE\ Std\ 1003.1-2001 +requires conformance to historical +practice. Historical practice was that whenever a non-word character +(that had not been escaped by a <control>-V) was entered +after a word character, \fIvi\fP would check for abbreviations. The +check was based on the type +of the character entered before the word character of the word/non-word +pair that triggered the check. The word character of the +word/non-word pair that triggered the check and all characters entered +before the trigger pair that were of that type were included +in the check, with the exception of <blank>s, which always delimited +the abbreviation. +.LP +This means that, for the abbreviation to work, the \fIlhs\fP must +end with a word character, there can be no transitions from +word to non-word characters (or \fIvice versa\fP) other than between +the last and next-to-last characters in the \fIlhs\fP, and +there can be no <blank>s in the \fIlhs\fP. In addition, because of +the historical quoting rules, it was impossible to enter +a literal <control>-V in the \fIlhs\fP. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice. +Historical implementations did not inform users when abbreviations +that could never be used were entered; implementations are +strongly encouraged to do so. +.LP +For example, the following abbreviations will work: +.sp +.RS +.nf + +\fB:ab (p REPLACE +:ab p REPLACE +:ab ((p REPLACE +\fP +.fi +.RE +.LP +The following abbreviations will not work: +.sp +.RS +.nf + +\fB:ab ( REPLACE +:ab (pp REPLACE +\fP +.fi +.RE +.LP +Historical practice is that words on the \fIvi\fP colon command line +were subject to +abbreviation expansion, including the arguments to the \fBabbrev\fP +(and more interestingly) the \fBunabbrev\fP command. Because +there are implementations that do not do abbreviation expansion for +the first argument to those commands, this is permitted, but +not required, by IEEE\ Std\ 1003.1-2001. However, the following sequence: +.sp +.RS +.nf + +\fB:ab foo bar +:ab foo baz +\fP +.fi +.RE +.LP +resulted in the addition of an abbreviation of \fB"baz"\fP for the +string \fB"bar"\fP in historical \fIex\fP/ \fIvi\fP, and the sequence: +.sp +.RS +.nf + +\fB:ab foo1 bar +:ab foo2 bar +:unabbreviate foo2 +\fP +.fi +.RE +.LP +deleted the abbreviation \fB"foo1"\fP , not \fB"foo2"\fP . These behaviors +are not permitted by +IEEE\ Std\ 1003.1-2001 because they clearly violate the expectations +of the user. +.LP +It was historical practice that <control>-V, not backslash, characters +be interpreted as escaping subsequent characters in +the \fBabbreviate\fP command. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice; however, it should be +noted that an abbreviation containing a <blank> will never work. +.SS Append +.LP +Historically, any text following a vertical-line command separator +after an \fBappend\fP, \fBchange\fP, or \fBinsert\fP +command became part of the insert text. For example, in the command: +.sp +.RS +.nf + +\fB:g/pattern/append|stuff1 +\fP +.fi +.RE +.LP +a line containing the text \fB"stuff1"\fP would be appended to each +line matching pattern. It was also historically valid to +enter: +.sp +.RS +.nf + +\fB:append|stuff1 +stuff2 +\&. +\fP +.fi +.RE +.LP +and the text on the \fIex\fP command line would be appended along +with the text inserted after it. There was an historical bug, +however, that the user had to enter two terminating lines (the \fB'.'\fP +lines) to terminate text input mode in this case. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice, +but disallows the historical need for multiple +terminating lines. +.SS Change +.LP +See the RATIONALE for the \fBappend\fP command. Historical practice +for cursor positioning after the change command when no +text is input, is as described in IEEE\ Std\ 1003.1-2001. However, +one System V implementation is known to have been +modified such that the cursor is positioned on the first address specified, +and not on the line before the first address. +IEEE\ Std\ 1003.1-2001 disallows this modification for consistency. +.LP +Historically, the \fBchange\fP command did not support buffer arguments, +although some implementations allow the specification +of an optional buffer. This behavior is neither required nor disallowed +by IEEE\ Std\ 1003.1-2001. +.SS Change Directory +.LP +A common extension in \fIex\fP implementations is to use the elements +of a \fBcdpath\fP edit option as prefix directories for +\fIpath\fP arguments to \fBchdir\fP that are relative pathnames and +that do not have \fB'.'\fP or \fB".."\fP as their first +component. Elements in the \fBcdpath\fP edit option are colon-separated. +The initial value of the \fBcdpath\fP edit option is the +value of the shell \fICDPATH\fP environment variable. This feature +was not included in IEEE\ Std\ 1003.1-2001 because it +does not exist in any of the implementations considered historical +practice. +.SS Copy +.LP +Historical implementations of \fIex\fP permitted copies to lines inside +of the specified range; for example, \fB:2,5copy3\fP +was a valid command. IEEE\ Std\ 1003.1-2001 requires conformance to +historical practice. +.SS Delete +.LP +IEEE\ Std\ 1003.1-2001 requires support for the historical parsing +of a \fBdelete\fP command followed by flags, without +any intervening <blank>s. For example: +.TP 7 +\fB1dp\fP +Deletes the first line and prints the line that was second. +.TP 7 +\fB1delep\fP +As for \fB1dp\fP. +.TP 7 +\fB1d\fP +Deletes the first line, saving it in buffer \fIp\fP. +.TP 7 +\fB1d\ p1l\fP +(Pee-one-ell.) Deletes the first line, saving it in buffer \fIp\fP, +and listing the line that was second. +.sp +.SS Edit +.LP +Historically, any \fIex\fP command could be entered as a \fB+\fP \fIcommand\fP +argument to the \fBedit\fP command, although +some (for example, \fBinsert\fP and \fBappend\fP) were known to confuse +historical implementations. For consistency and +simplicity of specification, IEEE\ Std\ 1003.1-2001 requires that +any command be supported as an argument to the +\fBedit\fP command. +.LP +Historically, the command argument was executed with the current line +set to the last line of the file, regardless of whether +the \fBedit\fP command was executed from visual mode or not. IEEE\ Std\ 1003.1-2001 +requires conformance to historical +practice. +.LP +Historically, the \fB+\fP \fIcommand\fP specified to the \fBedit\fP +and \fBnext\fP commands was delimited by the first +<blank>, and there was no way to quote them. For consistency, IEEE\ Std\ 1003.1-2001 +requires that the usual +\fIex\fP backslash quoting be provided. +.LP +Historically, specifying the \fB+\fP \fIcommand\fP argument to the +edit command required a filename to be specified as well; +for example, \fB:edit\ +100\fP would always fail. For consistency +and simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this usage to fail for that +reason. +.LP +Historically, only the cursor position of the last file edited was +remembered by the editor. IEEE\ Std\ 1003.1-2001 +requires that this be supported; however, implementations are permitted +to remember and restore the cursor position for any file +previously edited. +.SS File +.LP +Historical versions of the \fIex\fP editor \fBfile\fP command displayed +a current line and number of lines in the edit buffer +of 0 when the file was empty, while the \fIvi\fP <control>-G command +displayed a current +line and number of lines in the edit buffer of 1 in the same situation. +IEEE\ Std\ 1003.1-2001 does not permit this +discrepancy, instead requiring that a message be displayed indicating +that the file is empty. +.SS Global +.LP +The two-pass operation of the \fBglobal\fP and \fBv\fP commands is +not intended to imply implementation, only the required +result of the operation. +.LP +The current line and column are set as specified for the individual +\fIex\fP commands. This requirement is cumulative; that is, +the current line and column must track across all the commands executed +by the \fBglobal\fP or \fBv\fP commands. +.SS Insert +.LP +See the RATIONALE for the \fBappend\fP command. +.LP +Historically, \fBinsert\fP could not be used with an address of zero; +that is, not when the edit buffer was empty. +IEEE\ Std\ 1003.1-2001 requires that this command behave consistently +with the \fBappend\fP command. +.SS Join +.LP +The action of the \fBjoin\fP command in relation to the special characters +is only defined for the POSIX locale because the +correct amount of white space after a period varies; in Japanese none +is required, in French only a single space, and so on. +.SS List +.LP +The historical output of the \fBlist\fP command was potentially ambiguous. +The standard developers believed correcting this to +be more important than adhering to historical practice, and IEEE\ Std\ 1003.1-2001 +requires unambiguous output. +.SS Map +.LP +Historically, command mode maps only applied to command names; for +example, if the character \fB'x'\fP was mapped to +\fB'y'\fP , the command \fBfx\fP searched for the \fB'x'\fP character, +not the \fB'y'\fP character. +IEEE\ Std\ 1003.1-2001 requires this behavior. Historically, entering +<control>-V as the first character of a \fIvi\fP command was an error. +Several implementations have extended the semantics of \fIvi\fP such +that <control>-V means that the subsequent command character is not +mapped. This is +permitted, but not required, by IEEE\ Std\ 1003.1-2001. Regardless, +using <control>-V to escape the second or later +character in a sequence of characters that might match a \fBmap\fP +command, or any character in text input mode, is historical +practice, and stops the entered keys from matching a map. IEEE\ Std\ 1003.1-2001 +requires conformance to historical +practice. +.LP +Historical implementations permitted digits to be used as a \fBmap\fP +command \fIlhs\fP, but then ignored the map. +IEEE\ Std\ 1003.1-2001 requires that the mapped digits not be ignored. +.LP +The historical implementation of the \fBmap\fP command did not permit +\fBmap\fP commands that were more than a single +character in length if the first character was printable. This behavior +is permitted, but not required, by +IEEE\ Std\ 1003.1-2001. +.LP +Historically, mapped characters were remapped unless the \fBremap\fP +edit option was not set, or the prefix of the mapped +characters matched the mapping characters; for example, in the \fBmap\fP: +.sp +.RS +.nf + +\fB:map ab abcd +\fP +.fi +.RE +.LP +the characters \fB"ab"\fP were used as is and were not remapped, but +the characters \fB"cd"\fP were mapped if appropriate. +This can cause infinite loops in the \fIvi\fP mapping mechanisms. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice, +and that such loops be interruptible. +.LP +Text input maps had the same problems with expanding the \fIlhs\fP +for the \fIex\fP \fBmap!\fP and \fBunmap!\fP command as +did the \fIex\fP \fBabbreviate\fP and \fBunabbreviate\fP commands. +See the RATIONALE for the \fIex\fP \fBabbreviate\fP +command. IEEE\ Std\ 1003.1-2001 requires similar modification of some +historical practice for the \fBmap\fP and +\fBunmap\fP commands, as described for the \fBabbreviate\fP and \fBunabbreviate\fP +commands. +.LP +Historically, \fBmap\fPs that were subsets of other \fBmap\fPs behaved +differently depending on the order in which they were +defined. For example: +.sp +.RS +.nf + +\fB:map! ab short +:map! abc long +\fP +.fi +.RE +.LP +would always translate the characters \fB"ab"\fP to \fB"short"\fP +, regardless of how fast the characters \fB"abc"\fP +were entered. If the entry order was reversed: +.sp +.RS +.nf + +\fB:map! abc long +:map! ab short +\fP +.fi +.RE +.LP +the characters \fB"ab"\fP would cause the editor to pause, waiting +for the completing \fB'c'\fP character, and the +characters might never be mapped to \fB"short"\fP . For consistency +and simplicity of specification, +IEEE\ Std\ 1003.1-2001 requires that the shortest match be used at +all times. +.LP +The length of time the editor spends waiting for the characters to +complete the \fIlhs\fP is unspecified because the timing +capabilities of systems are often inexact and variable, and it may +depend on other factors such as the speed of the connection. The +time should be long enough for the user to be able to complete the +sequence, but not long enough for the user to have to wait. Some +implementations of \fIvi\fP have added a \fBkeytime\fP option, which +permits users to set the +number of 0,1 seconds the editor waits for the completing characters. +Because mapped terminal function and cursor keys tend to +start with an <ESC> character, and <ESC> is the key ending \fIvi\fP +text input +mode, \fBmap\fPs starting with <ESC> characters are generally exempted +from this timeout period, or, at least timed out +differently. +.SS Mark +.LP +Historically, users were able to set the "previous context" marks +explicitly. In addition, the \fIex\fP commands \fB"\fP +and \fB'`\fP and the \fIvi\fP commands \fB"\fP, \fB``\fP, \fB`'\fP, +and \fB'`\fP all +referred to the same mark. In addition, the previous context marks +were not set if the command, with which the address setting the +mark was associated, failed. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. Historically, if marked +lines were deleted, the mark was also deleted, but would reappear +if the change was undone. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice. +.LP +The description of the special events that set the \fB`\fP and \fB'\fP +marks matches historical practice. For example, +historically the command \fB/a/,/b/\fP did not set the \fB`\fP and +\fB'\fP marks, but the command \fB/a/,/b/delete\fP did. +.SS Next +.LP +Historically, any \fIex\fP command could be entered as a \fB+\fP \fIcommand\fP +argument to the \fBnext\fP command, although +some (for example, \fBinsert\fP and \fBappend\fP) were known to confuse +historical implementations. +IEEE\ Std\ 1003.1-2001 requires that any command be permitted and +that it behave as specified. The \fBnext\fP command can +accept more than one file, so usage such as: +.sp +.RS +.nf + +\fBnext `ls [abc] ` +\fP +.fi +.RE +.LP +is valid; it need not be valid for the \fBedit\fP or \fBread\fP commands, +for example, because they expect only one +filename. +.LP +Historically, the \fBnext\fP command behaved differently from the +\fB:rewind\fP command in that it ignored the force flag if +the \fBautowrite\fP flag was set. For consistency, IEEE\ Std\ 1003.1-2001 +does not permit this behavior. +.LP +Historically, the \fBnext\fP command positioned the cursor as if the +file had never been edited before, regardless. +IEEE\ Std\ 1003.1-2001 does not permit this behavior, for consistency +with the \fBedit\fP command. +.LP +Implementations wanting to provide a counterpart to the \fBnext\fP +command that edited the previous file have used the command +\fBprev[ious],\fP which takes no \fIfile\fP argument. IEEE\ Std\ 1003.1-2001 +does not require this command. +.SS Open +.LP +Historically, the \fBopen\fP command would fail if the \fBopen\fP +edit option was not set. IEEE\ Std\ 1003.1-2001 does +not mention the \fBopen\fP edit option and does not require this behavior. +Some historical implementations do not permit entering +open mode from open or visual mode, only from \fIex\fP mode. For consistency, +IEEE\ Std\ 1003.1-2001 does not permit this +behavior. +.LP +Historically, entering open mode from the command line (that is, \fIvi\fP +\fB+open\fP) +resulted in anomalous behaviors; for example, the \fIex\fP file and +\fIset\fP +commands, and the \fIvi\fP command <control>-G did not work. For consistency, +IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.LP +Historically, the \fBopen\fP command only permitted \fB'/'\fP characters +to be used as the search pattern delimiter. For +consistency, IEEE\ Std\ 1003.1-2001 requires that the search delimiters +used by the \fBs\fP, \fBglobal\fP, and \fBv\fP +commands be accepted as well. +.SS Preserve +.LP +The \fBpreserve\fP command does not historically cause the file to +be considered unmodified for the purposes of future commands +that may exit the editor. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. +.LP +Historical documentation stated that mail was not sent to the user +when preserve was executed; however, historical +implementations did send mail in this case. IEEE\ Std\ 1003.1-2001 +requires conformance to the historical +implementations. +.SS Print +.LP +The writing of NUL by the \fBprint\fP command is not specified as +a special case because the standard developers did not want +to require \fIex\fP to support NUL characters. Historically, characters +were displayed using the ARPA standard mappings, which are +as follows: +.IP " 1." 4 +Printable characters are left alone. +.LP +.IP " 2." 4 +Control characters less than \\177 are represented as \fB'^'\fP followed +by the character offset from the \fB'@'\fP +character in the ASCII map; for example, \\007 is represented as \fB'^G'\fP +\&. +.LP +.IP " 3." 4 +\\177 is represented as \fB'^'\fP followed by \fB'?'\fP . +.LP +.LP +The display of characters having their eighth bit set was less standard. +Existing implementations use hex (0x00), octal (\\000), +and a meta-bit display. (The latter displayed bytes that had their +eighth bit set as the two characters \fB"M-"\fP followed by +the seven-bit display as described above.) The latter probably has +the best claim to historical practice because it was used for +the \fB-v\fP option of 4 BSD and 4 BSD-derived versions of the \fIcat\fP +utility since +1980. +.LP +No specific display format is required by IEEE\ Std\ 1003.1-2001. +.LP +Explicit dependence on the ASCII character set has been avoided where +possible, hence the use of the phrase an +"implementation-defined multi-character sequence" for the display +of non-printable characters in preference to the historical +usage of, for instance, \fB"^I"\fP for the <tab>. Implementations +are encouraged to conform to historical practice in the +absence of any strong reason to diverge. +.LP +Historically, all \fIex\fP commands beginning with the letter \fB'p'\fP +could be entered using capitalized versions of the +commands; for example, \fBP[rint]\fP, \fBPre[serve]\fP, and \fBPu[t]\fP +were all valid command names. +IEEE\ Std\ 1003.1-2001 permits, but does not require, this historical +practice because capital forms of the commands are +used by some implementations for other purposes. +.SS Put +.LP +Historically, an \fIex\fP \fBput\fP command, executed from open or +visual mode, was the same as the open or visual mode +\fBP\fP command, if the buffer was named and was cut in character +mode, and the same as the \fBp\fP command if the buffer was +named and cut in line mode. If the unnamed buffer was the source of +the text, the entire line from which the text was taken was +usually \fBput\fP, and the buffer was handled as if in line mode, +but it was possible to get extremely anomalous behavior. In +addition, using the \fBQ\fP command to switch into \fIex\fP mode, +and then doing a \fBput\fP often resulted in errors as well, +such as appending text that was unrelated to the (supposed) contents +of the buffer. For consistency and simplicity of +specification, IEEE\ Std\ 1003.1-2001 does not permit these behaviors. +All \fIex\fP \fBput\fP commands are required to +operate in line mode, and the contents of the buffers are not altered +by changing the mode of the editor. +.SS Read +.LP +Historically, an \fIex\fP \fBread\fP command executed from open or +visual mode, executed in an empty file, left an empty line +as the first line of the file. For consistency and simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this +behavior. Historically, a \fBread\fP in open or visual mode from a +program left the cursor at the last line read in, not the +first. For consistency, IEEE\ Std\ 1003.1-2001 does not permit this +behavior. +.LP +Historical implementations of \fIex\fP were unable to undo \fBread\fP +commands that read from the output of a program. For +consistency, IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.LP +Historically, the \fIex\fP and \fIvi\fP message after a successful +\fBread\fP or +\fBwrite\fP command specified "characters", not "bytes". IEEE\ Std\ 1003.1-2001 +requires that the number of bytes be +displayed, not the number of characters, because it may be difficult +in multi-byte implementations to determine the number of +characters read. Implementations are encouraged to clarify the message +displayed to the user. +.LP +Historically, reads were not permitted on files other than type regular, +except that FIFO files could be read (probably only +because they did not exist when \fIex\fP and \fIvi\fP were originally +written). Because the +historical \fIex\fP evaluated \fBread!\fP and \fBread\ !\fP equivalently, +there can be no optional way to force the read. +IEEE\ Std\ 1003.1-2001 permits, but does not require, this behavior. +.SS Recover +.LP +Some historical implementations of the editor permitted users to recover +the edit buffer contents from a previous edit session, +and then exit without saving those contents (or explicitly discarding +them). The intent of IEEE\ Std\ 1003.1-2001 in +requiring that the edit buffer be treated as already modified is to +prevent this user error. +.SS Rewind +.LP +Historical implementations supported the \fBrewind\fP command when +the user was editing the first file in the list; that is, +the file that the \fBrewind\fP command would edit. IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice. +.SS Substitute +.LP +Historically, \fIex\fP accepted an \fBr\fP option to the \fBs\fP command. +The effect of the \fBr\fP option was to use the +last regular expression used in any command as the pattern, the same +as the \fB~\fP command. The \fBr\fP option is not +required by IEEE\ Std\ 1003.1-2001. Historically, the \fBc\fP and +\fBg\fP options were toggled; for example, the command +\fB:s/abc/def/\fP was the same as \fBs/abc/def/ccccgggg\fP. For simplicity +of specification, IEEE\ Std\ 1003.1-2001 does +not permit this behavior. +.LP +The tilde command is often used to replace the last search RE. For +example, in the sequence: +.sp +.RS +.nf + +\fBs/red/blue/ +/green +~ +\fP +.fi +.RE +.LP +the \fB~\fP command is equivalent to: +.sp +.RS +.nf + +\fBs/green/blue/ +\fP +.fi +.RE +.LP +Historically, \fIex\fP accepted all of the following forms: +.sp +.RS +.nf + +\fBs/abc/def/ +s/abc/def +s/abc/ +s/abc +\fP +.fi +.RE +.LP +IEEE\ Std\ 1003.1-2001 requires conformance to this historical practice. +.LP +The \fBs\fP command presumes that the \fB'^'\fP character only occupies +a single column in the display. Much of the +\fIex\fP and \fIvi\fP specification presumes that the <space> only +occupies a single +column in the display. There are no known character sets for which +this is not true. +.LP +Historically, the final column position for the substitute commands +was based on previous column movements; a search for a +pattern followed by a substitution would leave the column position +unchanged, while a 0 command followed by a substitution would +change the column position to the first non- <blank>. For consistency +and simplicity of specification, +IEEE\ Std\ 1003.1-2001 requires that the final column position always +be set to the first non- <blank>. +.SS Set +.LP +Historical implementations redisplayed all of the options for each +occurrence of the \fBall\fP keyword. +IEEE\ Std\ 1003.1-2001 permits, but does not require, this behavior. +.SS Tag +.LP +No requirement is made as to where \fIex\fP and \fIvi\fP shall look +for the file referenced +by the tag entry. Historical practice has been to look for the path +found in the \fBtags\fP file, based on the current directory. +A useful extension found in some implementations is to look based +on the directory containing the tags file that held the entry, as +well. No requirement is made as to which reference for the tag in +the tags file is used. This is deliberate, in order to permit +extensions such as multiple entries in a tags file for a tag. +.LP +Because users often specify many different tags files, some of which +need not be relevant or exist at any particular time, +IEEE\ Std\ 1003.1-2001 requires that error messages about problem +tags files be displayed only if the requested tag is not +found, and then, only once for each time that the \fBtag\fP edit option +is changed. +.LP +The requirement that the current edit buffer be unmodified is only +necessary if the file indicated by the tag entry is not the +same as the current file (as defined by the current pathname). Historically, +the file would be reloaded if the filename had +changed, as well as if the filename was different from the current +pathname. For consistency and simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this behavior, requiring that +the name be the only factor in the decision. +.LP +Historically, \fIvi\fP only searched for tags in the current file +from the current cursor to +the end of the file, and therefore, if the \fBwrapscan\fP option was +not set, tags occurring before the current cursor were not +found. IEEE\ Std\ 1003.1-2001 considers this a bug, and implementations +are required to search for the first occurrence in +the file, regardless. +.SS Undo +.LP +The \fBundo\fP description deliberately uses the word "modified". +The \fBundo\fP command is not intended to undo commands +that replace the contents of the edit buffer, such as \fBedit\fP, +\fBnext\fP, \fBtag\fP, or \fBrecover\fP. +.LP +Cursor positioning after the \fBundo\fP command was inconsistent in +the historical \fIvi\fP, sometimes attempting to restore the original +cursor position ( \fBglobal\fP, \fBundo\fP, +and \fBv\fP commands), and sometimes, in the presence of maps, placing +the cursor on the last line added or changed instead of the +first. IEEE\ Std\ 1003.1-2001 requires a simplified behavior for consistency +and simplicity of specification. +.SS Version +.LP +The \fBversion\fP command cannot be exactly specified since there +is no widely-accepted definition of what the version +information should contain. Implementations are encouraged to do something +reasonably intelligent. +.SS Write +.LP +Historically, the \fIex\fP and \fIvi\fP message after a successful +\fBread\fP or +\fBwrite\fP command specified "characters", not "bytes". IEEE\ Std\ 1003.1-2001 +requires that the number of bytes be +displayed, not the number of characters because it may be difficult +in multi-byte implementations to determine the number of +characters written. Implementations are encouraged to clarify the +message displayed to the user. +.LP +Implementation-defined tests are permitted so that implementations +can make additional checks; for example, for locks or file +modification times. +.LP +Historically, attempting to append to a nonexistent file caused an +error. It has been left unspecified in +IEEE\ Std\ 1003.1-2001 to permit implementations to let the \fBwrite\fP +succeed, so that the append semantics are similar +to those of the historical \fIcsh\fP. +.LP +Historical \fIvi\fP permitted empty edit buffers to be written. However, +since the way \fIvi\fP got around dealing with "empty" files was to +always have a line in the edit buffer, no +matter what, it wrote them as files of a single, empty line. IEEE\ Std\ 1003.1-2001 +does not permit this behavior. +.LP +Historically, \fIex\fP restored standard output and standard error +to their values as of when \fIex\fP was invoked, before +writes to programs were performed. This could disturb the terminal +configuration as well as be a security issue for some terminals. +IEEE\ Std\ 1003.1-2001 does not permit this, requiring that the program +output be captured and displayed as if by the +\fIex\fP \fBprint\fP command. +.SS Adjust Window +.LP +Historically, the line count was set to the value of the \fBscroll\fP +option if the type character was end-of-file. This +feature was broken on most historical implementations long ago, however, +and is not documented anywhere. For this reason, +IEEE\ Std\ 1003.1-2001 is resolutely silent. +.LP +Historically, the \fBz\fP command was <blank>-sensitive and \fBz\ +\fP +and \fBz\ -\fP did different things than +\fBz+\fP and \fBz-\fP because the type could not be distinguished +from a flag. (The commands \fBz\ .\fP and \fBz\ =\fP +were historically invalid.) IEEE\ Std\ 1003.1-2001 requires conformance +to this historical practice. +.LP +Historically, the \fBz\fP command was further <blank>-sensitive in +that the \fIcount\fP could not be +<blank>-delimited; for example, the commands \fBz=\ 5\fP and \fBz-\ 5\fP +were also invalid. Because the +\fIcount\fP is not ambiguous with respect to either the type character +or the flags, this is not permitted by +IEEE\ Std\ 1003.1-2001. +.SS Escape +.LP +Historically, \fIex\fP filter commands only read the standard output +of the commands, letting standard error appear on the +terminal as usual. The \fIvi\fP utility, however, read both standard +output and standard error. +IEEE\ Std\ 1003.1-2001 requires the latter behavior for both \fIex\fP +and \fIvi\fP, +for consistency. +.SS Shift Left and Shift Right +.LP +Historically, it was possible to add shift characters to increase +the effect of the command; for example, \fB<<<\fP +outdented (or \fB>>>\fP indented) the lines 3 levels of indentation +instead of the default 1. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.SS <control>-D +.LP +Historically, the <control>-D command erased the prompt, providing +the user with an unbroken presentation of lines from +the edit buffer. This is not required by IEEE\ Std\ 1003.1-2001; implementations +are encouraged to provide it if possible. +Historically, the <control>-D command took, and then ignored, a \fIcount\fP. +IEEE\ Std\ 1003.1-2001 does not permit +this behavior. +.SS Write Line Number +.LP +Historically, the \fIex\fP \fB=\fP command, when executed in \fIex\fP +mode in an empty edit buffer, reported 0, and from open +or visual mode, reported 1. For consistency and simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this +behavior. +.SS Execute +.LP +Historically, \fIex\fP did not correctly handle the inclusion of text +input commands (that is, \fBappend\fP, \fBinsert\fP, +and \fBchange\fP) in executed buffers. IEEE\ Std\ 1003.1-2001 does +not permit this exclusion for consistency. +.LP +Historically, the logical contents of the buffer being executed did +not change if the buffer itself were modified by the +commands being executed; that is, buffer execution did not support +self-modifying code. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice. +.LP +Historically, the \fB@\fP command took a range of lines, and the \fB@\fP +buffer was executed once per line, with the current +line ( \fB'.'\fP ) set to each specified line. IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice. +.LP +Some historical implementations did not notice if errors occurred +during buffer execution. This, coupled with the ability to +specify a range of lines for the \fIex\fP \fB@\fP command, makes it +trivial to cause them to drop \fBcore\fP. +IEEE\ Std\ 1003.1-2001 requires that implementations stop buffer execution +if any error occurs, if the specified line +doesn't exist, or if the contents of the edit buffer itself are replaced +(for example, the buffer executes the \fIex\fP +\fB:edit\fP command). +.SS Regular Expressions in ex +.LP +Historical practice is that the characters in the replacement part +of the last \fBs\fP command-that is, those matched by +entering a \fB'~'\fP in the regular expression-were not further expanded +by the regular expression engine. So, if the +characters contained the string \fB"a.,"\fP they would match \fB'a'\fP +followed by \fB".,"\fP and not \fB'a'\fP +followed by any character. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. +.SS Edit Options in ex +.LP +The following paragraphs describe the historical behavior of some +edit options that were not, for whatever reason, included in +IEEE\ Std\ 1003.1-2001. Implementations are strongly encouraged to +only use these names if the functionality described here +is fully supported. +.TP 7 +\fBextended\fP +The \fBextended\fP edit option has been used in some implementations +of \fIvi\fP to +provide extended regular expressions instead of basic regular expressions +This option was omitted from +IEEE\ Std\ 1003.1-2001 because it is not widespread historical practice. +.TP 7 +\fBflash\fP +The \fBflash\fP edit option historically caused the screen to flash +instead of beeping on error. This option was omitted from +IEEE\ Std\ 1003.1-2001 because it is not found in some historical +implementations. +.TP 7 +\fBhardtabs\fP +The \fBhardtabs\fP edit option historically defined the number of +columns between hardware tab settings. This option was +omitted from IEEE\ Std\ 1003.1-2001 because it was believed to no +longer be generally useful. +.TP 7 +\fBmodeline\fP +The \fBmodeline\fP (sometimes named \fBmodelines\fP) edit option historically +caused \fIex\fP or \fIvi\fP to read the five first and last lines +of the file for editor commands. This option is a +security problem, and vendors are strongly encouraged to delete it +from historical implementations. +.TP 7 +\fBopen\fP +The \fBopen\fP edit option historically disallowed the \fIex\fP \fBopen\fP +and \fBvisual\fP commands. This edit option was +omitted because these commands are required by IEEE\ Std\ 1003.1-2001. +.TP 7 +\fBoptimize\fP +The \fBoptimize\fP edit option historically expedited text throughput +by setting the terminal to not do automatic +<carriage-return>s when printing more than one logical line of output. +This option was omitted from +IEEE\ Std\ 1003.1-2001 because it was intended for terminals without +addressable cursors, which are rarely, if ever, still +used. +.TP 7 +\fBruler\fP +The \fBruler\fP edit option has been used in some implementations +of \fIvi\fP to present a +current row/column ruler for the user. This option was omitted from +IEEE\ Std\ 1003.1-2001 because it is not widespread +historical practice. +.TP 7 +\fBsourceany\fP +The \fBsourceany\fP edit option historically caused \fIex\fP or \fIvi\fP +to source +start-up files that were owned by users other than the user running +the editor. This option is a security problem, and vendors are +strongly encouraged to remove it from their implementations. +.TP 7 +\fBtimeout\fP +The \fBtimeout\fP edit option historically enabled the (now standard) +feature of only waiting for a short period before +returning keys that could be part of a macro. This feature was omitted +from IEEE\ Std\ 1003.1-2001 because its behavior is +now standard, it is not widely useful, and it was rarely documented. +.TP 7 +\fBverbose\fP +The \fBverbose\fP edit option has been used in some implementations +of \fIvi\fP to cause +\fIvi\fP to output error messages for common errors; for example, +attempting to move the cursor +past the beginning or end of the line instead of only alerting the +screen. (The historical \fIvi\fP only alerted the terminal and presented +no message for such errors. The historical editor +option \fBterse\fP did not select when to present error messages, +it only made existing error messages more or less verbose.) This +option was omitted from IEEE\ Std\ 1003.1-2001 because it is not widespread +historical practice; however, implementors are +encouraged to use it if they wish to provide error messages for naive +users. +.TP 7 +\fBwraplen\fP +The \fBwraplen\fP edit option has been used in some implementations +of \fIvi\fP to specify +an automatic margin measured from the left margin instead of from +the right margin. This is useful when multiple screen sizes are +being used to edit a single file. This option was omitted from IEEE\ Std\ 1003.1-2001 +because it is not widespread +historical practice; however, implementors are encouraged to use it +if they add this functionality. +.sp +.SS autoindent, ai +.LP +Historically, the command \fB0a\fP did not do any autoindentation, +regardless of the current indentation of line 1. +IEEE\ Std\ 1003.1-2001 requires that any indentation present in line +1 be used. +.SS autoprint, ap +.LP +Historically, the \fBautoprint\fP edit option was not completely consistent +or based solely on modifications to the edit +buffer. Exceptions were the \fBread\fP command (when reading from +a file, but not from a filter), the \fBappend\fP, +\fBchange\fP, \fBinsert\fP, \fBglobal\fP, and \fBv\fP commands, all +of which were not affected by \fBautoprint\fP, and the +\fBtag\fP command, which was affected by \fBautoprint\fP. IEEE\ Std\ 1003.1-2001 +requires conformance to historical +practice. +.LP +Historically, the \fBautoprint\fP option only applied to the last +of multiple commands entered using vertical-bar delimiters; +for example, \fBdelete\fP <newline> was affected by \fBautoprint\fP, +but \fBdelete|version\fP <newline> was not. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.SS autowrite, aw +.LP +Appending the \fB'!'\fP character to the \fIex\fP \fBnext\fP command +to avoid performing an automatic write was not +supported in historical implementations. IEEE\ Std\ 1003.1-2001 requires +that the behavior match the other \fIex\fP +commands for consistency. +.SS ignorecase, ic +.LP +Historical implementations of case-insensitive matching (the \fBignorecase\fP +edit option) lead to counterintuitive situations +when uppercase characters were used in range expressions. Historically, +the process was as follows: +.IP " 1." 4 +Take a line of text from the edit buffer. +.LP +.IP " 2." 4 +Convert uppercase to lowercase in text line. +.LP +.IP " 3." 4 +Convert uppercase to lowercase in regular expressions, except in character +class specifications. +.LP +.IP " 4." 4 +Match regular expressions against text. +.LP +.LP +This would mean that, with \fBignorecase\fP in effect, the text: +.sp +.RS +.nf + +\fBThe cat sat on the mat +\fP +.fi +.RE +.LP +would be matched by +.sp +.RS +.nf + +\fB/^the/ +\fP +.fi +.RE +.LP +but not by: +.sp +.RS +.nf + +\fB/^[A-Z]he/ +\fP +.fi +.RE +.LP +For consistency with other commands implementing regular expressions, +IEEE\ Std\ 1003.1-2001 does not permit this +behavior. +.SS paragraphs, para +.LP +The ISO\ POSIX-2:1993 standard made the default \fBparagraphs\fP and +\fBsections\fP edit options implementation-defined, +arguing they were historically oriented to the UNIX system \fItroff\fP +text formatter, and a "portable user" could use the +\fB{\fP, \fB}\fP, \fB[[\fP, \fB]]\fP, \fB(\fP, and \fB)\fP commands +in open or visual mode and have the cursor stop in +unexpected places. IEEE\ Std\ 1003.1-2001 specifies their values in +the POSIX locale because the unusual grouping (they +only work when grouped into two characters at a time) means that they +cannot be used for general-purpose movement, regardless. +.SS readonly +.LP +Implementations are encouraged to provide the best possible information +to the user as to the read-only status of the file, with +the exception that they should not consider the current special privileges +of the process. This provides users with a safety net +because they must force the overwrite of read-only files, even when +running with additional privileges. +.LP +The \fBreadonly\fP edit option specification largely conforms to historical +practice. The only difference is that historical +implementations did not notice that the user had set the \fBreadonly\fP +edit option in cases where the file was already marked +read-only for some reason, and would therefore reinitialize the \fBreadonly\fP +edit option the next time the contents of the edit +buffer were replaced. This behavior is disallowed by IEEE\ Std\ 1003.1-2001. +.SS report +.LP +The requirement that lines copied to a buffer interact differently +than deleted lines is historical practice. For example, if +the \fBreport\fP edit option is set to 3, deleting 3 lines will cause +a report to be written, but 4 lines must be copied before a +report is written. +.LP +The requirement that the \fIex\fP \fBglobal\fP, \fBv\fP, \fBopen\fP, +\fBundo\fP, and \fBvisual\fP commands present reports +based on the total number of lines added or deleted during the command +execution, and that commands executed by the \fBglobal\fP +and \fBv\fP commands not present reports, is historical practice. +IEEE\ Std\ 1003.1-2001 extends historical practice by +requiring that buffer execution be treated similarly. The reasons +for this are two-fold. Historically, only the report by the last +command executed from the buffer would be seen by the user, as each +new report would overwrite the last. In addition, the standard +developers believed that buffer execution had more in common with +\fBglobal\fP and \fBv\fP commands than it did with other +\fIex\fP commands, and should behave similarly, for consistency and +simplicity of specification. +.SS showmatch, sm +.LP +The length of time the cursor spends on the matching character is +unspecified because the timing capabilities of systems are +often inexact and variable. The time should be long enough for the +user to notice, but not long enough for the user to become +annoyed. Some implementations of \fIvi\fP have added a \fBmatchtime\fP +option that permits +users to set the number of 0,1 second intervals the cursor pauses +on the matching character. +.SS showmode +.LP +The \fBshowmode\fP option has been used in some historical implementations +of \fIex\fP and \fIvi\fP to display the current editing mode when +in open or visual mode. The editing modes have +generally included "command" and "input", and sometimes other modes +such as "replace" and "change". The string was usually +displayed on the bottom line of the screen at the far right-hand corner. +In addition, a preceding \fB'*'\fP character often +denoted whether the contents of the edit buffer had been modified. +The latter display has sometimes been part of the +\fBshowmode\fP option, and sometimes based on another option. This +option was not available in the 4 BSD historical implementation +of \fIvi\fP, but was viewed as generally useful, particularly to novice +users, and is required +by IEEE\ Std\ 1003.1-2001. +.LP +The \fBsmd\fP shorthand for the \fBshowmode\fP option was not present +in all historical implementations of the editor. +IEEE\ Std\ 1003.1-2001 requires it, for consistency. +.LP +Not all historical implementations of the editor displayed a mode +string for command mode, differentiating command mode from +text input mode by the absence of a mode string. IEEE\ Std\ 1003.1-2001 +permits this behavior for consistency with +historical practice, but implementations are encouraged to provide +a display string for both modes. +.SS slowopen +.LP +Historically the \fBslowopen\fP option was automatically set if the +terminal baud rate was less than 1200 baud, or if the baud +rate was 1200 baud and the \fBredraw\fP option was not set. The \fBslowopen\fP +option had two effects. First, when inserting +characters in the middle of a line, characters after the cursor would +not be pushed ahead, but would appear to be overwritten. +Second, when creating a new line of text, lines after the current +line would not be scrolled down, but would appear to be +overwritten. In both cases, ending text input mode would cause the +screen to be refreshed to match the actual contents of the edit +buffer. Finally, terminals that were sufficiently intelligent caused +the editor to ignore the \fBslowopen\fP option. +IEEE\ Std\ 1003.1-2001 permits most historical behavior, extending +historical practice to require \fBslowopen\fP behaviors +if the edit option is set by the user. +.SS tags +.LP +The default path for tags files is left unspecified as implementations +may have their own \fBtags\fP implementations that do +not correspond to the historical ones. The default \fBtags\fP option +value should probably at least include the file +\fB\&./tags\fP. +.SS term +.LP +Historical implementations of \fIex\fP and \fIvi\fP ignored changes +to the \fBterm\fP edit +option after the initial terminal information was loaded. This is +permitted by IEEE\ Std\ 1003.1-2001; however, +implementations are encouraged to permit the user to modify their +terminal type at any time. +.SS terse +.LP +Historically, the \fBterse\fP edit option optionally provided a shorter, +less descriptive error message, for some error +messages. This is permitted, but not required, by IEEE\ Std\ 1003.1-2001. +Historically, most common visual mode errors (for +example, trying to move the cursor past the end of a line) did not +result in an error message, but simply alerted the terminal. +Implementations wishing to provide messages for novice users are urged +to do so based on the \fBedit\fP option \fBverbose\fP, and +not \fBterse\fP. +.SS window +.LP +In historical implementations, the default for the \fBwindow\fP edit +option was based on the baud rate as follows: +.IP " 1." 4 +If the baud rate was less than 1200, the \fBedit\fP option \fBw300\fP +set the window value; for example, the line: +.sp +.RS +.nf + +\fBset w300=12 +\fP +.fi +.RE +.LP +would set the window option to 12 if the baud rate was less than 1200. +.LP +.IP " 2." 4 +If the baud rate was equal to 1200, the \fBedit\fP option \fBw1200\fP +set the window value. +.LP +.IP " 3." 4 +If the baud rate was greater than 1200, the \fBedit\fP option \fBw9600\fP +set the window value. +.LP +.LP +The \fBw300\fP, \fBw1200\fP, and \fBw9600\fP options do not appear +in IEEE\ Std\ 1003.1-2001 because of their +dependence on specific baud rates. +.LP +In historical implementations, the size of the window displayed by +various commands was related to, but not necessarily the same +as, the \fBwindow\fP edit option. For example, the size of the window +was set by the \fIex\fP command \fBvisual 10\fP, but it +did not change the value of the \fBwindow\fP edit option. However, +changing the value of the \fBwindow\fP edit option did change +the number of lines that were displayed when the screen was repainted. +IEEE\ Std\ 1003.1-2001 does not permit this behavior +in the interests of consistency and simplicity of specification, and +requires that all commands that change the number of lines +that are displayed do it by setting the value of the \fBwindow\fP +edit option. +.SS wrapmargin, wm +.LP +Historically, the \fBwrapmargin\fP option did not affect maps inserting +characters that also had associated \fIcount\fPs; for +example \fB:map\ K\ 5aABC\ DEF\fP. Unfortunately, there are widely +used maps that depend on this behavior. For +consistency and simplicity of specification, IEEE\ Std\ 1003.1-2001 +does not permit this behavior. +.LP +Historically, \fBwrapmargin\fP was calculated using the column display +width of all characters on the screen. For example, an +implementation using \fB"^I"\fP to represent <tab>s when the \fBlist\fP +edit option was set, where \fB'^'\fP and +\fB'I'\fP each took up a single column on the screen, would calculate +the \fBwrapmargin\fP based on a value of 2 for each +<tab>. The \fBnumber\fP edit option similarly changed the effective +length of the line as well. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fICommand Search and Execution\fP , \fIctags\fP , \fIed\fP , \fIsed\fP +, \fIsh\fP , \fIstty\fP , \fIvi\fP , the System Interfaces volume +of IEEE\ Std\ 1003.1-2001, \fIaccess\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/exec.1p b/man1p/exec.1p new file mode 100644 index 000000000..69f732928 --- /dev/null +++ b/man1p/exec.1p @@ -0,0 +1,157 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "EXEC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" exec +.SH NAME +exec \- execute commands and open, close, or copy file descriptors +.SH SYNOPSIS +.LP +\fBexec\fP \fB[\fP\fIcommand\fP \fB[\fP\fIargument\fP \fB...\fP\fB]]\fP +.SH DESCRIPTION +.LP +The \fIexec\fP utility shall open, close, and/or copy file descriptors +as specified by any redirections as part of the +command. +.LP +If \fIexec\fP is specified without \fIcommand\fP or \fIargument\fPs, +and any file descriptors with numbers greater than 2 are +opened with associated redirection statements, it is unspecified whether +those file descriptors remain open when the shell invokes +another utility. Scripts concerned that child shells could misuse +open file descriptors can always close them explicitly, as shown +in one of the following examples. +.LP +If \fIexec\fP is specified with \fIcommand\fP, it shall replace the +shell with \fIcommand\fP without creating a new process. +If \fIargument\fPs are specified, they shall be arguments to \fIcommand\fP. +Redirection affects the current shell execution +environment. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If \fIcommand\fP is specified, \fIexec\fP shall not return to the +shell; rather, the exit status of the process shall be the +exit status of the program implementing \fIcommand\fP, which overlaid +the shell. If \fIcommand\fP is not found, the exit status +shall be 127. If \fIcommand\fP is found, but it is not an executable +utility, the exit status shall be 126. If a redirection error +occurs (see \fIConsequences of Shell Errors\fP ), the shell shall +exit with a value in +the range 1-125. Otherwise, \fIexec\fP shall return a zero exit status. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +Open \fIreadfile\fP as file descriptor 3 for reading: +.sp +.RS +.nf + +\fBexec 3< readfile +\fP +.fi +.RE +.LP +Open \fIwritefile\fP as file descriptor 4 for writing: +.sp +.RS +.nf + +\fBexec 4> writefile +\fP +.fi +.RE +.LP +Make file descriptor 5 a copy of file descriptor 0: +.sp +.RS +.nf + +\fBexec 5<&0 +\fP +.fi +.RE +.LP +Close file descriptor 3: +.sp +.RS +.nf + +\fBexec 3<&- +\fP +.fi +.RE +.LP +Cat the file \fBmaggie\fP by replacing the current shell with the +\fIcat\fP utility: +.sp +.RS +.nf + +\fBexec cat maggie +\fP +.fi +.RE +.SH RATIONALE +.LP +Most historical implementations were not conformant in that: +.sp +.RS +.nf + +\fBfoo=bar exec cmd +\fP +.fi +.RE +.LP +did not pass \fBfoo\fP to \fBcmd\fP. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/exit.1p b/man1p/exit.1p new file mode 100644 index 000000000..19924ae45 --- /dev/null +++ b/man1p/exit.1p @@ -0,0 +1,118 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "EXIT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" exit +.SH NAME +exit \- cause the shell to exit +.SH SYNOPSIS +.LP +\fBexit\fP \fB[\fP\fIn\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIexit\fP utility shall cause the shell to exit with the exit +status specified by the unsigned decimal integer \fIn\fP. +If \fIn\fP is specified, but its value is not between 0 and 255 inclusively, +the exit status is undefined. +.LP +A \fItrap\fP on \fBEXIT\fP shall be executed before the shell terminates, +except when the +\fIexit\fP utility is invoked in that \fItrap\fP itself, in which +case the shell shall exit +immediately. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The exit status shall be \fIn\fP, if specified. Otherwise, the value +shall be the exit value of the last command executed, or +zero if no command was executed. When \fIexit\fP is executed in a +\fItrap\fP action, the +last command is considered to be the command that executed immediately +preceding the \fItrap\fP action. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +Exit with a \fItrue\fP value: +.sp +.RS +.nf + +\fBexit 0 +\fP +.fi +.RE +.LP +Exit with a \fIfalse\fP value: +.sp +.RS +.nf + +\fBexit 1 +\fP +.fi +.RE +.SH RATIONALE +.LP +As explained in other sections, certain exit status values have been +reserved for special uses and should be used by +applications only for those purposes: +.TP 7 +\ 126 +A file to be executed was found, but it was not an executable utility. +.TP 7 +\ 127 +A utility to be executed was not found. +.TP 7 +>128 +A command was interrupted by a signal. +.sp +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/expand.1p b/man1p/expand.1p new file mode 100644 index 000000000..673cc26ff --- /dev/null +++ b/man1p/expand.1p @@ -0,0 +1,161 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "EXPAND" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" expand +.SH NAME +expand \- convert tabs to spaces +.SH SYNOPSIS +.LP +\fBexpand\fP \fB[\fP\fB-t\fP \fItablist\fP\fB][\fP\fIfile\fP \fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIexpand\fP utility shall write files or the standard input to +the standard output with <tab>s replaced with one or +more <space>s needed to pad to the next tab stop. Any <backspace>s +shall be copied to the output and cause the column +position count for tab stop calculations to be decremented; the column +position count shall not be decremented below zero. +.SH OPTIONS +.LP +The \fIexpand\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-t\ \fP \fItablist\fP +Specify the tab stops. The application shall ensure that the argument +\fItablist\fP consists of either a single positive +decimal integer or a list of tabstops. If a single number is given, +tabs shall be set that number of column positions apart instead +of the default 8. +.LP +If a list of tabstops is given, the application shall ensure that +it consists of a list of two or more positive decimal +integers, separated by <blank>s or commas, in ascending order. The +tabs shall be set at those specific column positions. Each +tab stop \fIN\fP shall be an integer value greater than zero, and +the list is in strictly ascending order. This is taken to mean +that, from the start of a line of output, tabbing to position \fIN\fP +shall cause the next character output to be in the ( +\fIN\fP+1)th column position on that line. +.LP +In the event of \fIexpand\fP having to process a <tab> at a position +beyond the last of those specified in a multiple +tab-stop list, the <tab> shall be replaced by a single <space> in +the output. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +The pathname of a text file to be used as input. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +Input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIexpand\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +processing of <tab>s and <space>s, and for the +determination of the width in column positions each character would +occupy on an output device. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be equivalent to the input files with <tab>s +converted into the appropriate number of +<space>s. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The \fIexpand\fP utility shall terminate with an error message and +non-zero exit status upon encountering difficulties +accessing one of the \fIfile\fP operands. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIexpand\fP utility is useful for preprocessing text files (before +sorting, looking at specific columns, and so on) that +contain <tab>s. +.LP +See the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section +3.103, Column Position. +.LP +The \fItablist\fP option-argument consists of integers in ascending +order. Utility Syntax Guideline 8 mandates that +\fIexpand\fP shall accept the integers (within the single argument) +separated using either commas or <blank>s. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fItabs\fP , \fIunexpand\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/export.1p b/man1p/export.1p new file mode 100644 index 000000000..74a248b6c --- /dev/null +++ b/man1p/export.1p @@ -0,0 +1,160 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "EXPORT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" export +.SH NAME +export \- set the export attribute for variables +.SH SYNOPSIS +.LP +\fBexport name\fP\fB[\fP\fB=\fP\fIword\fP\fB]\fP\fB... +.br +.sp +export -p +.br +\fP +.SH DESCRIPTION +.LP +The shell shall give the \fIexport\fP attribute to the variables corresponding +to the specified \fIname\fPs, which shall cause +them to be in the environment of subsequently executed commands. If +the name of a variable is followed by = \fIword\fP, then the +value of that variable shall be set to \fIword\fP. +.LP +The \fIexport\fP special built-in shall support the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +When \fB-p\fP is specified, \fIexport\fP shall write to the standard +output the names and values of all exported variables, in +the following format: +.sp +.RS +.nf + +\fB"export %s=%s\\n", <\fP\fIname\fP\fB>, <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +if \fIname\fP is set, and: +.sp +.RS +.nf + +\fB"export %s\\n", <\fP\fIname\fP\fB> +\fP +.fi +.RE +.LP +if \fIname\fP is unset. +.LP +The shell shall format the output, including the proper use of quoting, +so that it is suitable for reinput to the shell as +commands that achieve the same exporting results, except: +.IP " 1." 4 +Read-only variables with values cannot be reset. +.LP +.IP " 2." 4 +Variables that were unset at the time they were output need not be +reset to the unset state if a value is assigned to the +variable between the time the state was saved and the time at which +the saved output is reinput to the shell. +.LP +.LP +When no arguments are given, the results are unspecified. +.SH OPTIONS +.LP +See the DESCRIPTION. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the DESCRIPTION. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +Zero. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +Export \fIPWD\fP and \fIHOME\fP variables: +.sp +.RS +.nf + +\fBexport PWD HOME +\fP +.fi +.RE +.LP +Set and export the \fIPATH\fP variable: +.sp +.RS +.nf + +\fBexport PATH=/local/bin:$PATH +\fP +.fi +.RE +.LP +Save and restore all exported variables: +.sp +.RS +.nf + +\fBexport -p >\fP \fItemp-file\fP\fBunset\fP \fIa lot of variables\fP\fB...\fP \fIprocessing\fP\fB.\fP \fItemp-file\fP +.fi +.RE +.SH RATIONALE +.LP +Some historical shells use the no-argument case as the functional +equivalent of what is required here with \fB-p\fP. This +feature was left unspecified because it is not historical practice +in all shells, and some scripts may rely on the now-unspecified +results on their implementations. Attempts to specify the \fB-p\fP +output as the default case were unsuccessful in achieving +consensus. The \fB-p\fP option was added to allow portable access +to the values that can be saved and then later restored using; +for example, a \fIdot\fP script. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/expr.1p b/man1p/expr.1p new file mode 100644 index 000000000..2e16fde1c --- /dev/null +++ b/man1p/expr.1p @@ -0,0 +1,411 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "EXPR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" expr +.SH NAME +expr \- evaluate arguments as an expression +.SH SYNOPSIS +.LP +\fBexpr\fP \fIoperand\fP +.SH DESCRIPTION +.LP +The \fIexpr\fP utility shall evaluate an expression and write the +result to standard output. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The single expression evaluated by \fIexpr\fP shall be formed from +the operands, as described in the EXTENDED DESCRIPTION +section. The application shall ensure that each of the expression +operator symbols: +.sp +.RS +.nf + +\fB( ) | & = > >= < <= != + - * / % : +\fP +.fi +.RE +.LP +and the symbols \fIinteger\fP and \fIstring\fP in the table are provided +as separate arguments to \fIexpr\fP. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIexpr\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions and by the string comparison operators. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments) and the behavior of +character classes within regular expressions. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIexpr\fP utility shall evaluate the expression and write the +result, followed by a <newline>, to standard +output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The formation of the expression to be evaluated is shown in the following +table. The symbols \fIexpr\fP, \fIexpr1\fP, and +\fIexpr2\fP represent expressions formed from \fIinteger\fP and \fIstring\fP +symbols and the expression operator symbols (all +separate arguments) by recursive application of the constructs described +in the table. The expressions are listed in order of +increasing precedence, with equal-precedence operators grouped between +horizontal lines. All of the operators shall be +left-associative. +.TS C +center; l lw(40). +\fBExpression\fP T{ +.na +\fBDescription\fP +.ad +T} +\fIexpr1\fP\ |\ \fIexpr2\fP T{ +.na +Returns the evaluation of \fIexpr1\fP if it is neither null nor zero; otherwise, returns the evaluation of \fIexpr2\fP if it is not null; otherwise, zero. +.ad +T} +\fIexpr1\fP\ &\ \fIexpr2\fP T{ +.na +Returns the evaluation of \fIexpr1\fP if neither expression evaluates to null or zero; otherwise, returns zero. +.ad +T} +\ T{ +.na +Returns the result of a decimal integer comparison if both arguments are integers; otherwise, returns the result of a string comparison using the locale-specific collation sequence. The result of each comparison is 1 if the specified relationship is true, or 0 if the relationship is false. +.ad +T} +\fIexpr1\fP\ =\ \fIexpr2\fP T{ +.na +Equal. +.ad +T} +\fIexpr1\fP\ >\ \fIexpr2\fP T{ +.na +Greater than. +.ad +T} +\fIexpr1\fP\ >=\ \fIexpr2\fP T{ +.na +Greater than or equal. +.ad +T} +\fIexpr1\fP\ <\ \fIexpr2\fP T{ +.na +Less than. +.ad +T} +\fIexpr1\fP\ <=\ \fIexpr2\fP T{ +.na +Less than or equal. +.ad +T} +\fIexpr1\fP\ !=\ \fIexpr2\fP T{ +.na +Not equal. +.ad +T} +\fIexpr1\fP\ +\ \fIexpr2\fP T{ +.na +Addition of decimal integer-valued arguments. +.ad +T} +\fIexpr1\fP\ -\ \fIexpr2\fP T{ +.na +Subtraction of decimal integer-valued arguments. +.ad +T} +\fIexpr1\fP\ *\ \fIexpr2\fP T{ +.na +Multiplication of decimal integer-valued arguments. +.ad +T} +\fIexpr1\fP\ /\ \fIexpr2\fP T{ +.na +Integer division of decimal integer-valued arguments, producing an integer result. +.ad +T} +\fIexpr1\fP\ %\ \fIexpr2\fP T{ +.na +Remainder of integer division of decimal integer-valued arguments. +.ad +T} +\fIexpr1\fP\ :\ \fIexpr2\fP T{ +.na +Matching expression; see below. +.ad +T} +(\ \fIexpr\fP\ ) T{ +.na +Grouping symbols. Any expression can be placed within parentheses. Parentheses can be nested to a depth of {EXPR_NEST_MAX}. +.ad +T} +\fIinteger\fP T{ +.na +An argument consisting only of an (optional) unary minus followed by digits. +.ad +T} +\fIstring\fP T{ +.na +A string argument; see below. +.ad +T} +.TE +.SS Matching Expression +.LP +The \fB':'\fP matching operator shall compare the string resulting +from the evaluation of \fIexpr1\fP with the regular +expression pattern resulting from the evaluation of \fIexpr2\fP. Regular +expression syntax shall be that defined in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 9.3, Basic Regular +Expressions, except that all patterns are anchored to the beginning +of the string (that is, only sequences starting at the +first character of a string are matched by the regular expression) +and, therefore, it is unspecified whether \fB'^'\fP is a +special character in that context. Usually, the matching operator +shall return a string representing the number of characters +matched ( \fB'0'\fP on failure). Alternatively, if the pattern contains +at least one regular expression subexpression +\fB"[\\(...\\)]"\fP , the string corresponding to \fB"\\1"\fP shall +be returned. +.SS String Operand +.LP +A string argument is an argument that cannot be identified as an \fIinteger\fP +argument or as one of the expression operator +symbols shown in the OPERANDS section. +.LP +The use of string arguments \fBlength\fP, \fBsubstr\fP, \fBindex\fP, +or \fBmatch\fP produces unspecified results. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The \fIexpression\fP evaluates to neither null nor zero. +.TP 7 +\ 1 +The \fIexpression\fP evaluates to null or zero. +.TP 7 +\ 2 +Invalid \fIexpression\fP. +.TP 7 +>2 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +After argument processing by the shell, \fIexpr\fP is not required +to be able to tell the difference between an operator and an +operand except by the value. If \fB"$a"\fP is \fB'='\fP , the command: +.sp +.RS +.nf + +\fBexpr $a = '=' +\fP +.fi +.RE +.LP +looks like: +.sp +.RS +.nf + +\fBexpr = = = +\fP +.fi +.RE +.LP +as the arguments are passed to \fIexpr\fP (and they all may be taken +as the \fB'='\fP operator). The following works +reliably: +.sp +.RS +.nf + +\fBexpr X$a = X= +\fP +.fi +.RE +.LP +Also note that this volume of IEEE\ Std\ 1003.1-2001 permits implementations +to extend utilities. The \fIexpr\fP +utility permits the integer arguments to be preceded with a unary +minus. This means that an integer argument could look like an +option. Therefore, the conforming application must employ the \fB"--"\fP +construct of Guideline 10 of the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax +Guidelines to protect its operands if there is any chance the first +operand might be a negative integer (or any string with a +leading minus). +.SH EXAMPLES +.LP +The \fIexpr\fP utility has a rather difficult syntax: +.IP " *" 3 +Many of the operators are also shell control operators or reserved +words, so they have to be escaped on the command line. +.LP +.IP " *" 3 +Each part of the expression is composed of separate arguments, so +liberal usage of <blank>s is required. For example: +.TS C +center; l l. +\fBInvalid\fP \fBValid\fP +\fIexpr\fP 1+2 \fIexpr\fP 1 + 2 +\fIexpr\fP "1 + 2" \fIexpr\fP 1 + 2 +\fIexpr\fP 1 + (2 * 3) \fIexpr\fP 1 + \\( 2 \\* 3 \\) +.TE +.LP +.LP +In many cases, the arithmetic and string features provided as part +of the shell command language are easier to use than their +equivalents in \fIexpr\fP. Newly written scripts should avoid \fIexpr\fP +in favor of the new features within the shell; see \fIParameters and +Variables\fP and \fIArithmetic +Expansion\fP . +.LP +The following command: +.sp +.RS +.nf + +\fBa=$(expr $a + 1) +\fP +.fi +.RE +.LP +adds 1 to the variable \fIa\fP. +.LP +The following command, for \fB"$a"\fP equal to either \fB/usr/abc/file\fP +or just \fBfile\fP: +.sp +.RS +.nf + +\fBexpr $a : '.*/\\(.*\\)' \\| $a +\fP +.fi +.RE +.LP +returns the last segment of a pathname (that is, \fBfile\fP). Applications +should avoid the character \fB'/'\fP used alone +as an argument; \fIexpr\fP may interpret it as the division operator. +.LP +The following command: +.sp +.RS +.nf + +\fBexpr "//$a" : '.*/\\(.*\\)' +\fP +.fi +.RE +.LP +is a better representation of the previous example. The addition of +the \fB"//"\fP characters eliminates any ambiguity about +the division operator and simplifies the whole expression. Also note +that pathnames may contain characters contained in the +\fIIFS\fP variable and should be quoted to avoid having \fB"$a"\fP +expand into multiple arguments. +.LP +The following command: +.sp +.RS +.nf + +\fBexpr "$VAR" : '.*' +\fP +.fi +.RE +.LP +returns the number of characters in \fIVAR\fP. +.SH RATIONALE +.LP +In an early proposal, EREs were used in the matching expression syntax. +This was changed to BREs to avoid breaking historical +applications. +.LP +The use of a leading circumflex in the BRE is unspecified because +many historical implementations have treated it as a special +character, despite their system documentation. For example: +.sp +.RS +.nf + +\fBexpr foo : ^foo expr ^foo : ^foo +\fP +.fi +.RE +.LP +return 3 and 0, respectively, on those systems; their documentation +would imply the reverse. Thus, the anchoring condition is +left unspecified to avoid breaking historical scripts relying on this +undocumented feature. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIParameters and Variables\fP , \fIArithmetic +Expansion\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/false.1p b/man1p/false.1p new file mode 100644 index 000000000..e4db60194 --- /dev/null +++ b/man1p/false.1p @@ -0,0 +1,75 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FALSE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" false +.SH NAME +false \- return false value +.SH SYNOPSIS +.LP +\fBfalse\fP +.SH DESCRIPTION +.LP +The \fIfalse\fP utility shall return with a non-zero exit code. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +Not used. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The \fIfalse\fP utility shall always exit with a value other than +zero. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fItrue\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/fc.1p b/man1p/fc.1p new file mode 100644 index 000000000..fdd8ccadb --- /dev/null +++ b/man1p/fc.1p @@ -0,0 +1,476 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" fc +.SH NAME +fc \- process the command history list +.SH SYNOPSIS +.LP +\fBfc\fP \fB[\fP\fB-r\fP\fB][\fP\fB-e\fP \fIeditor\fP\fB] +[\fP\fIfirst\fP\fB[\fP\fIlast\fP\fB]]\fP\fB +.br +.sp +fc -l\fP\fB[\fP\fB-nr\fP\fB] [\fP\fIfirst\fP\fB[\fP\fIlast\fP\fB]]\fP\fB +.br +.sp +fc -s\fP\fB[\fP\fIold\fP\fB=\fP\fInew\fP\fB][\fP\fIfirst\fP\fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIfc\fP utility shall list, or shall edit and re-execute, commands +previously entered to an interactive \fIsh\fP. +.LP +The command history list shall reference commands by number. The first +number in the list is selected arbitrarily. The +relationship of a number to its command shall not change except when +the user logs in and no other process is accessing the list, +at which time the system may reset the numbering to start the oldest +retained command at another number (usually 1). When the +number reaches an implementation-defined upper limit, which shall +be no smaller than the value in \fIHISTSIZE\fP or 32767 +(whichever is greater), the shell may wrap the numbers, starting the +next command with a lower number (usually 1). However, despite +this optional wrapping of numbers, \fIfc\fP shall maintain the time-ordering +sequence of the commands. For example, if four +commands in sequence are given the numbers 32766, 32767, 1 (wrapped), +and 2 as they are executed, command 32767 is considered the +command previous to 1, even though its number is higher. +.LP +When commands are edited (when the \fB-l\fP option is not specified), +the resulting lines shall be entered at the end of the +history list and then re-executed by \fIsh\fP. The \fIfc\fP command +that caused the editing +shall not be entered into the history list. If the editor returns +a non-zero exit status, this shall suppress the entry into the +history list and the command re-execution. Any command line variable +assignments or redirection operators used with \fIfc\fP shall +affect both the \fIfc\fP command itself as well as the command that +results; for example: +.sp +.RS +.nf + +\fBfc -s -- -1 2>/dev/null +\fP +.fi +.RE +.LP +reinvokes the previous command, suppressing standard error for both +\fIfc\fP and the previous command. +.SH OPTIONS +.LP +The \fIfc\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-e\ \fP \fIeditor\fP +Use the editor named by \fIeditor\fP to edit the commands. The \fIeditor\fP +string is a utility name, subject to search via +the \fIPATH\fP variable (see the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 8, Environment Variables). The value in the \fIFCEDIT\fP variable +shall be used as a +default when \fB-e\fP is not specified. If \fIFCEDIT\fP is null or +unset, \fIed\fP shall be +used as the editor. +.TP 7 +\fB-l\fP +(The letter ell.) List the commands rather than invoking an editor +on them. The commands shall be written in the sequence +indicated by the \fIfirst\fP and \fIlast\fP operands, as affected +by \fB-r\fP, with each command preceded by the command +number. +.TP 7 +\fB-n\fP +Suppress command numbers when listing with \fB-l\fP. +.TP 7 +\fB-r\fP +Reverse the order of the commands listed (with \fB-l\fP) or edited +(with neither \fB-l\fP nor \fB-s\fP). +.TP 7 +\fB-s\fP +Re-execute the command without invoking an editor. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfirst\fP,\ \fIlast\fP +Select the commands to list or edit. The number of previous commands +that can be accessed shall be determined by the value of +the \fIHISTSIZE\fP variable. The value of \fIfirst\fP or \fIlast\fP +or both shall be one of the following: +.TP 7 +\fB[+]\fP\fInumber\fP +.RS +A positive number representing a command number; command numbers can +be displayed with the \fB-l\fP option. +.RE +.TP 7 +\fB-\fP\fInumber\fP +.RS +A negative decimal number representing the command that was executed +\fInumber\fP of commands previously. For example, -1 is +the immediately previous command. +.RE +.TP 7 +\fIstring\fP +.RS +A string indicating the most recently entered command that begins +with that string. If the \fIold\fP= \fInew\fP operand is +not also specified with \fB-s\fP, the string form of the \fIfirst\fP +operand cannot contain an embedded equal sign. +.RE +.sp +.LP +When the synopsis form with \fB-s\fP is used: +.RS +.IP " *" 3 +If \fIfirst\fP is omitted, the previous command shall be used. +.LP +.RE +.LP +For the synopsis forms without \fB-s\fP: +.RS +.IP " *" 3 +If \fIlast\fP is omitted, \fIlast\fP shall default to the previous +command when \fB-l\fP is specified; otherwise, it shall +default to \fIfirst\fP. +.LP +.IP " *" 3 +If \fIfirst\fP and \fIlast\fP are both omitted, the previous 16 commands +shall be listed or the previous single command shall +be edited (based on the \fB-l\fP option). +.LP +.IP " *" 3 +If \fIfirst\fP and \fIlast\fP are both present, all of the commands +from \fIfirst\fP to \fIlast\fP shall be edited (without +\fB-l\fP) or listed (with \fB-l\fP). Editing multiple commands shall +be accomplished by presenting to the editor all of the +commands at one time, each command starting on a new line. If \fIfirst\fP +represents a newer command than \fIlast\fP, the +commands shall be listed or edited in reverse sequence, equivalent +to using \fB-r\fP. For example, the following commands on the +first line are equivalent to the corresponding commands on the second: +.sp +.RS +.nf + +\fBfc -r 10 20 fc 30 40 +fc 20 10 fc -r 40 30 +\fP +.fi +.RE +.LP +.IP " *" 3 +When a range of commands is used, it shall not be an error to specify +\fIfirst\fP or \fIlast\fP values that are not in the +history list; \fIfc\fP shall substitute the value representing the +oldest or newest command in the list, as appropriate. For +example, if there are only ten commands in the history list, numbered +1 to 10: +.sp +.RS +.nf + +\fBfc -l +fc 1 99 +\fP +.fi +.RE +.LP +shall list and edit, respectively, all ten commands. +.LP +.RE +.TP 7 +\fIold\fP=\fInew\fP +Replace the first occurrence of string \fIold\fP in the commands to +be re-executed by the string \fInew\fP. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIfc\fP: +.TP 7 +\fIFCEDIT\fP +This variable, when expanded by the shell, shall determine the default +value for the \fB-e\fP \fIeditor\fP option's +\fIeditor\fP option-argument. If \fIFCEDIT\fP is null or unset, \fIed\fP +shall be used as the +editor. +.TP 7 +\fIHISTFILE\fP +Determine a pathname naming a command history file. If the \fIHISTFILE\fP +variable is not set, the shell may attempt to access +or create a file \fB.sh_history\fP in the directory referred to by +the \fIHOME\fP environment variable. If the shell cannot +obtain both read and write access to, or create, the history file, +it shall use an unspecified mechanism that allows the history to +operate properly. (References to history "file" in this section shall +be understood to mean this unspecified mechanism in such +cases.) An implementation may choose to access this variable only +when initializing the history file; this initialization shall +occur when \fIfc\fP or \fIsh\fP first attempt to retrieve entries +from, or add entries to, the +file, as the result of commands issued by the user, the file named +by the \fIENV\fP variable, or implementation-defined system +start-up files. In some historical shells, the history file is initialized +just after the \fIENV\fP file has been processed. +Therefore, it is implementation-defined whether changes made to \fIHISTFILE\fP +after the history file has been initialized are +effective. Implementations may choose to disable the history list +mechanism for users with appropriate privileges who do not set +\fIHISTFILE ;\fP the specific circumstances under which this occurs +are implementation-defined. If more than one instance of the +shell is using the same history file, it is unspecified how updates +to the history file from those shells interact. As entries are +deleted from the history file, they shall be deleted oldest first. +It is unspecified when history file entries are physically +removed from the history file. +.TP 7 +\fIHISTSIZE\fP +Determine a decimal number representing the limit to the number of +previous commands that are accessible. If this variable is +unset, an unspecified default greater than or equal to 128 shall be +used. The maximum number of commands in the history list is +unspecified, but shall be at least 128. An implementation may choose +to access this variable only when initializing the history +file, as described under \fIHISTFILE .\fP Therefore, it is unspecified +whether changes made to \fIHISTSIZE\fP after the history +file has been initialized are effective. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When the \fB-l\fP option is used to list commands, the format of each +command in the list shall be as follows: +.sp +.RS +.nf + +\fB"%d\\t%s\\n", <\fP\fIline number\fP\fB>, <\fP\fIcommand\fP\fB> +\fP +.fi +.RE +.LP +If both the \fB-l\fP and \fB-n\fP options are specified, the format +of each command shall be: +.sp +.RS +.nf + +\fB"\\t%s\\n", <\fP\fIcommand\fP\fB> +\fP +.fi +.RE +.LP +If the <\fIcommand\fP> consists of more than one line, the lines after +the first shall be displayed as: +.sp +.RS +.nf + +\fB"\\t%s\\n", <\fP\fIcontinued-command\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion of the listing. +.TP 7 +>0 +An error occurred. +.sp +.LP +Otherwise, the exit status shall be that of the commands executed +by \fIfc\fP. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since editors sometimes use file descriptors as integral parts of +their editing, redirecting their file descriptors as part of +the \fIfc\fP command can produce unexpected results. For example, +if \fIvi\fP is the +\fIFCEDIT\fP editor, the command: +.sp +.RS +.nf + +\fBfc -s | more +\fP +.fi +.RE +.LP +does not work correctly on many systems. +.LP +Users on windowing systems may want to have separate history files +for each window by setting \fIHISTFILE\fP as follows: +.sp +.RS +.nf + +\fBHISTFILE=$HOME/.sh_hist$$ +\fP +.fi +.RE +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +This utility is based on the \fIfc\fP built-in of the KornShell. +.LP +An early proposal specified the \fB-e\fP option as \fB[-e\fP \fIeditor\fP +\fB[\fP \fIold\fP = \fInew\fP \fB]]\fP, which +is not historical practice. Historical practice in \fIfc\fP of either +\fB[-e\fP \fIeditor\fP \fB]\fP or \fB[-e - [\fP +\fIold\fP = \fInew\fP \fB]]\fP is acceptable, but not both together. +To clarify this, a new option \fB-s\fP was introduced +replacing the \fB[-e -]\fP. This resolves the conflict and makes \fIfc\fP +conform to the Utility Syntax Guidelines. +.TP 7 +\fIHISTFILE\fP +Some implementations of the KornShell check for the superuser and +do not create a history file unless \fIHISTFILE\fP is set. +This is done primarily to avoid creating unlinked files in the root +file system when logging in during single-user mode. +\fIHISTFILE\fP must be set for the superuser to have history. +.TP 7 +\fIHISTSIZE\fP +Needed to limit the size of history files. It is the intent of the +standard developers that when two shells share the same +history file, commands that are entered in one shell shall be accessible +by the other shell. Because of the difficulties of +synchronization over a network, the exact nature of the interaction +is unspecified. +.sp +.LP +The initialization process for the history file can be dependent on +the system start-up files, in that they may contain commands +that effectively preempt the settings the user has for \fIHISTFILE\fP +and \fIHISTSIZE .\fP For example, function definition +commands are recorded in the history file. If the system administrator +includes function definitions in some system start-up file +called before the \fIENV\fP file, the history file is initialized +before the user can influence its characteristics. In some +historical shells, the history file is initialized just after the +\fIENV\fP file has been processed. Because of these situations, +the text requires the initialization process to be implementation-defined. +.LP +Consideration was given to omitting the \fIfc\fP utility in favor +of the command line editing feature in \fIsh\fP. For example, in \fIvi\fP +editing mode, typing +\fB"<ESC> v"\fP is equivalent to: +.sp +.RS +.nf + +\fBEDITOR=vi fc +\fP +.fi +.RE +.LP +However, the \fIfc\fP utility allows the user the flexibility to edit +multiple commands simultaneously (such as \fIfc\fP 10 +20) and to use editors other than those supported by \fIsh\fP for +command line editing. +.LP +In the KornShell, the alias \fBr\fP (``re-do") is preset to \fIfc\fP +\fB-e -\fP (equivalent to the POSIX \fIfc\fP +\fB-s\fP). This is probably an easier command name to remember than +\fIfc\fP (``fix command"), but it does not meet the Utility +Syntax Guidelines. Renaming \fIfc\fP to \fIhist\fP or \fIredo\fP was +considered, but since this description closely matches +historical KornShell practice already, such a renaming was seen as +gratuitous. Users are free to create aliases whenever odd +historical names such as \fIfc\fP, \fIawk\fP, \fIcat\fP, +\fIgrep\fP, or \fIyacc\fP are standardized by +POSIX. +.LP +Command numbers have no ordering effects; they are like serial numbers. +The \fB-r\fP option and -\fInumber\fP operand address +the sequence of command execution, regardless of serial numbers. So, +for example, if the command number wrapped back to 1 at some +arbitrary point, there would be no ambiguity associated with traversing +the wrap point. For example, if the command history +were: +.sp +.RS +.nf + +\fB32766: echo 1 +32767: echo 2 +1: echo 3 +\fP +.fi +.RE +.LP +the number -2 refers to command 32767 because it is the second previous +command, regardless of serial number. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIsh\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/fg.1p b/man1p/fg.1p new file mode 100644 index 000000000..19100195f --- /dev/null +++ b/man1p/fg.1p @@ -0,0 +1,152 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FG" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" fg +.SH NAME +fg \- run jobs in the foreground +.SH SYNOPSIS +.LP +\fBfg\fP \fB[\fP\fIjob_id\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +If job control is enabled (see the description of \fIset\fP \fB-m\fP), +the +\fIfg\fP utility shall move a background job from the current environment +(see \fIShell +Execution Environment\fP ) into the foreground. +.LP +Using \fIfg\fP to place a job into the foreground shall remove its +process ID from the list of those "known in the current +shell execution environment''; see \fIAsynchronous Lists\fP . +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIjob_id\fP +Specify the job to be run as a foreground job. If no \fIjob_id\fP +operand is given, the \fIjob_id\fP for the job that was +most recently suspended, placed in the background, or run as a background +job shall be used. The format of \fIjob_id\fP is +described in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 3.203, Job Control Job ID. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIfg\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIfg\fP utility shall write the command line of the job to standard +output in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIcommand\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If job control is disabled, the \fIfg\fP utility shall exit with an +error and no job shall be placed in the foreground. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIfg\fP utility does not work as expected when it is operating +in its own utility execution environment because that +environment has no applicable jobs to manipulate. See the APPLICATION +USAGE section for \fIbg\fP . For this +reason, \fIfg\fP is generally implemented as a shell regular built-in. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The extensions to the shell specified in this volume of IEEE\ Std\ 1003.1-2001 +have mostly been based on features +provided by the KornShell. The job control features provided by \fIbg\fP, +\fIfg\fP, and \fIjobs\fP are also based on the KornShell. The standard +developers examined the characteristics +of the C shell versions of these utilities and found that differences +exist. Despite widespread use of the C shell, the KornShell +versions were selected for this volume of IEEE\ Std\ 1003.1-2001 to +maintain a degree of uniformity with the rest of the +KornShell features selected (such as the very popular command line +editing features). +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIAsynchronous Lists\fP , \fIShell Execution +Environment\fP , \fIbg\fP , \fIkill\fP() , \fIjobs\fP +, \fIwait\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/file.1p b/man1p/file.1p new file mode 100644 index 000000000..4a33fab19 --- /dev/null +++ b/man1p/file.1p @@ -0,0 +1,786 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FILE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" file +.SH NAME +file \- determine file type +.SH SYNOPSIS +.LP +\fBfile\fP \fB[\fP\fB-dh\fP\fB][\fP\fB-M\fP \fIfile\fP\fB][\fP\fB-m\fP +\fIfile\fP\fB]\fP +\fIfile\fP \fB... +.br +.sp +file -i\fP \fB[\fP\fB-h\fP\fB]\fP \fIfile\fP \fB... \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIfile\fP utility shall perform a series of tests in sequence +on each specified \fIfile\fP in an attempt to classify +it: +.IP " 1." 4 +If \fIfile\fP does not exist, cannot be read, or its file status could +not be determined, the output shall indicate that the +file was processed, but that its type could not be determined. +.LP +.IP " 2." 4 +If the file is not a regular file, its file type shall be identified. +The file types directory, FIFO, socket, block special, and +character special shall be identified as such. Other implementation-defined +file types may also be identified. If \fIfile\fP is a +symbolic link, by default the link shall be resolved and \fIfile\fP +shall test the type of file referenced by the symbolic link. +(See the \fB-h\fP and \fB-i\fP options below.) +.LP +.IP " 3." 4 +If the length of \fIfile\fP is zero, it shall be identified as an +empty file. +.LP +.IP " 4." 4 +The \fIfile\fP utility shall examine an initial segment of \fIfile\fP +and shall make a guess at identifying its contents based +on position-sensitive tests. (The answer is not guaranteed to be correct; +see the \fB-d\fP, \fB-M\fP, and \fB-m\fP options +below.) +.LP +.IP " 5." 4 +The \fIfile\fP utility shall examine \fIfile\fP and make a guess at +identifying its contents based on context-sensitive +default system tests. (The answer is not guaranteed to be correct.) +.LP +.IP " 6." 4 +The file shall be identified as a data file. +.LP +.LP +If \fIfile\fP does not exist, cannot be read, or its file status could +not be determined, the output shall indicate that the +file was processed, but that its type could not be determined. +.LP +If \fIfile\fP is a symbolic link, by default the link shall be resolved +and \fIfile\fP shall test the type of file referenced +by the symbolic link. +.SH OPTIONS +.LP +The \fIfile\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the order of the \fB-m\fP, +\fB-d\fP, and \fB-M\fP options shall be significant. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-d\fP +Apply any position-sensitive default system tests and context-sensitive +default system tests to the file. This is the default +if no \fB-M\fP or \fB-m\fP option is specified. +.TP 7 +\fB-h\fP +When a symbolic link is encountered, identify the file as a symbolic +link. If \fB-h\fP is not specified and \fIfile\fP is a +symbolic link that refers to a nonexistent file, \fIfile\fP shall +identify the file as a symbolic link, as if \fB-h\fP had been +specified. +.TP 7 +\fB-i\fP +If a file is a regular file, do not attempt to classify the type of +the file further, but identify the file as specified in the +STDOUT section. +.TP 7 +\fB-M\ \fP \fIfile\fP +Specify the name of a file containing position-sensitive tests that +shall be applied to a file in order to classify it (see the +EXTENDED DESCRIPTION). No position-sensitive default system tests +nor context-sensitive default system tests shall be applied +unless the \fB-d\fP option is also specified. +.TP 7 +\fB-m\ \fP \fIfile\fP +Specify the name of a file containing position-sensitive tests that +shall be applied to a file in order to classify it (see the +EXTENDED DESCRIPTION). +.sp +.LP +If the \fB-m\fP option is specified without specifying the \fB-d\fP +option or the \fB-M\fP option, position-sensitive default +system tests shall be applied after the position-sensitive tests specified +by the \fB-m\fP option. If the \fB-M\fP option is +specified with the \fB-d\fP option, the \fB-m\fP option, or both, +or the \fB-m\fP option is specified with the \fB-d\fP option, +the concatenation of the position-sensitive tests specified by these +options shall be applied in the order specified by the +appearance of these options. If a \fB-M\fP or \fB-m\fP \fIfile\fP +option-argument is \fB-\fP, the results are unspecified. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be tested. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The \fIfile\fP can be any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIfile\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +In the POSIX locale, the following format shall be used to identify +each operand, \fIfile\fP specified: +.sp +.RS +.nf + +\fB"%s: %s\\n", <\fP\fIfile\fP\fB>, <\fP\fItype\fP\fB> +\fP +.fi +.RE +.LP +The values for <\fItype\fP> are unspecified, except that in the POSIX +locale, if \fIfile\fP is identified as one of the +types listed in the following table, <\fItype\fP> shall contain (but +is not limited to) the corresponding string, unless the +file is identified by a position-sensitive test specified by a \fB-M\fP +or \fB-m\fP option. Each space shown in the strings shall +be exactly one <space>. +.br +.sp +.ce 1 +\fBTable: File Utility Output Strings\fP +.TS C +center; lw(40)1 lw(25)1 l. +T{ +.na +\fBIf \fIfile\fP is:\fP +.ad +T} T{ +.na +\fB<\fItype\fP> shall contain the string:\fP +.ad +T} \fBNotes\fP +T{ +.na +Nonexistent +.ad +T} T{ +.na +cannot open +.ad +T} \ +T{ +.na +Block special +.ad +T} T{ +.na +block special +.ad +T} 1 +T{ +.na +Character special +.ad +T} T{ +.na +character special +.ad +T} 1 +T{ +.na +Directory +.ad +T} T{ +.na +directory +.ad +T} 1 +T{ +.na +FIFO +.ad +T} T{ +.na +fifo +.ad +T} 1 +T{ +.na +Socket +.ad +T} T{ +.na +socket +.ad +T} 1 +T{ +.na +Symbolic link +.ad +T} T{ +.na +symbolic link to +.ad +T} 1 +T{ +.na +Regular file +.ad +T} T{ +.na +regular file +.ad +T} 1,2 +T{ +.na +Empty regular file +.ad +T} T{ +.na +empty +.ad +T} 3 +T{ +.na +Regular file that cannot be read +.ad +T} T{ +.na +cannot open +.ad +T} 3 +T{ +.na +Executable binary +.ad +T} T{ +.na +executable +.ad +T} 4,6 +T{ +.na +\fIar\fP archive library (see \fIar\fP) +.ad +T} T{ +.na +archive +.ad +T} 4,6 +T{ +.na +Extended \fIcpio\fP format (see \fIpax\fP) +.ad +T} T{ +.na +cpio archive +.ad +T} 4,6 +T{ +.na +Extended \fItar\fP format (see \fBustar\fP in \fIpax\fP) +.ad +T} T{ +.na +tar archive +.ad +T} 4,6 +T{ +.na +Shell script +.ad +T} T{ +.na +commands text +.ad +T} 5,6 +T{ +.na +C-language source +.ad +T} T{ +.na +c program text +.ad +T} 5,6 +T{ +.na +FORTRAN source +.ad +T} T{ +.na +fortran program text +.ad +T} 5,6 +T{ +.na +Regular file whose type cannot be determined +.ad +T} T{ +.na +data +.ad +T} \ +.TE +.TP 7 +\fBNotes:\fP +.RS +.IP " 1." 4 +This is a file type test. +.LP +.IP " 2." 4 +This test is applied only if the \fB-i\fP option is specified. +.LP +.IP " 3." 4 +This test is applied only if the \fB-i\fP option is not specified. +.LP +.IP " 4." 4 +This is a position-sensitive default system test. +.LP +.IP " 5." 4 +This is a context-sensitive default system test. +.LP +.IP " 6." 4 +Position-sensitive default system tests and context-sensitive default +system tests are not applied if the \fB-M\fP option is +specified unless the \fB-d\fP option is also specified. +.LP +.RE +.sp +.LP +In the POSIX locale, if \fIfile\fP is identified as a symbolic link +(see the \fB-h\fP option), the following alternative +output format shall be used: +.sp +.RS +.nf + +\fB"%s: %s %s\\n", <\fP\fIfile\fP\fB>, <\fP\fItype\fP\fB>, <\fP\fIcontents of link\fP\fB>" +\fP +.fi +.RE +.LP +If the file named by the \fIfile\fP operand does not exist, cannot +be read, or the type of the file named by the \fIfile\fP +operand cannot be determined, this shall not be considered an error +that affects the exit status. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +A file specified as an option-argument to the \fB-m\fP or \fB-M\fP +options shall contain one position-sensitive test per line, +which shall be applied to the file. If the test succeeds, the message +field of the line shall be printed and no further tests shall +be applied, with the exception that tests on immediately following +lines beginning with a single \fB'>'\fP character shall be +applied. +.LP +Each line shall be composed of the following four <blank>-separated +fields: +.TP 7 +\fIoffset\fP +An unsigned number (optionally preceded by a single \fB'>'\fP character) +specifying the \fIoffset\fP, in bytes, of the +value in the file that is to be compared against the \fIvalue\fP field +of the line. If the file is shorter than the specified +offset, the test shall fail. +.LP +If the \fIoffset\fP begins with the character \fB'>'\fP , the test +contained in the line shall not be applied to the file +unless the test on the last line for which the \fIoffset\fP did not +begin with a \fB'>'\fP was successful. By default, the +\fIoffset\fP shall be interpreted as an unsigned decimal number. With +a leading 0x or 0X, the \fIoffset\fP shall be interpreted +as a hexadecimal number; otherwise, with a leading 0, the \fIoffset\fP +shall be interpreted as an octal number. +.TP 7 +\fItype\fP +The type of the value in the file to be tested. The type shall consist +of the type specification characters \fBc\fP , +\fBd\fP , \fBf\fP , \fBs\fP , and \fBu\fP , specifying character, +signed decimal, floating point, string, and unsigned +decimal, respectively. +.LP +The \fItype\fP string shall be interpreted as the bytes from the file +starting at the specified \fIoffset\fP and including the +same number of bytes specified by the \fIvalue\fP field. If insufficient +bytes remain in the file past the \fIoffset\fP to match +the \fIvalue\fP field, the test shall fail. +.LP +The type specification characters \fBd\fP , \fBf\fP , and \fBu\fP +can be followed by an optional unsigned decimal +integer that specifies the number of bytes represented by the type. +The type specification character \fBf\fP can be followed by +an optional \fBF\fP , \fBD\fP , or \fBL\fP , indicating that the value +is of type \fBfloat\fP, \fBdouble\fP, or \fBlong +double\fP, respectively. The type specification characters \fBd\fP +and \fBu\fP can be followed by an optional \fBC\fP , +\fBS\fP , \fBI\fP , or \fBL\fP , indicating that the value is of type +\fBchar\fP, \fBshort\fP, \fBint\fP, or +\fBlong\fP, respectively. +.LP +The default number of bytes represented by the type specifiers \fBd\fP +, \fBf\fP , and \fBu\fP shall correspond to +their respective C-language types as follows. If the system claims +conformance to the C-Language Development Utilities option, +those specifiers shall correspond to the default sizes used in the +\fIc99\fP utility. +Otherwise, the default sizes shall be implementation-defined. +.LP +For the type specifier characters \fBd\fP and \fBu\fP , the default +number of bytes shall correspond to the size of a +basic integer type of the implementation. For these specifier characters, +the implementation shall support values of the optional +number of bytes to be converted corresponding to the number of bytes +in the C-language types \fBchar\fP, \fBshort\fP, \fBint\fP, +or \fBlong\fP. These numbers can also be specified by an application +as the characters \fBC\fP , \fBS\fP , \fBI\fP , and +\fBL\fP , respectively. The byte order used when interpreting numeric +values is implementation-defined, but shall correspond to +the order in which a constant of the corresponding type is stored +in memory on the system. +.LP +For the type specifier \fBf\fP , the default number of bytes shall +correspond to the number of bytes in the basic double +precision floating-point data type of the underlying implementation. +The implementation shall support values of the optional number +of bytes to be converted corresponding to the number of bytes in the +C-language types \fBfloat\fP, \fBdouble\fP, and \fBlong +double\fP. These numbers can also be specified by an application as +the characters \fBF\fP , \fBD\fP , and \fBL\fP , +respectively. +.LP +All type specifiers, except for \fBs\fP , can be followed by a mask +specifier of the form &\fInumber\fP. The mask value +shall be AND'ed with the value of the input file before the comparison +with the \fIvalue\fP field of the line is made. By default, +the mask shall be interpreted as an unsigned decimal number. With +a leading 0x or 0X, the mask shall be interpreted as an unsigned +hexadecimal number; otherwise, with a leading 0, the mask shall be +interpreted as an unsigned octal number. +.LP +The strings \fBbyte\fP, \fBshort\fP, \fBlong\fP, and \fBstring\fP +shall also be supported as type fields, being interpreted +as \fBdC\fP , \fBdS\fP , \fBdL\fP , and \fBs\fP , respectively. +.TP 7 +\fIvalue\fP +The \fIvalue\fP to be compared with the value from the file. +.LP +If the specifier from the type field is \fBs\fP or \fBstring\fP, then +interpret the value as a string. Otherwise, interpret +it as a number. If the value is a string, then the test shall succeed +only when a string value exactly matches the bytes from the +file. +.LP +If the \fIvalue\fP is a string, it can contain the following sequences: +.TP 7 +\\\fIcharacter\fP +.RS +The backslash-escape sequences as specified in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Table 5-1, Escape +Sequences and Associated Actions ( \fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP +, \fB'\\f'\fP , \fB'\\n'\fP , \fB'\\r'\fP , +\fB'\\t'\fP , \fB'\\v'\fP ). The results of using any other character, +other than an octal digit, following the backslash are +unspecified. +.RE +.TP 7 +\\\fIoctal\fP +.RS +Octal sequences that can be used to represent characters with specific +coded values. An octal sequence shall consist of a +backslash followed by the longest sequence of one, two, or three octal-digit +characters (01234567). If the size of a byte on the +system is greater than 9 bits, the valid escape sequence used to represent +a byte is implementation-defined. +.RE +.sp +.LP +By default, any value that is not a string shall be interpreted as +a signed decimal number. Any such value, with a leading 0x or +0X, shall be interpreted as an unsigned hexadecimal number; otherwise, +with a leading zero, the value shall be interpreted as an +unsigned octal number. +.LP +If the value is not a string, it can be preceded by a character indicating +the comparison to be performed. Permissible +characters and the comparisons they specify are as follows: +.TP 7 +\fB=\fP +.RS +The test shall succeed if the value from the file equals the \fIvalue\fP +field. +.RE +.TP 7 +\fB<\fP +.RS +The test shall succeed if the value from the file is less than the +\fIvalue\fP field. +.RE +.TP 7 +\fB>\fP +.RS +The test shall succeed if the value from the file is greater than +the \fIvalue\fP field. +.RE +.TP 7 +\fB&\fP +.RS +The test shall succeed if all of the set bits in the \fIvalue\fP field +are set in the value from the file. +.RE +.TP 7 +\fB^\fP +.RS +The test shall succeed if at least one of the set bits in the \fIvalue\fP +field is not set in the value from the file. +.RE +.TP 7 +\fBx\fP +.RS +The test shall succeed if the file is large enough to contain a value +of the type specified starting at the offset +specified. +.RE +.sp +.TP 7 +\fImessage\fP +The \fImessage\fP to be printed if the test succeeds. The \fImessage\fP +shall be interpreted using the notation for the \fIprintf\fP formatting +specification; see \fIprintf\fP() . If the +\fIvalue\fP field was a string, then the value from the file shall +be the argument for the \fIprintf\fP formatting specification; otherwise, +the value from the file shall be the +argument. +.sp +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIfile\fP utility can only be required to guess at many of the +file types because only exhaustive testing can determine +some types with certainty. For example, binary data on some implementations +might match the initial segment of an executable or a +\fItar\fP archive. +.LP +Note that the table indicates that the output contains the stated +string. Systems may add text before or after the string. For +executables, as an example, the machine architecture and various facts +about how the file was link-edited may be included. Note +also that on systems that recognize shell script files starting with +\fB"#!"\fP as executable files, these may be identified as +executable binary files rather than as shell scripts. +.SH EXAMPLES +.LP +Determine whether an argument is a binary executable file: +.sp +.RS +.nf + +\fBfile "$1" | grep -Fq executable && + printf "%s is executable.\\n" "$1" +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fB-f\fP option was omitted because the same effect can (and should) +be obtained using the \fIxargs\fP utility. +.LP +Historical versions of the \fIfile\fP utility attempt to identify +the following types of files: symbolic link, directory, +character special, block special, socket, \fItar\fP archive, \fIcpio\fP +archive, SCCS archive, archive library, empty, \fIcompress\fP output, +\fIpack\fP output, binary data, C source, FORTRAN source, assembler +source, \fInroff\fP/ \fItroff\fP/ \fIeqn\fP/ \fItbl\fP source \fItroff\fP +output, shell script, C shell script, English text, +ASCII text, various executables, APL workspace, compiled terminfo +entries, and CURSES screen images. Only those types that are +reasonably well specified in POSIX or are directly related to POSIX +utilities are listed in the table. +.LP +Historical systems have used a "magic file" named \fB/etc/magic\fP +to help identify file types. Because it is generally +useful for users and scripts to be able to identify special file types, +the \fB-m\fP flag and a portable format for user-created +magic files has been specified. No requirement is made that an implementation +of \fIfile\fP use this method of identifying files, +only that users be permitted to add their own classifying tests. +.LP +In addition, three options have been added to historical practice. +The \fB-d\fP flag has been added to permit users to cause +their tests to follow any default system tests. The \fB-i\fP flag +has been added to permit users to test portably for regular +files in shell scripts. The \fB-M\fP flag has been added to permit +users to ignore any default system tests. +.LP +The IEEE\ Std\ 1003.1-2001 description of default system tests and +the interaction between the \fB-d\fP, \fB-M\fP, and +\fB-m\fP options did not clearly indicate that there were two types +of "default system tests". The "position-sensitive tests'' +determine file types by looking for certain string or binary values +at specific offsets in the file being examined. These +position-sensitive tests were implemented in historical systems using +the magic file described above. Some of these tests are now +built into the \fIfile\fP utility itself on some implementations so +the output can provide more detail than can be provided by +magic files. For example, a magic file can easily identify a \fBcore\fP +file on most implementations, but cannot name the program +file that dropped the core. A magic file could produce output such +as: +.sp +.RS +.nf + +\fB/home/dwc/core: ELF 32-bit MSB core file SPARC Version 1 +\fP +.fi +.RE +.LP +but by building the test into the \fIfile\fP utility, you could get +output such as: +.sp +.RS +.nf + +\fB/home/dwc/core: ELF 32-bit MSB core file SPARC Version 1, from 'testprog' +\fP +.fi +.RE +.LP +These extended built-in tests are still to be treated as position-sensitive +default system tests even if they are not listed in +\fB/etc/magic\fP or any other magic file. +.LP +The context-sensitive default system tests were always built into +the \fIfile\fP utility. These tests looked for language +constructs in text files trying to identify shell scripts, C, FORTRAN, +and other computer language source files, and even plain +text files. With the addition of the \fB-m\fP and \fB-M\fP options +the distinction between position-sensitive and +context-sensitive default system tests became important because the +order of testing is important. The context-sensitive system +default tests should never be applied before any position-sensitive +tests even if the \fB-d\fP option is specified before a +\fB-m\fP option or \fB-M\fP option due to the high probability that +the context-sensitive system default tests will incorrectly +identify arbitrary text files as text files before position-sensitive +tests specified by the \fB-m\fP or \fB-M\fP option would be +applied to give a more accurate identification. +.LP +Leaving the meaning of \fB-M -\fP and \fB-m -\fP unspecified allows +an existing prototype of these options to continue to work +in a backwards-compatible manner. (In that implementation, \fB-M -\fP +was roughly equivalent to \fB-d\fP in +IEEE\ Std\ 1003.1-2001.) +.LP +The historical \fB-c\fP option was omitted as not particularly useful +to users or portable shell scripts. In addition, a +reasonable implementation of the \fIfile\fP utility would report any +errors found each time the magic file is read. +.LP +The historical format of the magic file was the same as that specified +by the Rationale in the ISO\ POSIX-2:1993 standard +for the \fIoffset\fP, \fIvalue\fP, and \fImessage\fP fields; however, +it used less precise type fields than the format specified +by the current normative text. The new type field values are a superset +of the historical ones. +.LP +The following is an example magic file: +.sp +.RS +.nf + +\fB0 short 070707 cpio archive +0 short 0143561 Byte-swapped cpio archive +0 string 070707 ASCII cpio archive +0 long 0177555 Very old archive +0 short 0177545 Old archive +0 short 017437 Old packed data +0 string \\037\\036 Packed data +0 string \\377\\037 Compacted data +0 string \\037\\235 Compressed data +>2 byte&0x80 >0 Block compressed +>2 byte&0x1f x %d bits +0 string \\032\\001 Compiled Terminfo Entry +0 short 0433 Curses screen image +0 short 0434 Curses screen image +0 string <ar> System V Release 1 archive +0 string !<arch>\\n__.SYMDEF Archive random library +0 string !<arch> Archive +0 string ARF_BEGARF PHIGS clear text archive +0 long 0x137A2950 Scalable OpenFont binary +0 long 0x137A2951 Encrypted scalable OpenFont binary +\fP +.fi +.RE +.LP +The use of a basic integer data type is intended to allow the implementation +to choose a word size commonly used by applications +on that architecture. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIar\fP , \fIls\fP , \fIpax\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/find.1p b/man1p/find.1p new file mode 100644 index 000000000..6dbca5e73 --- /dev/null +++ b/man1p/find.1p @@ -0,0 +1,696 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FIND" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" find +.SH NAME +find \- find files +.SH SYNOPSIS +.LP +\fBfind\fP \fB[\fP\fB-H | -L\fP\fB]\fP \fIpath\fP \fB...\fP \fB[\fP\fIoperand_expression\fP +\fB\&...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIfind\fP utility shall recursively descend the directory hierarchy +from each file specified by \fIpath\fP, evaluating a +Boolean expression composed of the primaries described in the OPERANDS +section for each file encountered. +.LP +The \fIfind\fP utility shall be able to descend to arbitrary depths +in a file hierarchy and shall not fail due to path length +limitations (unless a \fIpath\fP operand specified by the application +exceeds {PATH_MAX} requirements). +.LP +The \fIfind\fP utility shall detect infinite loops; that is, entering +a previously visited directory that is an ancestor of the +last file encountered. When it detects an infinite loop, \fIfind\fP +shall write a diagnostic message to standard error and shall +either recover its position in the hierarchy or terminate. +.SH OPTIONS +.LP +The \fIfind\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-H\fP +Cause the file information and file type evaluated for each symbolic +link encountered on the command line to be those of the +file referenced by the link, and not the link itself. If the referenced +file does not exist, the file information and type shall be +for the link itself. File information for all symbolic links not on +the command line shall be that of the link itself. +.TP 7 +\fB-L\fP +Cause the file information and file type evaluated for each symbolic +link to be those of the file referenced by the link, and +not the link itself. +.sp +.LP +Specifying more than one of the mutually-exclusive options \fB-H\fP +and \fB-L\fP shall not be considered an error. The last +option specified shall determine the behavior of the utility. +.SH OPERANDS +.LP +The following operands shall be supported: +.LP +The \fIpath\fP operand is a pathname of a starting point in the directory +hierarchy. +.LP +The first argument that starts with a \fB'-'\fP , or is a \fB'!'\fP +or a \fB'('\fP , and all subsequent arguments shall +be interpreted as an \fIexpression\fP made up of the following primaries +and operators. In the descriptions, wherever \fIn\fP is +used as a primary argument, it shall be interpreted as a decimal integer +optionally preceded by a plus ( \fB'+'\fP ) or minus ( +\fB'-'\fP ) sign, as follows: +.TP 7 ++\fIn\fP +More than \fIn\fP. +.TP 7 +\fIn\fP +Exactly \fIn\fP. +.TP 7 +-\fIn\fP +Less than \fIn\fP. +.sp +.LP +The following primaries shall be supported: +.TP 7 +\fB-name\ \fP \fIpattern\fP +.sp +The primary shall evaluate as true if the basename of the filename +being examined matches \fIpattern\fP using the pattern matching +notation described in \fIPattern Matching Notation\fP . +.TP 7 +\fB-nouser\fP +The primary shall evaluate as true if the file belongs to a user ID +for which the \fIgetpwuid\fP() function defined in the System Interfaces +volume of +IEEE\ Std\ 1003.1-2001 (or equivalent) returns NULL. +.TP 7 +\fB-nogroup\fP +The primary shall evaluate as true if the file belongs to a group +ID for which the \fIgetgrgid\fP() function defined in the System Interfaces +volume of +IEEE\ Std\ 1003.1-2001 (or equivalent) returns NULL. +.TP 7 +\fB-xdev\fP +The primary shall always evaluate as true; it shall cause \fIfind\fP +not to continue descending past directories that have a +different device ID ( \fIst_dev\fP, see the \fIstat\fP() function +defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001). If any \fB-xdev\fP primary +is specified, it shall apply to the entire +expression even if the \fB-xdev\fP primary would not normally be evaluated. +.TP 7 +\fB-prune\fP +The primary shall always evaluate as true; it shall cause \fIfind\fP +not to descend the current pathname if it is a directory. +If the \fB-depth\fP primary is specified, the \fB-prune\fP primary +shall have no effect. +.TP 7 +\fB-perm\ [-]\fP\fImode\fP +.sp +The \fImode\fP argument is used to represent file mode bits. It shall +be identical in format to the \fIsymbolic_mode\fP operand +described in \fIchmod\fP() , and shall be interpreted as follows. +To start, a template shall be assumed +with all file mode bits cleared. An \fIop\fP symbol of \fB'+'\fP shall +set the appropriate mode bits in the template; +\fB'-'\fP shall clear the appropriate bits; \fB'='\fP shall set the +appropriate mode bits, without regard to the contents of +process' file mode creation mask. The \fIop\fP symbol of \fB'-'\fP +cannot be the first character of \fImode\fP; this avoids +ambiguity with the optional leading hyphen. Since the initial mode +is all bits off, there are not any symbolic modes that need to +use \fB'-'\fP as the first character. +.LP +If the hyphen is omitted, the primary shall evaluate as true when +the file permission bits exactly match the value of the +resulting template. +.LP +Otherwise, if \fImode\fP is prefixed by a hyphen, the primary shall +evaluate as true if at least all the bits in the resulting +template are set in the file permission bits. +.TP 7 +\fB-perm\ [-]\fP\fIonum\fP +.sp +If the hyphen is omitted, the primary shall evaluate as true when +the file permission bits exactly match the value of the octal +number \fIonum\fP and only the bits corresponding to the octal mask +07777 shall be compared. (See the description of the octal +\fImode\fP in \fIchmod\fP() .) Otherwise, if \fIonum\fP is prefixed +by a hyphen, the primary shall +evaluate as true if at least all of the bits specified in \fIonum\fP +that are also set in the octal mask 07777 are set. +.TP 7 +\fB-type\ \fP \fIc\fP +The primary shall evaluate as true if the type of the file is \fIc\fP, +where \fIc\fP is \fB'b'\fP , \fB'c'\fP , +\fB'd'\fP , \fB'l'\fP , \fB'p'\fP , \fB'f'\fP , or \fB's'\fP for block +special file, character special file, +directory, symbolic link, FIFO, regular file, or socket, respectively. +.TP 7 +\fB-links\ \fP \fIn\fP +The primary shall evaluate as true if the file has \fIn\fP links. +.TP 7 +\fB-user\ \fP \fIuname\fP +The primary shall evaluate as true if the file belongs to the user +\fIuname.\fP If \fIuname\fP is a decimal integer and the +\fIgetpwnam\fP() (or equivalent) function does not return a valid +user name, \fIuname\fP +shall be interpreted as a user ID. +.TP 7 +\fB-group\ \fP \fIgname\fP +.sp +The primary shall evaluate as true if the file belongs to the group +\fIgname\fP. If \fIgname\fP is a decimal integer and the \fIgetgrnam\fP() +(or equivalent) function does not return a valid group name, \fIgname\fP +shall be interpreted as a group ID. +.TP 7 +\fB-size\ \fP \fIn\fP\fB[c]\fP +The primary shall evaluate as true if the file size in bytes, divided +by 512 and rounded up to the next integer, is \fIn\fP. +If \fIn\fP is followed by the character \fB'c'\fP , the size shall +be in bytes. +.TP 7 +\fB-atime\ \fP \fIn\fP +The primary shall evaluate as true if the file access time subtracted +from the initialization time, divided by 86400 (with any +remainder discarded), is \fIn\fP. +.TP 7 +\fB-ctime\ \fP \fIn\fP +The primary shall evaluate as true if the time of last change of file +status information subtracted from the initialization +time, divided by 86400 (with any remainder discarded), is \fIn\fP. +.TP 7 +\fB-mtime\ \fP \fIn\fP +The primary shall evaluate as true if the file modification time subtracted +from the initialization time, divided by 86400 +(with any remainder discarded), is \fIn\fP. +.TP 7 +\fB-exec\ \fP \fIutility_name\ \fP \fB[\fP\fIargument\fP\ ...\fB]\ ;\fP +.TP 7 +\fB-exec\ \fP \fIutility_name\ \fP \fB[\fP\fIargument\fP\ ...\fB]\ \ \fP +{}\ + +.sp +The end of the primary expression shall be punctuated by a semicolon +or by a plus sign. Only a plus sign that follows an argument +containing the two characters \fB"{}"\fP shall punctuate the end of +the primary expression. Other uses of the plus sign shall +not be treated as special. +.LP +If the primary expression is punctuated by a semicolon, the utility +\fIutility_name\fP shall be invoked once for each pathname +and the primary shall evaluate as true if the utility returns a zero +value as exit status. A \fIutility_name\fP or \fIargument\fP +containing only the two characters \fB"{}"\fP shall be replaced by +the current pathname. +.LP +If the primary expression is punctuated by a plus sign, the primary +shall always evaluate as true, and the pathnames for which +the primary is evaluated shall be aggregated into sets. The utility +\fIutility_name\fP shall be invoked once for each set of +aggregated pathnames. Each invocation shall begin after the last pathname +in the set is aggregated, and shall be completed before +the \fIfind\fP utility exits and before the first pathname in the +next set (if any) is aggregated for this primary, but it is +otherwise unspecified whether the invocation occurs before, during, +or after the evaluations of other primaries. If any invocation +returns a non-zero value as exit status, the \fIfind\fP utility shall +return a non-zero exit status. An argument containing only +the two characters \fB"{}"\fP shall be replaced by the set of aggregated +pathnames, with each pathname passed as a separate +argument to the invoked utility in the same order that it was aggregated. +The size of any set of two or more pathnames shall be +limited such that execution of the utility does not cause the system's +{ARG_MAX} limit to be exceeded. If more than one argument +containing only the two characters \fB"{}"\fP is present, the behavior +is unspecified. +.LP +If a \fIutility_name\fP or \fIargument\fP string contains the two +characters \fB"{}"\fP , but not just the two characters +\fB"{}"\fP , it is implementation-defined whether \fIfind\fP replaces +those two characters or uses the string without change. +The current directory for the invocation of \fIutility_name\fP shall +be the same as the current directory when the \fIfind\fP +utility was started. If the \fIutility_name\fP names any of the special +built-in utilities (see \fISpecial Built-In Utilities\fP ), the results +are undefined. +.TP 7 +\fB-ok\ \fP \fIutility_name\ \fP \fB[\fP\fIargument\fP\ ...\fB]\ ;\fP +.sp +The \fB-ok\fP primary shall be equivalent to \fB-exec\fP, except that +the use of a plus sign to punctuate the end of the primary +expression need not be supported, and \fIfind\fP shall request affirmation +of the invocation of \fIutility_name\fP using the +current file as an argument by writing to standard error as described +in the STDERR section. If the response on standard input is +affirmative, the utility shall be invoked. Otherwise, the command +shall not be invoked and the value of the \fB-ok\fP operand +shall be false. +.TP 7 +\fB-print\fP +The primary shall always evaluate as true; it shall cause the current +pathname to be written to standard output. +.TP 7 +\fB-newer\ \fP \fIfile\fP +The primary shall evaluate as true if the modification time of the +current file is more recent than the modification time of +the file named by the pathname \fIfile\fP. +.TP 7 +\fB-depth\fP +The primary shall always evaluate as true; it shall cause descent +of the directory hierarchy to be done so that all entries in +a directory are acted on before the directory itself. If a \fB-depth\fP +primary is not specified, all entries in a directory shall +be acted on after the directory itself. If any \fB-depth\fP primary +is specified, it shall apply to the entire expression even if +the \fB-depth\fP primary would not normally be evaluated. +.sp +.LP +The primaries can be combined using the following operators (in order +of decreasing precedence): +.TP 7 +(\ \fIexpression\fP\ ) +True if \fIexpression\fP is true. +.TP 7 +\fB!\ \fP \fIexpression\fP +Negation of a primary; the unary NOT operator. +.TP 7 +\fIexpression\ \fP \fB[-a]\ \fP \fIexpression\fP +.sp +Conjunction of primaries; the AND operator is implied by the juxtaposition +of two primaries or made explicit by the optional +\fB-a\fP operator. The second expression shall not be evaluated if +the first expression is false. +.TP 7 +\fIexpression\ \fP \fB-o\ \fP \fIexpression\fP +.sp +Alternation of primaries; the OR operator. The second expression shall +not be evaluated if the first expression is true. +.sp +.LP +If no \fIexpression\fP is present, \fB-print\fP shall be used as the +expression. Otherwise, if the given expression does not +contain any of the primaries \fB-exec\fP, \fB-ok\fP, or \fB-print\fP, +the given expression shall be effectively replaced by: +.sp +.RS +.nf + +\fB(\fP \fIgiven_expression\fP \fB) -print +\fP +.fi +.RE +.LP +The \fB-user\fP, \fB-group\fP, and \fB-newer\fP primaries each shall +evaluate their respective arguments only once. +.SH STDIN +.LP +If the \fB-ok\fP primary is used, the response shall be read from +the standard input. An entire line shall be read as the +response. Otherwise, the standard input shall not be used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIfind\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements used in the pattern +matching notation for the \fB-n\fP option and in the extended regular +expression defined for the \fByesexpr\fP locale keyword in +the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_CTYPE\fP +This variable determines the locale for the interpretation of sequences +of bytes of text data as characters (for example, +single-byte as opposed to multi-byte characters in arguments), the +behavior of character classes within the pattern matching +notation used for the \fB-n\fP option, and the behavior of character +classes within regular expressions used in the extended +regular expression defined for the \fByesexpr\fP locale keyword in +the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale for the processing of affirmative responses that +should be used to affect the format and contents of +diagnostic messages written to standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the location of the \fIutility_name\fP for the \fB-exec\fP +and \fB-ok\fP primaries, as described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fB-print\fP primary shall cause the current pathnames to be written +to standard output. The format shall be: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIpath\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The \fB-ok\fP primary shall write a prompt to standard error containing +at least the \fIutility_name\fP to be invoked and the +current pathname. In the POSIX locale, the last non- <blank> in the +prompt shall be \fB'?'\fP . The exact format used is +unspecified. +.LP +Otherwise, the standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All \fIpath\fP operands were traversed successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +When used in operands, pattern matching notation, semicolons, opening +parentheses, and closing parentheses are special to the +shell and must be quoted (see \fIQuoting\fP ). +.LP +The bit that is traditionally used for sticky (historically 01000) +is specified in the \fB-perm\fP primary using the octal +number argument form. Since this bit is not defined by this volume +of IEEE\ Std\ 1003.1-2001, applications must not assume +that it actually refers to the traditional sticky bit. +.SH EXAMPLES +.IP " 1." 4 +The following commands are equivalent: +.sp +.RS +.nf + +\fBfind . +find . -print +\fP +.fi +.RE +.LP +They both write out the entire directory hierarchy from the current +directory. +.LP +.IP " 2." 4 +The following command: +.sp +.RS +.nf + +\fBfind / \\( -name tmp -o -name '*.xx' \\) -atime +7 -exec rm {} \\; +\fP +.fi +.RE +.LP +removes all files named \fBtmp\fP or ending in \fB.xx\fP that have +not been accessed for seven or more 24-hour periods. +.LP +.IP " 3." 4 +The following command: +.sp +.RS +.nf + +\fBfind . -perm -o+w,+s +\fP +.fi +.RE +.LP +prints ( \fB-print\fP is assumed) the names of all files in or below +the current directory, with all of the file permission +bits S_ISUID, S_ISGID, and S_IWOTH set. +.LP +.IP " 4." 4 +The following command: +.sp +.RS +.nf + +\fBfind . -name SCCS -prune -o -print +\fP +.fi +.RE +.LP +recursively prints pathnames of all files in the current directory +and below, but skips directories named SCCS and files in +them. +.LP +.IP " 5." 4 +The following command: +.sp +.RS +.nf + +\fBfind . -print -name SCCS -prune +\fP +.fi +.RE +.LP +behaves as in the previous example, but prints the names of the SCCS +directories. +.LP +.IP " 6." 4 +The following command is roughly equivalent to the \fB-nt\fP extension +to \fItest\fP: +.sp +.RS +.nf + +\fBif [ -n "$(find file1 -prune -newer file2)" ]; then + printf %s\\\\n "file1 is newer than file2" +fi +\fP +.fi +.RE +.LP +.IP " 7." 4 +The descriptions of \fB-atime\fP, \fB-ctime\fP, and \fB-mtime\fP use +the terminology \fIn\fP "86400 second periods +(days)". For example, a file accessed at 23:59 is selected by: +.sp +.RS +.nf + +\fBfind . -atime -1 -print +\fP +.fi +.RE +.LP +at 00:01 the next day (less than 24 hours later, not more than one +day ago); the midnight boundary between days has no effect on +the 24-hour calculation. +.LP +.SH RATIONALE +.LP +The \fB-a\fP operator was retained as an optional operator for compatibility +with historical shell scripts, even though it is +redundant with expression concatenation. +.LP +The descriptions of the \fB'-'\fP modifier on the \fImode\fP and \fIonum\fP +arguments to the \fB-perm\fP primary agree +with historical practice on BSD and System V implementations. System +V and BSD documentation both describe it in terms of checking +additional bits; in fact, it uses the same bits, but checks for having +at least all of the matching bits set instead of having +exactly the matching bits set. +.LP +The exact format of the interactive prompts is unspecified. Only the +general nature of the contents of prompts are specified +because: +.IP " *" 3 +Implementations may desire more descriptive prompts than those used +on historical implementations. +.LP +.IP " *" 3 +Since the historical prompt strings do not terminate with <newline>s, +there is no portable way for another program to +interact with the prompts of this utility via pipes. +.LP +.LP +Therefore, an application using this prompting option relies on the +system to provide the most suitable dialog directly with the +user, based on the general guidelines specified. +.LP +The \fB-name\fP \fIfile\fP operand was changed to use the shell pattern +matching notation so that \fIfind\fP is consistent +with other utilities using pattern matching. +.LP +The \fB-size\fP operand refers to the size of a file, rather than +the number of blocks it may occupy in the file system. The +intent is that the \fIst_size\fP field defined in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 should be used, +not the \fIst_blocks\fP found in historical implementations. There +are at least two reasons for this: +.IP " 1." 4 +In both System V and BSD, \fIfind\fP only uses \fIst_size\fP in size +calculations for the operands specified by this volume of +IEEE\ Std\ 1003.1-2001. (BSD uses \fIst_blocks\fP only when processing +the \fB-ls\fP primary.) +.LP +.IP " 2." 4 +Users usually think of file size in terms of bytes, which is also +the unit used by the \fIls\fP utility for the output from the \fB-l\fP +option. (In both System V and BSD, \fIls\fP uses \fIst_size\fP for +the \fB-l\fP option size field and uses \fIst_blocks\fP for the \fIls\fP +\fB-s\fP calculations. This volume of IEEE\ Std\ 1003.1-2001 does +not specify \fIls\fP \fB-s\fP.) +.LP +.LP +The descriptions of \fB-atime\fP, \fB-ctime\fP, and \fB-mtime\fP were +changed from the SVID description of \fIn\fP "days'' +to "24-hour periods". The description is also different in terms of +the exact timeframe for the \fIn\fP case (\fIversus\fP the +\fI+n\fP or \fI-n\fP), but it matches all known historical implementations. +It refers to one 86400 second period in the past, not +any time from the beginning of that period to the current time. For +example, \fB-atime\fP 3 is true if the file was accessed any +time in the period from 72 hours to 48 hours ago. +.LP +Historical implementations do not modify \fB"{}"\fP when it appears +as a substring of an \fB-exec\fP or \fB-ok\fP +\fIutility_name\fP or argument string. There have been numerous user +requests for this extension, so this volume of +IEEE\ Std\ 1003.1-2001 allows the desired behavior. At least one recent +implementation does support this feature, but +encountered several problems in managing memory allocation and dealing +with multiple occurrences of \fB"{}"\fP in a string while +it was being developed, so it is not yet required behavior. +.LP +Assuming the presence of \fB-print\fP was added to correct a historical +pitfall that plagues novice users, it is entirely +upwards-compatible from the historical System V \fIfind\fP utility. +In its simplest form ( \fIfind\fP \fIdirectory\fP), it could +be confused with the historical BSD fast \fIfind\fP. The BSD developers +agreed that adding \fB-print\fP as a default expression +was the correct decision and have added the fast \fIfind\fP functionality +within a new utility called \fIlocate\fP. +.LP +Historically, the \fB-L\fP option was implemented using the primary +\fB-follow\fP. The \fB-H\fP and \fB-L\fP options were +added for two reasons. First, they offer a finer granularity of control +and consistency with other programs that walk file +hierarchies. Second, the \fB-follow\fP primary always evaluated to +true. As they were historically really global variables that +took effect before the traversal began, some valid expressions had +unexpected results. An example is the expression \fB-print\fP +\fB-o\fP \fB-follow\fP. Because \fB-print\fP always evaluates to true, +the standard order of evaluation implies that +\fB-follow\fP would never be evaluated. This was never the case. Historical +practice for the \fB-follow\fP primary, however, is +not consistent. Some implementations always follow symbolic links +on the command line whether \fB-follow\fP is specified or not. +Others follow symbolic links on the command line only if \fB-follow\fP +is specified. Both behaviors are provided by the \fB-H\fP +and \fB-L\fP options, but scripts using the current \fB-follow\fP +primary would be broken if the \fB-follow\fP option is +specified to work either way. +.LP +Since the \fB-L\fP option resolves all symbolic links and the \fB-type\fP +\fIl\fP primary is true for symbolic links that +still exist after symbolic links have been resolved, the command: +.sp +.RS +.nf + +\fBfind -L . -type l +\fP +.fi +.RE +.LP +prints a list of symbolic links reachable from the current directory +that do not resolve to accessible files. +.LP +A feature of SVR4's \fIfind\fP utility was the \fB-exec\fP primary's +\fB+\fP terminator. This allowed filenames containing +special characters (especially <newline>s) to be grouped together +without the problems that occur if such filenames are piped +to \fIxargs\fP. Other implementations have added other ways to get +around this problem, +notably a \fB-print0\fP primary that wrote filenames with a null byte +terminator. This was considered here, but not adopted. Using +a null terminator meant that any utility that was going to process +\fIfind\fP's \fB-print0\fP output had to add a new option to +parse the null terminators it would now be reading. +.LP +The \fB"-exec ... {} +"\fP syntax adopted was a result of IEEE PASC +Interpretation 1003.2 #210. It should be noted that this +is an incompatible change to the ISO/IEC\ 9899:1999 standard. For +example, the following command prints all files with a +\fB'-'\fP after their name if they are regular files, and a \fB'+'\fP +otherwise: +.sp +.RS +.nf + +\fBfind / -type f -exec echo {} - ';' -o -exec echo {} + ';' +\fP +.fi +.RE +.LP +The change invalidates usage like this. Even though the previous standard +stated that this usage would work, in practice many +did not support it and the standard developers felt it better to now +state that this was not allowable. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIQuoting\fP , \fIPattern Matching +Notation\fP , \fISpecial Built-In Utilities\fP , \fIchmod\fP() , \fIpax\fP +, \fIsh\fP , \fItest\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIgetgrgid\fP(), \fIgetpwuid\fP(), \fIstat\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/fold.1p b/man1p/fold.1p new file mode 100644 index 000000000..888061ec8 --- /dev/null +++ b/man1p/fold.1p @@ -0,0 +1,225 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FOLD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" fold +.SH NAME +fold \- filter for folding lines +.SH SYNOPSIS +.LP +\fBfold\fP \fB[\fP\fB-bs\fP\fB][\fP\fB-w\fP \fIwidth\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIfold\fP utility is a filter that shall fold lines from its +input files, breaking the lines to have a maximum of +\fIwidth\fP column positions (or bytes, if the \fB-b\fP option is +specified). Lines shall be broken by the insertion of a +<newline> such that each output line (referred to later in this section +as a \fIsegment\fP) is the maximum width possible +that does not exceed the specified number of column positions (or +bytes). A line shall not be broken in the middle of a character. +The behavior is undefined if \fIwidth\fP is less than the number of +columns any single character in the input would occupy. +.LP +If the <carriage-return>s, <backspace>s, or <tab>s are encountered +in the input, and the \fB-b\fP option is +not specified, they shall be treated specially: +.TP 7 +<backspace> +The current count of line width shall be decremented by one, although +the count never shall become negative. The \fIfold\fP +utility shall not insert a <newline> immediately before or after any +<backspace>. +.TP 7 +<carriage-return> +.sp +The current count of line width shall be set to zero. The \fIfold\fP +utility shall not insert a <newline> immediately before +or after any <carriage-return>. +.TP 7 +<tab> +Each <tab> encountered shall advance the column position pointer to +the next tab stop. Tab stops shall be at each column +position \fIn\fP such that \fIn\fP modulo 8 equals 1. +.sp +.SH OPTIONS +.LP +The \fIfold\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-b\fP +Count \fIwidth\fP in bytes rather than column positions. +.TP 7 +\fB-s\fP +If a segment of a line contains a <blank> within the first \fIwidth\fP +column positions (or bytes), break the line after +the last such <blank> meeting the width constraints. If there is no +<blank> meeting the requirements, the \fB-s\fP +option shall have no effect for that output segment of the input line. +.TP 7 +\fB-w\ \fP \fIwidth\fP +Specify the maximum line length, in column positions (or bytes if +\fB-b\fP is specified). The results are unspecified if +\fIwidth\fP is not a positive decimal number. The default value shall +be 80. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a text file to be folded. If no \fIfile\fP operands +are specified, the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +If the \fB-b\fP option is specified, the input files shall be text +files except that the lines are not limited to {LINE_MAX} +bytes in length. If the \fB-b\fP option is not specified, the input +files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIfold\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), and +for the determination of the width in column positions each +character would occupy on a constant-width font output device. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be a file containing a sequence of characters +whose order shall be preserved from the input files, +possibly with inserted <newline>s. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were processed successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIcut\fP and \fIfold\fP utilities can be used to create text +files out of files with +arbitrary line lengths. The \fIcut\fP utility should be used when +the number of lines (or +records) needs to remain constant. The \fIfold\fP utility should be +used when the contents of long lines need to be kept +contiguous. +.LP +The \fIfold\fP utility is frequently used to send text files to printers +that truncate, rather than fold, lines wider than the +printer is able to print (usually 80 or 132 column positions). +.SH EXAMPLES +.LP +An example invocation that submits a file of possibly long lines to +the printer (under the assumption that the user knows the +line width of the printer to be assigned by \fIlp\fP): +.sp +.RS +.nf + +\fBfold -w 132 bigfile | lp +\fP +.fi +.RE +.SH RATIONALE +.LP +Although terminal input in canonical processing mode requires the +erase character (frequently set to <backspace>) to erase +the previous character (not byte or column position), terminal output +is not buffered and is extremely difficult, if not +impossible, to parse correctly; the interpretation depends entirely +on the physical device that actually displays/prints/stores the +output. In all known internationalized implementations, the utilities +producing output for mixed column-width output assume that a +<backspace> backs up one column position and outputs enough <backspace>s +to return to the start of the character when +<backspace> is used to provide local line motions to support underlining +and emboldening operations. Since \fIfold\fP +without the \fB-b\fP option is dealing with these same constraints, +<backspace> is always treated as backing up one column +position rather than backing up one character. +.LP +Historical versions of the \fIfold\fP utility assumed 1 byte was one +character and occupied one column position when written +out. This is no longer always true. Since the most common usage of +\fIfold\fP is believed to be folding long lines for output to +limited-length output devices, this capability was preserved as the +default case. The \fB-b\fP option was added so that +applications could \fIfold\fP files with arbitrary length lines into +text files that could then be processed by the standard +utilities. Note that although the width for the \fB-b\fP option is +in bytes, a line is never split in the middle of a character. +(It is unspecified what happens if a width is specified that is too +small to hold a single character found in the input followed by +a <newline>.) +.LP +The tab stops are hardcoded to be every eighth column to meet historical +practice. No new method of specifying other tab stops +was invented. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcut\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/fort77.1p b/man1p/fort77.1p new file mode 100644 index 000000000..b860f70ca --- /dev/null +++ b/man1p/fort77.1p @@ -0,0 +1,500 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FORT77" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" fort77 +.SH NAME +fort77 \- FORTRAN compiler (\fBFORTRAN\fP) +.SH SYNOPSIS +.LP +\fBfort77\fP \fB[\fP\fB-c\fP\fB][\fP\fB-g\fP\fB][\fP\fB-L\fP +\fIdirectory\fP\fB]\fP\fB...\fP \fB[\fP\fB-O\fP \fIoptlevel\fP\fB][\fP\fB-o\fP +\fIoutfile\fP\fB][\fP\fB-s\fP\fB][\fP\fB-w\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB\fP\fIoperand\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIfort77\fP utility is the interface to the FORTRAN compilation +system; it shall accept the full FORTRAN-77 language +defined by the ANSI\ X3.9-1978 standard. The system conceptually consists +of a compiler and link editor. The files referenced +by \fIoperand\fPs are compiled and linked to produce an executable +file. It is unspecified whether the linking occurs entirely +within the operation of \fIfort77\fP; some implementations may produce +objects that are not fully resolved until the file is +executed. +.LP +If the \fB-c\fP option is present, for all pathname operands of the +form \fIfile\fP \fB.f\fP, the files: +.sp +.RS +.nf + +\fB$(basename\fP \fIpathname\fP\fB.f).o +\fP +.fi +.RE +.LP +shall be created or overwritten as the result of successful compilation. +If the \fB-c\fP option is not specified, it is +unspecified whether such \fB.o\fP files are created or deleted for +the \fIfile\fP \fB.f\fP operands. +.LP +If there are no options that prevent link editing (such as \fB-c\fP) +and all operands compile and link without error, the +resulting executable file shall be written into the file named by +the \fB-o\fP option (if present) or to the file \fBa.out\fP. +The executable file shall be created as specified in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, except that +the file permissions shall be set to: +.sp +.RS +.nf + +S_IRWXO | S_IRWXG | S_IRWXU +.fi +.RE +.LP +and that the bits specified by the \fIumask\fP of the process shall +be cleared. +.SH OPTIONS +.LP +The \fIfort77\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that: +.IP " *" 3 +The \fB-l\fP \fIlibrary\fP operands have the format of options, but +their position within a list of operands affects the order +in which libraries are searched. +.LP +.IP " *" 3 +The order of specifying the multiple \fB-L\fP options is significant. +.LP +.IP " *" 3 +Conforming applications shall specify each option separately; that +is, grouping option letters (for example, \fB-cg\fP) need +not be recognized by all implementations. +.LP +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Suppress the link-edit phase of the compilation, and do not remove +any object files that are produced. +.TP 7 +\fB-g\fP +Produce symbolic information in the object or executable files; the +nature of this information is unspecified, and may be +modified by implementation-defined interactions with other options. +.TP 7 +\fB-s\fP +Produce object or executable files, or both, from which symbolic and +other information not required for proper execution using +the \fIexec\fP family of functions defined in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 has been removed +(stripped). If both \fB-g\fP and \fB-s\fP options are present, the +action taken is unspecified. +.TP 7 +\fB-o\ \fP \fIoutfile\fP +Use the pathname \fIoutfile\fP, instead of the default \fBa.out\fP, +for the executable file produced. If the \fB-o\fP option +is present with \fB-c\fP, the result is unspecified. +.TP 7 +\fB-L\ \fP \fIdirectory\fP +Change the algorithm of searching for the libraries named in \fB-l\fP +operands to look in the directory named by the +\fIdirectory\fP pathname before looking in the usual places. Directories +named in \fB-L\fP options shall be searched in the +specified order. At least ten instances of this option shall be supported +in a single \fIfort77\fP command invocation. If a +directory specified by a \fB-L\fP option contains a file named \fBlibf.a\fP, +the results are unspecified. +.TP 7 +\fB-O\ \fP \fIoptlevel\fP +Specify the level of code optimization. If the \fIoptlevel\fP option-argument +is the digit \fB'0'\fP , all special code +optimizations shall be disabled. If it is the digit \fB'1'\fP , the +nature of the optimization is unspecified. If the \fB-O\fP +option is omitted, the nature of the system's default optimization +is unspecified. It is unspecified whether code generated in the +presence of the \fB-O\fP 0 option is the same as that generated when +\fB-O\fP is omitted. Other \fIoptlevel\fP values may be +supported. +.TP 7 +\fB-w\fP +Suppress warnings. +.sp +.LP +Multiple instances of \fB-L\fP options can be specified. +.SH OPERANDS +.LP +An \fIoperand\fP is either in the form of a pathname or the form \fB-l\fP +\fIlibrary\fP. At least one operand of the pathname +form shall be specified. The following operands shall be supported: +.TP 7 +\fIfile.\fP\fBf\fP +The pathname of a FORTRAN source file to be compiled and optionally +passed to the link editor. The filename operand shall be of +this form if the \fB-c\fP option is used. +.TP 7 +\fIfile.\fP\fBa\fP +A library of object files typically produced by \fIar\fP, and passed +directly to the link +editor. Implementations may recognize implementation-defined suffixes +other than \fB.a\fP as denoting object file libraries. +.TP 7 +\fIfile.\fP\fBo\fP +An object file produced by \fIfort77\fP \fB-c\fP and passed directly +to the link editor. Implementations may recognize +implementation-defined suffixes other than \fB.o\fP as denoting object +files. +.sp +.LP +The processing of other files is implementation-defined. +.TP 7 +\fB-l\ \fP \fIlibrary\fP +(The letter ell.) Search the library named: +.sp +.RS +.nf + +\fBlib\fP\fIlibrary\fP\fB.a +\fP +.fi +.RE +.LP +A library is searched when its name is encountered, so the placement +of a \fB-l\fP operand is significant. Several standard +libraries can be specified in this manner, as described in the EXTENDED +DESCRIPTION section. Implementations may recognize +implementation-defined suffixes other than \fB.a\fP as denoting libraries. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The input file shall be one of the following: a text file containing +FORTRAN source code; an object file in the format produced +by \fIfort77\fP \fB-c\fP; or a library of object files, in the format +produced by archiving zero or more object files, using \fIar\fP. Implementations +may supply additional utilities that produce files in these formats. +Additional input files are implementation-defined. +.LP +A <tab> encountered within the first six characters on a line of source +code shall cause the compiler to interpret the +following character as if it were the seventh character on the line +(that is, in column 7). +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIfort77\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITMPDIR\fP +Determine the pathname that should override the default directory +for temporary files, if any. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. If +more than one \fIfile\fP operand ending in \fB.f\fP (or +possibly other unspecified suffixes) is given, for each such file: +.sp +.RS +.nf + +\fB"%s:\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +may be written to allow identification of the diagnostic message with +the appropriate input file. +.LP +This utility may produce warning messages about certain conditions +that do not warrant returning an error (non-zero) exit +value. +.SH OUTPUT FILES +.LP +Object files, listing files, and executable files shall be produced +in unspecified formats. +.SH EXTENDED DESCRIPTION +.SS Standard Libraries +.LP +The \fIfort77\fP utility shall recognize the following \fB-l\fP operand +for the standard library: +.TP 7 +\fB-l\ f\fP +This library contains all functions referenced in the ANSI\ X3.9-1978 +standard. This operand shall not be required to be +present to cause a search of this library. +.sp +.LP +In the absence of options that inhibit invocation of the link editor, +such as \fB-c\fP, the \fIfort77\fP utility shall cause +the equivalent of a \fB-l\ f\fP operand to be passed to the link editor +as the last \fB-l\fP operand, causing it to be +searched after all other object files and libraries are loaded. +.LP +It is unspecified whether the library \fBlibf.a\fP exists as a regular +file. The implementation may accept as \fB-l\fP +operands names of objects that do not exist as regular files. +.SS External Symbols +.LP +The FORTRAN compiler and link editor shall support the significance +of external symbols up to a length of at least 31 bytes; +case folding is permitted. The action taken upon encountering symbols +exceeding the implementation-defined maximum symbol length is +unspecified. +.LP +The compiler and link editor shall support a minimum of 511 external +symbols per source or object file, and a minimum of 4095 +external symbols total. A diagnostic message is written to standard +output if the implementation-defined limit is exceeded; other +actions are unspecified. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful compilation or link edit. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +When \fIfort77\fP encounters a compilation error, it shall write a +diagnostic to standard error and continue to compile other +source code operands. It shall return a non-zero exit status, but +it is implementation-defined whether an object module is created. +If the link edit is unsuccessful, a diagnostic message shall be written +to standard error, and \fIfort77\fP shall exit with a +non-zero status. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +The following usage example compiles \fBxyz.f\fP and creates the executable +file \fBfoo\fP: +.sp +.RS +.nf + +\fBfort77 -o foo xyz.f +\fP +.fi +.RE +.LP +The following example compiles \fBxyz.f\fP and creates the object +file \fBxyz.o\fP: +.sp +.RS +.nf + +\fBfort77 -c xyz.f +\fP +.fi +.RE +.LP +The following example compiles \fBxyz.f\fP and creates the executable +file \fBa.out\fP: +.sp +.RS +.nf + +\fBfort77 xyz.f +\fP +.fi +.RE +.LP +The following example compiles \fBxyz.f\fP, links it with \fBb.o\fP, +and creates the executable \fBa.out\fP: +.sp +.RS +.nf + +\fBfort77 xyz.f b.o +\fP +.fi +.RE +.SH RATIONALE +.LP +The name of this utility was chosen as \fIfort77\fP to parallel the +renaming of the C compiler. The name \fIf77\fP was not +chosen to avoid problems with historical implementations. The ANSI\ X3.9-1978 +standard was selected as a normative reference +because the ISO/IEC version of FORTRAN-77 has been superseded by the +ISO/IEC\ 1539:1990 standard (Fortran-90). +.LP +The file inclusion and symbol definition \fB#define\fP mechanisms +used by the \fIc99\fP +utility were not included in this volume of IEEE\ Std\ 1003.1-2001-even +though they are commonly implemented-since there is +no requirement that the FORTRAN compiler use the C preprocessor. +.LP +The \fB-onetrip\fP option was not included in this volume of IEEE\ Std\ 1003.1-2001, +even though many historical +compilers support it, because it is derived from FORTRAN-66; it is +an anachronism that should not be perpetuated. +.LP +Some implementations produce compilation listings. This aspect of +FORTRAN has been left unspecified because there was +controversy concerning the various methods proposed for implementing +it: a \fB-V\fP option overlapped with historical vendor +practice and a naming convention of creating files with \fB.l\fP suffixes +collided with historical \fIlex\fP file naming practice. +.LP +There is no \fB-I\fP option in this version of this volume of IEEE\ Std\ 1003.1-2001 +to specify a directory for file +inclusion. An INCLUDE directive has been a part of the Fortran-90 +discussions, but an interface supporting that standard is not in +the current scope. +.LP +It is noted that many FORTRAN compilers produce an object module even +when compilation errors occur; during a subsequent +compilation, the compiler may patch the object module rather than +recompiling all the code. Consequently, it is left to the +implementor whether or not an object file is created. +.LP +A reference to MIL-STD-1753 was removed from an early proposal in +response to a request from the POSIX FORTRAN-binding standard +developers. It was not the intention of the standard developers to +require certification of the FORTRAN compiler, and +IEEE\ Std\ 1003.9-1992 does not specify the military standard or any +special preprocessing requirements. Furthermore, use +of that document would have been inappropriate for an international +standard. +.LP +The specification of optimization has been subject to changes through +early proposals. At one time, \fB-O\fP and \fB-N\fP were +Booleans: optimize and do not optimize (with an unspecified default). +Some historical practice led this to be changed to: +.TP 7 +\fB-O\fP\ 0 +No optimization. +.TP 7 +\fB-O\fP\ 1 +Some level of optimization. +.TP 7 +\fB-O\ \fP \fIn\fP +Other, unspecified levels of optimization. +.sp +.LP +It is not always clear whether "good code generation" is the same +thing as optimization. Simple optimizations of local actions +do not usually affect the semantics of a program. The \fB-O\fP 0 option +has been included to accommodate the very particular +nature of scientific calculations in a highly optimized environment; +compilers make errors. Some degree of optimization is +expected, even if it is not documented here, and the ability to shut +it off completely could be important when porting an +application. An implementation may treat \fB-O\fP 0 as "do less than +normal" if it wishes, but this is only meaningful if any of +the operations it performs can affect the semantics of a program. +It is highly dependent on the implementation whether doing less +than normal is logical. It is not the intent of the \fB-O\fP 0 option +to ask for inefficient code generation, but rather to assure +that any semantically visible optimization is suppressed. +.LP +The specification of standard library access is consistent with the +C compiler specification. Implementations are not required +to have \fB/usr/lib/libf.a\fP, as many historical implementations +do, but if not they are required to recognize \fBf\fP as a +token. +.LP +External symbol size limits are in normative text; conforming applications +need to know these limits. However, the minimum +maximum symbol length should be taken as a constraint on a conforming +application, not on an implementation, and consequently the +action taken for a symbol exceeding the limit is unspecified. The +minimum size for the external symbol table was added for similar +reasons. +.LP +The CONSEQUENCES OF ERRORS section clearly specifies the behavior +of the compiler when compilation or link-edit errors occur. +The behavior of several historical implementations was examined, and +the choice was made to be silent on the status of the +executable, or \fBa.out\fP, file in the face of compiler or linker +errors. If a linker writes the executable file, then links it +on disk with \fIlseek\fP()s and \fIwrite\fP()s, the +partially linked executable file can be left on disk and its execute +bits turned off if the link edit fails. However, if the linker +links the image in memory before writing the file to disk, it need +not touch the executable file (if it already exists) because the +link edit fails. Since both approaches are historical practice, a +conforming application shall rely on the exit status of +\fIfort77\fP, rather than on the existence or mode of the executable +file. +.LP +The \fB-g\fP and \fB-s\fP options are not specified as mutually-exclusive. +Historically these two options have been +mutually-exclusive, but because both are so loosely specified, it +seemed appropriate to leave their interaction unspecified. +.LP +The requirement that conforming applications specify compiler options +separately is to reserve the multi-character option name +space for vendor-specific compiler options, which are known to exist +in many historical implementations. Implementations are not +required to recognize, for example, \fB-gc\fP as if it were \fB-g\fP +\fB-c\fP; nor are they forbidden from doing so. The +SYNOPSIS shows all of the options separately to highlight this requirement +on applications. +.LP +Echoing filenames to standard error is considered a diagnostic message +because it would otherwise be difficult to associate an +error message with the erring file. They are described with "may" +to allow implementations to use other methods of identifying +files and to parallel the description in \fIc99\fP. +.SH FUTURE DIRECTIONS +.LP +A compilation system based on the ISO/IEC\ 1539:1990 standard (Fortran-90) +may be considered for a future version; it may +have a different utility name from \fIfort77\fP. +.SH SEE ALSO +.LP +\fIar\fP , \fIasa\fP , \fIc99\fP , \fIumask\fP() , the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, \fIexec\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/fuser.1p b/man1p/fuser.1p new file mode 100644 index 000000000..fcaf5a2df --- /dev/null +++ b/man1p/fuser.1p @@ -0,0 +1,200 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "FUSER" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" fuser +.SH NAME +fuser \- list process IDs of all processes that have one or more files +open +.SH SYNOPSIS +.LP +\fBfuser\fP \fB[\fP \fB-cfu\fP \fB]\fP \fIfile\fP \fB... \fP +.SH DESCRIPTION +.LP +The \fIfuser\fP utility shall write to standard output the process +IDs of processes running on the local system that have one +or more named files open. For block special devices, all processes +using any file on that device are listed. +.LP +The \fIfuser\fP utility shall write to standard error additional information +about the named files indicating how the file is +being used. +.LP +Any output for processes running on remote systems that have a named +file open is unspecified. +.LP +A user may need appropriate privilege to invoke the \fIfuser\fP utility. +.SH OPTIONS +.LP +The \fIfuser\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +The file is treated as a mount point and the utility shall report +on any files open in the file system. +.TP 7 +\fB-f\fP +The report shall be only for the named files. +.TP 7 +\fB-u\fP +The user name, in parentheses, associated with each process ID written +to standard output shall be written to standard +error. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname on which the file or file system is to be reported. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The user database. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIfuser\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIfuser\fP utility shall write the process ID for each process +using each file given as an operand to standard output in +the following format: +.sp +.RS +.nf + +\fB"%d", <\fP\fIprocess_id\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The \fIfuser\fP utility shall write diagnostic messages to standard +error. +.LP +The \fIfuser\fP utility also shall write the following to standard +error: +.IP " *" 3 +The pathname of each named file is written followed immediately by +a colon. +.LP +.IP " *" 3 +For each process ID written to standard output, the character \fB'c'\fP +shall be written to standard error if the process is +using the file as its current directory and the character \fB'r'\fP +shall be written to standard error if the process is using +the file as its root directory. Implementations may write other alphabetic +characters to indicate other uses of files. +.LP +.IP " *" 3 +When the \fB-u\fP option is specified, characters indicating the use +of the file shall be followed immediately by the user +name, in parentheses, corresponding to the process' real user ID. +If the user name cannot be resolved from the process' real user +ID, the process' real user ID shall be written instead of the user +name. +.LP +.LP +When standard output and standard error are directed to the same file, +the output shall be interleaved so that the filename +appears at the start of each line, followed by the process ID and +characters indicating the use of the file. Then, if the \fB-u\fP +option is specified, the user name or user ID for each process using +that file shall be written. +.LP +A <newline> shall be written to standard error after the last output +described above for each \fIfile\fP operand. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +The command: +.sp +.RS +.nf + +\fBfuser -fu . +\fP +.fi +.RE +.LP +writes to standard output the process IDs of processes that are using +the current directory and writes to standard error an +indication of how those processes are using the directory and the +user names associated with the processes that are using the +current directory. +.SH RATIONALE +.LP +The definition of the \fIfuser\fP utility follows existing practice. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +None. +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/gencat.1p b/man1p/gencat.1p new file mode 100644 index 000000000..243137c3d --- /dev/null +++ b/man1p/gencat.1p @@ -0,0 +1,237 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "GENCAT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" gencat +.SH NAME +gencat \- generate a formatted message catalog +.SH SYNOPSIS +.LP +\fBgencat\fP \fIcatfile msgfile\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIgencat\fP utility shall merge the message text source file +\fImsgfile\fP into a formatted message catalog +\fIcatfile\fP. The file \fIcatfile\fP shall be created if it does +not already exist. If \fIcatfile\fP does exist, its messages +shall be included in the new \fIcatfile\fP. If set and message numbers +collide, the new message text defined in \fImsgfile\fP +shall replace the old message text currently contained in \fIcatfile\fP. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIcatfile\fP +A pathname of the formatted message catalog. If \fB'-'\fP is specified, +standard output shall be used. The format of the +message catalog produced is unspecified. +.TP 7 +\fImsgfile\fP +A pathname of a message text source file. If \fB'-'\fP is specified +for an instance of \fImsgfile\fP, standard input shall +be used. The format of message text source files is defined in the +EXTENDED DESCRIPTION section. +.sp +.SH STDIN +.LP +The standard input shall not be used unless a \fImsgfile\fP operand +is specified as \fB'-'\fP . +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIgencat\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall not be used unless the \fIcatfile\fP operand +is specified as \fB'-'\fP . +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The content of a message text file shall be in the format defined +as follows. Note that the fields of a message text source line +are separated by a single <blank>. Any other <blank>s are considered +to be part of the subsequent field. +.TP 7 +\fB$set\ \fP \fIn\ comment\fP +.sp +This line specifies the set identifier of the following messages until +the next \fB$set\fP or end-of-file appears. The \fIn\fP +denotes the set identifier, which is defined as a number in the range +[1, {NL_SETMAX}] (see the \fI<limits.h>\fP header defined in the Base +Definitions volume of +IEEE\ Std\ 1003.1-2001). The application shall ensure that set identifiers +are presented in ascending order within a single +source file, but need not be contiguous. Any string following the +set identifier shall be treated as a comment. If no \fB$set\fP +directive is specified in a message text source file, all messages +shall be located in an implementation-defined default message +set NL_SETD (see the \fI<nl_types.h>\fP header defined in the Base +Definitions +volume of IEEE\ Std\ 1003.1-2001). +.TP 7 +\fB$delset\ \fP \fIn\ comment\fP +.sp +This line deletes message set \fIn\fP from an existing message catalog. +The \fIn\fP denotes the set number [1, {NL_SETMAX}]. Any +string following the set number shall be treated as a comment. +.TP 7 +\fB$\ \fP \fIcomment\fP +A line beginning with \fB'$'\fP followed by a <blank> shall be treated +as a comment. +.TP 7 +\fIm\ message-text\fP +.sp +The \fIm\fP denotes the message identifier, which is defined as a +number in the range [1, {NL_MSGMAX}] (see the \fI<limits.h>\fP header). +The \fImessage-text\fP shall be stored in the message catalog +with the set identifier specified by the last \fB$set\fP directive, +and with message identifier \fIm\fP. If the +\fImessage-text\fP is empty, and a <blank> field separator is present, +an empty string shall be stored in the message +catalog. If a message source line has a message number, but neither +a field separator nor \fImessage-text\fP, the existing message +with that number (if any) shall be deleted from the catalog. The application +shall ensure that message identifiers are in ascending +order within a single set, but need not be contiguous. The application +shall ensure that the length of \fImessage-text\fP is in +the range [0, {NL_TEXTMAX}] (see the \fI<limits.h>\fP header). +.TP 7 +\fB$quote\ \fP \fIn\fP +This line specifies an optional quote character \fIc\fP, which can +be used to surround \fImessage-text\fP so that trailing +spaces or null (empty) messages are visible in a message source line. +By default, or if an empty \fB$quote\fP directive is +supplied, no quoting of \fImessage-text\fP shall be recognized. +.sp +.LP +Empty lines in a message text source file shall be ignored. The effects +of lines starting with any character other than those +defined above are implementation-defined. +.LP +Text strings can contain the special characters and escape sequences +defined in the following table: +.TS C +center; l l l. +\fBDescription\fP \fBSymbol\fP \fBSequence\fP +<newline> NL(LF) \\n +Horizontal-tab HT \\t +<vertical-tab> VT \\v +<backspace> BS \\b +<carriage-return> CR \\r +<form-feed> FF \\f +Backslash \fB\\\fP \\\\ +Bit pattern \fBddd\fP \\ddd +.TE +.LP +The escape sequence \fB"\\ddd"\fP consists of backslash followed by +one, two, or three octal digits, which shall be taken to +specify the value of the desired character. If the character following +a backslash is not one of those specified, the backslash +shall be ignored. +.LP +Backslash ( \fB'\\'\fP ) followed by a <newline> is also used to continue +a string on the following line. Thus, the +following two lines describe a single message string: +.sp +.RS +.nf + +\fB1 This line continues \\ +to the next line +\fP +.fi +.RE +.LP +which shall be equivalent to: +.sp +.RS +.nf + +\fB1 This line continues to the next line +\fP +.fi +.RE +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Message catalogs produced by \fIgencat\fP are binary encoded, meaning +that their portability cannot be guaranteed between +different types of machine. Thus, just as C programs need to be recompiled +for each type of machine, so message catalogs must be +recreated via \fIgencat\fP. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIiconv\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +\fI<limits.h>\fP, \fI<nl_types.h>\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/get.1p b/man1p/get.1p new file mode 100644 index 000000000..9d0d31b1b --- /dev/null +++ b/man1p/get.1p @@ -0,0 +1,737 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "GET" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" get +.SH NAME +get \- get a version of an SCCS file (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBget\fP \fB[\fP\fB-begkmnlLpst\fP\fB][\fP\fB-c\fP \fIcutoff\fP\fB][\fP\fB-i\fP +\fIlist\fP\fB][\fP\fB-r\fP \fISID\fP\fB][\fP\fB-x\fP \fIlist\fP\fB]\fP +\fIfile\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIget\fP utility shall generate a text file from each named SCCS +\fIfile\fP according to the specifications given by its +options. +.LP +The generated text shall normally be written into a file called the +\fBg-file\fP whose name is derived from the SCCS filename +by simply removing the leading \fB"s."\fP . +.SH OPTIONS +.LP +The \fIget\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-r\ \fP \fISID\fP +Indicate the SCCS Identification String (SID) of the version (delta) +of an SCCS file to be retrieved. The table shows, for the +most useful cases, what version of an SCCS file is retrieved (as well +as the SID of the version to be eventually created by \fIdelta\fP +if the \fB-e\fP option is also used), as a function of the SID specified. +.TP 7 +\fB-c\ \fP \fIcutoff\fP +Indicate the \fIcutoff\fP date-time, in the form: +.sp +.RS +.nf + +\fIYY\fP\fB[\fP\fIMM\fP\fB[\fP\fIDD\fP\fB[\fP\fIHH\fP\fB[\fP\fIMM\fP\fB[\fP\fISS\fP\fB]]]]]\fP +.fi +.RE +.LP +For the \fIYY\fP component, values in the range [69,99] shall refer +to years 1969 to 1999 inclusive, and values in the range +[00,68] shall refer to years 2000 to 2068 inclusive. +.TP 7 +\fBNote:\fP +.RS +It is expected that in a future version of IEEE\ Std\ 1003.1-2001 +the default century inferred from a 2-digit year will +change. (This would apply to all commands accepting a 2-digit year +as input.) +.RE +.sp +.LP +No changes (deltas) to the SCCS file that were created after the specified +\fIcutoff\fP date-time shall be included in the +generated text file. Units omitted from the date-time default to their +maximum possible values; for example, \fB-c\fP 7502 is +equivalent to \fB-c\fP 750228235959. +.LP +Any number of non-numeric characters may separate the various 2-digit +pieces of the \fIcutoff\fP date-time. This feature allows +the user to specify a \fIcutoff\fP date in the form: \fB-c\fP "77/2/2\ 9:22:25". +.TP 7 +\fB-e\fP +Indicate that the \fIget\fP is for the purpose of editing or making +a change (delta) to the SCCS file via a subsequent use of +\fIdelta\fP. The \fB-e\fP option used in a \fIget\fP for a particular +version (SID) of the +SCCS file shall prevent further \fIget\fP commands from editing on +the same SID until \fIdelta\fP is executed or the \fBj\fP (joint edit) +flag is set in the SCCS file. Concurrent use of +\fIget\fP \fB-e\fP for different SIDs is always allowed. +.LP +If the \fBg-file\fP generated by \fIget\fP with a \fB-e\fP option +is accidentally ruined in the process of editing, it may be +regenerated by re-executing the \fIget\fP command with the \fB-k\fP +option in place of the \fB-e\fP option. +.LP +SCCS file protection specified via the ceiling, floor, and authorized +user list stored in the SCCS file shall be enforced when +the \fB-e\fP option is used. +.TP 7 +\fB-b\fP +Use with the \fB-e\fP option to indicate that the new delta should +have an SID in a new branch as shown in the table below. +This option shall be ignored if the \fBb\fP flag is not present in +the file or if the retrieved delta is not a leaf delta. (A leaf +delta is one that has no successors on the SCCS file tree.) +.TP 7 +\fBNote:\fP +.RS +A branch delta may always be created from a non-leaf delta. +.RE +.sp +.TP 7 +\fB-i\ \fP \fIlist\fP +Indicate a \fIlist\fP of deltas to be included (forced to be applied) +in the creation of the generated file. The \fIlist\fP +has the following syntax: +.sp +.RS +.nf + +\fB<list> ::= <range> | <list> , <range> +<range> ::= SID | SID - SID +\fP +.fi +.RE +.LP +SID, the SCCS Identification of a delta, may be in any form shown +in the "SID Specified" column of the table in the EXTENDED +DESCRIPTION section, except that the result of supplying a partial +SID is unspecified. A diagnostic message shall be written if the +first SID in the range is not an ancestor of the second SID in the +range. +.TP 7 +\fB-x\ \fP \fIlist\fP +Indicate a \fIlist\fP of deltas to be excluded (forced not to be applied) +in the creation of the generated file. See the +\fB-i\fP option for the \fIlist\fP format. +.TP 7 +\fB-k\fP +Suppress replacement of identification keywords (see below) in the +retrieved text by their value. The \fB-k\fP option shall be +implied by the \fB-e\fP option. +.TP 7 +\fB-l\fP +Write a delta summary into an \fBl-file\fP. +.TP 7 +\fB-L\fP +Write a delta summary to standard output. All informative output that +normally is written to standard output shall be written +to standard error instead, unless the \fB-s\fP option is used, in +which case it shall be suppressed. +.TP 7 +\fB-p\fP +Write the text retrieved from the SCCS file to the standard output. +No \fBg-file\fP shall be created. All informative output +that normally goes to the standard output shall go to standard error +instead, unless the \fB-s\fP option is used, in which case it +shall disappear. +.TP 7 +\fB-s\fP +Suppress all informative output normally written to standard output. +However, fatal error messages (which shall always be +written to the standard error) shall remain unaffected. +.TP 7 +\fB-m\fP +Precede each text line retrieved from the SCCS file by the SID of +the delta that inserted the text line in the SCCS file. The +format shall be: +.sp +.RS +.nf + +\fB"%s\\t%s", <\fP\fISID\fP\fB>, <\fP\fItext line\fP\fB> +\fP +.fi +.RE +.TP 7 +\fB-n\fP +Precede each generated text line with the %\fBM\fP% identification +keyword value (see below). The format shall be: +.sp +.RS +.nf + +\fB"%s\\t%s", <\fP\fI%M% value\fP\fB>, <\fP\fItext line\fP\fB> +\fP +.fi +.RE +.LP +When both the \fB-m\fP and \fB-n\fP options are used, the <\fItext\ line\fP> +shall be replaced by the \fB-m\fP +option-generated format. +.TP 7 +\fB-g\fP +Suppress the actual retrieval of text from the SCCS file. It is primarily +used to generate an \fBl-file\fP, or to verify the +existence of a particular SID. +.TP 7 +\fB-t\fP +Use to access the most recently created (top) delta in a given release +(for example, \fB-r 1\fP), or release and level (for +example, \fB-r 1.2\fP). +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file or a directory. If \fIfile\fP +is a directory, the \fIget\fP utility shall behave as +though each file in the directory were specified as a named file, +except that non-SCCS files (last component of the pathname does +not begin with \fBs.\fP) and unreadable files shall be silently ignored. +.LP +If exactly one \fIfile\fP operand appears, and it is \fB'-'\fP , the +standard input shall be read; each line of the standard +input is taken to be the name of an SCCS file to be processed. Non-SCCS +files and unreadable files shall be silently ignored. +.sp +.SH STDIN +.LP +The standard input shall be a text file used only if the \fIfile\fP +operand is specified as \fB'-'\fP . Each line of the +text file shall be interpreted as an SCCS pathname. +.SH INPUT FILES +.LP +The SCCS files shall be files of an unspecified format. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIget\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error, +and informative messages written to standard output (or standard error, +if the \fB-p\fP option is used). +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone in which the times and dates written in the +SCCS file are evaluated. If the \fITZ\fP variable is unset +or NULL, an unspecified system default timezone is used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +For each file processed, \fIget\fP shall write to standard output +the SID being accessed and the number of lines retrieved from +the SCCS file, in the following format: +.sp +.RS +.nf + +\fB"%s\\n%d lines\\n", <\fP\fISID\fP\fB>, <\fP\fInumber of lines\fP\fB> +\fP +.fi +.RE +.LP +If the \fB-e\fP option is used, the SID of the delta to be made shall +appear after the SID accessed and before the number of +lines generated, in the POSIX locale: +.sp +.RS +.nf + +\fB"%s\\nnew delta %s\\n%d lines\\n", <\fP\fISID accessed\fP\fB>, + <\fP\fISID to be made\fP\fB>, <\fP\fInumber of lines\fP\fB> +\fP +.fi +.RE +.LP +If there is more than one named file or if a directory or standard +input is named, each pathname shall be written before each of +the lines shown in one of the preceding formats: +.sp +.RS +.nf + +\fB"\\n%s:\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +If the \fB-L\fP option is used, a delta summary shall be written following +the format specified below for \fBl-files\fP. +.LP +If the \fB-i\fP option is used, included deltas shall be listed following +the notation, in the POSIX locale: +.sp +.RS +.nf + +\fB"Included:\\n" +\fP +.fi +.RE +.LP +If the \fB-x\fP option is used, excluded deltas shall be listed following +the notation, in the POSIX locale: +.sp +.RS +.nf + +\fB"Excluded:\\n" +\fP +.fi +.RE +.LP +If the \fB-p\fP or \fB-L\fP options are specified, the standard output +shall consist of the text retrieved from the SCCS +file. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages, except +if the \fB-p\fP or \fB-L\fP options are specified, it +shall include all informative messages normally sent to standard output. +.SH OUTPUT FILES +.LP +Several auxiliary files may be created by \fIget\fP. These files are +known generically as the \fBg-file\fP, \fBl-file\fP, +\fBp-file\fP, and \fBz-file\fP. The letter before the hyphen is called +the \fItag\fP. An auxiliary filename shall be formed from +the SCCS filename: the application shall ensure that the last component +of all SCCS filenames is of the form \fBs.\fP +\fImodule-name\fP; the auxiliary files shall be named by replacing +the leading \fBs\fP with the tag. The \fBg-file\fP shall be +an exception to this scheme: the \fBg-file\fP is named by removing +the \fBs.\fP prefix. For example, for \fBs.xyz.c\fP, the +auxiliary filenames would be \fBxyz.c\fP, \fBl.xyz.c\fP, \fBp.xyz.c\fP, +and \fBz.xyz.c\fP, respectively. +.LP +The \fBg-file\fP, which contains the generated text, shall be created +in the current directory (unless the \fB-p\fP option is +used). A \fBg-file\fP shall be created in all cases, whether or not +any lines of text were generated by the \fIget\fP. It shall +be owned by the real user. If the \fB-k\fP option is used or implied, +the \fBg-file\fP shall be writable by the owner only +(read-only for everyone else); otherwise, it shall be read-only. Only +the real user need have write permission in the current +directory. +.LP +The \fBl-file\fP shall contain a table showing which deltas were applied +in generating the retrieved text. The \fBl-file\fP +shall be created in the current directory if the \fB-l\fP option is +used; it shall be read-only and it is owned by the real user. +Only the real user need have write permission in the current directory. +.LP +Lines in the \fBl-file\fP shall have the following format: +.sp +.RS +.nf + +\fB"%c%c%c %s\\t%s %s\\n", <\fP\fIcode1\fP\fB>, <\fP\fIcode2\fP\fB>, <\fP\fIcode3\fP\fB>, + <\fP\fISID\fP\fB>, <\fP\fIdate-time\fP\fB>, <\fP\fIlogin\fP\fB> +\fP +.fi +.RE +.LP +where the entries are: +.TP 7 +<\fIcode1\fP> +A <space> if the delta was applied; \fB'*'\fP otherwise. +.TP 7 +<\fIcode2\fP> +A <space> if the delta was applied or was not applied and ignored; +\fB'*'\fP if the delta was not applied and was not +ignored. +.TP 7 +<\fIcode3\fP> +A character indicating a special reason why the delta was or was not +applied: +.TP 7 +\fBI\fP +.RS +Included. +.RE +.TP 7 +\fBX\fP +.RS +Excluded. +.RE +.TP 7 +\fBC\fP +.RS +Cut off (by a \fB-c\fP option). +.RE +.sp +.TP 7 +<\fIdate-time\fP> +Date and time (using the format of the \fIdate\fP utility's \fB%y\fP +/ \fB%m\fP / +\fB%d\fP \fB%T\fP conversion specification format) of creation. +.TP 7 +<\fIlogin\fP> +Login name of person who created \fIdelta\fP. +.sp +.LP +The comments and MR data shall follow on subsequent lines, indented +one <tab>. A blank line shall terminate each +entry. +.LP +The \fBp-file\fP shall be used to pass information resulting from +a \fIget\fP with a \fB-e\fP option along to \fIdelta\fP. Its contents +shall also be used to prevent a subsequent execution of \fIget\fP +with a +\fB-e\fP option for the same SID until \fIdelta\fP is executed or +the joint edit flag, +\fBj\fP, is set in the SCCS file. The \fBp-file\fP shall be created +in the directory containing the SCCS file and the application +shall ensure that the effective user has write permission in that +directory. It shall be writable by owner only, and owned by the +effective user. Each line in the \fBp-file\fP shall have the following +format: +.sp +.RS +.nf + +\fB"%s %s %s %s%s%s\\n", <\fP\fIg-file SID\fP\fB>, + <\fP\fISID of new delta\fP\fB>, <\fP\fIlogin-name of real user\fP\fB>, + <\fP\fIdate-time\fP\fB>, <\fP\fIi-value\fP\fB>, <\fP\fIx-value\fP\fB> +\fP +.fi +.RE +.LP +where <\fIi-value\fP> uses the format \fB""\fP if no \fB-i\fP option +was specified, and shall use the format: +.sp +.RS +.nf + +\fB" -i%s", <-i option\fP \fIoption-argument\fP\fB> +\fP +.fi +.RE +.LP +if a \fB-i\fP option was specified and <\fIx-value\fP> uses the format +\fB""\fP if no \fB-x\fP option was specified, +and shall use the format: +.sp +.RS +.nf + +\fB" -x%s", <-x option\fP \fIoption-argument\fP\fB> +\fP +.fi +.RE +.LP +if a \fB-x\fP option was specified. There can be an arbitrary number +of lines in the \fBp-file\fP at any time; no two lines +shall have the same new delta SID. +.LP +The \fBz-file\fP shall serve as a lock-out mechanism against simultaneous +updates. Its contents shall be the binary process ID +of the command (that is, \fIget\fP) that created it. The \fBz-file\fP +shall be created in the directory containing the SCCS file +for the duration of \fIget\fP. The same protection restrictions as +those for the \fBp-file\fP shall apply for the \fBz-file\fP. +The \fBz-file\fP shall be created read-only. +.br +.SH EXTENDED DESCRIPTION +.TS C +center;c1 s1 s1 s1 s. +\fBDetermination of SCCS Identification String\fP +.T& + l1 l1 lw(22)1 l1 l. +\fBSID*\fP \fB-b Keyletter\fP T{ +.na +\fBOther\fP +.ad +T} \fBSID\fP \fBSID of Delta\fP +\fBSpecified\fP \fBUsed&\fP T{ +.na +\fBConditions\fP +.ad +T} \fBRetrieved\fP \fBto be Created\fP +none&& no T{ +.na +R defaults to mR +.ad +T} mR.mL mR.(mL+1) +none&& yes T{ +.na +R defaults to mR +.ad +T} mR.mL mR.mL.(mB+1).1 +R no T{ +.na +R > mR +.ad +T} mR.mL R.1*** +R no T{ +.na +R = mR +.ad +T} mR.mL mR.(mL+1) +R yes T{ +.na +R > mR +.ad +T} mR.mL mR.mL.(mB+1).1 +R yes T{ +.na +R = mR +.ad +T} mR.mL mR.mL.(mB+1).1 +R - T{ +.na +R < mR and R does not exist +.ad +T} hR.mL** hR.mL.(mB+1).1 +R - T{ +.na +Trunk successor in release > R and R exists +.ad +T} R.mL R.mL.(mB+1).1 +R.L no T{ +.na +No trunk successor +.ad +T} R.L R.(L+1) +R.L yes T{ +.na +No trunk successor +.ad +T} R.L R.L.(mB+1).1 +R.L - T{ +.na +Trunk successor in release >= R +.ad +T} R.L R.L.(mB+1).1 +R.L.B no T{ +.na +No branch successor +.ad +T} R.L.B.mS R.L.B.(mS+1) +R.L.B yes T{ +.na +No branch successor +.ad +T} R.L.B.mS R.L.(mB+1).1 +R.L.B.S no T{ +.na +No branch successor +.ad +T} R.L.B.S R.L.B.(S+1) +R.L.B.S yes T{ +.na +No branch successor +.ad +T} R.L.B.S R.L.(mB+1).1 +R.L.B.S - T{ +.na +Branch successor +.ad +T} R.L.B.S R.L.(mB+1).1 +.TE +.TP 7 +* +R, L, B, and S are the release, level, branch, and sequence components +of the SID, respectively; m means maximum. Thus, for +example, R.mL means "the maximum level number within release R''; +R.L.(mB+1).1 means "the first sequence number on the new branch +(that is, maximum branch number plus one) of level L within release +R". Note that if the SID specified is of the form R.L, R.L.B, +or R.L.B.S, each of the specified components shall exist. +.TP 7 +** +hR is the highest existing release that is lower than the specified, +nonexistent, release R. +.TP 7 +*** +This is used to force creation of the first delta in a new release. +.TP 7 +& +The \fB-b\fP option is effective only if the \fBb\fP flag is present +in the file. An entry of \fB'-'\fP means +"irrelevant". +.TP 7 +&& +This case applies if the \fBd\fP (default SID) flag is not present +in the file. If the \fBd\fP flag is present in the file, +then the SID obtained from the \fBd\fP flag is interpreted as if it +had been specified on the command line. Thus, one of the other +cases in this table applies. +.sp +.SS System Date and Time +.LP +When a \fBg-file\fP is generated, the creation time of deltas in the +SCCS file may be taken into account. If any of these times +are apparently in the future, the behavior is unspecified. +.SS Identification Keywords +.LP +Identifying information shall be inserted into the text retrieved +from the SCCS file by replacing identification keywords with +their value wherever they occur. The following keywords may be used +in the text stored in an SCCS file: +.TP 7 +%\fBM\fP% +Module name: either the value of the \fBm\fP flag in the file, or +if absent, the name of the SCCS file with the leading +\fBs.\fP removed. +.TP 7 +%\fBI\fP% +SCCS identification (SID) (%\fBR\fP%.%\fBL\fP% or %\fBR\fP%.%\fBL\fP%.%\fBB\fP%.%\fBS\fP%) +of the retrieved text. +.TP 7 +%\fBR\fP% +Release. +.TP 7 +%\fBL\fP% +Level. +.TP 7 +%\fBB\fP% +Branch. +.TP 7 +%\fBS\fP% +Sequence. +.TP 7 +%\fBD\fP% +Current date (\fIYY\fP/\fIMM\fP/\fIDD\fP). +.TP 7 +%\fBH\fP% +Current date (\fIMM\fP/\fIDD\fP/\fIYY\fP). +.TP 7 +%\fBT\fP% +Current time (\fIHH\fP:\fIMM\fP:\fISS\fP). +.TP 7 +%\fBE\fP% +Date newest applied delta was created (\fIYY\fP/\fIMM\fP/\fIDD\fP). +.TP 7 +%\fBG\fP% +Date newest applied delta was created (\fIMM\fP/\fIDD\fP/\fIYY\fP). +.TP 7 +%\fBU\fP% +Time newest applied delta was created (\fIHH\fP:\fIMM\fP:\fISS\fP). +.TP 7 +%\fBY\fP% +Module type: value of the \fBt\fP flag in the SCCS file. +.TP 7 +%\fBF\fP% +SCCS filename. +.TP 7 +%\fBP\fP% +SCCS absolute pathname. +.TP 7 +%\fBQ\fP% +The value of the \fBq\fP flag in the file. +.TP 7 +%\fBC\fP% +Current line number. This keyword is intended for identifying messages +output by the program, such as "this should not have +happened" type errors. It is not intended to be used on every line +to provide sequence numbers. +.TP 7 +%\fBZ\fP% +The four-character string \fB"@(#)"\fP recognizable by \fIwhat\fP. +.TP 7 +%\fBW\fP% +A shorthand notation for constructing \fIwhat\fP strings: +.sp +.RS +.nf + +\fB%W%=%Z%%M%<tab>%I% +\fP +.fi +.RE +.TP 7 +%\fBA\fP% +Another shorthand notation for constructing \fIwhat\fP strings: +.sp +.RS +.nf + +\fB%A%=%Z%%Y%%M%%I%%Z% +\fP +.fi +.RE +.sp +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Problems can arise if the system date and time have been modified +(for example, put forward and then back again, or +unsynchronized clocks across a network) and can also arise when different +values of the \fITZ\fP environment variable are +used. +.LP +Problems of a similar nature can also arise for the operation of the +\fIdelta\fP utility, +which compares the previous file body against the working file as +part of its normal operation. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +The \fB-lp\fP option may be withdrawn in a future version. +.SH SEE ALSO +.LP +\fIadmin\fP , \fIdelta\fP , \fIprs\fP , \fIwhat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/getconf.1p b/man1p/getconf.1p new file mode 100644 index 000000000..a1ce37e61 --- /dev/null +++ b/man1p/getconf.1p @@ -0,0 +1,459 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "GETCONF" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" getconf +.SH NAME +getconf \- get configuration values +.SH SYNOPSIS +.LP +\fBgetconf\fP \fB[\fP \fB-v specification\fP \fB]\fP \fIsystem_var\fP\fB +.br +.sp +getconf\fP \fB[\fP \fB-v specification\fP \fB]\fP \fIpath_var pathname\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +In the first synopsis form, the \fIgetconf\fP utility shall write +to the standard output the value of the variable specified by +the \fIsystem_var\fP operand. +.LP +In the second synopsis form, the \fIgetconf\fP utility shall write +to the standard output the value of the variable specified +by the \fIpath_var\fP operand for the path specified by the \fIpathname\fP +operand. +.LP +The value of each configuration variable shall be determined as if +it were obtained by calling the function from which it is +defined to be available by this volume of IEEE\ Std\ 1003.1-2001 or +by the System Interfaces volume of +IEEE\ Std\ 1003.1-2001 (see the OPERANDS section). The value shall +reflect conditions in the current operating +environment. +.SH OPTIONS +.LP +The \fIgetconf\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-v\ \fP \fIspecification\fP +.sp +Indicate a specific specification and version for which configuration +variables shall be determined. If this option is not +specified, the values returned correspond to an implementation default +conforming compilation environment. +.LP +If the command: +.sp +.RS +.nf + +\fBgetconf _POSIX_V6_ILP32_OFF32 +\fP +.fi +.RE +.LP +does not write \fB"-1\\n"\fP or \fB"undefined\\n"\fP to standard output, +then commands of the form: +.sp +.RS +.nf + +\fBgetconf -v POSIX_V6_ILP32_OFF32 ... +\fP +.fi +.RE +.LP +determine values for configuration variables corresponding to the +POSIX_V6_ILP32_OFF32 compilation environment specified in \fIc99\fP +, the EXTENDED DESCRIPTION. +.LP +If the command: +.sp +.RS +.nf + +\fBgetconf _POSIX_V6_ILP32_OFFBIG +\fP +.fi +.RE +.LP +does not write \fB"-1\\n"\fP or \fB"undefined\\n"\fP to standard output, +then commands of the form: +.sp +.RS +.nf + +\fBgetconf -v POSIX_V6_ILP32_OFFBIG ... +\fP +.fi +.RE +.LP +determine values for configuration variables corresponding to the +POSIX_V6_ILP32_OFFBIG compilation environment specified in \fIc99\fP +, the EXTENDED DESCRIPTION. +.LP +If the command: +.sp +.RS +.nf + +\fBgetconf _POSIX_V6_LP64_OFF64 +\fP +.fi +.RE +.LP +does not write \fB"-1\\n"\fP or \fB"undefined\\n"\fP to standard output, +then commands of the form: +.sp +.RS +.nf + +\fBgetconf -v POSIX_V6_LP64_OFF64 ... +\fP +.fi +.RE +.LP +determine values for configuration variables corresponding to the +POSIX_V6_LP64_OFF64 compilation environment specified in \fIc99\fP +, the EXTENDED DESCRIPTION. +.LP +If the command: +.sp +.RS +.nf + +\fBgetconf _POSIX_V6_LPBIG_OFFBIG +\fP +.fi +.RE +.LP +does not write \fB"-1\\n"\fP or \fB"undefined\\n"\fP to standard output, +then commands of the form: +.sp +.RS +.nf + +\fBgetconf -v POSIX_V6_LPBIG_OFFBIG ... +\fP +.fi +.RE +.LP +determine values for configuration variables corresponding to the +POSIX_V6_LPBIG_OFFBIG compilation environment specified in \fIc99\fP +, the EXTENDED DESCRIPTION. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIpath_var\fP +A name of a configuration variable. All of the variables in the Variable +column of the table in the DESCRIPTION of the \fIfpathconf\fP() function +defined in the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, without the enclosing braces, shall be supported. +The implementation may add other local +variables. +.TP 7 +\fIpathname\fP +A pathname for which the variable specified by \fIpath_var\fP is to +be determined. +.TP 7 +\fIsystem_var\fP +A name of a configuration variable. All of the following variables +shall be supported: +.RS +.IP " *" 3 +The names in the Variable column of the table in the DESCRIPTION of +the \fIsysconf\fP() +function in the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +except for the entries corresponding to _SC_CLK_TCK, +_SC_GETGR_R_SIZE_MAX, and _SC_GETPW_R_SIZE_MAX, without the enclosing +braces. +.LP +For compatibility with earlier versions, the following variable names +shall also be supported: +.sp +.RS +.nf + +POSIX2_C_BIND +POSIX2_C_DEV +POSIX2_CHAR_TERM +POSIX2_FORT_DEV +POSIX2_FORT_RUN +POSIX2_LOCALEDEF +POSIX2_SW_DEV +POSIX2_UPE +POSIX2_VERSION +.fi +.RE +.LP +and shall be equivalent to the same name prefixed with an underscore. +This requirement may be removed in a future version. +.LP +.IP " *" 3 +The names of the symbolic constants used as the \fIname\fP argument +of the \fIconfstr\fP() function in the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, +without the _CS_ prefix. +.LP +.IP " *" 3 +The names of the symbolic constants listed under the headings ``Maximum +Values'' and ``Minimum Values'' in the description of +the \fI<limits.h>\fP header in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, without the enclosing braces. +.LP +For compatibility with earlier versions, the following variable names +shall also be supported: +.sp +.RS +.nf + +POSIX2_BC_BASE_MAX +POSIX2_BC_DIM_MAX +POSIX2_BC_SCALE_MAX +POSIX2_BC_STRING_MAX +POSIX2_COLL_WEIGHTS_MAX +POSIX2_EXPR_NEST_MAX +POSIX2_LINE_MAX +POSIX2_RE_DUP_MAX +.fi +.RE +.LP +and shall be equivalent to the same name prefixed with an underscore. +This requirement may be removed in a future version. +.LP +.RE +.LP +The implementation may add other local values. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIgetconf\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If the specified variable is defined on the system and its value is +described to be available from the \fIconfstr\fP() function defined +in the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, its value shall be written in the following +format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +Otherwise, if the specified variable is defined on the system, its +value shall be written in the following format: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +If the specified variable is valid, but is undefined on the system, +\fIgetconf\fP shall write using the following format: +.sp +.RS +.nf + +\fB"undefined\\n" +\fP +.fi +.RE +.LP +If the variable name is invalid or an error occurs, nothing shall +be written to standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The specified variable is valid and information about its current +state was written successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +The following example illustrates the value of {NGROUPS_MAX}: +.sp +.RS +.nf + +\fBgetconf NGROUPS_MAX +\fP +.fi +.RE +.LP +The following example illustrates the value of {NAME_MAX} for a specific +directory: +.sp +.RS +.nf + +\fBgetconf NAME_MAX /usr +\fP +.fi +.RE +.LP +The following example shows how to deal more carefully with results +that might be unspecified: +.sp +.RS +.nf + +\fBif value=$(getconf PATH_MAX /usr); then + if [ "$value" = "undefined" ]; then + echo PATH_MAX in /usr is infinite. + else + echo PATH_MAX in /usr is $value. + fi +else + echo Error in getconf. +fi +\fP +.fi +.RE +.LP +Note that: +.sp +.RS +.nf + +\fBsysconf(_SC_POSIX_C_BIND); +\fP +.fi +.RE +.LP +and: +.sp +.RS +.nf + +\fBsystem("getconf POSIX2_C_BIND"); +\fP +.fi +.RE +.LP +in a C program could give different answers. The \fIsysconf\fP() call +supplies a value +that corresponds to the conditions when the program was either compiled +or executed, depending on the implementation; the \fIsystem\fP() call +to \fIgetconf\fP always supplies a value corresponding to conditions +when the +program is executed. +.SH RATIONALE +.LP +The original need for this utility, and for the \fIconfstr\fP() function, +was to +provide a way of finding the configuration-defined default value for +the \fIPATH\fP environment variable. Since \fIPATH\fP can be +modified by the user to include directories that could contain utilities +replacing the standard utilities, shell scripts need a way +to determine the system-supplied \fIPATH\fP environment variable value +that contains the correct search path for the standard +utilities. It was later suggested that access to the other variables +described in this volume of IEEE\ Std\ 1003.1-2001 +could also be useful to applications. +.LP +This functionality of \fIgetconf\fP would not be adequately subsumed +by another command such as: +.sp +.RS +.nf + +\fBgrep\fP \fIvar\fP \fB/etc/conf +\fP +.fi +.RE +.LP +because such a strategy would provide correct values for neither those +variables that can vary at runtime, nor those that can +vary depending on the path. +.LP +Early proposal versions of \fIgetconf\fP specified exit status 1 when +the specified variable was valid, but not defined on the +system. The output string \fB"undefined"\fP is now used to specify +this case with exit code 0 because so many things depend on +an exit code of zero when an invoked utility is successful. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +\fI<limits.h>\fP, the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIconfstr\fP(), \fIpathconf\fP(), \fIsysconf\fP(), \fIsystem\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/getopts.1p b/man1p/getopts.1p new file mode 100644 index 000000000..8c96c5730 --- /dev/null +++ b/man1p/getopts.1p @@ -0,0 +1,349 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "GETOPTS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" getopts +.SH NAME +getopts \- parse utility options +.SH SYNOPSIS +.LP +\fBgetopts\fP \fIoptstring name\fP \fB[\fP\fIarg\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIgetopts\fP utility shall retrieve options and option-arguments +from a list of parameters. It shall support the Utility +Syntax Guidelines 3 to 10, inclusive, described in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +Each time it is invoked, the \fIgetopts\fP utility shall place the +value of the next option in the shell variable specified by +the \fIname\fP operand and the index of the next argument to be processed +in the shell variable \fIOPTIND .\fP Whenever the shell +is invoked, \fIOPTIND\fP shall be initialized to 1. +.LP +When the option requires an option-argument, the \fIgetopts\fP utility +shall place it in the shell variable \fIOPTARG .\fP If +no option was found, or if the option that was found does not have +an option-argument, \fIOPTARG\fP shall be unset. +.LP +If an option character not contained in the \fIoptstring\fP operand +is found where an option character is expected, the shell +variable specified by \fIname\fP shall be set to the question-mark +( \fB'?'\fP ) character. In this case, if the first +character in \fIoptstring\fP is a colon ( \fB':'\fP ), the shell variable +\fIOPTARG\fP shall be set to the option character +found, but no output shall be written to standard error; otherwise, +the shell variable \fIOPTARG\fP shall be unset and a +diagnostic message shall be written to standard error. This condition +shall be considered to be an error detected in the way +arguments were presented to the invoking application, but shall not +be an error in \fIgetopts\fP processing. +.LP +If an option-argument is missing: +.IP " *" 3 +If the first character of \fIoptstring\fP is a colon, the shell variable +specified by \fIname\fP shall be set to the colon +character and the shell variable \fIOPTARG\fP shall be set to the +option character found. +.LP +.IP " *" 3 +Otherwise, the shell variable specified by \fIname\fP shall be set +to the question-mark character, the shell variable +\fIOPTARG\fP shall be unset, and a diagnostic message shall be written +to standard error. This condition shall be considered to be +an error detected in the way arguments were presented to the invoking +application, but shall not be an error in \fIgetopts\fP +processing; a diagnostic message shall be written as stated, but the +exit status shall be zero. +.LP +.LP +When the end of options is encountered, the \fIgetopts\fP utility +shall exit with a return value greater than zero; the shell +variable \fIOPTIND\fP shall be set to the index of the first non-option-argument, +where the first \fB"--"\fP argument is +considered to be an option-argument if there are no other non-option-arguments +appearing before it, or the value \fB"$#"\fP +1 +if there are no non-option-arguments; the \fIname\fP variable shall +be set to the question-mark character. Any of the following +shall identify the end of options: the special option \fB"--"\fP , +finding an argument that does not begin with a \fB'-'\fP , +or encountering an error. +.LP +The shell variables \fIOPTIND\fP and \fIOPTARG\fP shall be local to +the caller of \fIgetopts\fP and shall not be exported by +default. +.LP +The shell variable specified by the \fIname\fP operand, \fIOPTIND +,\fP and \fIOPTARG\fP shall affect the current shell +execution environment; see \fIShell Execution Environment\fP . +.LP +If the application sets \fIOPTIND\fP to the value 1, a new set of +parameters can be used: either the current positional +parameters or new \fIarg\fP values. Any other attempt to invoke \fIgetopts\fP +multiple times in a single shell execution +environment with parameters (positional parameters or \fIarg\fP operands) +that are not the same in all invocations, or with an +\fIOPTIND\fP value modified to be a value other than 1, produces unspecified +results. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIoptstring\fP +A string containing the option characters recognized by the utility +invoking \fIgetopts\fP. If a character is followed by a +colon, the option shall be expected to have an argument, which should +be supplied as a separate argument. Applications should +specify an option character and its option-argument as separate arguments, +but \fIgetopts\fP shall interpret the characters +following an option character requiring arguments as an argument whether +or not this is done. An explicit null option-argument need +not be recognized if it is not supplied as a separate argument when +\fIgetopts\fP is invoked. (See also the \fIgetopt\fP() function defined +in the System Interfaces volume of IEEE\ Std\ 1003.1-2001.) +The characters question-mark and colon shall not be used as option +characters by an application. The use of other option characters +that are not alphanumeric produces unspecified results. If the option-argument +is not supplied as a separate argument from the +option character, the value in \fIOPTARG\fP shall be stripped of the +option character and the \fB'-'\fP . The first character +in \fIoptstring\fP determines how \fIgetopts\fP behaves if an option +character is not known or an option-argument is +missing. +.TP 7 +\fIname\fP +The name of a shell variable that shall be set by the \fIgetopts\fP +utility to the option character that was found. +.sp +.LP +The \fIgetopts\fP utility by default shall parse positional parameters +passed to the invoking shell procedure. If \fIarg\fPs +are given, they shall be parsed instead of the positional parameters. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIgetopts\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIOPTIND\fP +This variable shall be used by the \fIgetopts\fP utility as the index +of the next argument to be processed. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +Whenever an error is detected and the first character in the \fIoptstring\fP +operand is not a colon ( \fB':'\fP ), a +diagnostic message shall be written to standard error with the following +information in an unspecified format: +.IP " *" 3 +The invoking program name shall be identified in the message. The +invoking program name shall be the value of the shell special +parameter 0 (see \fISpecial Parameters\fP ) at the time the \fIgetopts\fP +utility is +invoked. A name equivalent to: +.sp +.RS +.nf + +\fBbasename "$0" +\fP +.fi +.RE +.LP +may be used. +.LP +.IP " *" 3 +If an option is found that was not specified in \fIoptstring\fP, this +error is identified and the invalid option character +shall be identified in the message. +.LP +.IP " *" 3 +If an option requiring an option-argument is found, but an option-argument +is not found, this error shall be identified and the +invalid option character shall be identified in the message. +.LP +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +An option, specified or unspecified by \fIoptstring\fP, was found. +.TP 7 +>0 +The end of options was encountered or an error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since \fIgetopts\fP affects the current shell execution environment, +it is generally provided as a shell regular built-in. If +it is called in a subshell or separate utility execution environment, +such as one of the following: +.sp +.RS +.nf + +\fB(getopts abc value "$@") +nohup getopts ... +find . -exec getopts ... \\; +\fP +.fi +.RE +.LP +it does not affect the shell variables in the caller's environment. +.LP +Note that shell functions share \fIOPTIND\fP with the calling shell +even though the positional parameters are changed. If the +calling shell and any of its functions uses \fIgetopts\fP to parse +arguments, the results are unspecified. +.SH EXAMPLES +.LP +The following example script parses and displays its arguments: +.sp +.RS +.nf + +\fBaflag= +bflag= +while getopts ab: name +do + case $name in + a) aflag=1;; + b) bflag=1 + bval="$OPTARG";; + ?) printf "Usage: %s: [-a] [-b value] args\\n" $0 + exit 2;; + esac +done +if [ ! -z "$aflag" ]; then + printf "Option -a specified\\n" +fi +if [ ! -z "$bflag" ]; then + printf 'Option -b "%s" specified\\n' "$bval" +fi +shift $(($OPTIND - 1)) +printf "Remaining arguments are: %s\\n" "$*" +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fIgetopts\fP utility was chosen in preference to the System V +\fIgetopt\fP utility because \fIgetopts\fP handles +option-arguments containing <blank>s. +.LP +The \fIOPTARG\fP variable is not mentioned in the ENVIRONMENT VARIABLES +section because it does not affect the execution of +\fIgetopts\fP; it is one of the few "output-only" variables used by +the standard utilities. +.LP +The colon is not allowed as an option character because that is not +historical behavior, and it violates the Utility Syntax +Guidelines. The colon is now specified to behave as in the KornShell +version of the \fIgetopts\fP utility; when used as the first +character in the \fIoptstring\fP operand, it disables diagnostics +concerning missing option-arguments and unexpected option +characters. This replaces the use of the \fIOPTERR\fP variable that +was specified in an early proposal. +.LP +The formats of the diagnostic messages produced by the \fIgetopts\fP +utility and the \fIgetopt\fP() function are not fully specified because +implementations with superior +(``friendlier") formats objected to the formats used by some historical +implementations. The standard developers considered it +important that the information in the messages used be uniform between +\fIgetopts\fP and \fIgetopt\fP(). Exact duplication of the messages +might not be possible, particularly if a utility +is built on another system that has a different \fIgetopt\fP() function, +but the messages +must have specific information included so that the program name, +invalid option character, and type of error can be distinguished +by a user. +.LP +Only a rare application program intercepts a \fIgetopts\fP standard +error message and wants to parse it. Therefore, +implementations are free to choose the most usable messages they can +devise. The following formats are used by many historical +implementations: +.sp +.RS +.nf + +\fB"%s: illegal option -- %c\\n", <\fP\fIprogram name\fP\fB>, <\fP\fIoption character\fP\fB> +.sp + +"%s: option requires an argument -- %c\\n", <\fP\fIprogram name\fP\fB>, \\ + <\fP\fIoption character\fP\fB> +\fP +.fi +.RE +.LP +Historical shells with built-in versions of \fIgetopt\fP() or \fIgetopts\fP +have used +different formats, frequently not even indicating the option character +found in error. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Parameters\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIgetopt\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/grep.1p b/man1p/grep.1p new file mode 100644 index 000000000..5031592a3 --- /dev/null +++ b/man1p/grep.1p @@ -0,0 +1,450 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "GREP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" grep +.SH NAME +grep \- search a file for a pattern +.SH SYNOPSIS +.LP +\fBgrep\fP \fB[\fP\fB-E| -F\fP\fB][\fP\fB-c| -l| -q\fP\fB][\fP\fB-insvx\fP\fB]\fP +\fB-e\fP +\fIpattern_list... +.br +\fP \fB\ \ \ \ \ \ \fP \fI\fP\fB[\fP\fB-f\fP +\fIpattern_file\fP\fB]\fP\fB...\fP\fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +.sp +grep\fP \fB[\fP\fB-E| -F\fP\fB][\fP\fB-c| -l| -q\fP\fB][\fP\fB-insvx\fP\fB][\fP\fB-e\fP +\fIpattern_list\fP\fB]... +.br +\fP \fB\ \ \ \ \ \ \fP \fB\fP\fB-f\fP +\fIpattern_file\fP\fB...\fP\fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +.sp +grep\fP \fB[\fP\fB-E| -F\fP\fB][\fP\fB-c| -l| -q\fP\fB][\fP\fB-insvx\fP\fB]\fP +\fIpattern_list\fP\fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIgrep\fP utility shall search the input files, selecting lines +matching one or more patterns; the types of patterns are +controlled by the options specified. The patterns are specified by +the \fB-e\fP option, \fB-f\fP option, or the +\fIpattern_list\fP operand. The \fIpattern_list\fP's value shall consist +of one or more patterns separated by <newline>s; +the \fIpattern_file\fP's contents shall consist of one or more patterns +terminated by <newline>. By default, an input line +shall be selected if any pattern, treated as an entire basic regular +expression (BRE) as described in the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 9.3, Basic Regular Expressions, +matches any part of the line excluding the terminating <newline>; +a null BRE shall match every line. By default, each +selected input line shall be written to the standard output. +.LP +Regular expression matching shall be based on text lines. Since a +<newline> separates or terminates patterns (see the +\fB-e\fP and \fB-f\fP options below), regular expressions cannot contain +a <newline>. Similarly, since patterns are matched +against individual lines (excluding the terminating <newline>s) of +the input, there is no way for a pattern to match a +<newline> found in the input. +.SH OPTIONS +.LP +The \fIgrep\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-E\fP +Match using extended regular expressions. Treat each pattern specified +as an ERE, as described in the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 9.4, Extended Regular Expressions. +If any entire ERE pattern matches some part of an input line excluding +the terminating <newline>, the line shall be matched. +A null ERE shall match every line. +.TP 7 +\fB-F\fP +Match using fixed strings. Treat each pattern specified as a string +instead of a regular expression. If an input line contains +any of the patterns as a contiguous sequence of bytes, the line shall +be matched. A null string shall match every line. +.TP 7 +\fB-c\fP +Write only a count of selected lines to standard output. +.TP 7 +\fB-e\ \fP \fIpattern_list\fP +.sp +Specify one or more patterns to be used during the search for input. +The application shall ensure that patterns in +\fIpattern_list\fP are separated by a <newline>. A null pattern can +be specified by two adjacent <newline>s in +\fIpattern_list\fP. Unless the \fB-E\fP or \fB-F\fP option is also +specified, each pattern shall be treated as a BRE, as +described in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section +9.3, Basic Regular Expressions. Multiple \fB-e\fP and \fB-f\fP options +shall be accepted by the \fIgrep\fP utility. All of +the specified patterns shall be used when matching lines, but the +order of evaluation is unspecified. +.TP 7 +\fB-f\ \fP \fIpattern_file\fP +.sp +Read one or more patterns from the file named by the pathname \fIpattern_file\fP. +Patterns in \fIpattern_file\fP shall be +terminated by a <newline>. A null pattern can be specified by an empty +line in \fIpattern_file\fP. Unless the \fB-E\fP or +\fB-F\fP option is also specified, each pattern shall be treated as +a BRE, as described in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 9.3, Basic Regular Expressions. +.TP 7 +\fB-i\fP +Perform pattern matching in searches without regard to case; see the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 9.2, Regular Expression General Requirements. +.TP 7 +\fB-l\fP +(The letter ell.) Write only the names of files containing selected +lines to standard output. Pathnames shall be written once +per file searched. If the standard input is searched, a pathname of +\fB"(standard input)"\fP shall be written, in the POSIX +locale. In other locales, \fB"standard input"\fP may be replaced by +something more appropriate in those locales. +.TP 7 +\fB-n\fP +Precede each output line by its relative line number in the file, +each file starting at line 1. The line number counter shall +be reset for each file processed. +.TP 7 +\fB-q\fP +Quiet. Nothing shall be written to the standard output, regardless +of matching lines. Exit with zero status if an input line is +selected. +.TP 7 +\fB-s\fP +Suppress the error messages ordinarily written for nonexistent or +unreadable files. Other error messages shall not be +suppressed. +.TP 7 +\fB-v\fP +Select lines not matching any of the specified patterns. If the \fB-v\fP +option is not specified, selected lines shall be +those that match any of the specified patterns. +.TP 7 +\fB-x\fP +Consider only input lines that use all characters in the line excluding +the terminating <newline> to match an entire +fixed string or regular expression to be matching lines. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIpattern_list\fP +Specify one or more patterns to be used during the search for input. +This operand shall be treated as if it were specified as +\fB-e\fP \fIpattern_list\fP. +.TP 7 +\fIfile\fP +A pathname of a file to be searched for the patterns. If no \fIfile\fP +operands are specified, the standard input shall be +used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIgrep\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classes within regular +expressions. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If the \fB-l\fP option is in effect, and the \fB-q\fP option is not, +the following shall be written for each file containing +at least one selected input line: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +Otherwise, if more than one \fIfile\fP argument appears, and \fB-q\fP +is not specified, the \fIgrep\fP utility shall prefix +each output line by: +.sp +.RS +.nf + +\fB"%s:", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +The remainder of each output line shall depend on the other options +specified: +.IP " *" 3 +If the \fB-c\fP option is in effect, the remainder of each output +line shall contain: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fIcount\fP\fB> +\fP +.fi +.RE +.LP +.IP " *" 3 +Otherwise, if \fB-c\fP is not in effect and the \fB-n\fP option is +in effect, the following shall be written to standard +output: +.sp +.RS +.nf + +\fB"%d:", <\fP\fIline number\fP\fB> +\fP +.fi +.RE +.LP +.IP " *" 3 +Finally, the following shall be written to standard output: +.sp +.RS +.nf + +\fB"%s", <\fP\fIselected-line contents\fP\fB> +\fP +.fi +.RE +.LP +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +One or more lines were selected. +.TP 7 +\ 1 +No lines were selected. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If the \fB-q\fP option is specified, the exit status shall be zero +if an input line is selected, even if an error was detected. +Otherwise, default actions shall be performed. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Care should be taken when using characters in \fIpattern_list\fP that +may also be meaningful to the command interpreter. It is +safest to enclose the entire \fIpattern_list\fP argument in single +quotes: +.sp +.RS +.nf + +\fB'...' +\fP +.fi +.RE +.LP +The \fB-e\fP \fIpattern_list\fP option has the same effect as the +\fIpattern_list\fP operand, but is useful when +\fIpattern_list\fP begins with the hyphen delimiter. It is also useful +when it is more convenient to provide multiple patterns as +separate arguments. +.LP +Multiple \fB-e\fP and \fB-f\fP options are accepted and \fIgrep\fP +uses all of the patterns it is given while matching input +text lines. (Note that the order of evaluation is not specified. If +an implementation finds a null string as a pattern, it is +allowed to use that pattern first, matching every line, and effectively +ignore any other patterns.) +.LP +The \fB-q\fP option provides a means of easily determining whether +or not a pattern (or string) exists in a group of files. +When searching several files, it provides a performance improvement +(because it can quit as soon as it finds the first match) and +requires less care by the user in choosing the set of files to supply +as arguments (because it exits zero if it finds a match even +if \fIgrep\fP detected an access or read error on earlier \fIfile\fP +operands). +.SH EXAMPLES +.IP " 1." 4 +To find all uses of the word \fB"Posix"\fP (in any case) in file \fBtext.mm\fP +and write with line numbers: +.sp +.RS +.nf + +\fBgrep -i -n posix text.mm +\fP +.fi +.RE +.LP +.IP " 2." 4 +To find all empty lines in the standard input: +.sp +.RS +.nf + +\fBgrep ^$ +\fP +.fi +.RE +.LP +or: +.sp +.RS +.nf + +\fBgrep -v . +\fP +.fi +.RE +.LP +.IP " 3." 4 +Both of the following commands print all lines containing strings +\fB"abc"\fP or \fB"def"\fP or both: +.sp +.RS +.nf + +\fBgrep -E 'abc|def' +.sp + +grep -F 'abc +def' +\fP +.fi +.RE +.LP +.IP " 4." 4 +Both of the following commands print all lines matching exactly \fB"abc"\fP +or \fB"def"\fP : +.sp +.RS +.nf + +\fBgrep -E '^abc$|^def$' +.sp + +grep -F -x 'abc +def' +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +This \fIgrep\fP has been enhanced in an upwards-compatible way to +provide the exact functionality of the historical +\fIegrep\fP and \fIfgrep\fP commands as well. It was the clear intention +of the standard developers to consolidate the three +\fIgrep\fPs into a single command. +.LP +The old \fIegrep\fP and \fIfgrep\fP commands are likely to be supported +for many years to come as implementation extensions, +allowing historical applications to operate unmodified. +.LP +Historical implementations usually silently ignored all but one of +multiply-specified \fB-e\fP and \fB-f\fP options, but were +not consistent as to which specification was actually used. +.LP +The \fB-b\fP option was omitted from the OPTIONS section because block +numbers are implementation-defined. +.LP +The System V restriction on using \fB-\fP to mean standard input was +omitted. +.LP +A definition of action taken when given a null BRE or ERE is specified. +This is an error condition in some historical +implementations. +.LP +The \fB-l\fP option previously indicated that its use was undefined +when no files were explicitly named. This behavior was +historical and placed an unnecessary restriction on future implementations. +It has been removed. +.LP +The historical BSD \fIgrep\fP \fB-s\fP option practice is easily duplicated +by redirecting standard output to +\fB/dev/null\fP. The \fB-s\fP option required here is from System +V. +.LP +The \fB-x\fP option, historically available only with \fIfgrep\fP, +is available here for all of the non-obsolescent +versions. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIsed\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/hash.1p b/man1p/hash.1p new file mode 100644 index 000000000..4213d0525 --- /dev/null +++ b/man1p/hash.1p @@ -0,0 +1,184 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "HASH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" hash +.SH NAME +hash \- remember or report utility locations +.SH SYNOPSIS +.LP +\fBhash\fP \fB[\fP\fIutility\fP\fB...\fP\fB]\fP\fB +.br +.sp +hash -r \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIhash\fP utility shall affect the way the current shell environment +remembers the locations of utilities found as +described in \fICommand Search and Execution\fP . Depending on the +arguments +specified, it shall add utility locations to its list of remembered +locations or it shall purge the contents of the list. When no +arguments are specified, it shall report on the contents of the list. +.LP +Utilities provided as built-ins to the shell shall not be reported +by \fIhash\fP. +.SH OPTIONS +.LP +The \fIhash\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-r\fP +Forget all previously remembered utility locations. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIutility\fP +The name of a utility to be searched for and added to the list of +remembered locations. If \fIutility\fP contains one or more +slashes, the results are unspecified. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIhash\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the location of \fIutility\fP, as described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output of \fIhash\fP shall be used when no arguments +are specified. Its format is unspecified, but includes the +pathname of each utility in the list of remembered locations for the +current shell environment. This list shall consist of those +utilities named in previous \fIhash\fP invocations that have been +invoked, and may contain those invoked and found through the +normal command search process. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since \fIhash\fP affects the current shell execution environment, +it is always provided as a shell regular built-in. If it is +called in a separate utility execution environment, such as one of +the following: +.sp +.RS +.nf + +\fBnohup hash -r +find . -type f | xargs hash +\fP +.fi +.RE +.LP +it does not affect the command search process of the caller's environment. +.LP +The \fIhash\fP utility may be implemented as an alias-for example, +\fIalias\fP +\fB-t\ -\fP, in which case utilities found through normal command +search are not listed by the \fIhash\fP command. +.LP +The effects of \fIhash\fP \fB-r\fP can also be achieved portably by +resetting the value of \fIPATH ;\fP in the simplest form, +this can be: +.sp +.RS +.nf + +\fBPATH="$PATH" +\fP +.fi +.RE +.LP +The use of \fIhash\fP with \fIutility\fP names is unnecessary for +most applications, but may provide a performance improvement +on a few implementations; normally, the hashing process is included +by default. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fICommand Search and Execution\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/head.1p b/man1p/head.1p new file mode 100644 index 000000000..c9bb3d50e --- /dev/null +++ b/man1p/head.1p @@ -0,0 +1,176 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "HEAD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" head +.SH NAME +head \- copy the first part of files +.SH SYNOPSIS +.LP +\fBhead\fP \fB[\fP\fB-n\fP \fInumber\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIhead\fP utility shall copy its input files to the standard +output, ending the output for each file at a designated +point. +.LP +Copying shall end at the point in each input file indicated by the +\fB-n\fP \fInumber\fP option. The option-argument +\fInumber\fP shall be counted in units of lines. +.SH OPTIONS +.LP +The \fIhead\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-n\ \fP \fInumber\fP +The first \fInumber\fP lines of each input file shall be copied to +standard output. The application shall ensure that the +\fInumber\fP option-argument is a positive decimal integer. +.sp +.LP +When a file contains less than \fInumber\fP lines, it shall be copied +to standard output in its entirety. This shall not be an +error. +.LP +If no options are specified, \fIhead\fP shall act as if \fB-n 10\fP +had been specified. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If no \fIfile\fP operands are specified, +the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +Input files shall be text files, but the line length is not restricted +to {LINE_MAX} bytes. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIhead\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall contain designated portions of the input +files. +.LP +If multiple \fIfile\fP operands are specified, \fIhead\fP shall precede +the output for each with the header: +.sp +.RS +.nf + +\fB"\\n==> %s <==\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +except that the first header written shall not include the initial +<newline>. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The obsolescent \fB-\fP \fInumber\fP form is withdrawn in this version. +Applications should use the \fB-n\fP \fInumber\fP +option. +.SH EXAMPLES +.LP +To write the first ten lines of all files (except those with a leading +period) in the directory: +.sp +.RS +.nf + +\fBhead * +\fP +.fi +.RE +.SH RATIONALE +.LP +Although it is possible to simulate \fIhead\fP with \fIsed\fP 10q +for a single file, the +standard developers decided that the popularity of \fIhead\fP on historical +BSD systems warranted its inclusion alongside \fItail\fP. +.LP +This standard version of \fIhead\fP follows the Utility Syntax Guidelines. +The \fB-n\fP option was added to this new interface +so that \fIhead\fP and \fItail\fP would be more logically related. +.LP +There is no \fB-c\fP option (as there is in \fItail\fP) because it +is not historical +practice and because other utilities in this volume of IEEE\ Std\ 1003.1-2001 +provide similar functionality. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIsed\fP , \fItail\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/iconv.1p b/man1p/iconv.1p new file mode 100644 index 000000000..ec0ef527e --- /dev/null +++ b/man1p/iconv.1p @@ -0,0 +1,258 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ICONV" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" iconv +.SH NAME +iconv \- codeset conversion +.SH SYNOPSIS +.LP +\fBiconv\fP \fB[\fP\fB-cs\fP\fB]\fP \fB-f\fP \fIfrommap\fP \fB-t\fP +\fItomap\fP \fB[\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +.sp +iconv -f\fP \fIfromcode\fP \fB[\fP\fB-cs\fP\fB] [\fP\fB-t\fP \fItocode\fP +\fB[\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +.sp +iconv -t\fP \fItocode\fP \fB[\fP\fB-cs\fP\fB] [\fP\fB-f\fP \fIfromcode\fP\fB] +[\fP\fIfile\fP +\fB\&...\fP\fB]\fP\fB +.br +.sp +iconv -l +.br +\fP +.SH DESCRIPTION +.LP +The \fIiconv\fP utility shall convert the encoding of characters in +\fIfile\fP from one codeset to another and write the +results to standard output. +.LP +When the options indicate that charmap files are used to specify the +codesets (see OPTIONS), the codeset conversion shall be +accomplished by performing a logical join on the symbolic character +names in the two charmaps. The implementation need not support +the use of charmap files for codeset conversion unless the POSIX2_LOCALEDEF +symbol is defined on the system. +.SH OPTIONS +.LP +The \fIiconv\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Omit any characters that are invalid in the codeset of the input file +from the output. When \fB-c\fP is not used, the results +of encountering invalid characters in the input stream (either those +that are not characters in the codeset of the input file or +that have no corresponding character in the codeset of the output +file) shall be specified in the system documentation. The +presence or absence of \fB-c\fP shall not affect the exit status of +\fIiconv\fP. +.TP 7 +\fB-f\ \fP \fIfromcodeset\fP +.sp +Identify the codeset of the input file. The implementation shall recognize +the following two forms of the \fIfromcodeset\fP +option-argument: +.TP 7 +\fIfromcode\fP +.RS +The \fIfromcode\fP option-argument must not contain a slash character. +It shall be interpreted as the name of one of the +codeset descriptions provided by the implementation in an unspecified +format. Valid values of \fIfromcode\fP are +implementation-defined. +.RE +.TP 7 +\fIfrommap\fP +.RS +The \fIfrommap\fP option-argument must contain a slash character. +It shall be interpreted as the pathname of a charmap file as +defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section +6.4, Character Set Description File. If the pathname does not represent +a valid, readable charmap file, the results are +undefined. +.RE +.sp +.LP +If this option is omitted, the codeset of the current locale shall +be used. +.TP 7 +\fB-l\fP +Write all supported \fIfromcode\fP and \fItocode\fP values to standard +output in an unspecified format. +.TP 7 +\fB-s\fP +Suppress any messages written to standard error concerning invalid +characters. When \fB-s\fP is not used, the results of +encountering invalid characters in the input stream (either those +that are not valid characters in the codeset of the input file or +that have no corresponding character in the codeset of the output +file) shall be specified in the system documentation. The +presence or absence of \fB-s\fP shall not affect the exit status of +\fIiconv\fP. +.TP 7 +\fB-t\ \fP \fItocodeset\fP +Identify the codeset to be used for the output file. The implementation +shall recognize the following two forms of the +\fItocodeset\fP option-argument: +.TP 7 +\fItocode\fP +.RS +The semantics shall be equivalent to the \fB-f\fP \fIfromcode\fP option. +.RE +.TP 7 +\fItomap\fP +.RS +The semantics shall be equivalent to the \fItomap\fP option. +.RE +.sp +.LP +If this option is omitted, the codeset of the current locale shall +be used. +.sp +.LP +If either \fB-f\fP or \fB-t\fP represents a charmap file, but the +other does not (or is omitted), or both \fB-f\fP and +\fB-t\fP are omitted, the results are undefined. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If no \fIfile\fP operands are specified, +or if a \fIfile\fP operand is \fB'-'\fP , the +standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP +\&. +.SH INPUT FILES +.LP +The input file shall be a text file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIiconv\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). During translation +of the file, this variable is superseded by the use of the +\fIfromcode\fP option-argument. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When the \fB-l\fP option is used, the standard output shall contain +all supported \fIfromcode\fP and \fItocode\fP values, +written in an unspecified format. +.LP +When the \fB-l\fP option is not used, the standard output shall contain +the sequence of characters read from the input files, +translated to the specified codeset. Nothing else shall be written +to the standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The user must ensure that both charmap files use the same symbolic +names for characters the two codesets have in common. +.SH EXAMPLES +.LP +The following example converts the contents of file \fBmail.x400\fP +from the ISO/IEC\ 6937:1994 standard codeset to the +ISO/IEC\ 8859-1:1998 standard codeset, and stores the results in file +\fBmail.local\fP: +.sp +.RS +.nf + +\fBiconv -f IS6937 -t IS8859 mail.x400 > mail.local +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fIiconv\fP utility can be used portably only when the user provides +two charmap files as option-arguments. This is because +a single charmap provided by the user cannot reliably be joined with +the names in a system-provided character set description. The +valid values for \fIfromcode\fP and \fItocode\fP are implementation-defined +and do not have to have any relation to the charmap +mechanisms. As an aid to interactive users, the \fB-l\fP option was +adopted from the Plan 9 operating system. It writes +information concerning these implementation-defined values. The format +is unspecified because there are many possible useful +formats that could be chosen, such as a matrix of valid combinations +of \fIfromcode\fP and \fItocode\fP. The \fB-l\fP option is +not intended for shell script usage; conforming applications will +have to use charmaps. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIgencat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/id.1p b/man1p/id.1p new file mode 100644 index 000000000..ed9df18bb --- /dev/null +++ b/man1p/id.1p @@ -0,0 +1,323 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ID" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" id +.SH NAME +id \- return user identity +.SH SYNOPSIS +.LP +\fBid\fP \fB[\fP\fIuser\fP\fB]\fP\fB +.br +.sp +id -G\fP\fB[\fP\fB-n\fP\fB] [\fP\fIuser\fP\fB]\fP\fB +.br +.sp +id -g\fP\fB[\fP\fB-nr\fP\fB] [\fP\fIuser\fP\fB]\fP\fB +.br +.sp +id -u\fP\fB[\fP\fB-nr\fP\fB] [\fP\fIuser\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +If no \fIuser\fP operand is provided, the \fIid\fP utility shall write +the user and group IDs and the corresponding user and +group names of the invoking process to standard output. If the effective +and real IDs do not match, both shall be written. If +multiple groups are supported by the underlying system (see the description +of {NGROUPS_MAX} in the System Interfaces volume of +IEEE\ Std\ 1003.1-2001), the supplementary group affiliations of the +invoking process shall also be written. +.LP +If a \fIuser\fP operand is provided and the process has the appropriate +privileges, the user and group IDs of the selected user +shall be written. In this case, effective IDs shall be assumed to +be identical to real IDs. If the selected user has more than one +allowable group membership listed in the group database, these shall +be written in the same manner as the supplementary groups +described in the preceding paragraph. +.SH OPTIONS +.LP +The \fIid\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-G\fP +Output all different group IDs (effective, real, and supplementary) +only, using the format \fB"%u\\n"\fP . If there is more +than one distinct group affiliation, output each such affiliation, +using the format \fB"\ %u"\fP , before the +<newline> is output. +.TP 7 +\fB-g\fP +Output only the effective group ID, using the format \fB"%u\\n"\fP +\&. +.TP 7 +\fB-n\fP +Output the name in the format \fB"%s"\fP instead of the numeric ID +using the format \fB"%u"\fP . +.TP 7 +\fB-r\fP +Output the real ID instead of the effective ID. +.TP 7 +\fB-u\fP +Output only the effective user ID, using the format \fB"%u\\n"\fP +\&. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIuser\fP +The login name for which information is to be written. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIid\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The following formats shall be used when the \fILC_MESSAGES\fP locale +category specifies the POSIX locale. In other locales, +the strings \fIuid\fP, \fIgid\fP, \fIeuid\fP, \fIegid\fP, and \fIgroups\fP +may be replaced with more appropriate strings +corresponding to the locale. +.sp +.RS +.nf + +\fB"uid=%u(%s) gid=%u(%s)\\n", <\fP\fIreal user ID\fP\fB>, <\fP\fIuser-name\fP\fB>, + <\fP\fIreal group ID\fP\fB>, <\fP\fIgroup-name\fP\fB> +\fP +.fi +.RE +.LP +If the effective and real user IDs do not match, the following shall +be inserted immediately before the \fB'\\n'\fP character +in the previous format: +.sp +.RS +.nf + +\fB" euid=%u(%s)" +\fP +.fi +.RE +.LP +with the following arguments added at the end of the argument list: +.sp +.RS +.nf + +\fB<\fP\fIeffective user ID\fP\fB>, <\fP\fIeffective user-name\fP\fB> +\fP +.fi +.RE +.LP +If the effective and real group IDs do not match, the following shall +be inserted directly before the \fB'\\n'\fP character in +the format string (and after any addition resulting from the effective +and real user IDs not matching): +.sp +.RS +.nf + +\fB" egid=%u(%s)" +\fP +.fi +.RE +.LP +with the following arguments added at the end of the argument list: +.sp +.RS +.nf + +\fB<\fP\fIeffective group-ID\fP\fB>, <\fP\fIeffective group name\fP\fB> +\fP +.fi +.RE +.LP +If the process has supplementary group affiliations or the selected +user is allowed to belong to multiple groups, the first +shall be added directly before the <newline> in the format string: +.sp +.RS +.nf + +\fB" groups=%u(%s)" +\fP +.fi +.RE +.LP +with the following arguments added at the end of the argument list: +.sp +.RS +.nf + +\fB<\fP\fIsupplementary group ID\fP\fB>, <\fP\fIsupplementary group name\fP\fB> +\fP +.fi +.RE +.LP +and the necessary number of the following added after that for any +remaining supplementary group IDs: +.sp +.RS +.nf + +\fB",%u(%s)" +\fP +.fi +.RE +.LP +and the necessary number of the following arguments added at the end +of the argument list: +.sp +.RS +.nf + +\fB<\fP\fIsupplementary group ID\fP\fB>, <\fP\fIsupplementary group name\fP\fB> +\fP +.fi +.RE +.LP +If any of the user ID, group ID, effective user ID, effective group +ID, or supplementary/multiple group IDs cannot be mapped by +the system into printable user or group names, the corresponding \fB"(%s)"\fP +and \fIname\fP argument shall be omitted from the +corresponding format string. +.LP +When any of the options are specified, the output format shall be +as described in the OPTIONS section. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Output produced by the \fB-G\fP option and by the default case could +potentially produce very long lines on systems that +support large numbers of supplementary groups. (On systems with user +and group IDs that are 32-bit integers and with group names +with a maximum of 8 bytes per name, 93 supplementary groups plus distinct +effective and real group and user IDs could theoretically +overflow the 2048-byte {LINE_MAX} text file line limit on the default +output case. It would take about 186 supplementary groups to +overflow the 2048-byte barrier using \fIid\fP \fB-G\fP). This is not +expected to be a problem in practice, but in cases where it +is a concern, applications should consider using \fIfold\fP \fB-s\fP +before postprocessing +the output of \fIid\fP. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The functionality provided by the 4 BSD \fIgroups\fP utility can be +simulated using: +.sp +.RS +.nf + +\fBid -Gn [ user ] +\fP +.fi +.RE +.LP +The 4 BSD command \fIgroups\fP was considered, but it was not included +because it did not provide the functionality of the +\fIid\fP utility of the SVID. Also, it was thought that it would be +easier to modify \fIid\fP to provide the additional +functionality necessary to systems with multiple groups than to invent +another command. +.LP +The options \fB-u\fP, \fB-g\fP, \fB-n\fP, and \fB-r\fP were added +to ease the use of \fIid\fP with shell commands +substitution. Without these options it is necessary to use some preprocessor +such as \fIsed\fP +to select the desired piece of information. Since output such as that +produced by: +.sp +.RS +.nf + +\fBid -u -n +\fP +.fi +.RE +.LP +is frequently wanted, it seemed desirable to add the options. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIfold\fP , \fIlogname\fP , \fIwho\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIgetgid\fP(), \fIgetgroups\fP(), +\fIgetuid\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ipcrm.1p b/man1p/ipcrm.1p new file mode 100644 index 000000000..f58733406 --- /dev/null +++ b/man1p/ipcrm.1p @@ -0,0 +1,154 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "IPCRM" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ipcrm +.SH NAME +ipcrm \- remove an XSI message queue, semaphore set, or shared memory +segment identifier +.SH SYNOPSIS +.LP +\fBipcrm\fP \fB[\fP \fB-q msgid | -Q msgkey | -s semid | -S semkey +| +.br +\ \ \ \ \ \ -m shmid | -M shmkey\fP \fB]\fP \fB... \fP +.SH DESCRIPTION +.LP +The \fIipcrm\fP utility shall remove zero or more message queues, +semaphore sets, or shared memory segments. The interprocess +communication facilities to be removed are specified by the options. +.LP +Only a user with appropriate privilege shall be allowed to remove +an interprocess communication facility that was not created by +or owned by the user invoking \fIipcrm\fP. +.SH OPTIONS +.LP +The \fIipcrm\fP facility supports the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-q\ \fP \fImsgid\fP +Remove the message queue identifier \fImsgid\fP from the system and +destroy the message queue and data structure associated +with it. +.TP 7 +\fB-m\ \fP \fIshmid\fP +Remove the shared memory identifier \fIshmid\fP from the system. The +shared memory segment and data structure associated with +it shall be destroyed after the last detach. +.TP 7 +\fB-s\ \fP \fIsemid\fP +Remove the semaphore identifier \fIsemid\fP from the system and destroy +the set of semaphores and data structure associated +with it. +.TP 7 +\fB-Q\ \fP \fImsgkey\fP +Remove the message queue identifier, created with key \fImsgkey\fP, +from the system and destroy the message queue and data +structure associated with it. +.TP 7 +\fB-M\ \fP \fIshmkey\fP +Remove the shared memory identifier, created with key \fIshmkey\fP, +from the system. The shared memory segment and data +structure associated with it shall be destroyed after the last detach. +.TP 7 +\fB-S\ \fP \fIsemkey\fP +Remove the semaphore identifier, created with key \fIsemkey\fP, from +the system and destroy the set of semaphores and data +structure associated with it. +.sp +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIipcrm\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIipcs\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fImsgctl\fP(), \fIsemctl\fP(), \fIshmctl\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ipcs.1p b/man1p/ipcs.1p new file mode 100644 index 000000000..43c719c25 --- /dev/null +++ b/man1p/ipcs.1p @@ -0,0 +1,559 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "IPCS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ipcs +.SH NAME +ipcs \- report XSI interprocess communication facilities status +.SH SYNOPSIS +.LP +\fBipcs\fP \fB[\fP\fB-qms\fP\fB][\fP\fB-a | -bcopt\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIipcs\fP utility shall write information about active interprocess +communication facilities. +.LP +Without options, information shall be written in short format for +message queues, shared memory segments, and semaphore sets +that are currently active in the system. Otherwise, the information +that is displayed is controlled by the options specified. +.SH OPTIONS +.LP +The \fIipcs\fP facility supports the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 12.2, Utility Syntax Guidelines. +.LP +The \fIipcs\fP utility accepts the following options: +.TP 7 +\fB-q\fP +Write information about active message queues. +.TP 7 +\fB-m\fP +Write information about active shared memory segments. +.TP 7 +\fB-s\fP +Write information about active semaphore sets. +.sp +.LP +If \fB-q\fP, \fB-m\fP, or \fB-s\fP are specified, only information +about those facilities shall be written. If none of these +three are specified, information about all three shall be written +subject to the following options: +.TP 7 +\fB-a\fP +Use all print options. (This is a shorthand notation for \fB-b\fP, +\fB-c\fP, \fB-o\fP, \fB-p\fP, and \fB-t\fP.) +.TP 7 +\fB-b\fP +Write information on maximum allowable size. (Maximum number of bytes +in messages on queue for message queues, size of segments +for shared memory, and number of semaphores in each set for semaphores.) +.TP 7 +\fB-c\fP +Write creator's user name and group name; see below. +.TP 7 +\fB-o\fP +Write information on outstanding usage. (Number of messages on queue +and total number of bytes in messages on queue for message +queues, and number of processes attached to shared memory segments.) +.TP 7 +\fB-p\fP +Write process number information. (Process ID of the last process +to send a message and process ID of the last process to +receive a message on message queues, process ID of the creating process, +and process ID of the last process to attach or detach on +shared memory segments.) +.TP 7 +\fB-t\fP +Write time information. (Time of the last control operation that changed +the access permissions for all facilities, time of the +last \fImsgsnd\fP() and \fImsgrcv\fP() operations +on message queues, time of the last \fIshmat\fP() and \fIshmdt\fP() +operations on shared memory, and time of the last \fIsemop\fP() operation +on semaphores.) +.sp +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.IP " *" 3 +The group database +.LP +.IP " *" 3 +The user database +.LP +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIipcs\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone for the date and time strings written by \fIipcs\fP. +If \fITZ\fP is unset or null, an unspecified +default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +An introductory line shall be written with the format: +.sp +.RS +.nf + +\fB"IPC status from %s as of %s\\n", <\fP\fIsource\fP\fB>, <\fP\fIdate\fP\fB> +\fP +.fi +.RE +.LP +where <\fIsource\fP> indicates the source used to gather the statistics +and <\fIdate\fP> is the information that +would be produced by the \fIdate\fP command when invoked in the POSIX +locale. +.LP +The \fIipcs\fP utility then shall create up to three reports depending +upon the \fB-q\fP, \fB-m\fP, and \fB-s\fP options. +The first report shall indicate the status of message queues, the +second report shall indicate the status of shared memory +segments, and the third report shall indicate the status of semaphore +sets. +.LP +If the corresponding facility is not installed or has not been used +since the last reboot, then the report shall be written out +in the format: +.sp +.RS +.nf + +\fB"%s facility not in system.\\n", <\fP\fIfacility\fP\fB> +\fP +.fi +.RE +.LP +where <\fIfacility\fP> is \fIMessage Queue\fP, \fIShared Memory\fP, +or \fISemaphore\fP, as appropriate. If the +facility has been installed and has been used since the last reboot, +column headings separated by one or more spaces and followed +by a <newline> shall be written as indicated below followed by the +facility name written out using the format: +.sp +.RS +.nf + +\fB"%s:\\n", <\fP\fIfacility\fP\fB> +\fP +.fi +.RE +.LP +where <\fIfacility\fP> is \fIMessage Queues\fP, \fIShared Memory\fP, +or \fISemaphores\fP, as appropriate. On the +second and third reports the column headings need not be written if +the last column headings written already provide column +headings for all information in that report. +.LP +The column headings provided in the first column below and the meaning +of the information in those columns shall be given in +order below; the letters in parentheses indicate the options that +shall cause the corresponding column to appear; "all" means +that the column shall always appear. Each column is separated by one +or more <space>s. Note that these options only determine +what information is provided for each report; they do not determine +which reports are written. +.TP 7 +T (all) +Type of facility: +.TP 7 +\fBq\fP +.RS +Message queue. +.RE +.TP 7 +\fBm\fP +.RS +Shared memory segment. +.RE +.TP 7 +\fBs\fP +.RS +Semaphore. +.RE +.sp +.LP +This field is a single character written using the format \fB%c\fP +\&. +.TP 7 +ID (all) +The identifier for the facility entry. This field shall be written +using the format \fB%d\fP . +.TP 7 +KEY (all) +The key used as an argument to \fImsgget\fP(), \fIsemget\fP(), or +\fIshmget\fP() to create the facility +entry. +.TP 7 +\fBNote:\fP +.RS +The key of a shared memory segment is changed to IPC_PRIVATE when +the segment has been removed until all processes attached to +the segment detach it. +.RE +.sp +This field shall be written using the format \fB0x%x\fP. +.TP 7 +MODE (all) +The facility access modes and flags. The mode shall consist of 11 +characters that are interpreted as follows. +.LP +The first character shall be: +.TP 7 +\fBS\fP +.RS +If a process is waiting on a \fImsgsnd\fP() operation. +.RE +.TP 7 +\fB-\fP +.RS +If the above is not true. +.RE +.sp +.LP +The second character shall be: +.TP 7 +\fBR\fP +.RS +If a process is waiting on a \fImsgrcv\fP() operation. +.RE +.TP 7 +\fBC\fP\ or\ \fB-\fP +.RS +If the associated shared memory segment is to be cleared when the +first attach operation is executed. +.RE +.TP 7 +\fB-\fP +.RS +If none of the above is true. +.RE +.sp +.LP +The next nine characters shall be interpreted as three sets of three +bits each. The first set refers to the owner's permissions; +the next to permissions of others in the usergroup of the facility +entry; and the last to all others. Within each set, the first +character indicates permission to read, the second character indicates +permission to write or alter the facility entry, and the +last character is a minus sign ( \fB'-'\fP ). +.LP +The permissions shall be indicated as follows: +.TP 7 +\fIr\fP +.RS +If read permission is granted. +.RE +.TP 7 +\fIw\fP +.RS +If write permission is granted. +.RE +.TP 7 +\fIa\fP +.RS +If alter permission is granted. +.RE +.TP 7 +\fB-\fP +.RS +If the indicated permission is not granted. +.RE +.sp +.LP +The first character following the permissions specifies if there is +an alternate or additional access control method associated +with the facility. If there is no alternate or additional access control +method associated with the facility, a single +<space> shall be written; otherwise, another printable character is +written. +.TP 7 +OWNER (all) +The user name of the owner of the facility entry. If the user name +of the owner is found in the user database, at least the +first eight column positions of the name shall be written using the +format \fB%s\fP . Otherwise, the user ID of the owner shall +be written using the format \fB%d\fP . +.TP 7 +GROUP (all) +The group name of the owner of the facility entry. If the group name +of the owner is found in the group database, at least the +first eight column positions of the name shall be written using the +format \fB%s\fP . Otherwise, the group ID of the owner shall +be written using the format \fB%d\fP . +.sp +.LP +The following nine columns shall be only written out for message queues: +.TP 7 +CREATOR (\fBa\fP,\fBc\fP) +The user name of the creator of the facility entry. If the user name +of the creator is found in the user database, at least the +first eight column positions of the name shall be written using the +format \fB%s\fP . Otherwise, the user ID of the creator +shall be written using the format \fB%d\fP . +.TP 7 +CGROUP (\fBa\fP,\fBc\fP) +The group name of the creator of the facility entry. If the group +name of the creator is found in the group database, at least +the first eight column positions of the name shall be written using +the format \fB%s\fP . Otherwise, the group ID of the creator +shall be written using the format \fB%d\fP . +.TP 7 +CBYTES (\fBa\fP,\fBo\fP) +The number of bytes in messages currently outstanding on the associated +message queue. This field shall be written using the +format \fB%d\fP . +.TP 7 +QNUM (\fBa\fP,\fBo\fP) +The number of messages currently outstanding on the associated message +queue. This field shall be written using the format +\fB%d\fP . +.TP 7 +QBYTES (\fBa\fP,\fBb\fP) +The maximum number of bytes allowed in messages outstanding on the +associated message queue. This field shall be written using +the format \fB%d\fP . +.TP 7 +LSPID (\fBa\fP,\fBp\fP) +The process ID of the last process to send a message to the associated +queue. This field shall be written using the format: +.sp +.RS +.nf + +\fB"%d", <\fP\fIpid\fP\fB> +\fP +.fi +.RE +.LP +where <\fIpid\fP> is 0 if no message has been sent to the corresponding +message queue; otherwise, <\fIpid\fP> +shall be the process ID of the last process to send a message to the +queue. +.TP 7 +LRPID (\fBa\fP,\fBp\fP) +The process ID of the last process to receive a message from the associated +queue. This field shall be written using the +format: +.sp +.RS +.nf + +\fB"%d", <\fP\fIpid\fP\fB> +\fP +.fi +.RE +.LP +where <\fIpid\fP> is 0 if no message has been received from the corresponding +message queue; otherwise, +<\fIpid\fP> shall be the process ID of the last process to receive +a message from the queue. +.TP 7 +STIME (\fBa\fP,\fBt\fP) +The time the last message was sent to the associated queue. If a message +has been sent to the corresponding message queue, the +hour, minute, and second of the last time a message was sent to the +queue shall be written using the format \fB%d\fP : +\fB%2.2d\fP : \fB%2.2d\fP . Otherwise, the format \fB"\ no-entry"\fP +shall be written. +.TP 7 +RTIME (\fBa\fP,\fBt\fP) +The time the last message was received from the associated queue. +If a message has been received from the corresponding message +queue, the hour, minute, and second of the last time a message was +received from the queue shall be written using the format +\fB%d\fP : \fB%2.2d\fP : \fB%2.2d\fP . Otherwise, the format \fB"\ no-entry"\fP +shall be written. +.sp +.LP +The following eight columns shall be only written out for shared memory +segments. +.TP 7 +CREATOR (\fBa\fP,\fBc\fP) +The user of the creator of the facility entry. If the user name of +the creator is found in the user database, at least the +first eight column positions of the name shall be written using the +format \fB%s\fP . Otherwise, the user ID of the creator +shall be written using the format \fB%d\fP . +.TP 7 +CGROUP (\fBa\fP,\fBc\fP) +The group name of the creator of the facility entry. If the group +name of the creator is found in the group database, at least +the first eight column positions of the name shall be written using +the format \fB%s\fP . Otherwise, the group ID of the creator +shall be written using the format \fB%d\fP . +.TP 7 +NATTCH (\fBa\fP,\fBo\fP) +The number of processes attached to the associated shared memory segment. +This field shall be written using the format +\fB%d\fP . +.TP 7 +SEGSZ (\fBa\fP,\fBb\fP) +The size of the associated shared memory segment. This field shall +be written using the format \fB%d\fP . +.TP 7 +CPID (\fBa\fP,\fBp\fP) +The process ID of the creator of the shared memory entry. This field +shall be written using the format \fB%d\fP . +.TP 7 +LPID (\fBa\fP,\fBp\fP) +The process ID of the last process to attach or detach the shared +memory segment. This field shall be written using the format: +.sp +.RS +.nf + +\fB"%d", <\fP\fIpid\fP\fB> +\fP +.fi +.RE +.LP +where <\fIpid\fP> is 0 if no process has attached the corresponding +shared memory segment; otherwise, <\fIpid\fP> +shall be the process ID of the last process to attach or detach the +segment. +.TP 7 +ATIME (\fBa\fP,\fBt\fP) +The time the last attach on the associated shared memory segment was +completed. If the corresponding shared memory segment has +ever been attached, the hour, minute, and second of the last time +the segment was attached shall be written using the format +\fB%d\fP : \fB%2.2d\fP : \fB%2.2d\fP . Otherwise, the format \fB"\ no-entry"\fP +shall be written. +.TP 7 +DTIME (\fBa\fP,\fBt\fP) +The time the last detach on the associated shared memory segment was +completed. If the corresponding shared memory segment has +ever been detached, the hour, minute, and second of the last time +the segment was detached shall be written using the format +\fB%d\fP : \fB%2.2d\fP : \fB%2.2d\fP . Otherwise, the format \fB"\ no-entry"\fP +shall be written. +.sp +.LP +The following four columns shall be only written out for semaphore +sets: +.TP 7 +CREATOR (\fBa\fP,\fBc\fP) +The user of the creator of the facility entry. If the user name of +the creator is found in the user database, at least the +first eight column positions of the name shall be written using the +format \fB%s\fP . Otherwise, the user ID of the creator +shall be written using the format \fB%d\fP . +.TP 7 +CGROUP (\fBa\fP,\fBc\fP) +The group name of the creator of the facility entry. If the group +name of the creator is found in the group database, at least +the first eight column positions of the name shall be written using +the format \fB%s\fP . Otherwise, the group ID of the creator +shall be written using the format \fB%d\fP . +.TP 7 +NSEMS (\fBa\fP,\fBb\fP) +The number of semaphores in the set associated with the semaphore +entry. This field shall be written using the format +\fB%d\fP . +.TP 7 +OTIME (\fBa\fP,\fBt\fP) +The time the last semaphore operation on the set associated with the +semaphore entry was completed. If a semaphore operation +has ever been performed on the corresponding semaphore set, the hour, +minute, and second of the last semaphore operation on the +semaphore set shall be written using the format \fB%d\fP : \fB%2.2d\fP +: \fB%2.2d\fP . Otherwise, the format +\fB"\ no-entry"\fP shall be written. +.sp +.LP +The following column shall be written for all three reports when it +is requested: +.TP 7 +CTIME (\fBa\fP,\fBt\fP) +The time the associated entry was created or changed. The hour, minute, +and second of the time when the associated entry was +created shall be written using the format \fB%d\fP : \fB%2.2d\fP : +\fB%2.2d\fP . +.sp +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Things can change while \fIipcs\fP is running; the information it +gives is guaranteed to be accurate only when it was +retrieved. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fImsgrcv\fP(), +\fImsgsnd\fP(), \fIsemget\fP(), \fIsemop\fP(), \fIshmat\fP(), \fIshmdt\fP(), +\fIshmget\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/jobs.1p b/man1p/jobs.1p new file mode 100644 index 000000000..3dac15e59 --- /dev/null +++ b/man1p/jobs.1p @@ -0,0 +1,313 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "JOBS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" jobs +.SH NAME +jobs \- display status of jobs in the current session +.SH SYNOPSIS +.LP +\fBjobs\fP \fB[\fP\fB-l| -p\fP\fB][\fP\fIjob_id\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIjobs\fP utility shall display the status of jobs that were +started in the current shell environment; see \fIShell Execution Environment\fP +\&. +.LP +When \fIjobs\fP reports the termination status of a job, the shell +shall remove its process ID from the list of those "known +in the current shell execution environment''; see \fIAsynchronous +Lists\fP . +.SH OPTIONS +.LP +The \fIjobs\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-l\fP +(The letter ell.) Provide more information about each job listed. +This information shall include the job number, current job, +process group ID, state, and the command that formed the job. +.TP 7 +\fB-p\fP +Display only the process IDs for the process group leaders of the +selected jobs. +.sp +.LP +By default, the \fIjobs\fP utility shall display the status of all +stopped jobs, running background jobs and all jobs whose +status has changed and have not been reported by the shell. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIjob_id\fP +Specifies the jobs for which the status is to be displayed. If no +\fIjob_id\fP is given, the status information for all jobs +shall be displayed. The format of \fIjob_id\fP is described in the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 3.203, +Job Control Job ID. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIjobs\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If the \fB-p\fP option is specified, the output shall consist of one +line for each process ID: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fIprocess ID\fP\fB> +\fP +.fi +.RE +.LP +Otherwise, if the \fB-l\fP option is not specified, the output shall +be a series of lines of the form: +.sp +.RS +.nf + +\fB"[%d] %c %s %s\\n", <\fP\fIjob-number\fP\fB>, <\fP\fIcurrent\fP\fB>, <\fP\fIstate\fP\fB>, <\fP\fIcommand\fP\fB> +\fP +.fi +.RE +.LP +where the fields shall be as follows: +.TP 7 +<\fIcurrent\fP> +The character \fB'+'\fP identifies the job that would be used as a +default for the \fIfg\fP or \fIbg\fP utilities; this job can also +be specified +using the \fIjob_id\fP %+ or \fB"%%"\fP . The character \fB'-'\fP +identifies the job that would become the default if the +current default job were to exit; this job can also be specified using +the \fIjob_id\fP %-. For other jobs, this field is a +<space>. At most one job can be identified with \fB'+'\fP and at most +one job can be identified with \fB'-'\fP . If +there is any suspended job, then the current job shall be a suspended +job. If there are at least two suspended jobs, then the +previous job also shall be a suspended job. +.TP 7 +<\fIjob-number\fP> +A number that can be used to identify the process group to the \fIwait\fP, +\fIfg\fP, \fIbg\fP, and \fIkill\fP utilities. Using these utilities, +the job can be identified by prefixing the job number +with \fB'%'\fP . +.TP 7 +<\fIstate\fP> +One of the following strings (in the POSIX locale): +.TP 7 +\fBRunning\fP +.RS +Indicates that the job has not been suspended by a signal and has +not exited. +.RE +.TP 7 +\fBDone\fP +.RS +Indicates that the job completed and returned exit status zero. +.RE +.TP 7 +\fBDone\fP(\fIcode\fP) +.RS +Indicates that the job completed normally and that it exited with +the specified non-zero exit status, \fIcode\fP, expressed as +a decimal number. +.RE +.TP 7 +\fBStopped\fP +.RS +Indicates that the job was suspended by the SIGTSTP signal. +.RE +.TP 7 +\fBStopped\fP\ (\fBSIGTSTP\fP) +.RS +.sp +Indicates that the job was suspended by the SIGTSTP signal. +.RE +.TP 7 +\fBStopped\fP\ (\fBSIGSTOP\fP) +.RS +.sp +Indicates that the job was suspended by the SIGSTOP signal. +.RE +.TP 7 +\fBStopped\fP\ (\fBSIGTTIN\fP) +.RS +.sp +Indicates that the job was suspended by the SIGTTIN signal. +.RE +.TP 7 +\fBStopped\fP\ (\fBSIGTTOU\fP) +.RS +.sp +Indicates that the job was suspended by the SIGTTOU signal. +.RE +.sp +.LP +The implementation may substitute the string \fBSuspended\fP in place +of \fBStopped\fP. If the job was terminated by a signal, +the format of <\fIstate\fP> is unspecified, but it shall be visibly +distinct from all of the other <\fIstate\fP> +formats shown here and shall indicate the name or description of the +signal causing the termination. +.TP 7 +<\fIcommand\fP> +The associated command that was given to the shell. +.sp +.LP +If the \fB-l\fP option is specified, a field containing the process +group ID shall be inserted before the <\fIstate\fP> +field. Also, more processes in a process group may be output on separate +lines, using only the process ID and +<\fIcommand\fP> fields. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-p\fP option is the only portable way to find out the process +group of a job because different implementations have +different strategies for defining the process group of the job. Usage +such as $( \fIjobs\fP \fB-p\fP) provides a way of referring +to the process group of the job in an implementation-independent way. +.LP +The \fIjobs\fP utility does not work as expected when it is operating +in its own utility execution environment because that +environment has no applicable jobs to manipulate. See the APPLICATION +USAGE section for \fIbg\fP . For this +reason, \fIjobs\fP is generally implemented as a shell regular built-in. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Both \fB"%%"\fP and \fB"%+"\fP are used to refer to the current job. +Both forms are of equal validity-the \fB"%%"\fP +mirroring \fB"$$"\fP and \fB"%+"\fP mirroring the output of \fIjobs\fP. +Both forms reflect historical practice of the +KornShell and the C shell with job control. +.LP +The job control features provided by \fIbg\fP, \fIfg\fP, +and \fIjobs\fP are based on the KornShell. The standard developers +examined the characteristics of the C shell versions of these +utilities and found that differences exist. Despite widespread use +of the C shell, the KornShell versions were selected for this +volume of IEEE\ Std\ 1003.1-2001 to maintain a degree of uniformity +with the rest of the KornShell features selected (such +as the very popular command line editing features). +.LP +The \fIjobs\fP utility is not dependent on the job control option, +as are the seemingly related \fIbg\fP and \fIfg\fP utilities because +\fIjobs\fP is useful for +examining background jobs, regardless of the condition of job control. +When the user has invoked a \fIset\fP \fB+m\fP command and job control +has been turned off, \fIjobs\fP can still be +used to examine the background jobs associated with that current session. +Similarly, \fIkill\fP can then be used to kill background jobs with +\fIkill\fP% <\fIbackground job number\fP>. +.LP +The output for terminated jobs is left unspecified to accommodate +various historical systems. The following formats have been +witnessed: +.IP " 1." 4 +\fBKilled\fP( \fIsignal name\fP) +.LP +.IP " 2." 4 +\fIsignal name\fP +.LP +.IP " 3." 4 +\fIsignal name\fP( \fBcoredump\fP) +.LP +.IP " 4." 4 +\fIsignal description\fP- \fBcore dumped\fP +.LP +.LP +Most users should be able to understand these formats, although it +means that applications have trouble parsing them. +.LP +The calculation of job IDs was not described since this would suggest +an implementation, which may impose unnecessary +restrictions. +.LP +In an early proposal, a \fB-n\fP option was included to "Display the +status of jobs that have changed, exited, or stopped +since the last status report". It was removed because the shell always +writes any changed status of jobs before each prompt. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Execution Environment\fP , \fIbg\fP , \fIfg\fP , \fIkill\fP() +, \fIwait\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/join.1p b/man1p/join.1p new file mode 100644 index 000000000..22351f302 --- /dev/null +++ b/man1p/join.1p @@ -0,0 +1,410 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "JOIN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" join +.SH NAME +join \- relational database operator +.SH SYNOPSIS +.LP +\fBjoin\fP \fB[\fP\fB-a\fP \fIfile_number\fP \fB| -v\fP \fIfile_number\fP\fB][\fP\fB-e\fP +\fIstring\fP\fB][\fP\fB-o\fP \fIlist\fP\fB][\fP\fB-t\fP \fIchar\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-1\fP \fIfield\fP\fB][\fP\fB-2\fP +\fIfield\fP\fB]\fP +\fIfile1 file2\fP +.SH DESCRIPTION +.LP +The \fIjoin\fP utility shall perform an equality join on the files +\fIfile1\fP and \fIfile2\fP. The joined files shall be +written to the standard output. +.LP +The join field is a field in each file on which the files are compared. +The \fIjoin\fP utility shall write one line in the +output for each pair of lines in \fIfile1\fP and \fIfile2\fP that +have identical join fields. The output line by default shall +consist of the join field, then the remaining fields from \fIfile1\fP, +then the remaining fields from \fIfile2\fP. This format +can be changed by using the \fB-o\fP option (see below). The \fB-a\fP +option can be used to add unmatched lines to the output. +The \fB-v\fP option can be used to output only unmatched lines. +.LP +The files \fIfile1\fP and \fIfile2\fP shall be ordered in the collating +sequence of \fIsort\fP \fB-b\fP on the fields on which they shall +be joined, by default the first in each line. +All selected output shall be written in the same collating sequence. +.LP +The default input field separators shall be <blank>s. In this case, +multiple separators shall count as one field +separator, and leading separators shall be ignored. The default output +field separator shall be a <space>. +.LP +The field separator and collating sequence can be changed by using +the \fB-t\fP option (see below). +.LP +If the same key appears more than once in either file, all combinations +of the set of remaining fields in \fIfile1\fP and the +set of remaining fields in \fIfile2\fP are output in the order of +the lines encountered. +.LP +If the input files are not in the appropriate collating sequence, +the results are unspecified. +.SH OPTIONS +.LP +The \fIjoin\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\ \fP \fIfile_number\fP +.sp +Produce a line for each unpairable line in file \fIfile_number\fP, +where \fIfile_number\fP is 1 or 2, in addition to the default +output. If both \fB-a\fP1 and \fB-a\fP2 are specified, all unpairable +lines shall be output. +.TP 7 +\fB-e\ \fP \fIstring\fP +Replace empty output fields in the list selected by \fB-o\fP with +the string \fIstring\fP. +.TP 7 +\fB-o\ \fP \fIlist\fP +Construct the output line to comprise the fields specified in \fIlist\fP, +each element of which shall have one of the +following two forms: +.RS +.IP " 1." 4 +\fIfile_number.field\fP, where \fIfile_number\fP is a file number +and \fIfield\fP is a decimal integer field number +.LP +.IP " 2." 4 +0 (zero), representing the join field +.LP +.RE +.LP +The elements of \fIlist\fP shall be either comma-separated or <blank>-separated, +as specified in Guideline 8 of the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility +Syntax +Guidelines. The fields specified by \fIlist\fP shall be written for +all selected output lines. Fields selected by \fIlist\fP +that do not appear in the input shall be treated as empty output fields. +(See the \fB-e\fP option.) Only specifically requested +fields shall be written. The application shall ensure that \fIlist\fP +is a single command line argument. +.TP 7 +\fB-t\ \fP \fIchar\fP +Use character \fIchar\fP as a separator, for both input and output. +Every appearance of \fIchar\fP in a line shall be +significant. When this option is specified, the collating sequence +shall be the same as \fIsort\fP without the \fB-b\fP option. +.TP 7 +\fB-v\ \fP \fIfile_number\fP +.sp +Instead of the default output, produce a line only for each unpairable +line in \fIfile_number\fP, where \fIfile_number\fP is 1 or +2. If both \fB-v\fP1 and \fB-v\fP2 are specified, all unpairable lines +shall be output. +.TP 7 +\fB-1\ \fP \fIfield\fP +Join on the \fIfield\fPth field of file 1. Fields are decimal integers +starting with 1. +.TP 7 +\fB-2\ \fP \fIfield\fP +Join on the \fIfield\fPth field of file 2. Fields are decimal integers +starting with 1. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile1\fP,\ \fIfile2\fP +A pathname of a file to be joined. If either of the \fIfile1\fP or +\fIfile2\fP operands is \fB'-'\fP , the standard input +shall be used in its place. +.sp +.SH STDIN +.LP +The standard input shall be used only if the \fIfile1\fP or \fIfile2\fP +operand is \fB'-'\fP . See the INPUT FILES +section. +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIjoin\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale of the collating sequence \fIjoin\fP expects +to have been used when the input files were sorted. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIjoin\fP utility output shall be a concatenation of selected +character fields. When the \fB-o\fP option is not +specified, the output shall be: +.sp +.RS +.nf + +\fB"%s%s%s\\n", <\fP\fIjoin field\fP\fB>, <\fP\fIother file1 fields\fP\fB>, + <\fP\fIother file2 fields\fP\fB> +\fP +.fi +.RE +.LP +If the join field is not the first field in a file, the <\fIother\ file\ fields\fP> +for that file shall be: +.sp +.RS +.nf + +\fB<\fP\fIfields preceding join field\fP\fB>, <\fP\fIfields following join field\fP\fB> +\fP +.fi +.RE +.LP +When the \fB-o\fP option is specified, the output format shall be: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIconcatenation of fields\fP\fB> +\fP +.fi +.RE +.LP +where the concatenation of fields is described by the \fB-o\fP option, +above. +.LP +For either format, each field (except the last) shall be written with +its trailing separator character. If the separator is the +default ( <blank>s), a single <space> shall be written after each +field (except the last). +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were output successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Pathnames consisting of numeric digits or of the form \fIstring.string\fP +should not be specified directly following the +\fB-o\fP list. +.SH EXAMPLES +.LP +The \fB-o\fP 0 field essentially selects the union of the join fields. +For example, given file \fBphone\fP: +.sp +.RS +.nf + +\fB!Name Phone Number +Don +1 123-456-7890 +Hal +1 234-567-8901 +Yasushi +2 345-678-9012 +\fP +.fi +.RE +.LP +and file \fBfax\fP: +.sp +.RS +.nf + +\fB!Name Fax Number +Don +1 123-456-7899 +Keith +1 456-789-0122 +Yasushi +2 345-678-9011 +\fP +.fi +.RE +.LP +(where the large expanses of white space are meant to each represent +a single <tab>), the command: +.sp +.RS +.nf + +\fBjoin -t "<tab>" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax +\fP +.fi +.RE +.LP +would produce: +.sp +.RS +.nf + +\fB!Name Phone Number Fax Number +Don +1 123-456-7890 +1 123-456-7899 +Hal +1 234-567-8901 (unknown) +Keith (unknown) +1 456-789-0122 +Yasushi +2 345-678-9012 +2 345-678-9011 +\fP +.fi +.RE +.LP +Multiple instances of the same key will produce combinatorial results. +The following: +.sp +.RS +.nf + +\fBfa: + a x + a y + a z +fb: + a p +\fP +.fi +.RE +.LP +will produce: +.sp +.RS +.nf + +\fBa x p +a y p +a z p +\fP +.fi +.RE +.LP +And the following: +.sp +.RS +.nf + +\fBfa: + a b c + a d e +fb: + a w x + a y z + a o p +\fP +.fi +.RE +.LP +will produce: +.sp +.RS +.nf + +\fBa b c w x +a b c y z +a b c o p +a d e w x +a d e y z +a d e o p +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fB-e\fP option is only effective when used with \fB-o\fP because, +unless specific fields are identified using \fB-o\fP, +\fIjoin\fP is not aware of what fields might be empty. The exception +to this is the join field, but identifying an empty join +field with the \fB-e\fP string is not historical practice and some +scripts might break if this were changed. +.LP +The 0 field in the \fB-o\fP list was adopted from the Tenth Edition +version of \fIjoin\fP to satisfy international objections +that the \fIjoin\fP in the base documents does not support the "full +join" or "outer join" described in relational database +literature. Although it has been possible to include a join field +in the output (by default, or by field number using \fB-o\fP), +the join field could not be included for an unpaired line selected +by \fB-a\fP. The \fB-o\fP 0 field essentially selects the +union of the join fields. +.LP +This sort of outer join was not possible with the \fIjoin\fP commands +in the base documents. The \fB-o\fP 0 field was chosen +because it is an upwards-compatible change for applications. An alternative +was considered: have the join field represent the union +of the fields in the files (where they are identical for matched lines, +and one or both are null for unmatched lines). This was not +adopted because it would break some historical applications. +.LP +The ability to specify \fIfile2\fP as \fB-\fP is not historical practice; +it was added for completeness. +.LP +The \fB-v\fP option is not historical practice, but was considered +necessary because it permitted the writing of \fIonly\fP +those lines that do not match on the join field, as opposed to the +\fB-a\fP option, which prints both lines that do and do not +match. This additional facility is parallel with the \fB-v\fP option +of \fIgrep\fP. +.LP +Some historical implementations have been encountered where a blank +line in one of the input files was considered to be the end +of the file; the description in this volume of IEEE\ Std\ 1003.1-2001 +does not cite this as an allowable case. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIawk\fP , \fIcomm\fP , \fIsort\fP , \fIuniq\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/kill.1p b/man1p/kill.1p new file mode 100644 index 000000000..c494b742b --- /dev/null +++ b/man1p/kill.1p @@ -0,0 +1,393 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "KILL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" kill +.SH NAME +kill \- terminate or signal processes +.SH SYNOPSIS +.LP +\fBkill -s\fP \fIsignal_name pid\fP \fB... +.br +.sp +kill -l\fP \fB[\fP\fIexit_status\fP\fB]\fP\fB +.br +.sp +\fP +.LP +\fBkill\fP \fB[\fP\fB-\fP\fIsignal_name\fP\fB]\fP \fIpid\fP \fB... +.br +.sp +kill\fP \fB[\fP\fB-\fP\fIsignal_number\fP\fB]\fP \fIpid\fP \fB... +\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIkill\fP utility shall send a signal to the process or processes +specified by each \fIpid\fP operand. +.LP +For each \fIpid\fP operand, the \fIkill\fP utility shall perform actions +equivalent to the \fIkill\fP() function defined in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 +called with the following arguments: +.IP " *" 3 +The value of the \fIpid\fP operand shall be used as the \fIpid\fP +argument. +.LP +.IP " *" 3 +The \fIsig\fP argument is the value specified by the \fB-s\fP option, +\fB-\fP \fIsignal_number\fP option, or the \fB-\fP +\fIsignal_name\fP option, or by SIGTERM, if none of these options +is specified. +.LP +.SH OPTIONS +.LP +The \fIkill\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +\ except that +in the last two SYNOPSIS forms, the \fB-\fP \fIsignal_number\fP and +\fB-\fP \fIsignal_name\fP options are usually more than a +single character. +.LP +The following options shall be supported: +.TP 7 +\fB-l\fP +(The letter ell.) Write all values of \fIsignal_name\fP supported +by the implementation, if no operand is given. If an +\fIexit_status\fP operand is given and it is a value of the \fB'?'\fP +shell special parameter (see \fISpecial Parameters\fP and \fIwait\fP() +) corresponding to a process +that was terminated by a signal, the \fIsignal_name\fP corresponding +to the signal that terminated the process shall be written. +If an \fIexit_status\fP operand is given and it is the unsigned decimal +integer value of a signal number, the \fIsignal_name\fP +(the symbolic constant name without the \fBSIG\fP prefix defined in +the Base Definitions volume of IEEE\ Std\ 1003.1-2001) +corresponding to that signal shall be written. Otherwise, the results +are unspecified. +.TP 7 +\fB-s\ \fP \fIsignal_name\fP +.sp +Specify the signal to send, using one of the symbolic names defined +in the \fI<signal.h>\fP header. Values of \fIsignal_name\fP shall +be recognized in a +case-independent fashion, without the \fBSIG\fP prefix. In addition, +the symbolic name 0 shall be recognized, representing the +signal value zero. The corresponding signal shall be sent instead +of SIGTERM. +.TP 7 +\fB-\fP\fIsignal_name\fP +.sp +Equivalent to \fB-s\fP \fIsignal_name\fP. +.TP 7 +\fB-\fP\fIsignal_number\fP +.sp +Specify a non-negative decimal integer, \fIsignal_number\fP, representing +the signal to be used instead of SIGTERM, as the +\fIsig\fP argument in the effective call to \fIkill\fP(). The correspondence +between integer +values and the \fIsig\fP value used is shown in the following table. +.LP +The effects of specifying any \fIsignal_number\fP other than those +listed in the table are undefined. +.sp +.sp +.TS C +center; l l. +\fIsignal_number\fP \fB\fIsig\fP Value\fP +0 0 +1 SIGHUP +2 SIGINT +3 SIGQUIT +6 SIGABRT +9 SIGKILL +14 SIGALRM +15 SIGTERM +.TE +.LP +If the first argument is a negative integer, it shall be interpreted +as a \fB-\fP \fIsignal_number\fP option, not as a +negative \fIpid\fP operand specifying a process group. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIpid\fP +One of the following: +.RS +.IP " 1." 4 +A decimal integer specifying a process or process group to be signaled. +The process or processes selected by positive, negative, +and zero values of the \fIpid\fP operand shall be as described for +the \fIkill\fP() +function. If process number 0 is specified, all processes in the current +process group shall be signaled. For the effects of +negative \fIpid\fP numbers, see the \fIkill\fP() function defined +in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001. If the first \fIpid\fP operand is +negative, it should be preceded by \fB"--"\fP to +keep it from being interpreted as an option. +.LP +.IP " 2." 4 +A job control job ID (see the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 3.203, Job Control Job ID) that identifies a background process +group to be +signaled. The job control job ID notation is applicable only for invocations +of \fIkill\fP in the current shell execution +environment; see \fIShell Execution Environment\fP . +.LP +.RE +.TP 7 +\fIexit_status\fP +A decimal integer specifying a signal number or the exit status of +a process terminated by a signal. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIkill\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When the \fB-l\fP option is not specified, the standard output shall +not be used. +.LP +When the \fB-l\fP option is specified, the symbolic name of each signal +shall be written in the following format: +.sp +.RS +.nf + +\fB"%s%c", <\fP\fIsignal_name\fP\fB>, <\fP\fIseparator\fP\fB> +\fP +.fi +.RE +.LP +where the <\fIsignal_name\fP> is in uppercase, without the \fBSIG\fP +prefix, and the <\fIseparator\fP> shall be +either a <newline> or a <space>. For the last signal written, <\fIseparator\fP> +shall be a <newline>. +.LP +When both the \fB-l\fP option and \fIexit_status\fP operand are specified, +the symbolic name of the corresponding signal shall +be written in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIsignal_name\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +At least one matching process was found for each \fIpid\fP operand, +and the specified signal was successfully processed for at +least one matching process. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Process numbers can be found by using \fIps\fP. +.LP +The job control job ID notation is not required to work as expected +when \fIkill\fP is operating in its own utility execution +environment. In either of the following examples: +.sp +.RS +.nf + +\fBnohup kill %1 & +system("kill %1"); +\fP +.fi +.RE +.LP +the \fIkill\fP operates in a different environment and does not share +the shell's understanding of job numbers. +.SH EXAMPLES +.LP +Any of the commands: +.sp +.RS +.nf + +\fBkill -9 100 -165 +kill -s kill 100 -165 +kill -s KILL 100 -165 +\fP +.fi +.RE +.LP +sends the SIGKILL signal to the process whose process ID is 100 and +to all processes whose process group ID is 165, assuming the +sending process has permission to send that signal to the specified +processes, and that they exist. +.LP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001 and this volume +of IEEE\ Std\ 1003.1-2001 do not require +specific signal numbers for any \fIsignal_names\fP. Even the \fB-\fP +\fIsignal_number\fP option provides symbolic (although +numeric) names for signals. If a process is terminated by a signal, +its exit status indicates the signal that killed it, but the +exact values are not specified. The \fIkill\fP \fB-l\fP option, however, +can be used to map decimal signal numbers and exit +status values into the name of a signal. The following example reports +the status of a terminated job: +.sp +.RS +.nf + +\fBjob +stat=$? +if [ $stat -eq 0 ] +then + echo job completed successfully. +elif [ $stat -gt 128 ] +then + echo job terminated by signal SIG$(kill -l $stat). +else + echo job terminated with error code $stat. +fi +\fP +.fi +.RE +.LP +To send the default signal to a process group (say 123), an application +should use a command similar to one of the +following: +.sp +.RS +.nf + +\fBkill -TERM -123 +kill -- -123 +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fB-l\fP option originated from the C shell, and is also implemented +in the KornShell. The C shell output can consist of +multiple output lines because the signal names do not always fit on +a single line on some terminal screens. The KornShell output +also included the implementation-defined signal numbers and was considered +by the standard developers to be too difficult for +scripts to parse conveniently. The specified output format is intended +not only to accommodate the historical C shell output, but +also to permit an entirely vertical or entirely horizontal listing +on systems for which this is appropriate. +.LP +An early proposal invented the name SIGNULL as a \fIsignal_name\fP +for signal 0 (used by the System Interfaces volume of +IEEE\ Std\ 1003.1-2001 to test for the existence of a process without +sending it a signal). Since the \fIsignal_name\fP 0 +can be used in this case unambiguously, SIGNULL has been removed. +.LP +An early proposal also required symbolic \fIsignal_name\fPs to be +recognized with or without the \fBSIG\fP prefix. Historical +versions of \fIkill\fP have not written the \fBSIG\fP prefix for the +\fB-l\fP option and have not recognized the \fBSIG\fP +prefix on \fIsignal_name\fPs. Since neither applications portability +nor ease-of-use would be improved by requiring this +extension, it is no longer required. +.LP +To avoid an ambiguity of an initial negative number argument specifying +either a signal number or a process group, +IEEE\ Std\ 1003.1-2001 mandates that it is always considered the former +by implementations that support the XSI option. It +also requires that conforming applications always use the \fB"--"\fP +options terminator argument when specifying a process +group, unless an option is also specified. +.LP +The \fB-s\fP option was added in response to international interest +in providing some form of \fIkill\fP that meets the +Utility Syntax Guidelines. +.LP +The job control job ID notation is not required to work as expected +when \fIkill\fP is operating in its own utility execution +environment. In either of the following examples: +.sp +.RS +.nf + +\fBnohup kill %1 & +system("kill %1"); +\fP +.fi +.RE +.LP +the \fIkill\fP operates in a different environment and does not understand +how the shell has managed its job numbers. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIps\fP , \fIwait\fP() , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIkill\fP(), the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<signal.h>\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/lex.1p b/man1p/lex.1p new file mode 100644 index 000000000..6d84cb9fa --- /dev/null +++ b/man1p/lex.1p @@ -0,0 +1,954 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LEX" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" lex +.SH NAME +lex \- generate programs for lexical tasks (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBlex\fP \fB[\fP\fB-t\fP\fB][\fP\fB-n|-v\fP\fB][\fP\fIfile\fP \fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIlex\fP utility shall generate C programs to be used in lexical +processing of character input, and that can be used as an +interface to \fIyacc\fP. The C programs shall be generated from \fIlex\fP +source code and +conform to the ISO\ C standard. Usually, the \fIlex\fP utility shall +write the program it generates to the file +\fBlex.yy.c\fP; the state of this file is unspecified if \fIlex\fP +exits with a non-zero exit status. See the EXTENDED +DESCRIPTION section for a complete description of the \fIlex\fP input +language. +.SH OPTIONS +.LP +The \fIlex\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-n\fP +Suppress the summary of statistics usually written with the \fB-v\fP +option. If no table sizes are specified in the \fIlex\fP +source code and the \fB-v\fP option is not specified, then \fB-n\fP +is implied. +.TP 7 +\fB-t\fP +Write the resulting program to standard output instead of \fBlex.yy.c\fP. +.TP 7 +\fB-v\fP +Write a summary of \fIlex\fP statistics to the standard output. (See +the discussion of \fIlex\fP table sizes in Definitions in lex .) If +the \fB-t\fP option is specified and \fB-n\fP is not specified, this +report shall +be written to standard error. If table sizes are specified in the +\fIlex\fP source code, and if the \fB-n\fP option is not +specified, the \fB-v\fP option may be enabled. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If more than one such \fIfile\fP is specified, +all files shall be concatenated to produce a +single \fIlex\fP program. If no \fIfile\fP operands are specified, +or if a \fIfile\fP operand is \fB'-'\fP , the standard +input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used if no \fIfile\fP operands are specified, +or if a \fIfile\fP operand is \fB'-'\fP . See +INPUT FILES. +.SH INPUT FILES +.LP +The input files shall be text files containing \fIlex\fP source code, +as described in the EXTENDED DESCRIPTION section. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIlex\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. If this variable is not set to the POSIX locale, the +results are unspecified. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), and +the behavior of character classes within regular expressions. +If this variable is not set to the POSIX locale, the results are unspecified. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If the \fB-t\fP option is specified, the text file of C source code +output of \fIlex\fP shall be written to standard +output. +.LP +If the \fB-t\fP option is not specified: +.IP " *" 3 +Implementation-defined informational, error, and warning messages +concerning the contents of \fIlex\fP source code input shall +be written to either the standard output or standard error. +.LP +.IP " *" 3 +If the \fB-v\fP option is specified and the \fB-n\fP option is not +specified, \fIlex\fP statistics shall also be written to +either the standard output or standard error, in an implementation-defined +format. These statistics may also be generated if table +sizes are specified with a \fB'%'\fP operator in the \fIDefinitions\fP +section, as long as the \fB-n\fP option is not +specified. +.LP +.SH STDERR +.LP +If the \fB-t\fP option is specified, implementation-defined informational, +error, and warning messages concerning the contents +of \fIlex\fP source code input shall be written to the standard error. +.LP +If the \fB-t\fP option is not specified: +.IP " 1." 4 +Implementation-defined informational, error, and warning messages +concerning the contents of \fIlex\fP source code input shall +be written to either the standard output or standard error. +.LP +.IP " 2." 4 +If the \fB-v\fP option is specified and the \fB-n\fP option is not +specified, \fIlex\fP statistics shall also be written to +either the standard output or standard error, in an implementation-defined +format. These statistics may also be generated if table +sizes are specified with a \fB'%'\fP operator in the \fIDefinitions\fP +section, as long as the \fB-n\fP option is not +specified. +.LP +.SH OUTPUT FILES +.LP +A text file containing C source code shall be written to \fBlex.yy.c\fP, +or to the standard output if the \fB-t\fP option is +present. +.SH EXTENDED DESCRIPTION +.LP +Each input file shall contain \fIlex\fP source code, which is a table +of regular expressions with corresponding actions in the +form of C program fragments. +.LP +When \fBlex.yy.c\fP is compiled and linked with the \fIlex\fP library +(using the \fB-l\ l\fP operand with \fIc99\fP), the resulting program +shall read character input from the standard input and shall +partition it into strings that match the given expressions. +.LP +When an expression is matched, these actions shall occur: +.IP " *" 3 +The input string that was matched shall be left in \fIyytext\fP as +a null-terminated string; \fIyytext\fP shall either be an +external character array or a pointer to a character string. As explained +in Definitions in lex , +the type can be explicitly selected using the \fB%array\fP or \fB%pointer\fP +declarations, but the default is +implementation-defined. +.LP +.IP " *" 3 +The external \fBint\fP \fIyyleng\fP shall be set to the length of +the matching string. +.LP +.IP " *" 3 +The expression's corresponding program fragment, or action, shall +be executed. +.LP +.LP +During pattern matching, \fIlex\fP shall search the set of patterns +for the single longest possible match. Among rules that +match the same number of characters, the rule given first shall be +chosen. +.LP +The general format of \fIlex\fP source shall be: +.sp +.RS +.nf + +\fIDefinitions\fP +\fB%%\fP +\fIRules\fP +\fB%%\fP +\fIUser\fPSubroutines +.fi +.RE +.LP +The first \fB"%%"\fP is required to mark the beginning of the rules +(regular expressions and actions); the second +\fB"%%"\fP is required only if user subroutines follow. +.LP +Any line in the \fIDefinitions\fP section beginning with a <blank> +shall be assumed to be a C program fragment and shall +be copied to the external definition area of the \fBlex.yy.c\fP file. +Similarly, anything in the \fIDefinitions\fP section +included between delimiter lines containing only \fB"%{"\fP and \fB"%}"\fP +shall also be copied unchanged to the external +definition area of the \fBlex.yy.c\fP file. +.LP +Any such input (beginning with a <blank> or within \fB"%{"\fP and +\fB"%}"\fP delimiter lines) appearing at the +beginning of the \fIRules\fP section before any rules are specified +shall be written to \fBlex.yy.c\fP after the declarations of +variables for the \fIyylex\fP() function and before the first line +of code in \fIyylex\fP(). Thus, user variables local to +\fIyylex\fP() can be declared here, as well as application code to +execute upon entry to \fIyylex\fP(). +.LP +The action taken by \fIlex\fP when encountering any input beginning +with a <blank> or within \fB"%{"\fP and +\fB"%}"\fP delimiter lines appearing in the \fIRules\fP section but +coming after one or more rules is undefined. The presence +of such input may result in an erroneous definition of the \fIyylex\fP() +function. +.SS Definitions in lex +.LP +\fIDefinitions\fP appear before the first \fB"%%"\fP delimiter. Any +line in this section not contained between \fB"%{"\fP +and \fB"%}"\fP lines and not beginning with a <blank> shall be assumed +to define a \fIlex\fP substitution string. The +format of these lines shall be: +.sp +.RS +.nf + +\fIname substitute\fP +.fi +.RE +.LP +If a \fIname\fP does not meet the requirements for identifiers in +the ISO\ C standard, the result is undefined. The string +\fIsubstitute\fP shall replace the string { \fIname\fP} when it is +used in a rule. The \fIname\fP string shall be recognized in +this context only when the braces are provided and when it does not +appear within a bracket expression or within double-quotes. +.LP +In the \fIDefinitions\fP section, any line beginning with a \fB'%'\fP +(percent sign) character and followed by an +alphanumeric word beginning with either \fB's'\fP or \fB'S'\fP shall +define a set of start conditions. Any line beginning +with a \fB'%'\fP followed by a word beginning with either \fB'x'\fP +or \fB'X'\fP shall define a set of exclusive start +conditions. When the generated scanner is in a \fB%s\fP state, patterns +with no state specified shall be also active; in a +\fB%x\fP state, such patterns shall not be active. The rest of the +line, after the first word, shall be considered to be one or +more <blank>-separated names of start conditions. Start condition +names shall be constructed in the same way as definition +names. Start conditions can be used to restrict the matching of regular +expressions to one or more states as described in Regular Expressions +in lex . +.LP +Implementations shall accept either of the following two mutually-exclusive +declarations in the \fIDefinitions\fP section: +.TP 7 +\fB%array\fP +Declare the type of \fIyytext\fP to be a null-terminated character +array. +.TP 7 +\fB%pointer\fP +Declare the type of \fIyytext\fP to be a pointer to a null-terminated +character string. +.sp +.LP +The default type of \fIyytext\fP is implementation-defined. If an +application refers to \fIyytext\fP outside of the scanner +source file (that is, via an \fBextern\fP), the application shall +include the appropriate \fB%array\fP or \fB%pointer\fP +declaration in the scanner source file. +.LP +Implementations shall accept declarations in the \fIDefinitions\fP +section for setting certain internal table sizes. The +declarations are shown in the following table. +.sp +.ce 1 +\fBTable: Table Size Declarations in \fIlex\fP\fP +.TS C +center; l2 l2 l. +\fBDeclaration\fP \fBDescription\fP \fBMinimum Value\fP +%\fBp\fP \fIn\fP Number of positions 2500 +%\fBn\fP \fIn\fP Number of states 500 +%\fBa\fP \fIn\fP Number of transitions 2000 +%\fBe\fP \fIn\fP Number of parse tree nodes 1000 +%\fBk\fP \fIn\fP Number of packed character classes 1000 +%\fBo\fP \fIn\fP Size of the output array 3000 +.TE +.LP +In the table, \fIn\fP represents a positive decimal integer, preceded +by one or more <blank>s. The exact meaning of these +table size numbers is implementation-defined. The implementation shall +document how these numbers affect the \fIlex\fP utility and +how they are related to any output that may be generated by the implementation +should limitations be encountered during the +execution of \fIlex\fP. It shall be possible to determine from this +output which of the table size values needs to be modified to +permit \fIlex\fP to successfully generate tables for the input language. +The values in the column Minimum Value represent the +lowest values conforming implementations shall provide. +.SS Rules in lex +.LP +The rules in \fIlex\fP source files are a table in which the left +column contains regular expressions and the right column +contains actions (C program fragments) to be executed when the expressions +are recognized. +.sp +.RS +.nf + +\fIERE action +ERE action\fP\fB... +\fP +.fi +.RE +.LP +The extended regular expression (ERE) portion of a row shall be separated +from \fIaction\fP by one or more <blank>s. A +regular expression containing <blank>s shall be recognized under one +of the following conditions: +.IP " *" 3 +The entire expression appears within double-quotes. +.LP +.IP " *" 3 +The <blank>s appear within double-quotes or square brackets. +.LP +.IP " *" 3 +Each <blank> is preceded by a backslash character. +.LP +.SS User Subroutines in lex +.LP +Anything in the user subroutines section shall be copied to \fBlex.yy.c\fP +following \fIyylex\fP(). +.SS Regular Expressions in lex +.LP +The \fIlex\fP utility shall support the set of extended regular expressions +(see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 9.4, Extended Regular Expressions), +with the following additions and exceptions to the syntax: +.TP 7 +\fB"..."\fP +Any string enclosed in double-quotes shall represent the characters +within the double-quotes as themselves, except that +backslash escapes (which appear in the following table) shall be recognized. +Any backslash-escape sequence shall be terminated by +the closing quote. For example, \fB"\\01"\fP \fB"1"\fP represents +a single string: the octal value 1 followed by the character +\fB'1'\fP . +.TP 7 +<\fIstate\fP>\fIr\fP,\ <\fIstate1,state2,\fP...>\fIr\fP +.sp +The regular expression \fIr\fP shall be matched only when the program +is in one of the start conditions indicated by \fIstate\fP, +\fIstate1\fP, and so on; see Actions in lex . (As an exception to +the typographical conventions of +the rest of this volume of IEEE\ Std\ 1003.1-2001, in this case <\fIstate\fP> +does not represent a metavariable, but +the literal angle-bracket characters surrounding a symbol.) The start +condition shall be recognized as such only at the beginning +of a regular expression. +.TP 7 +\fIr\fP/\fIx\fP +The regular expression \fIr\fP shall be matched only if it is followed +by an occurrence of regular expression \fIx\fP ( +\fIx\fP is the instance of trailing context, further defined below). +The token returned in \fIyytext\fP shall only match +\fIr\fP. If the trailing portion of \fIr\fP matches the beginning +of \fIx\fP, the result is unspecified. The \fIr\fP expression +cannot include further trailing context or the \fB'$'\fP (match-end-of-line) +operator; \fIx\fP cannot include the \fB'^'\fP +(match-beginning-of-line) operator, nor trailing context, nor the +\fB'$'\fP operator. That is, only one occurrence of trailing +context is allowed in a \fIlex\fP regular expression, and the \fB'^'\fP +operator only can be used at the beginning of such an +expression. +.TP 7 +{\fIname\fP} +When \fIname\fP is one of the substitution symbols from the \fIDefinitions\fP +section, the string, including the enclosing +braces, shall be replaced by the \fIsubstitute\fP value. The \fIsubstitute\fP +value shall be treated in the extended regular +expression as if it were enclosed in parentheses. No substitution +shall occur if { \fIname\fP} occurs within a bracket expression +or within double-quotes. +.sp +.LP +Within an ERE, a backslash character shall be considered to begin +an escape sequence as specified in the table in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 5, File Format +Notation ( +\fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , \fB'\\n'\fP +, \fB'\\r'\fP , \fB'\\t'\fP , \fB'\\v'\fP ). In +addition, the escape sequences in the following table shall be recognized. +.LP +A literal <newline> cannot occur within an ERE; the escape sequence +\fB'\\n'\fP can be used to represent a +<newline>. A <newline> shall not be matched by a period operator. +.br +.sp +.ce 1 +\fBTable: Escape Sequences in \fIlex\fP\fP +.TS C +center; l1 lw(30)1 lw(30). +\fBEscape\fP T{ +.na +\fB\ \fP +.ad +T} T{ +.na +\fB\ \fP +.ad +T} +\fBSequence\fP T{ +.na +\fBDescription\fP +.ad +T} T{ +.na +\fBMeaning\fP +.ad +T} +\\\fIdigits\fP T{ +.na +A backslash character followed by the longest sequence of one, two, or three octal-digit characters (01234567). If all of the digits are 0 (that is, representation of the NUL character), the behavior is undefined. +.ad +T} T{ +.na +The character whose encoding is represented by the one, two, or three-digit octal integer. If the size of a byte on the system is greater than nine bits, the valid escape sequence used to represent a byte is implementation-defined. Multi-byte characters require multiple, concatenated escape sequences of this type, including the leading \fB'\\'\fP for each byte. +.ad +T} +\\x\fIdigits\fP T{ +.na +A backslash character followed by the longest sequence of hexadecimal-digit characters (01234567abcdefABCDEF). If all of the digits are 0 (that is, representation of the NUL character), the behavior is undefined. +.ad +T} T{ +.na +The character whose encoding is represented by the hexadecimal integer. +.ad +T} +\\c T{ +.na +A backslash character followed by any character not described in this table or in the table in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation ( \fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , \fB'\\n'\fP , \fB'\\r'\fP , \fB'\\t'\fP , \fB'\\v'\fP ). +.ad +T} T{ +.na +The character \fB'c'\fP , unchanged. +.ad +T} +.TE +.TP 7 +\fBNote:\fP +If a \fB'\\x'\fP sequence needs to be immediately followed by a hexadecimal +digit character, a sequence such as +\fB"\\x1"\fP \fB"1"\fP can be used, which represents a character containing +the value 1, followed by the character +\fB'1'\fP . +.sp +.LP +The order of precedence given to extended regular expressions for +\fIlex\fP differs from that specified in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 9.4, Extended Regular +Expressions. The order of precedence for \fIlex\fP shall be as shown +in the following table, from high to low. +.TP 7 +\fBNote:\fP +The escaped characters entry is not meant to imply that these are +operators, but they are included in the table to show their +relationships to the true operators. The start condition, trailing +context, and anchoring notations have been omitted from the +table because of the placement restrictions described in this section; +they can only appear at the beginning or ending of an +ERE. +.sp +.sp +.sp +.ce 1 +\fBTable: ERE Precedence in \fIlex\fP\fP +.TS C +center; l2 l. +\fBExtended Regular Expression\fP \fBPrecedence\fP +collation-related bracket symbols [= =] [: :] [. .] +escaped characters \\<\fIspecial character\fP> +bracket expression [ ] +quoting "..." +grouping ( ) +definition {\fIname\fP} +single-character RE duplication * + ? +concatenation \ +interval expression {m,n} +alternation | +.TE +.LP +The ERE anchoring operators \fB'^'\fP and \fB'$'\fP do not appear +in the table. With \fIlex\fP regular expressions, these +operators are restricted in their use: the \fB'^'\fP operator can +only be used at the beginning of an entire regular expression, +and the \fB'$'\fP operator only at the end. The operators apply to +the entire regular expression. Thus, for example, the pattern +\fB"(^abc)|(def$)"\fP is undefined; it can instead be written as two +separate rules, one with the regular expression +\fB"^abc"\fP and one with \fB"def$"\fP , which share a common action +via the special \fB'|'\fP action (see below). If the +pattern were written \fB"^abc|def$"\fP , it would match either \fB"abc"\fP +or \fB"def"\fP on a line by itself. +.LP +Unlike the general ERE rules, embedded anchoring is not allowed by +most historical \fIlex\fP implementations. An example of +embedded anchoring would be for patterns such as \fB"(^|\ )foo(\ |$)"\fP +to match \fB"foo"\fP when it exists as a +complete word. This functionality can be obtained using existing \fIlex\fP +features: +.sp +.RS +.nf + +\fB^foo/[ \\n] | +" foo"/[ \\n] /* Found foo as a separate word. */ +\fP +.fi +.RE +.LP +Note also that \fB'$'\fP is a form of trailing context (it is equivalent +to \fB"/\\n"\fP ) and as such cannot be used with +regular expressions containing another instance of the operator (see +the preceding discussion of trailing context). +.LP +The additional regular expressions trailing-context operator \fB'/'\fP +can be used as an ordinary character if presented +within double-quotes, \fB"/"\fP ; preceded by a backslash, \fB"\\/"\fP +; or within a bracket expression, \fB"[/]"\fP . The +start-condition \fB'<'\fP and \fB'>'\fP operators shall be special +only in a start condition at the beginning of a +regular expression; elsewhere in the regular expression they shall +be treated as ordinary characters. +.SS Actions in lex +.LP +The action to be taken when an ERE is matched can be a C program fragment +or the special actions described below; the program +fragment can contain one or more C statements, and can also include +special actions. The empty C statement \fB';'\fP shall be a +valid action; any string in the \fBlex.yy.c\fP input that matches +the pattern portion of such a rule is effectively ignored or +skipped. However, the absence of an action shall not be valid, and +the action \fIlex\fP takes in such a condition is +undefined. +.LP +The specification for an action, including C statements and special +actions, can extend across several lines if enclosed in +braces: +.sp +.RS +.nf + +\fIERE\fP \fB<\fP\fIone or more blanks\fP\fB> {\fP \fIprogram statement + program statement\fP \fB} +\fP +.fi +.RE +.LP +The default action when a string in the input to a \fBlex.yy.c\fP +program is not matched by any expression shall be to copy the +string to the output. Because the default behavior of a program generated +by \fIlex\fP is to read the input and copy it to the +output, a minimal \fIlex\fP source program that has just \fB"%%"\fP +shall generate a C program that simply copies the input to +the output unchanged. +.LP +Four special actions shall be available: +.sp +.RS +.nf + +\fB| ECHO; REJECT; BEGIN +\fP +.fi +.RE +.TP 7 +\fB|\fP +The action \fB'|'\fP means that the action for the next rule is the +action for this rule. Unlike the other three actions, +\fB'|'\fP cannot be enclosed in braces or be semicolon-terminated; +the application shall ensure that it is specified alone, with +no other actions. +.TP 7 +\fBECHO;\fP +Write the contents of the string \fIyytext\fP on the output. +.TP 7 +\fBREJECT;\fP +Usually only a single expression is matched by a given string in the +input. \fBREJECT\fP means "continue to the next +expression that matches the current input", and shall cause whatever +rule was the second choice after the current rule to be +executed for the same input. Thus, multiple rules can be matched and +executed for one input string or overlapping input strings. +For example, given the regular expressions \fB"xyz"\fP and \fB"xy"\fP +and the input \fB"xyz"\fP , usually only the regular +expression \fB"xyz"\fP would match. The next attempted match would +start after \fBz.\fP If the last action in the +\fB"xyz"\fP rule is \fBREJECT\fP, both this rule and the \fB"xy"\fP +rule would be executed. The \fBREJECT\fP action may be +implemented in such a fashion that flow of control does not continue +after it, as if it were equivalent to a \fBgoto\fP to another +part of \fIyylex\fP(). The use of \fBREJECT\fP may result in somewhat +larger and slower scanners. +.TP 7 +\fBBEGIN\fP +The action: +.sp +.RS +.nf + +\fBBEGIN\fP \fInewstate\fP\fB; +\fP +.fi +.RE +.LP +switches the state (start condition) to \fInewstate\fP. If the string +\fInewstate\fP has not been declared previously as a +start condition in the \fIDefinitions\fP section, the results are +unspecified. The initial state is indicated by the digit +\fB'0'\fP or the token \fBINITIAL\fP. +.sp +.LP +The functions or macros described below are accessible to user code +included in the \fIlex\fP input. It is unspecified whether +they appear in the C code output of \fIlex\fP, or are accessible only +through the \fB-l\ l\fP operand to \fIc99\fP (the \fIlex\fP library). +.TP 7 +\fBint\ \fP \fIyylex\fP(\fBvoid\fP) +.sp +Performs lexical analysis on the input; this is the primary function +generated by the \fIlex\fP utility. The function shall return +zero when the end of input is reached; otherwise, it shall return +non-zero values (tokens) determined by the actions that are +selected. +.TP 7 +\fBint\ \fP \fIyymore\fP(\fBvoid\fP) +.sp +When called, indicates that when the next input string is recognized, +it is to be appended to the current value of \fIyytext\fP +rather than replacing it; the value in \fIyyleng\fP shall be adjusted +accordingly. +.TP 7 +\fBint\ \fP \fIyyless\fP(\fBint\ \fP \fIn\fP) +.sp +Retains \fIn\fP initial characters in \fIyytext\fP, NUL-terminated, +and treats the remaining characters as if they had not been +read; the value in \fIyyleng\fP shall be adjusted accordingly. +.TP 7 +\fBint\ \fP \fIinput\fP(\fBvoid\fP) +.sp +Returns the next character from the input, or zero on end-of-file. +It shall obtain input from the stream pointer \fIyyin\fP, +although possibly via an intermediate buffer. Thus, once scanning +has begun, the effect of altering the value of \fIyyin\fP is +undefined. The character read shall be removed from the input stream +of the scanner without any processing by the scanner. +.TP 7 +\fBint\ \fP \fIunput\fP(\fBint\ \fP \fIc\fP) +.sp +Returns the character \fB'c'\fP to the input; \fIyytext\fP and \fIyyleng\fP +are undefined until the next expression is +matched. The result of using \fIunput\fP() for more characters than +have been input is unspecified. +.sp +.LP +The following functions shall appear only in the \fIlex\fP library +accessible through the \fB-l\ l\fP operand; they can +therefore be redefined by a conforming application: +.TP 7 +\fBint\ \fP \fIyywrap\fP(\fBvoid\fP) +.sp +Called by \fIyylex\fP() at end-of-file; the default \fIyywrap\fP() +shall always return 1. If the application requires +\fIyylex\fP() to continue processing with another source of input, +then the application can include a function \fIyywrap\fP(), +which associates another file with the external variable \fBFILE *\fP +\fIyyin\fP and shall return a value of zero. +.TP 7 +\fBint\ \fP \fImain\fP(\fBint\ \fP \fIargc\fP, \fBchar *\fP\fIargv\fP[]) +.sp +Calls \fIyylex\fP() to perform lexical analysis, then exits. The user +code can contain \fImain\fP() to perform +application-specific operations, calling \fIyylex\fP() as applicable. +.sp +.LP +Except for \fIinput\fP(), \fIunput\fP(), and \fImain\fP(), all external +and static names generated by \fIlex\fP shall begin +with the prefix \fByy\fP or \fBYY\fP. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Conforming applications are warned that in the \fIRules\fP section, +an ERE without an action is not acceptable, but need not be +detected as erroneous by \fIlex\fP. This may result in compilation +or runtime errors. +.LP +The purpose of \fIinput\fP() is to take characters off the input stream +and discard them as far as the lexical analysis is +concerned. A common use is to discard the body of a comment once the +beginning of a comment is recognized. +.LP +The \fIlex\fP utility is not fully internationalized in its treatment +of regular expressions in the \fIlex\fP source code or +generated lexical analyzer. It would seem desirable to have the lexical +analyzer interpret the regular expressions given in the +\fIlex\fP source according to the environment specified when the lexical +analyzer is executed, but this is not possible with the +current \fIlex\fP technology. Furthermore, the very nature of the +lexical analyzers produced by \fIlex\fP must be closely tied to +the lexical requirements of the input language being described, which +is frequently locale-specific anyway. (For example, writing +an analyzer that is used for French text is not automatically useful +for processing other languages.) +.SH EXAMPLES +.LP +The following is an example of a \fIlex\fP program that implements +a rudimentary scanner for a Pascal-like syntax: +.sp +.RS +.nf + +\fB%{ +/* Need this for the call to atof() below. */ +#include <math.h> +/* Need this for printf(), fopen(), and stdin below. */ +#include <stdio.h> +%} +.sp + +DIGIT [0-9] +ID [a-z][a-z0-9]* +.sp + +%% +.sp + +{DIGIT}+ { + printf("An integer: %s (%d)\\n", yytext, + atoi(yytext)); + } +.sp + +{DIGIT}+"."{DIGIT}* { + printf("A float: %s (%g)\\n", yytext, + atof(yytext)); + } +.sp + +if|then|begin|end|procedure|function { + printf("A keyword: %s\\n", yytext); + } +.sp + +{ID} printf("An identifier: %s\\n", yytext); +.sp + +"+"|"-"|"*"|"/" printf("An operator: %s\\n", yytext); +.sp + +"{"[^}\\n]*"}" /* Eat up one-line comments. */ +.sp + +[ \\t\\n]+ /* Eat up white space. */ +.sp + +\&. printf("Unrecognized character: %s\\n", yytext); +.sp + +%% +.sp + +int main(int argc, char *argv[]) +{ + ++argv, --argc; /* Skip over program name. */ + if (argc > 0) + yyin = fopen(argv[0], "r"); + else + yyin = stdin; +.sp + + yylex(); +} +\fP +.fi +.RE +.SH RATIONALE +.LP +Even though the \fB-c\fP option and references to the C language are +retained in this description, \fIlex\fP may be +generalized to other languages, as was done at one time for EFL, the +Extended FORTRAN Language. Since the \fIlex\fP input +specification is essentially language-independent, versions of this +utility could be written to produce Ada, Modula-2, or Pascal +code, and there are known historical implementations that do so. +.LP +The current description of \fIlex\fP bypasses the issue of dealing +with internationalized EREs in the \fIlex\fP source code or +generated lexical analyzer. If it follows the model used by \fIawk\fP +(the source code is +assumed to be presented in the POSIX locale, but input and output +are in the locale specified by the environment variables), then +the tables in the lexical analyzer produced by \fIlex\fP would interpret +EREs specified in the \fIlex\fP source in terms of the +environment variables specified when \fIlex\fP was executed. The desired +effect would be to have the lexical analyzer interpret +the EREs given in the \fIlex\fP source according to the environment +specified when the lexical analyzer is executed, but this is +not possible with the current \fIlex\fP technology. +.LP +The description of octal and hexadecimal-digit escape sequences agrees +with the ISO\ C standard use of escape sequences. See +the RATIONALE for \fIed\fP for a discussion of bytes larger than 9 +bits being represented by octal values. +Hexadecimal values can represent larger bytes and multi-byte characters +directly, using as many digits as required. +.LP +There is no detailed output format specification. The observed behavior +of \fIlex\fP under four different historical +implementations was that none of these implementations consistently +reported the line numbers for error and warning messages. +Furthermore, there was a desire that \fIlex\fP be allowed to output +additional diagnostic messages. Leaving message formats +unspecified avoids these formatting questions and problems with internationalization. +.LP +Although the \fB%x\fP specifier for \fIexclusive\fP start conditions +is not historical practice, it is believed to be a +minor change to historical implementations and greatly enhances the +usability of \fIlex\fP programs since it permits an +application to obtain the expected functionality with fewer statements. +.LP +The \fB%array\fP and \fB%pointer\fP declarations were added as a compromise +between historical systems. The System V-based +\fIlex\fP copies the matched text to a \fIyytext\fP array. The \fIflex\fP +program, supported in BSD and GNU systems, uses a +pointer. In the latter case, significant performance improvements +are available for some scanners. Most historical programs should +require no change in porting from one system to another because the +string being referenced is null-terminated in both cases. (The +method used by \fIflex\fP in its case is to null-terminate the token +in place by remembering the character that used to come right +after the token and replacing it before continuing on to the next +scan.) Multi-file programs with external references to +\fIyytext\fP outside the scanner source file should continue to operate +on their historical systems, but would require one of the +new declarations to be considered strictly portable. +.LP +The description of EREs avoids unnecessary duplication of ERE details +because their meanings within a \fIlex\fP ERE are the +same as that for the ERE in this volume of IEEE\ Std\ 1003.1-2001. +.LP +The reason for the undefined condition associated with text beginning +with a <blank> or within \fB"%{"\fP and +\fB"%}"\fP delimiter lines appearing in the \fIRules\fP section is +historical practice. Both the BSD and System V \fIlex\fP +copy the indented (or enclosed) input in the \fIRules\fP section (except +at the beginning) to unreachable areas of the +\fIyylex\fP() function (the code is written directly after a \fIbreak\fP +statement). In some cases, the System V \fIlex\fP generates an error +message or a syntax error, depending on the form of indented +input. +.LP +The intention in breaking the list of functions into those that may +appear in \fBlex.yy.c\fP \fIversus\fP those that only +appear in \fBlibl.a\fP is that only those functions in \fBlibl.a\fP +can be reliably redefined by a conforming application. +.LP +The descriptions of standard output and standard error are somewhat +complicated because historical \fIlex\fP implementations +chose to issue diagnostic messages to standard output (unless \fB-t\fP +was given). IEEE\ Std\ 1003.1-2001 allows this +behavior, but leaves an opening for the more expected behavior of +using standard error for diagnostics. Also, the System V behavior +of writing the statistics when any table sizes are given is allowed, +while BSD-derived systems can avoid it. The programmer can +always precisely obtain the desired results by using either the \fB-t\fP +or \fB-n\fP options. +.LP +The OPERANDS section does not mention the use of \fB-\fP as a synonym +for standard input; not all historical implementations +support such usage for any of the \fIfile\fP operands. +.LP +A description of the \fItranslation table\fP was deleted from early +proposals because of its relatively low usage in historical +applications. +.LP +The change to the definition of the \fIinput\fP() function that allows +buffering of input presents the opportunity for major +performance gains in some applications. +.LP +The following examples clarify the differences between \fIlex\fP regular +expressions and regular expressions appearing +elsewhere in this volume of IEEE\ Std\ 1003.1-2001. For regular expressions +of the form \fB"r/x"\fP , the string +matching \fIr\fP is always returned; confusion may arise when the +beginning of \fIx\fP matches the trailing portion of \fIr\fP. +For example, given the regular expression \fB"a*b/cc"\fP and the input +\fB"aaabcc"\fP , \fIyytext\fP would contain the +string \fB"aaab"\fP on this match. But given the regular expression +\fB"x*/xy"\fP and the input \fB"xxxy"\fP , the token +\fBxxx\fP, not \fBxx\fP, is returned by some implementations because +\fBxxx\fP matches \fB"x*"\fP . +.LP +In the rule \fB"ab*/bc"\fP , the \fB"b*"\fP at the end of \fIr\fP +extends \fIr\fP's match into the beginning of the +trailing context, so the result is unspecified. If this rule were +\fB"ab/bc"\fP , however, the rule matches the text +\fB"ab"\fP when it is followed by the text \fB"bc"\fP . In this latter +case, the matching of \fIr\fP cannot extend into the +beginning of \fIx\fP, so the result is specified. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP , \fIed\fP , \fIyacc\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/link.1p b/man1p/link.1p new file mode 100644 index 000000000..0a6c157e9 --- /dev/null +++ b/man1p/link.1p @@ -0,0 +1,127 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LINK" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" link +.SH NAME +link \- call link function +.SH SYNOPSIS +.LP +\fBlink\fP \fIfile1 file2\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIlink\fP utility shall perform the function call: +.sp +.RS +.nf + +\fBlink(\fP\fIfile1\fP\fB,\fP \fIfile2\fP\fB); +\fP +.fi +.RE +.LP +A user may need appropriate privilege to invoke the \fIlink\fP utility. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile1\fP +The pathname of an existing file. +.TP 7 +\fIfile2\fP +The pathname of the new directory entry to be created. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +Not used. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIlink\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +.sp +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIln\fP , \fIunlink\fP() , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIlink\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ln.1p b/man1p/ln.1p new file mode 100644 index 000000000..6b2f3eb9d --- /dev/null +++ b/man1p/ln.1p @@ -0,0 +1,262 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ln +.SH NAME +ln \- link files +.SH SYNOPSIS +.LP +\fBln\fP \fB[\fP\fB-fs\fP\fB]\fP \fIsource_file target_file\fP\fB +.br +.sp +ln\fP \fB[\fP\fB-fs\fP\fB]\fP \fIsource_file\fP \fB...\fP \fItarget_dir\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +In the first synopsis form, the \fIln\fP utility shall create a new +directory entry (link) at the destination path specified by +the \fItarget_file\fP operand. If the \fB-s\fP option is specified, +a symbolic link shall be created for the file specified by +the \fIsource_file\fP operand. This first synopsis form shall be assumed +when the final operand does not name an existing +directory; if more than two operands are specified and the final is +not an existing directory, an error shall result. +.LP +In the second synopsis form, the \fIln\fP utility shall create a new +directory entry (link), or if the \fB-s\fP option is +specified a symbolic link, for each file specified by a \fIsource_file\fP +operand, at a destination path in the existing directory +named by \fItarget_dir\fP. +.LP +If the last operand specifies an existing file of a type not specified +by the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, the behavior is implementation-defined. +.LP +The corresponding destination path for each \fIsource_file\fP shall +be the concatenation of the target directory pathname, a +slash character, and the last pathname component of the \fIsource_file\fP. +The second synopsis form shall be assumed when the +final operand names an existing directory. +.LP +For each \fIsource_file\fP: +.IP " 1." 4 +If the destination path exists: +.RS +.IP " a." 4 +If the \fB-f\fP option is not specified, \fIln\fP shall write a diagnostic +message to standard error, do nothing more with the +current \fIsource_file\fP, and go on to any remaining \fIsource_files\fP. +.LP +.IP " b." 4 +Actions shall be performed equivalent to the \fIunlink\fP() function +defined in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001, called using \fIdestination\fP +as the \fIpath\fP argument. If this +fails for any reason, \fIln\fP shall write a diagnostic message to +standard error, do nothing more with the current +\fIsource_file\fP, and go on to any remaining \fIsource_files\fP. +.LP +.RE +.LP +.IP " 2." 4 +If the \fB-s\fP option is specified, \fIln\fP shall create a symbolic +link named by the destination path and containing as its +pathname \fIsource_file\fP. The \fIln\fP utility shall do nothing +more with \fIsource_file\fP and shall go on to any remaining +files. +.LP +.IP " 3." 4 +If \fIsource_file\fP is a symbolic link, actions shall be performed +equivalent to the \fIlink\fP() function using the object that \fIsource_file\fP +references as the \fIpath1\fP +argument and the destination path as the \fIpath2\fP argument. The +\fIln\fP utility shall do nothing more with \fIsource_file\fP +and shall go on to any remaining files. +.LP +.IP " 4." 4 +Actions shall be performed equivalent to the \fIlink\fP() function +defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001 using \fIsource_file\fP +as the \fIpath1\fP argument, and the destination path +as the \fIpath2\fP argument. +.LP +.SH OPTIONS +.LP +The \fIln\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-f\fP +Force existing destination pathnames to be removed to allow the link. +.TP 7 +\fB-s\fP +Create symbolic links instead of hard links. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIsource_file\fP +A pathname of a file to be linked. If the \fB-s\fP option is specified, +no restrictions on the type of file or on its +existence shall be made. If the \fB-s\fP option is not specified, +whether a directory can be linked is +implementation-defined. +.TP 7 +\fItarget_file\fP +The pathname of the new directory entry to be created. +.TP 7 +\fItarget_dir\fP +A pathname of an existing directory in which the new directory entries +are created. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIln\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All the specified files were linked successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Some historic versions of \fIln\fP (including the one specified by +the SVID) unlink the destination file, if it exists, by +default. If the mode does not permit writing, these versions prompt +for confirmation before attempting the unlink. In these +versions the \fB-f\fP option causes \fIln\fP not to attempt to prompt +for confirmation. +.LP +This allows \fIln\fP to succeed in creating links when the target +file already exists, even if the file itself is not writable +(although the directory must be). Early proposals specified this functionality. +.LP +This volume of IEEE\ Std\ 1003.1-2001 does not allow the \fIln\fP +utility to unlink existing destination paths by +default for the following reasons: +.IP " *" 3 +The \fIln\fP utility has historically been used to provide locking +for shell applications, a usage that is incompatible with +\fIln\fP unlinking the destination path by default. There was no corresponding +technical advantage to adding this +functionality. +.LP +.IP " *" 3 +This functionality gave \fIln\fP the ability to destroy the link structure +of files, which changes the historical behavior of +\fIln\fP. +.LP +.IP " *" 3 +This functionality is easily replicated with a combination of \fIrm\fP +and \fIln\fP. +.LP +.IP " *" 3 +It is not historical practice in many systems; BSD and BSD-derived +systems do not support this behavior. Unfortunately, +whichever behavior is selected can cause scripts written expecting +the other behavior to fail. +.LP +.IP " *" 3 +It is preferable that \fIln\fP perform in the same manner as the \fIlink\fP() +function, +which does not permit the target to exist already. +.LP +.LP +This volume of IEEE\ Std\ 1003.1-2001 retains the \fB-f\fP option +to provide support for shell scripts depending on the +SVID semantics. It seems likely that shell scripts would not be written +to handle prompting by \fIln\fP and would therefore have +specified the \fB-f\fP option. +.LP +The \fB-f\fP option is an undocumented feature of many historical +versions of the \fIln\fP utility, allowing linking to +directories. These versions require modification. +.LP +Early proposals of this volume of IEEE\ Std\ 1003.1-2001 also required +a \fB-i\fP option, which behaved like the +\fB-i\fP options in \fIcp\fP and \fImv\fP, prompting for +confirmation before unlinking existing files. This was not historical +practice for the \fIln\fP utility and has been omitted. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIchmod\fP() , \fIfind\fP , \fIpax\fP , \fIrm\fP , the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, \fIlink\fP(), \fIunlink\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/locale.1p b/man1p/locale.1p new file mode 100644 index 000000000..da12fdfa6 --- /dev/null +++ b/man1p/locale.1p @@ -0,0 +1,441 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LOCALE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" locale +.SH NAME +locale \- get locale-specific information +.SH SYNOPSIS +.LP +\fBlocale\fP \fB[\fP\fB-a| -m\fP\fB]\fP\fB +.br +.sp +locale\fP \fB[\fP\fB-ck\fP\fB]\fP \fIname\fP\fB... +.br +\fP +.SH DESCRIPTION +.LP +The \fIlocale\fP utility shall write information about the current +locale environment, or all public locales, to the standard +output. For the purposes of this section, a \fIpublic locale\fP is +one provided by the implementation that is accessible to the +application. +.LP +When \fIlocale\fP is invoked without any arguments, it shall summarize +the current locale environment for each locale category +as determined by the settings of the environment variables defined +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 7, Locale. +.LP +When invoked with operands, it shall write values that have been assigned +to the keywords in the locale categories, as +follows: +.IP " *" 3 +Specifying a keyword name shall select the named keyword and the category +containing that keyword. +.LP +.IP " *" 3 +Specifying a category name shall select the named category and all +keywords in that category. +.LP +.SH OPTIONS +.LP +The \fIlocale\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Write information about all available public locales. The available +locales shall include \fBPOSIX\fP, representing the POSIX +locale. The manner in which the implementation determines what other +locales are available is implementation-defined. +.TP 7 +\fB-c\fP +Write the names of selected locale categories; see the STDOUT section. +The \fB-c\fP option increases readability when more +than one category is selected (for example, via more than one keyword +name or via a category name). It is valid both with and +without the \fB-k\fP option. +.TP 7 +\fB-k\fP +Write the names and values of selected keywords. The implementation +may omit values for some keywords; see the OPERANDS +section. +.TP 7 +\fB-m\fP +Write names of available charmaps; see the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character Set. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIname\fP +The name of a locale category as defined in the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Chapter 7, Locale, the name of a keyword +in a locale category, or the reserved name +\fBcharmap\fP. The named category or keyword shall be selected for +output. If a single \fIname\fP represents both a locale +category name and a keyword name in the current locale, the results +are unspecified. Otherwise, both category and keyword names can +be specified as \fIname\fP operands, in any sequence. It is implementation-defined +whether any keyword values are written for the +categories \fILC_CTYPE\fP and \fILC_COLLATE .\fP +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIlocale\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.LP +The application shall ensure that the \fILANG ,\fP \fILC_* ,\fP and +\fINLSPATH\fP \ environment variables specify the current locale +environment to be written out; they shall be used +if the \fB-a\fP option is not specified. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If \fIlocale\fP is invoked without any options or operands, the names +and values of the \fILANG\fP and \fILC_*\fP environment +variables described in this volume of IEEE\ Std\ 1003.1-2001 shall +be written to the standard output, one variable per +line, with \fILANG\fP first, and each line using the following format. +Only those variables set in the environment and not +overridden by \fILC_ALL\fP shall be written using this format: +.sp +.RS +.nf + +\fB"%s=%s\\n", <\fP\fIvariable_name\fP\fB>, <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +The names of those \fILC_*\fP variables associated with locale categories +defined in this volume of +IEEE\ Std\ 1003.1-2001 that are not set in the environment or are +overridden by \fILC_ALL\fP shall be written in the +following format: +.sp +.RS +.nf + +\fB"%s=\\"%s\\"\\n", <\fP\fIvariable_name\fP\fB>, <\fP\fIimplied value\fP\fB> +\fP +.fi +.RE +.LP +The <\fIimplied\ value\fP> shall be the name of the locale that has +been selected for that category by the +implementation, based on the values in \fILANG\fP and \fILC_ALL ,\fP +as described in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables. +.LP +The <\fIvalue\fP> and <\fIimplied\ value\fP> shown above shall be +properly quoted for possible later reentry +to the shell. The <\fIvalue\fP> shall not be quoted using double-quotes +(so that it can be distinguished by the user from +the <\fIimplied\ value\fP> case, which always requires double-quotes). +.LP +The \fILC_ALL\fP variable shall be written last, using the first format +shown above. If it is not set, it shall be written +as: +.sp +.RS +.nf + +\fB"LC_ALL=\\n" +\fP +.fi +.RE +.LP +If any arguments are specified: +.IP " 1." 4 +If the \fB-a\fP option is specified, the names of all the public locales +shall be written, each in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIlocale name\fP\fB> +\fP +.fi +.RE +.LP +.IP " 2." 4 +If the \fB-c\fP option is specified, the names of all selected categories +shall be written, each in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIcategory name\fP\fB> +\fP +.fi +.RE +.LP +If keywords are also selected for writing (see following items), the +category name output shall precede the keyword output for +that category. +.LP +If the \fB-c\fP option is not specified, the names of the categories +shall not be written; only the keywords, as selected by +the <\fIname\fP> operand, shall be written. +.LP +.IP " 3." 4 +If the \fB-k\fP option is specified, the names and values of selected +keywords shall be written. If a value is non-numeric, it +shall be written in the following format: +.sp +.RS +.nf + +\fB"%s=\\"%s\\"\\n", <\fP\fIkeyword name\fP\fB>, <\fP\fIkeyword value\fP\fB> +\fP +.fi +.RE +.LP +If the keyword was \fBcharmap\fP, the name of the charmap (if any) +that was specified via the \fIlocaledef\fP \fB-f\fP option when the +locale was created shall be written, with the word +\fBcharmap\fP as <\fIkeyword\ name\fP>. +.LP +If a value is numeric, it shall be written in one of the following +formats: +.sp +.RS +.nf + +\fB"%s=%d\\n", <\fP\fIkeyword name\fP\fB>, <\fP\fIkeyword value\fP\fB> +.sp + +"%s=%c%o\\n", <\fP\fIkeyword name\fP\fB>, <\fP\fIescape character\fP\fB>, <\fP\fIkeyword value\fP\fB> +.sp + +"%s=%cx%x\\n", <\fP\fIkeyword name\fP\fB>, <\fP\fIescape character\fP\fB>, <\fP\fIkeyword value\fP\fB> +\fP +.fi +.RE +.LP +where the <\fIescape\ character\fP> is that identified by the \fBescape_char\fP +keyword in the current locale; see +the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 7.3, +Locale +Definition. +.LP +Compound keyword values (list entries) shall be separated in the output +by semicolons. When included in keyword values, the +semicolon, the double-quote, the backslash, and any control character +shall be preceded (escaped) with the escape character. +.LP +.IP " 4." 4 +If the \fB-k\fP option is not specified, selected keyword values shall +be written, each in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIkeyword value\fP\fB> +\fP +.fi +.RE +.LP +If the keyword was \fBcharmap\fP, the name of the charmap (if any) +that was specified via the \fIlocaledef\fP \fB-f\fP option when the +locale was created shall be written. +.LP +.IP " 5." 4 +If the \fB-m\fP option is specified, then a list of all available +charmaps shall be written, each in the format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIcharmap\fP\fB> +\fP +.fi +.RE +.LP +where <\fIcharmap\fP> is in a format suitable for use as the option-argument +to the \fIlocaledef\fP \fB-f\fP option. +.LP +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All the requested information was found and output successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +If the \fILANG\fP environment variable is not set or set to an empty +value, or one of the \fILC_*\fP environment variables is +set to an unrecognized value, the actual locales assumed (if any) +are implementation-defined as described in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables. +.LP +Implementations are not required to write out the actual values for +keywords in the categories \fILC_CTYPE\fP and \fILC_COLLATE +;\fP however, they must write out the categories (allowing an application +to determine, for example, which character classes are +available). +.SH EXAMPLES +.LP +In the following examples, the assumption is that locale environment +variables are set as follows: +.sp +.RS +.nf + +\fBLANG=locale_x +LC_COLLATE=locale_y +\fP +.fi +.RE +.LP +The command \fIlocale\fP would result in the following output: +.sp +.RS +.nf + +\fBLANG=locale_x +LC_CTYPE="locale_x" +LC_COLLATE=locale_y +LC_TIME="locale_x" +LC_NUMERIC="locale_x" +LC_MONETARY="locale_x" +LC_MESSAGES="locale_x" +LC_ALL= +\fP +.fi +.RE +.LP +The order of presentation of the categories is not specified by this +volume of IEEE\ Std\ 1003.1-2001. +.LP +The command: +.sp +.RS +.nf + +\fBLC_ALL=POSIX locale -ck decimal_point +\fP +.fi +.RE +.LP +would produce: +.sp +.RS +.nf + +\fBLC_NUMERIC +decimal_point="." +\fP +.fi +.RE +.LP +The following command shows an application of \fIlocale\fP to determine +whether a user-supplied response is affirmative: +.sp +.RS +.nf + +\fBif printf "%s\\n" "$response" | grep -Eq "$(locale yesexpr)" +then + affirmative processing goes here +else + non-affirmative processing goes here +fi +\fP +.fi +.RE +.SH RATIONALE +.LP +The output for categories \fILC_CTYPE\fP and \fILC_COLLATE\fP has +been made implementation-defined because there is a +questionable value in having a shell script receive an entire array +of characters. It is also difficult to return a logical +collation description, short of returning a complete \fIlocaledef\fP +source. +.LP +The \fB-m\fP option was included to allow applications to query for +the existence of charmaps. The output is a list of the +charmaps (implementation-supplied and user-supplied, if any) on the +system. +.LP +The \fB-c\fP option was included for readability when more than one +category is selected (for example, via more than one +keyword name or via a category name). It is valid both with and without +the \fB-k\fP option. +.LP +The \fBcharmap\fP keyword, which returns the name of the charmap (if +any) that was used when the current locale was created, +was included to allow applications needing the information to retrieve +it. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIlocaledef\fP , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 7.3, Locale Definition +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/localedef.1p b/man1p/localedef.1p new file mode 100644 index 000000000..e15c7dc6e --- /dev/null +++ b/man1p/localedef.1p @@ -0,0 +1,307 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LOCALEDEF" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" localedef +.SH NAME +localedef \- define locale environment +.SH SYNOPSIS +.LP +\fBlocaledef\fP \fB[\fP\fB-c\fP\fB][\fP\fB-f\fP \fIcharmap\fP\fB][\fP\fB-i\fP +\fIsourcefile\fP\fB][\fP\fB-u\fP \fIcode_set_name\fP\fB]\fP \fIname\fP +.SH DESCRIPTION +.LP +The \fIlocaledef\fP utility shall convert source definitions for locale +categories into a format usable by the functions and +utilities whose operational behavior is determined by the setting +of the locale environment variables defined in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 7, Locale. It +is +implementation-defined whether users have the capability to create +new locales, in addition to those supplied by the +implementation. If the symbolic constant POSIX2_LOCALEDEF is defined, +the system supports the creation of new locales. \ On +XSI-conformant systems, the symbolic constant POSIX2_LOCALEDEF shall +be defined. +.LP +The utility shall read source definitions for one or more locale categories +belonging to the same locale from the file named in +the \fB-i\fP option (if specified) or from standard input. +.LP +The \fIname\fP operand identifies the target locale. The utility shall +support the creation of \fIpublic\fP, or generally +accessible locales, as well as \fIprivate\fP, or restricted-access +locales. Implementations may restrict the capability to create +or modify public locales to users with the appropriate privileges. +.LP +Each category source definition shall be identified by the corresponding +environment variable name and terminated by an +\fBEND\fP \fIcategory-name\fP statement. The following categories +shall be supported. In addition, the input may contain source +for implementation-defined categories. +.TP 7 +\fILC_CTYPE\fP +Defines character classification and case conversion. +.TP 7 +\fILC_COLLATE\fP +.sp +Defines collation rules. +.TP 7 +\fILC_MONETARY\fP +.sp +Defines the format and symbols used in formatting of monetary information. +.TP 7 +\fILC_NUMERIC\fP +.sp +Defines the decimal delimiter, grouping, and grouping symbol for non-monetary +numeric editing. +.TP 7 +\fILC_TIME\fP +Defines the format and content of date and time information. +.TP 7 +\fILC_MESSAGES\fP +.sp +Defines the format and values of affirmative and negative responses. +.sp +.SH OPTIONS +.LP +The \fIlocaledef\fP utility shall conform to the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Create permanent output even if warning messages have been issued. +.TP 7 +\fB-f\ \fP \fIcharmap\fP +Specify the pathname of a file containing a mapping of character symbols +and collating element symbols to actual character +encodings. The format of the \fIcharmap\fP is described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 6.4, Character +Set Description File. The application shall ensure that this +option is specified if symbolic names (other than collating symbols +defined in a \fBcollating-symbol\fP keyword) are used. If the +\fB-f\fP option is not present, an implementation-defined character +mapping shall be used. +.TP 7 +\fB-i\ \fP \fIinputfile\fP +The pathname of a file containing the source definitions. If this +option is not present, source definitions shall be read from +standard input. The format of the \fIinputfile\fP is described in +the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 7.3, Locale Definition. +.TP 7 +\fB-u\ \fP \fIcode_set_name\fP +.sp +Specify the name of a codeset used as the target mapping of character +symbols and collating element symbols whose encoding values +are defined in terms of the ISO/IEC\ 10646-1:2000 standard position +constant values. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIname\fP +Identifies the locale; see the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 7, Locale for a description of the use of this name. If the +name contains one or more +slash characters, \fIname\fP shall be interpreted as a pathname where +the created locale definitions shall be stored. If +\fIname\fP does not contain any slash characters, the interpretation +of the name is implementation-defined and the locale shall be +public. This capability may be restricted to users with appropriate +privileges. (As a consequence of specifying one \fIname\fP, +although several categories can be processed in one execution, only +categories belonging to the same locale can be processed.) +.sp +.SH STDIN +.LP +Unless the \fB-i\fP option is specified, the standard input shall +be a text file containing one or more locale category source +definitions, as described in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 7.3, Locale Definition. When lines are continued using the +escape character +mechanism, there is no limit to the length of the accumulated continued +line. +.SH INPUT FILES +.LP +The character set mapping file specified as the \fIcharmap\fP option-argument +is described in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 6.4, Character Set Description File. +If +a locale category source definition contains a \fBcopy\fP statement, +as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 7, Locale, and the \fBcopy\fP statement +names a +valid, existing locale, then \fIlocaledef\fP shall behave as if the +source definition had contained a valid category source +definition for the named locale. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIlocaledef\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +(This variable has no affect on \fIlocaledef\fP; the POSIX locale +is used for this category.) +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). This +variable has no affect on the processing of \fIlocaledef\fP +input data; the POSIX locale is used for this purpose, regardless +of the value of this variable. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The utility shall report all categories successfully processed, in +an unspecified format. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The format of the created output is unspecified. If the \fIname\fP +operand does not contain a slash, the existence of an output +file for the locale is unspecified. +.SH EXTENDED DESCRIPTION +.LP +When the \fB-u\fP option is used, the \fIcode_set_name\fP option-argument +shall be interpreted as an implementation-defined +name of a codeset to which the ISO/IEC\ 10646-1:2000 standard position +constant values shall be converted via an +implementation-defined method. Both the ISO/IEC\ 10646-1:2000 standard +position constant values and other formats (decimal, +hexadecimal, or octal) shall be valid as encoding values within the +\fIcharmap\fP file. The codeset represented by the +implementation-defined name can be any codeset that is supported by +the implementation. +.LP +When conflicts occur between the \fIcharmap\fP specification of <\fIcode_set_name\fP>, +<\fImb_cur_max\fP>, or +<\fImb_cur_min\fP> and the implementation-defined interpretation of +these respective items for the codeset represented by +the \fB-u\fP option-argument \fIcode_set_name\fP, the result is unspecified. +.LP +When conflicts occur between the \fIcharmap\fP encoding values specified +for symbolic names of characters of the portable +character set and the implementation-defined assignment of character +encoding values, the result is unspecified. +.LP +If a non-printable character in the \fIcharmap\fP has a width specified +that is not \fB-1\fP, \fIlocaledef\fP shall generate +a warning. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +No errors occurred and the locales were successfully created. +.TP 7 +\ 1 +Warnings occurred and the locales were successfully created. +.TP 7 +\ 2 +The locale specification exceeded implementation limits or the coded +character set or sets used were not supported by the +implementation, and no locale was created. +.TP 7 +\ 3 +The capability to create new locales is not supported by the implementation. +.TP 7 +>3 +Warnings or errors occurred and no output was created. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If an error is detected, no permanent output shall be created. +.LP +If warnings occur, permanent output shall be created if the \fB-c\fP +option was specified. The following conditions shall cause +warning messages to be issued: +.IP " *" 3 +If a symbolic name not found in the \fIcharmap\fP file is used for +the descriptions of the \fILC_CTYPE\fP or \fILC_COLLATE\fP +categories (for other categories, this shall be an error condition). +.LP +.IP " *" 3 +If the number of operands to the \fBorder\fP keyword exceeds the {COLL_WEIGHTS_MAX} +limit. +.LP +.IP " *" 3 +If optional keywords not supported by the implementation are present +in the source. +.LP +.IP " *" 3 +If a non-printable character has a width specified other than -1. +.LP +.LP +Other implementation-defined conditions may also cause warnings. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIcharmap\fP definition is optional, and is contained outside +the locale definition. This allows both completely +self-defined source files, and generic sources (applicable to more +than one codeset). To aid portability, all \fIcharmap\fP +definitions must use the same symbolic names for the portable character +set. As explained in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 6.4, Character Set Description File, +it +is implementation-defined whether or not users or applications can +provide additional character set description files. Therefore, +the \fB-f\fP option might be operable only when an implementation-defined +\fIcharmap\fP is named. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The output produced by the \fIlocaledef\fP utility is implementation-defined. +The \fIname\fP operand is used to identify the +specific locale. (As a consequence, although several categories can +be processed in one execution, only categories belonging to the +same locale can be processed.) +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIlocale\fP , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 7.3, Locale Definition +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/logger.1p b/man1p/logger.1p new file mode 100644 index 000000000..ec1f9d064 --- /dev/null +++ b/man1p/logger.1p @@ -0,0 +1,160 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LOGGER" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" logger +.SH NAME +logger \- log messages +.SH SYNOPSIS +.LP +\fBlogger\fP \fIstring\fP \fB...\fP +.SH DESCRIPTION +.LP +The \fIlogger\fP utility saves a message, in an unspecified manner +and format, containing the \fIstring\fP operands provided +by the user. The messages are expected to be evaluated later by personnel +performing system administration tasks. +.LP +It is implementation-defined whether messages written in locales other +than the POSIX locale are effective. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIstring\fP +One of the string arguments whose contents are concatenated together, +in the order specified, separated by single +<space>s. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIlogger\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error. +(This means diagnostics from \fIlogger\fP to the user or application, +not diagnostic messages that the user is sending to the +system administrator.) +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Unspecified. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +This utility allows logging of information for later use by a system +administrator or programmer in determining why +non-interactive utilities have failed. The locations of the saved +messages, their format, and retention period are all unspecified. +There is no method for a conforming application to read messages, +once written. +.SH EXAMPLES +.LP +A batch application, running non-interactively, tries to read a configuration +file and fails; it may attempt to notify the +system administrator with: +.sp +.RS +.nf + +\fBlogger myname: unable to read file foo. [timestamp] +\fP +.fi +.RE +.SH RATIONALE +.LP +The standard developers believed strongly that some method of alerting +administrators to errors was necessary. The obvious +example is a batch utility, running non-interactively, that is unable +to read its configuration files or that is unable to create +or write its results file. However, the standard developers did not +wish to define the format or delivery mechanisms as they have +historically been (and will probably continue to be) very system-specific, +as well as involving functionality clearly outside the +scope of this volume of IEEE\ Std\ 1003.1-2001. +.LP +The text with \fILC_MESSAGES\fP about diagnostic messages means diagnostics +from \fIlogger\fP to the user or application, not +diagnostic messages that the user is sending to the system administrator. +.LP +Multiple \fIstring\fP arguments are allowed, similar to \fIecho\fP, +for ease-of-use. +.LP +Like the utilities \fImailx\fP and \fIlp\fP, +\fIlogger\fP is admittedly difficult to test. This was not deemed +sufficient justification to exclude these utilities from this +volume of IEEE\ Std\ 1003.1-2001. It is also arguable that they are, +in fact, testable, but that the tests themselves are +not portable. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIlp\fP , \fImailx\fP , \fIwrite\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/logname.1p b/man1p/logname.1p new file mode 100644 index 000000000..8c3b45246 --- /dev/null +++ b/man1p/logname.1p @@ -0,0 +1,129 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LOGNAME" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" logname +.SH NAME +logname \- return the user's login name +.SH SYNOPSIS +.LP +\fBlogname\fP +.SH DESCRIPTION +.LP +The \fIlogname\fP utility shall write the user's login name to standard +output. The login name shall be the string that would +be returned by the \fIgetlogin\fP() function defined in the System +Interfaces volume of +IEEE\ Std\ 1003.1-2001. Under the conditions where the \fIgetlogin\fP() +function +would fail, the \fIlogname\fP utility shall write a diagnostic message +to standard error and exit with a non-zero exit status. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIlogname\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIlogname\fP utility output shall be a single line consisting +of the user's login name: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIlogin name\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIlogname\fP utility explicitly ignores the \fILOGNAME\fP environment +variable because environment changes could produce +erroneous results. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fBpasswd\fP file is not listed as required because the implementation +may have other means of mapping login names. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIid\fP , \fIwho\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIgetlogin\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/lp.1p b/man1p/lp.1p new file mode 100644 index 000000000..4f8649413 --- /dev/null +++ b/man1p/lp.1p @@ -0,0 +1,388 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" lp +.SH NAME +lp \- send files to a printer +.SH SYNOPSIS +.LP +\fBlp\fP \fB[\fP\fB-c\fP\fB][\fP\fB-d\fP \fIdest\fP\fB][\fP\fB-n\fP +\fIcopies\fP\fB][\fP\fB-msw\fP\fB][\fP\fB-o\fP \fIoption\fP\fB]\fP\fB...\fP +\fB[\fP\fB-t\fP +\fItitle\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIlp\fP utility shall copy the input files to an output destination +in an unspecified manner. The default output +destination should be to a hardcopy device, such as a printer or microfilm +recorder, that produces non-volatile, human-readable +documents. If such a device is not available to the application, or +if the system provides no such device, the \fIlp\fP utility +shall exit with a non-zero exit status. +.LP +The actual writing to the output device may occur some time after +the \fIlp\fP utility successfully exits. During the portion +of the writing that corresponds to each input file, the implementation +shall guarantee exclusive access to the device. +.LP +The \fIlp\fP utility shall associate a unique \fIrequest ID\fP with +each request. +.LP +Normally, a banner page is produced to separate and identify each +print job. This page may be suppressed by +implementation-defined conditions, such as an operator command or +one of the \fB-o\fP \fIoption\fP values. +.SH OPTIONS +.LP +The \fIlp\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Exit only after further access to any of the input files is no longer +required. The application can then safely delete or +modify the files without affecting the output operation. Normally, +files are not copied, but are linked whenever possible. If the +\fB-c\fP option is not given, then the user should be careful not +to remove any of the files before the request has been printed +in its entirety. It should also be noted that in the absence of the +\fB-c\fP option, any changes made to the named files after the +request is made but before it is printed may be reflected in the printed +output. On some implementations, \fB-c\fP may be on by +default. +.TP 7 +\fB-d\ \fP \fIdest\fP +Specify a string that names the destination ( \fIdest\fP). If \fIdest\fP +is a printer, the request shall be printed only on +that specific printer. If \fIdest\fP is a class of printers, the request +shall be printed on the first available printer that is a +member of the class. Under certain conditions (printer unavailability, +file space limitation, and so on), requests for specific +destinations need not be accepted. Destination names vary between +systems. +.LP +If \fB-d\fP is not specified, and neither the \fILPDEST\fP nor \fIPRINTER\fP +environment variable is set, an unspecified +destination is used. The \fB-d\fP \fIdest\fP option shall take precedence +over \fILPDEST ,\fP which in turn shall take +precedence over \fIPRINTER .\fP Results are undefined when \fIdest\fP +contains a value that is not a valid destination name. +.TP 7 +\fB-m\fP +Send mail (see \fImailx\fP ) after the files have been printed. By +default, no mail is sent upon +normal completion of the print request. +.TP 7 +\fB-n\ \fP \fIcopies\fP +Write \fIcopies\fP number of copies of the files, where \fIcopies\fP +is a positive decimal integer. The methods for producing +multiple copies and for arranging the multiple copies when multiple +\fIfile\fP operands are used are unspecified, except that each +file shall be output as an integral whole, not interleaved with portions +of other files. +.TP 7 +\fB-o\ \fP \fIoption\fP +Specify printer-dependent or class-dependent \fIoption\fPs. Several +such \fIoption\fPs may be collected by specifying the +\fB-o\fP option more than once. +.TP 7 +\fB-s\fP +Suppress messages from \fIlp\fP. +.TP 7 +\fB-t\ \fP \fItitle\fP +Write \fItitle\fP on the banner page of the output. +.TP 7 +\fB-w\fP +Write a message on the user's terminal after the files have been printed. +If the user is not logged in, then mail shall be sent +instead. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be output. If no \fIfile\fP operands are specified, +or if a \fIfile\fP operand is \fB'-'\fP , the +standard input shall be used. If a \fIfile\fP operand is used, but +the \fB-c\fP option is not specified, the process performing +the writing to the output device may have user and group permissions +that differ from that of the process invoking \fIlp\fP. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP . +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIlp\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fILC_TIME\fP +Determine the format and contents of date and time strings displayed +in the \fIlp\fP banner page, if any. +.TP 7 +\fILPDEST\fP +Determine the destination. If the \fILPDEST\fP environment variable +is not set, the \fIPRINTER\fP environment variable shall +be used. The \fB-d\fP \fIdest\fP option takes precedence over \fILPDEST +\&.\fP Results are undefined when \fB-d\fP is not +specified and \fILPDEST\fP contains a value that is not a valid destination +name. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPRINTER\fP +Determine the output device or destination. If the \fILPDEST\fP and +\fIPRINTER\fP environment variables are not set, an +unspecified output device is used. The \fB-d\fP \fIdest\fP option +and the \fILPDEST\fP environment variable shall take +precedence over \fIPRINTER .\fP Results are undefined when \fB-d\fP +is not specified, \fILPDEST\fP is unset, and \fIPRINTER\fP +contains a value that is not a valid device or destination name. +.TP 7 +\fITZ\fP +Determine the timezone used to calculate date and time strings displayed +in the \fIlp\fP banner page, if any. If \fITZ\fP is +unset or null, an unspecified default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIlp\fP utility shall write a \fIrequest ID\fP to the standard +output, unless \fB-s\fP is specified. The format of the +message is unspecified. The request ID can be used on systems supporting +the historical \fIcancel\fP and \fIlpstat\fP +utilities. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were processed successfully. +.TP 7 +>0 +No output device was available, or an error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIpr\fP and \fIfold\fP utilities can be used to +achieve reasonable formatting for the implementation's default page +size. +.LP +A conforming application can use one of the \fIfile\fP operands only +with the \fB-c\fP option or if the file is publicly +readable and guaranteed to be available at the time of printing. This +is because IEEE\ Std\ 1003.1-2001 gives the +implementation the freedom to queue up the request for printing at +some later time by a different process that might not be able to +access the file. +.SH EXAMPLES +.IP " 1." 4 +To print file \fIfile\fP: +.sp +.RS +.nf + +\fBlp -c\fP \fIfile\fP +.fi +.RE +.LP +.IP " 2." 4 +To print multiple files with headers: +.sp +.RS +.nf + +\fBpr\fP \fIfile1 file2\fP \fB| lp +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fIlp\fP utility was designed to be a basic version of a utility +that is already available in many historical +implementations. The standard developers considered that it should +be implementable simply as: +.sp +.RS +.nf + +\fBcat "$@" > /dev/lp +\fP +.fi +.RE +.LP +after appropriate processing of options, if that is how the implementation +chose to do it and if exclusive access could be +granted (so that two users did not write to the device simultaneously). +Although in the future the standard developers may add +other options to this utility, it should always be able to execute +with no options or operands and send the standard input to an +unspecified output device. +.LP +This volume of IEEE\ Std\ 1003.1-2001 makes no representations concerning +the format of the printed output, except that +it must be "human-readable" and "non-volatile". Thus, writing by default +to a disk or tape drive or a display terminal would +not qualify. (Such destinations are not prohibited when \fB-d\fP \fIdest\fP, +\fILPDEST ,\fP or \fIPRINTER\fP are used, +however.) +.LP +This volume of IEEE\ Std\ 1003.1-2001 is worded such that a "print +job" consisting of multiple input files, possibly +in multiple copies, is guaranteed to print so that any one file is +not intermixed with another, but there is no statement that all +the files or copies have to print out together. +.LP +The \fB-c\fP option may imply a spooling operation, but this is not +required. The utility can be implemented to wait until the +printer is ready and then wait until it is finished. Because of that, +there is no attempt to define a queuing mechanism +(priorities, classes of output, and so on). +.LP +On some historical systems, the request ID reported on the STDOUT +can be used to later cancel or find the status of a request +using utilities not defined in this volume of IEEE\ Std\ 1003.1-2001. +.LP +Although the historical System V \fIlp\fP and BSD \fIlpr\fP utilities +have provided similar functionality, they used different +names for the environment variable specifying the destination printer. +Since the name of the utility here is \fIlp\fP, +\fILPDEST\fP (used by the System V \fIlp\fP utility) was given precedence +over \fIPRINTER\fP (used by the BSD \fIlpr\fP +utility). Since environments of users frequently contain one or the +other environment variable, the \fIlp\fP utility is required +to recognize both. If this was not done, many applications would send +output to unexpected output devices when users moved from +system to system. +.LP +Some have commented that \fIlp\fP has far too little functionality +to make it worthwhile. Requests have proposed additional +options or operands or both that added functionality. The requests +included: +.IP " *" 3 +Wording \fIrequiring\fP the output to be "hardcopy" +.LP +.IP " *" 3 +A requirement for multiple printers +.LP +.IP " *" 3 +Options for supporting various page-description languages +.LP +.LP +Given that a compliant system is not required to even have a printer, +placing further restrictions upon the behavior of the +printer is not useful. Since hardcopy format is so application-dependent, +it is difficult, if not impossible, to select a +reasonable subset of functionality that should be required on all +compliant systems. +.LP +The term \fIunspecified\fP is used in this section in lieu of \fIimplementation-defined\fP +as most known implementations would +not be able to make definitive statements in their conformance documents; +the existence and usage of printers is very dependent on +how the system administrator configures each individual system. +.LP +Since the default destination, device type, queuing mechanisms, and +acceptable forms of input are all unspecified, usage +guidelines for what a conforming application can do are as follows: +.IP " *" 3 +Use the command in a pipeline, or with \fB-c\fP, so that there are +no permission problems and the files can be safely deleted +or modified. +.LP +.IP " *" 3 +Limit output to text files of reasonable line lengths and printable +characters and include no device-specific formatting +information, such as a page description language. The meaning of "reasonable" +in this context can only be answered as a +quality-of-implementation issue, but it should be apparent from historical +usage patterns in the industry and the locale. The \fIpr\fP and \fIfold\fP +utilities can be used to achieve +reasonable formatting for the default page size of the implementation. +.LP +.LP +Alternatively, the application can arrange its installation in such +a way that it requires the system administrator or operator +to provide the appropriate information on \fIlp\fP options and environment +variable values. +.LP +At a minimum, having this utility in this volume of IEEE\ Std\ 1003.1-2001 +tells the industry that conforming +applications require a means to print output and provides at least +a command name and \fILPDEST\fP routing mechanism that can be +used for discussions between vendors, application writers, and users. +The use of "should" in the DESCRIPTION of \fIlp\fP clearly +shows the intent of the standard developers, even if they cannot mandate +that all systems (such as laptops) have printers. +.LP +This volume of IEEE\ Std\ 1003.1-2001 does not specify what the ownership +of the process performing the writing to the +output device may be. If \fB-c\fP is not used, it is unspecified whether +the process performing the writing to the output device +has permission to read \fIfile\fP if there are any restrictions in +place on who may read \fIfile\fP until after it is printed. +Also, if \fB-c\fP is not used, the results of deleting \fIfile\fP +before it is printed are unspecified. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fImailx\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ls.1p b/man1p/ls.1p new file mode 100644 index 000000000..f30dbe421 --- /dev/null +++ b/man1p/ls.1p @@ -0,0 +1,737 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "LS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ls +.SH NAME +ls \- list directory contents +.SH SYNOPSIS +.LP +\fBls\fP \fB[\fP\fB-CFRacdilqrtu1\fP\fB][\fP\fB-H | -L\fP +\fB][\fP\fB-fgmnopsx\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +For each operand that names a file of a type other than directory +or symbolic link to a directory, \fIls\fP shall write the +name of the file as well as any requested, associated information. +For each operand that names a file of type directory, \fIls\fP +shall write the names of files contained within the directory as well +as any requested, associated information. If one of the +\fB-d\fP, \fB-F\fP, or \fB-l\fP options are specified, and one of +the \fB-H\fP or \fB-L\fP options are not specified, for each +operand that names a file of type symbolic link to a directory, \fIls\fP +shall write the name of the file as well as any +requested, associated information. If none of the \fB-d\fP, \fB-F\fP, +or \fB-l\fP options are specified, or the \fB-H\fP or +\fB-L\fP options are specified, for each operand that names a file +of type symbolic link to a directory, \fIls\fP shall write the +names of files contained within the directory as well as any requested, +associated information. +.LP +If no operands are specified, \fIls\fP shall write the contents of +the current directory. If more than one operand is +specified, \fIls\fP shall write non-directory operands first; it shall +sort directory and non-directory operands separately +according to the collating sequence in the current locale. +.LP +The \fIls\fP utility shall detect infinite loops; that is, entering +a previously visited directory that is an ancestor of the +last file encountered. When it detects an infinite loop, \fIls\fP +shall write a diagnostic message to standard error and shall +either recover its position in the hierarchy or terminate. +.SH OPTIONS +.LP +The \fIls\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-C\fP +Write multi-text-column output with entries sorted down the columns, +according to the collating sequence. The number of text +columns and the column separator characters are unspecified, but should +be adapted to the nature of the output device. +.TP 7 +\fB-F\fP +Do not follow symbolic links named as operands unless the \fB-H\fP +or \fB-L\fP options are specified. Write a slash ( +\fB'/'\fP ) immediately after each pathname that is a directory, an +asterisk ( \fB'*'\fP ) after each that is executable, a +vertical bar ( \fB'|'\fP ) after each that is a FIFO, and an at sign +( \fB'@'\fP ) after each that is a symbolic link. For +other file types, other symbols may be written. +.TP 7 +\fB-H\fP +If a symbolic link referencing a file of type directory is specified +on the command line, \fIls\fP shall evaluate the file +information and file type to be those of the file referenced by the +link, and not the link itself; however, \fIls\fP shall write +the name of the link itself and not the file referenced by the link. +.TP 7 +\fB-L\fP +Evaluate the file information and file type for all symbolic links +(whether named on the command line or encountered in a file +hierarchy) to be those of the file referenced by the link, and not +the link itself; however, \fIls\fP shall write the name of the +link itself and not the file referenced by the link. When \fB-L\fP +is used with \fB-l\fP, write the contents of symbolic links in +the long format (see the STDOUT section). +.TP 7 +\fB-R\fP +Recursively list subdirectories encountered. +.TP 7 +\fB-a\fP +Write out all directory entries, including those whose names begin +with a period ( \fB'.'\fP ). Entries beginning with a +period shall not be written out unless explicitly referenced, the +\fB-a\fP option is supplied, or an implementation-defined +condition shall cause them to be written. +.TP 7 +\fB-c\fP +Use time of last modification of the file status information (see +\fI<sys/stat.h>\fP in the System Interfaces volume of IEEE\ Std\ 1003.1-2001) +instead of last modification of the file itself for sorting ( \fB-t\fP) +or writing ( \fB-l\fP). +.TP 7 +\fB-d\fP +Do not follow symbolic links named as operands unless the \fB-H\fP +or \fB-L\fP options are specified. Do not treat +directories differently than other types of files. The use of \fB-d\fP +with \fB-R\fP produces unspecified results. +.TP 7 +\fB-f\fP +Force each argument to be interpreted as a directory and list the +name found in each slot. This option shall turn off \fB-l\fP, +\fB-t\fP, \fB-s\fP, and \fB-r\fP, and shall turn on \fB-a\fP; the +order is the order in which entries appear in the directory. +.TP 7 +\fB-g\fP +The same as \fB-l\fP, except that the owner shall not be written. +.TP 7 +\fB-i\fP +For each file, write the file's file serial number (see \fIstat\fP() +in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001). +.TP 7 +\fB-l\fP +(The letter ell.) Do not follow symbolic links named as operands unless +the \fB-H\fP or \fB-L\fP options are specified. Write +out in long format (see the STDOUT section). When \fB-l\fP (ell) is +specified, -1 (one) shall be assumed. +.TP 7 +\fB-m\fP +Stream output format; list files across the page, separated by commas. +.TP 7 +\fB-n\fP +The same as \fB-l\fP, except that the owner's UID and GID numbers +shall be written, rather than the associated character strings. +.TP 7 +\fB-o\fP +The same as \fB-l\fP, except that the group shall not be written. +.TP 7 +\fB-p\fP +Write a slash ( \fB'/'\fP ) after each filename if that file is a +directory. +.TP 7 +\fB-q\fP +Force each instance of non-printable filename characters and <tab>s +to be written as the question-mark ( \fB'?'\fP ) +character. Implementations may provide this option by default if the +output is to a terminal device. +.TP 7 +\fB-r\fP +Reverse the order of the sort to get reverse collating sequence or +oldest first. +.TP 7 +\fB-s\fP +Indicate the total number of file system blocks consumed by each file +displayed. The block size is implementation-defined. +.TP 7 +\fB-t\fP +Sort with the primary key being time modified (most recently modified +first) and the secondary key being filename in the +collating sequence. +.TP 7 +\fB-u\fP +Use time of last access (see \fI<sys/stat.h>\fP) instead of last modification +of the file for sorting ( \fB-t\fP) or writing ( \fB-l\fP). +.TP 7 +\fB-x\fP +The same as \fB-C\fP, except that the multi-text-column output is +produced with entries sorted across, rather than down, the +columns. +.TP 7 +\fB-1\fP +(The numeric digit one.) Force output to be one entry per line. +.sp +.LP +Specifying more than one of the options in the following mutually-exclusive +pairs shall not be considered an error: \fB-C\fP +and \fB-l\fP (ell), \fB-m\fP and \fB-l\fP (ell), \fB-x\fP and \fB-l\fP +(ell), \fB-C\fP and \fB-1\fP (one), \fB-H\fP and \fB-L\fP, \fB-c\fP +and \fB-u\fP. The last option +specified in each pair shall determine the output format. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be written. If the file specified is not found, +a diagnostic message shall be output on standard +error. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIls\fP: +.TP 7 +\fICOLUMNS\fP +Determine the user's preferred column position width for writing multiple +text-column output. If this variable contains a +string representing a decimal integer, the \fIls\fP utility shall +calculate how many pathname text columns to write (see +\fB-C\fP) based on the width provided. If \fICOLUMNS\fP is not set +or invalid, an implementation-defined number of column +positions shall be assumed, based on the implementation's knowledge +of the output device. The column width chosen to write the +names of files in any given directory shall be constant. Filenames +shall not be truncated to fit into the multiple text-column +output. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for character collation information in determining +the pathname collation sequence. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments) and which characters +are defined as printable (character class \fBprint\fP). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_TIME\fP +Determine the format and contents for date and time strings written +by \fIls\fP. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone for date and time strings written by \fIls\fP. +If \fITZ\fP is unset or null, an unspecified default +timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The default format shall be to list one entry per line to standard +output; the exceptions are to terminals or when one of the +\fB-C\fP, \fB-m\fP, or \fB-x\fP options is specified. If the +output is to a terminal, the format is implementation-defined. +.LP +When \fB-m\fP is specified, the format used shall be: +.sp +.RS +.nf + +\fB"%s, %s, ...\\n", <\fP\fIfilename1\fP\fB>, <\fP\fIfilename2\fP\fB> +\fP +.fi +.RE +.LP +where the largest number of filenames shall be written without exceeding +the length of the line. +.LP +If the \fB-i\fP option is specified, the file's file serial number +(see \fI<sys/stat.h>\fP) shall be written in the following format +before any other output for +the corresponding entry: +.sp +.RS +.nf + +\fB%u ", <\fP\fIfile serial number\fP\fB> +\fP +.fi +.RE +.LP +If the \fB-l\fP option is specified without \fB-L\fP, the following +information shall be written: +.sp +.RS +.nf + +\fB"%s %u %s %s %u %s %s\\n", <\fP\fIfile mode\fP\fB>, <\fP\fInumber of links\fP\fB>, + <\fP\fIowner name\fP\fB>, <\fP\fIgroup name\fP\fB>, <\fP\fInumber of bytes in the file\fP\fB>, + <\fP\fIdate and time\fP\fB>, <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +If the file is a symbolic link, this information shall be about the +link itself and the <\fIpathname\fP> field shall be +of the form: +.sp +.RS +.nf + +\fB"%s -> %s", <\fP\fIpathname of link\fP\fB>, <\fP\fIcontents of link\fP\fB> +\fP +.fi +.RE +.LP +If both \fB-l\fP and \fB-L\fP are specified, the following information +shall be written: +.sp +.RS +.nf + +\fB"%s %u %s %s %u %s %s\\n", <\fP\fIfile mode\fP\fB>, <\fP\fInumber of links\fP\fB>, + <\fP\fIowner name\fP\fB>, <\fP\fIgroup name\fP\fB>, <\fP\fInumber of bytes in the file\fP\fB>, + <\fP\fIdate and time\fP\fB>, <\fP\fIpathname of link\fP\fB> +\fP +.fi +.RE +.LP +where all fields except <\fIpathname of link\fP> shall be for the +file resolved from the symbolic link. +.LP +The \fB-g\fP, \fB-n\fP, and \fB-o\fP options use the same format as +\fB-l\fP, but with omitted items and their associated +<blank>s. See the OPTIONS section. +.LP +In both the preceding \fB-l\fP forms, if <\fIowner name\fP> or <\fIgroup +name\fP> cannot be determined, \ or if +\fB-n\fP is given, they shall be replaced with their associated +numeric values using the format \fB%u\fP . +.LP +The <\fIdate\ and\ time\fP> field shall contain the appropriate date +and timestamp of when the file was last +modified. In the POSIX locale, the field shall be the equivalent of +the output of the following \fIdate\fP command: +.sp +.RS +.nf + +\fBdate "+%b %e %H:%M" +\fP +.fi +.RE +.LP +if the file has been modified in the last six months, or: +.sp +.RS +.nf + +\fBdate "+%b %e %Y" +\fP +.fi +.RE +.LP +(where two <space>s are used between \fB%e\fP and \fB%Y\fP ) if the +file has not been modified in the last six +months or if the modification date is in the future, except that, +in both cases, the final <newline> produced by \fIdate\fP shall not +be included and the output shall be as if the \fIdate\fP command were +executed at the time of the last modification date of the file rather +than +the current time. When the \fILC_TIME\fP locale category is not set +to the POSIX locale, a different format and order of +presentation of this field may be used. +.LP +If the file is a character special or block special file, the size +of the file may be replaced with implementation-defined +information associated with the device in question. +.LP +If the pathname was specified as a \fIfile\fP operand, it shall be +written as specified. +.LP +The file mode written under the \fB-l\fP, \fB-g\fP, \fB-n\fP, and +\fB-o\fP options shall consist of the following format: +.sp +.RS +.nf + +\fB"%c%s%s%s%c", <\fP\fIentry type\fP\fB>, <\fP\fIowner permissions\fP\fB>, + <\fP\fIgroup permissions\fP\fB>, <\fP\fIother permissions\fP\fB>, + <\fP\fIoptional alternate access method flag\fP\fB> +\fP +.fi +.RE +.LP +The <\fIoptional\ alternate\ access\ method\ flag\fP> shall be a single +<space> if there is no +alternate or additional access control method associated with the +file; otherwise, a printable character shall be used. +.LP +The <\fIentry\ type\fP> character shall describe the type of file, +as follows: +.TP 7 +\fBd\fP +Directory. +.TP 7 +\fBb\fP +Block special file. +.TP 7 +\fBc\fP +Character special file. +.TP 7 +\fBl\fP\ (ell) +Symbolic link. +.TP 7 +\fBp\fP +FIFO. +.TP 7 +\fB-\fP +Regular file. +.sp +.LP +Implementations may add other characters to this list to represent +other implementation-defined file types. +.LP +The next three fields shall be three characters each: +.TP 7 +<\fIowner permissions\fP> +.sp +Permissions for the file owner class (see the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 4.4, File Access Permissions). +.TP 7 +<\fIgroup permissions\fP> +.sp +Permissions for the file group class. +.TP 7 +<\fIother permissions\fP> +.sp +Permissions for the file other class. +.sp +.LP +Each field shall have three character positions: +.IP " 1." 4 +If \fB'r'\fP , the file is readable; if \fB'-'\fP , the file is not +readable. +.LP +.IP " 2." 4 +If \fB'w'\fP , the file is writable; if \fB'-'\fP , the file is not +writable. +.LP +.IP " 3." 4 +The first of the following that applies: +.TP 7 +\fBS\fP +.RS +If in <\fIowner\ permissions\fP>, the file is not executable and set-user-ID +mode is set. If in +<\fIgroup\ permissions\fP>, the file is not executable and set-group-ID +mode is set. +.RE +.TP 7 +\fBs\fP +.RS +If in <\fIowner\ permissions\fP>, the file is executable and set-user-ID +mode is set. If in +<\fIgroup\ permissions\fP>, the file is executable and set-group-ID +mode is set. +.RE +.TP 7 +\fBT\fP +.RS +If in <\fIother\ permissions\fP> and the file is a directory, search +permission is not granted to others, and the +restricted deletion flag is set. +.RE +.TP 7 +\fBt\fP +.RS +If in <\fIother\ permissions\fP> and the file is a directory, search +permission is granted to others, and the restricted +deletion flag is set. +.RE +.TP 7 +\fBx\fP +.RS +The file is executable or the directory is searchable. +.RE +.TP 7 +\fB-\fP +.RS +None of the attributes of \fB'S'\fP , \fB's'\fP , \fB'T'\fP , \fB't'\fP +, or \fB'x'\fP applies. +.RE +.sp +.LP +Implementations may add other characters to this list for the third +character position. Such additions shall, however, be +written in lowercase if the file is executable or searchable, and +in uppercase if it is not. +.LP +.LP +If any of the \fB-l\fP, \fB-g\fP, \fB-n\fP, \fB-o\fP, or \fB-s\fP +options is specified, each list of files within the directory shall +be preceded by a status line indicating the number +of file system blocks occupied by files in the directory in 512-byte +units, rounded up to the next integral number of units, if +necessary. In the POSIX locale, the format shall be: +.sp +.RS +.nf + +\fB"total %u\\n", <\fP\fInumber of units in the directory\fP\fB> +\fP +.fi +.RE +.LP +If more than one directory, or a combination of non-directory files +and directories are written, either as a result of +specifying multiple operands, or the \fB-R\fP option, each list of +files within a directory shall be preceded by: +.sp +.RS +.nf + +\fB"\\n%s:\\n", <\fP\fIdirectory name\fP\fB> +\fP +.fi +.RE +.LP +If this string is the first thing to be written, the first <newline> +shall not be written. This output shall precede the +number of units in the directory. +.LP +If the \fB-s\fP option is given, each file shall be written with the +number of blocks used by the file. Along with \fB-C\fP, +\fB-1\fP, \fB-m\fP, or \fB-x\fP, the number and a <space> shall precede +the filename; with \fB-g\fP, \fB-l\fP, +\fB-n\fP, or \fB-o\fP, they shall precede each line describing a file. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Many implementations use the equal sign ( \fB'='\fP ) to denote sockets +bound to the file system for the \fB-F\fP option. +Similarly, many historical implementations use the \fB's'\fP character +to denote sockets as the entry type characters for the +\fB-l\fP option. +.LP +It is difficult for an application to use every part of the file modes +field of \fIls\fP \fB-l\fP in a portable manner. +Certain file types and executable bits are not guaranteed to be exactly +as shown, as implementations may have extensions. +Applications can use this field to pass directly to a user printout +or prompt, but actions based on its contents should generally +be deferred, instead, to the \fItest\fP utility. +.LP +The output of \fIls\fP (with the \fB-l\fP and related options) contains +information that logically could be used by utilities +such as \fIchmod\fP and \fItouch\fP to restore files +to a known state. However, this information is presented in a format +that cannot be used directly by those utilities or be easily +translated into a format that can be used. A character has been added +to the end of the permissions string so that applications at +least have an indication that they may be working in an area they +do not understand instead of assuming that they can translate the +permissions string into something that can be used. Future issues +or related documents may define one or more specific characters +to be used based on different standard additional or alternative access +control mechanisms. +.LP +As with many of the utilities that deal with filenames, the output +of \fIls\fP for multiple files or in one of the long listing +formats must be used carefully on systems where filenames can contain +embedded white space. Systems and system administrators +should institute policies and user training to limit the use of such +filenames. +.LP +The number of disk blocks occupied by the file that it reports varies +depending on underlying file system type, block size units +reported, and the method of calculating the number of blocks. On some +file system types, the number is the actual number of blocks +occupied by the file (counting indirect blocks and ignoring holes +in the file); on others it is calculated based on the file size +(usually making an allowance for indirect blocks, but ignoring holes). +.SH EXAMPLES +.LP +An example of a small directory tree being fully listed with \fIls\fP +\fB-laRF\ a\fP in the POSIX locale: +.sp +.RS +.nf + +\fBtotal 11 +drwxr-xr-x 3 hlj prog 64 Jul 4 12:07 ./ +drwxrwxrwx 4 hlj prog 3264 Jul 4 12:09 ../ +drwxr-xr-x 2 hlj prog 48 Jul 4 12:07 b/ +-rwxr--r-- 1 hlj prog 572 Jul 4 12:07 foo* +.sp + +a/b: +total 4 +drwxr-xr-x 2 hlj prog 48 Jul 4 12:07 ./ +drwxr-xr-x 3 hlj prog 64 Jul 4 12:07 ../ +-rw-r--r-- 1 hlj prog 700 Jul 4 12:07 bar +\fP +.fi +.RE +.SH RATIONALE +.LP +Some historical implementations of the \fIls\fP utility show all entries +in a directory except dot and dot-dot when a superuser +invokes \fIls\fP without specifying the \fB-a\fP option. When "normal" +users invoke \fIls\fP without specifying \fB-a\fP, +they should not see information about any files with names beginning +with a period unless they were named as \fIfile\fP +operands. +.LP +Implementations are expected to traverse arbitrary depths when processing +the \fB-R\fP option. The only limitation on depth +should be based on running out of physical storage for keeping track +of untraversed directories. +.LP +The \fB-1\fP (one) option was historically found in BSD and BSD-derived +implementations only. It is required in this volume of +IEEE\ Std\ 1003.1-2001 so that conforming applications might ensure +that output is one entry per line, even if the output +is to a terminal. +.LP +Generally, this volume of IEEE\ Std\ 1003.1-2001 is silent about what +happens when options are given multiple times. In +the cases of \fB-C\fP, \fB-l\fP, and \fB-1\fP, however, it does specify +the results of these overlapping options. Since +\fIls\fP is one of the most aliased commands, it is important that +the implementation perform intuitively. For example, if the +alias were: +.sp +.RS +.nf + +\fBalias ls="ls -C" +\fP +.fi +.RE +.LP +and the user typed \fIls\fP \fB-1\fP, single-text-column output should +result, not an error. +.LP +The BSD \fIls\fP provides a \fB-A\fP option (like \fB-a\fP, but dot +and dot-dot are not written out). The small difference +from \fB-a\fP did not seem important enough to require both. +.LP +Implementations may make \fB-q\fP the default for terminals to prevent +trojan horse attacks on terminals with special escape +sequences. This is not required because: +.IP " *" 3 +Some control characters may be useful on some terminals; for example, +a system might write them as \fB"\\001"\fP or +\fB"^A"\fP . +.LP +.IP " *" 3 +Special behavior for terminals is not relevant to applications portability. +.LP +.LP +An early proposal specified that the optional alternate access method +flag had to be \fB'+'\fP if there was an alternate +access method used on the file or <space> if there was not. This was +changed to be <space> if there is not and a single +printable character if there is. This was done for three reasons: +.IP " 1." 4 +There are historical implementations using characters other than \fB'+'\fP +\&. +.LP +.IP " 2." 4 +There are implementations that vary this character used in that position +to distinguish between various alternate access methods +in use. +.LP +.IP " 3." 4 +The standard developers did not want to preclude future specifications +that might need a way to specify more than one alternate +access method. +.LP +.LP +Nonetheless, implementations providing a single alternate access method +are encouraged to use \fB'+'\fP . +.LP +In an early proposal, the units used to specify the number of blocks +occupied by files in a directory in an \fIls\fP \fB-l\fP +listing were implementation-defined. This was because BSD systems +have historically used 1024-byte units and System V systems have +historically used 512-byte units. It was pointed out by BSD developers +that their system has used 512-byte units in some places and +1024-byte units in other places. (System V has consistently used 512.) +Therefore, this volume of IEEE\ Std\ 1003.1-2001 +usually specifies 512. Future releases of BSD are expected to consistently +provide 512 bytes as a default with a way of specifying +1024-byte units where appropriate. +.LP +The <\fIdate\ and\ time\fP> field in the \fB-l\fP format is specified +only for the POSIX locale. As noted, the +format can be different in other locales. No mechanism for defining +this is present in this volume of +IEEE\ Std\ 1003.1-2001, as the appropriate vehicle is a messaging +system; that is, the format should be specified as a +"message". +.SH FUTURE DIRECTIONS +.LP +The \fB-s\fP uses implementation-defined units and cannot be used +portably; it may be withdrawn in a future version. +.SH SEE ALSO +.LP +\fIchmod\fP() , \fIfind\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIstat\fP(), the Base Definitions volume +of +IEEE\ Std\ 1003.1-2001, \fI<sys/stat.h>\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/m4.1p b/man1p/m4.1p new file mode 100644 index 000000000..56c3b5882 --- /dev/null +++ b/man1p/m4.1p @@ -0,0 +1,556 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "M4" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" m4 +.SH NAME +m4 \- macro processor (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBm4\fP \fB[\fP\fB-s\fP\fB][\fP\fB-D\fP +\fIname\fP\fB[\fP\fB=\fP\fIval\fP\fB]]\fP\fB...\fP\fB[\fP\fB-U\fP +\fIname\fP\fB]\fP\fB...\fP \fIfile\fP\fB... +\fP +.SH DESCRIPTION +.LP +The \fIm4\fP utility is a macro processor that shall read one or more +text files, process them according to their included +macro statements, and write the results to standard output. +.SH OPTIONS +.LP +The \fIm4\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the order of the \fB-D\fP and +\fB-U\fP options shall be significant. +.LP +The following options shall be supported: +.TP 7 +\fB-s\fP +Enable line synchronization output for the \fIc99\fP preprocessor +phase (that is, +\fB#line\fP directives). +.TP 7 +\fB-D\ \fP \fIname\fP\fB[\fP=\fIval\fP\fB]\fP +.sp +Define \fIname\fP to \fIval\fP or to null if = \fIval\fP is omitted. +.TP 7 +\fB-U\ \fP \fIname\fP +Undefine \fIname\fP. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a text file to be processed. If no \fIfile\fP is given, +or if it is \fB'-'\fP , the standard input shall be +read. +.sp +.SH STDIN +.LP +The standard input shall be a text file that is used if no \fIfile\fP +operand is given, or if it is \fB'-'\fP . +.SH INPUT FILES +.LP +The input file named by the \fIfile\fP operand shall be a text file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIm4\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be the same as the input files, after being +processed for macro expansion. +.SH STDERR +.LP +The standard error shall be used to display strings with the \fBerrprint\fP +macro, macro tracing enabled by the \fBtraceon\fP +macro, the defined text for macros written by the \fBdumpdef\fP macro, +or for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The \fIm4\fP utility shall compare each token from the input against +the set of built-in and user-defined macros. If the token +matches the name of a macro, then the token shall be replaced by the +macro's defining text, if any, and rescanned for matching +macro names. Once no portion of the token matches the name of a macro, +it shall be written to standard output. Macros may have +arguments, in which case the arguments shall be substituted into the +defining text before it is rescanned. +.LP +Macro calls have the form: +.sp +.RS +.nf + +\fIname\fP\fB(\fP\fIarg1\fP\fB,\fP \fIarg2\fP\fB, ...,\fP \fIargn\fP\fB) +\fP +.fi +.RE +.LP +Macro names shall consist of letters, digits, and underscores, where +the first character is not a digit. Tokens not of this form +shall not be treated as macros. +.LP +The application shall ensure that the left parenthesis immediately +follows the name of the macro. If a token matching the name +of a macro is not followed by a left parenthesis, it is handled as +a use of that macro without arguments. +.LP +If a macro name is followed by a left parenthesis, its arguments are +the comma-separated tokens between the left parenthesis and +the matching right parenthesis. Unquoted <blank>s and <newline>s preceding +each argument shall be ignored. All other +characters, including trailing <blank>s and <newline>s, are retained. +Commas enclosed between left and right +parenthesis characters do not delimit arguments. +.LP +Arguments are positionally defined and referenced. The string \fB"$1"\fP +in the defining text shall be replaced by the first +argument. Systems shall support at least nine arguments; only the +first nine can be referenced, using the strings \fB"$1"\fP to +\fB"$9"\fP , inclusive. The string \fB"$0"\fP is replaced with the +name of the macro. The string \fB"$#"\fP is replaced by +the number of arguments as a string. The string \fB"$*"\fP is replaced +by a list of all of the arguments, separated by commas. +The string \fB"$@"\fP is replaced by a list of all of the arguments +separated by commas, and each argument is quoted using the +current left and right quoting strings. +.LP +If fewer arguments are supplied than are in the macro definition, +the omitted arguments are taken to be null. It is not an error +if more arguments are supplied than are in the macro definition. +.LP +No special meaning is given to any characters enclosed between matching +left and right quoting strings, but the quoting strings +are themselves discarded. By default, the left quoting string consists +of a grave accent ( \fB'`'\fP ) and the right quoting +string consists of an acute accent ( \fB'"\fP ); see also the \fBchangequote\fP +macro. +.LP +Comments are written but not scanned for matching macro names; by +default, the begin-comment string consists of the number sign +character and the end-comment string consists of a <newline>. See +also the \fBchangecom\fP and \fBdnl\fP macros. +.LP +The \fIm4\fP utility shall make available the following built-in macros. +They can be redefined, but once this is done the +original meaning is lost. Their values shall be null unless otherwise +stated. In the descriptions below, the term \fIdefining +text\fP refers to the value of the macro: the second argument to the +\fBdefine\fP macro, among other things. Except for the first +argument to the \fBeval\fP macro, all numeric arguments to built-in +macros shall be interpreted as decimal values. The string +values produced as the defining text of the \fBdecr\fP, \fBdivnum\fP, +\fBincr\fP, \fBindex\fP, \fBlen\fP, and \fBsysval\fP +built-in macros shall be in the form of a decimal-constant as defined +in the C language. +.TP 7 +\fBchangecom\fP +The \fBchangecom\fP macro shall set the begin-comment and end-comment +strings. With no arguments, the comment mechanism shall +be disabled. With a single argument, that argument shall become the +begin-comment string and the <newline> shall become the +end-comment string. With two arguments, the first argument shall become +the begin-comment string and the second argument shall +become the end-comment string. Systems shall support comment strings +of at least five characters. +.TP 7 +\fBchangequote\fP +The \fBchangequote\fP macro shall set the begin-quote and end-quote +strings. With no arguments, the quote strings shall be set +to the default values (that is, \fB`'\fP). With a single argument, +that argument shall become the begin-quote string and the +<newline> shall become the end-quote string. With two arguments, the +first argument shall become the begin-quote string and +the second argument shall become the end-quote string. Systems shall +support quote strings of at least five characters. +.TP 7 +\fBdecr\fP +The defining text of the \fBdecr\fP macro shall be its first argument +decremented by 1. It shall be an error to specify an +argument containing any non-numeric characters. +.TP 7 +\fBdefine\fP +The second argument shall become the defining text of the macro whose +name is the first argument. +.TP 7 +\fBdefn\fP +The defining text of the \fBdefn\fP macro shall be the quoted definition +(using the current quoting strings) of its +arguments. +.TP 7 +\fBdivert\fP +The \fIm4\fP utility maintains nine temporary buffers, numbered 1 +to 9, inclusive. When the last of the input has been +processed, any output that has been placed in these buffers shall +be written to standard output in buffer-numerical order. The +\fBdivert\fP macro shall divert future output to the buffer specified +by its argument. Specifying no argument or an argument of 0 +shall resume the normal output process. Output diverted to a stream +other than 0 to 9 shall be discarded. It shall be an error to +specify an argument containing any non-numeric characters. +.TP 7 +\fBdivnum\fP +The defining text of the \fBdivnum\fP macro shall be the number of +the current output stream as a string. +.TP 7 +\fBdnl\fP +The \fBdnl\fP macro shall cause \fIm4\fP to discard all input characters +up to and including the next <newline>. +.TP 7 +\fBdumpdef\fP +The \fBdumpdef\fP macro shall write the defined text to standard error +for each of the macros specified as arguments, or, if +no arguments are specified, for all macros. +.TP 7 +\fBerrprint\fP +The \fBerrprint\fP macro shall write its arguments to standard error. +.TP 7 +\fBeval\fP +The \fBeval\fP macro shall evaluate its first argument as an arithmetic +expression, using 32-bit signed integer arithmetic. +All of the C-language operators shall be supported, except for: +.sp +.RS +.nf + +\fB[] +-> +++ +-- +(\fP\fItype\fP\fB) +unary * +\fP\fIsizeof\fP\fB, +\&. +?: +unary & +\fP +.fi +.RE +.LP +and all assignment operators. It shall be an error to specify any +of these operators. Precedence and associativity shall be as +in the ISO\ C standard. Systems shall support octal and hexadecimal +numbers as in the ISO\ C standard. The second argument, +if specified, shall set the radix for the result; the default is 10. +The third argument, if specified, sets the minimum number of +digits in the result. It shall be an error to specify the second or +third argument containing any non-numeric characters. +.TP 7 +\fBifdef\fP +If the first argument to the \fBifdef\fP macro is defined, the defining +text shall be the second argument. Otherwise, the +defining text shall be the third argument, if specified, or the null +string, if not. +.TP 7 +\fBifelse\fP +The \fBifelse\fP macro takes three or more arguments. If the first +two arguments compare as equal strings (after macro +expansion of both arguments), the defining text shall be the third +argument. If the first two arguments do not compare as equal +strings and there are three arguments, the defining text shall be +null. If the first two arguments do not compare as equal strings +and there are four or five arguments, the defining text shall be the +fourth argument. If the first two arguments do not compare as +equal strings and there are six or more arguments, the first three +arguments shall be discarded and processing shall restart with +the remaining arguments. +.TP 7 +\fBinclude\fP +The defining text for the \fBinclude\fP macro shall be the contents +of the file named by the first argument. It shall be an +error if the file cannot be read. +.TP 7 +\fBincr\fP +The defining text of the \fBincr\fP macro shall be its first argument +incremented by 1. It shall be an error to specify an +argument containing any non-numeric characters. +.TP 7 +\fBindex\fP +The defining text of the \fBindex\fP macro shall be the first character +position (as a string) in the first argument where a +string matching the second argument begins (zero origin), or -1 if +the second argument does not occur. +.TP 7 +\fBlen\fP +The defining text of the \fBlen\fP macro shall be the length (as a +string) of the first argument. +.TP 7 +\fBm4exit\fP +Exit from the \fIm4\fP utility. If the first argument is specified, +it is the exit code. The default is zero. It shall be an +error to specify an argument containing any non-numeric characters. +.TP 7 +\fBm4wrap\fP +The first argument shall be processed when EOF is reached. If the +\fBm4wrap\fP macro is used multiple times, the arguments +specified shall be processed in the order in which the \fBm4wrap\fP +macros were processed. +.TP 7 +\fBmaketemp\fP +The defining text shall be the first argument, with any trailing \fB'X'\fP +characters replaced with the current process ID +as a string. +.TP 7 +\fBpopdef\fP +The \fBpopdef\fP macro shall delete the current definition of its +arguments, replacing that definition with the previous one. +If there is no previous definition, the macro is undefined. +.TP 7 +\fBpushdef\fP +The \fBpushdef\fP macro shall be equivalent to the \fBdefine\fP macro +with the exception that it shall preserve any current +definition for future retrieval using the \fBpopdef\fP macro. +.TP 7 +\fBshift\fP +The defining text for the \fBshift\fP macro shall be all of its arguments +except for the first one. +.TP 7 +\fBsinclude\fP +The \fBsinclude\fP macro shall be equivalent to the \fBinclude\fP +macro, except that it shall not be an error if the file is +inaccessible. +.TP 7 +\fBsubstr\fP +The defining text for the \fBsubstr\fP macro shall be the substring +of the first argument beginning at the zero-offset +character position specified by the second argument. The third argument, +if specified, shall be the number of characters to select; +if not specified, the characters from the starting point to the end +of the first argument shall become the defining text. It shall +not be an error to specify a starting point beyond the end of the +first argument and the defining text shall be null. It shall be +an error to specify an argument containing any non-numeric characters. +.TP 7 +\fBsyscmd\fP +The \fBsyscmd\fP macro shall interpret its first argument as a shell +command line. The defining text shall be the string +result of that command. No output redirection shall be performed by +the \fIm4\fP utility. The exit status value from the command +can be retrieved using the \fBsysval\fP macro. +.TP 7 +\fBsysval\fP +The defining text of the \fBsysval\fP macro shall be the exit value +of the utility last invoked by the \fBsyscmd\fP macro (as +a string). +.TP 7 +\fBtraceon\fP +The \fBtraceon\fP macro shall enable tracing for the macros specified +as arguments, or, if no arguments are specified, for all +macros. The trace output shall be written to standard error in an +unspecified format. +.TP 7 +\fBtraceoff\fP +The \fBtraceoff\fP macro shall disable tracing for the macros specified +as arguments, or, if no arguments are specified, for +all macros. +.TP 7 +\fBtranslit\fP +The defining text of the \fBtranslit\fP macro shall be the first argument +with every character that occurs in the second +argument replaced with the corresponding character from the third +argument. +.TP 7 +\fBundefine\fP +The \fBundefine\fP macro shall delete all definitions (including those +preserved using the \fBpushdef\fP macro) of the macros +named by its arguments. +.TP 7 +\fBundivert\fP +The \fBundivert\fP macro shall cause immediate output of any text +in temporary buffers named as arguments, or all temporary +buffers if no arguments are specified. Buffers can be undiverted into +other temporary buffers. Undiverting shall discard the +contents of the temporary buffer. It shall be an error to specify +an argument containing any non-numeric characters. +.sp +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred +.sp +.LP +If the \fBm4exit\fP macro is used, the exit value can be specified +by the input file. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fBdefn\fP macro is useful for renaming macros, especially built-ins. +.SH EXAMPLES +.LP +If the file \fBm4src\fP contains the lines: +.sp +.RS +.nf + +\fBThe value of `VER' is "VER". +ifdef(`VER', "VER" is defined to be VER., VER is not defined.) +ifelse(VER, 1, "VER" is `VER'.) +ifelse(VER, 2, "VER" is `VER'., "VER" is not 2.) +end +\fP +.fi +.RE +.LP +then the command +.sp +.RS +.nf + +\fBm4 m4src +\fP +.fi +.RE +.LP +or the command: +.sp +.RS +.nf + +\fBm4 -U VER m4src +\fP +.fi +.RE +.LP +produces the output: +.sp +.RS +.nf + +\fBThe value of VER is "VER". +VER is not defined. +.sp + +VER is not 2. +end +\fP +.fi +.RE +.LP +The command: +.sp +.RS +.nf + +\fBm4 -D VER m4src +\fP +.fi +.RE +.LP +produces the output: +.sp +.RS +.nf + +\fBThe value of VER is "". +VER is defined to be . +.sp + +VER is not 2. +end +\fP +.fi +.RE +.LP +The command: +.sp +.RS +.nf + +\fBm4 -D VER=1 m4src +\fP +.fi +.RE +.LP +produces the output: +.sp +.RS +.nf + +\fBThe value of VER is "1". +VER is defined to be 1. +VER is 1. +VER is not 2. +end +\fP +.fi +.RE +.LP +The command: +.sp +.RS +.nf + +\fBm4 -D VER=2 m4src +.sp + +produces the output: +The value of VER is "2". +VER is defined to be 2. +.sp + +VER is 2. +end +\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/mailx.1p b/man1p/mailx.1p new file mode 100644 index 000000000..2a5aacc23 --- /dev/null +++ b/man1p/mailx.1p @@ -0,0 +1,2208 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MAILX" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" mailx +.SH NAME +mailx \- process messages +.SH SYNOPSIS +.SS Send Mode +.sp +.RS +.nf + +\fBmailx\fP \fB[\fP\fB-s\fP \fIsubject\fP\fB]\fP \fIaddress\fP\fB... +\fP +.fi +.RE +.SS Receive Mode +.sp +.RS +.nf + +\fBmailx -e +.sp + +.sp + +mailx\fP \fB[\fP\fB-HiNn\fP\fB][\fP\fB-F\fP\fB][\fP\fB-u\fP \fIuser\fP\fB]\fP\fB +.br + +.sp + +mailx -f\fP\fB[\fP\fB-HiNn\fP\fB][\fP\fB-F\fP\fB][\fP\fIfile\fP\fB]\fP\fB +.br + +\fP +.fi +.RE +.SH DESCRIPTION +.LP +The \fImailx\fP utility provides a message sending and receiving facility. +It has two major modes, selected by the options +used: Send Mode and Receive Mode. +.LP +On systems that do not support the User Portability Utilities option, +an application using \fImailx\fP shall have the ability +to send messages in an unspecified manner (Send Mode). Unless the +first character of one or more lines is tilde ( \fB'~'\fP +), all characters in the input message shall appear in the delivered +message, but additional characters may be inserted in the +message before it is retrieved. +.LP +On systems supporting the User Portability Utilities option, mail-receiving +capabilities and other interactive features, Receive +Mode, described below, also shall be enabled. +.SS Send Mode +.LP +Send Mode can be used by applications or users to send messages from +the text in standard input. +.SS Receive Mode +.LP +Receive Mode is more oriented towards interactive users. Mail can +be read and sent in this interactive mode. +.LP +When reading mail, \fImailx\fP provides commands to facilitate saving, +deleting, and responding to messages. When sending mail, +\fImailx\fP allows editing, reviewing, and other modification of the +message as it is entered. +.LP +Incoming mail shall be stored in one or more unspecified locations +for each user, collectively called the system \fImailbox\fP +for that user. When \fImailx\fP is invoked in Receive Mode, the system +mailbox shall be the default place to find new mail. As +messages are read, they shall be marked to be moved to a secondary +file for storage, unless specific action is taken. This +secondary file is called the \fBmbox\fP and is normally located in +the directory referred to by the \fIHOME\fP environment +variable (see \fIMBOX\fP in the ENVIRONMENT VARIABLES section for +a description of this file). Messages shall remain in this file +until explicitly removed. When the \fB-f\fP option is used to read +mail messages from secondary files, messages shall be retained +in those files unless specifically removed. All three of these locations-system +mailbox, \fBmbox\fP, and secondary file-are +referred to in this section as simply "mailboxes", unless more specific +identification is required. +.SH OPTIONS +.LP +The \fImailx\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported. (Only the \fB-s\fP \fIsubject\fP +option shall be required on all systems. The other +options are required only on systems supporting the User Portability +Utilities option.) +.TP 7 +\fB-e\fP +Test for the presence of mail in the system mailbox. The \fImailx\fP +utility shall write nothing and exit with a successful +return code if there is mail to read. +.TP 7 +\fB-f\fP +Read messages from the file named by the \fIfile\fP operand instead +of the system mailbox. (See also \fBfolder\fP.) If no +\fIfile\fP operand is specified, read messages from \fBmbox\fP instead +of the system mailbox. +.TP 7 +\fB-F\fP +Record the message in a file named after the first recipient. The +name is the login-name portion of the address found first on +the \fBTo:\fP line in the mail header. Overrides the \fBrecord\fP +variable, if set (see Internal +Variables in mailx .) +.TP 7 +\fB-H\fP +Write a header summary only. +.TP 7 +\fB-i\fP +Ignore interrupts. (See also \fBignore\fP.) +.TP 7 +\fB-n\fP +Do not initialize from the system default start-up file. See the EXTENDED +DESCRIPTION section. +.TP 7 +\fB-N\fP +Do not write an initial header summary. +.TP 7 +\fB-s\ \fP \fIsubject\fP +Set the \fBSubject\fP header field to \fIsubject\fP. All characters +in the \fIsubject\fP string shall appear in the +delivered message. The results are unspecified if \fIsubject\fP is +longer than {LINE_MAX} - 10 bytes or contains a +<newline>. +.TP 7 +\fB-u\ \fP \fIuser\fP +Read the system mailbox of the login name \fIuser\fP. This shall only +be successful if the invoking user has the appropriate +privileges to read the system mailbox of that user. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIaddress\fP +Addressee of message. When \fB-n\fP is specified and no user start-up +files are accessed (see the EXTENDED DESCRIPTION +section), the user or application shall ensure this is an address +to pass to the mail delivery system. Any system or user start-up +files may enable aliases (see \fBalias\fP under Commands in mailx +) that may modify the form of +\fIaddress\fP before it is passed to the mail delivery system. +.TP 7 +\fIfile\fP +A pathname of a file to be read instead of the system mailbox when +\fB-f\fP is specified. The meaning of the \fIfile\fP +option-argument shall be affected by the contents of the \fBfolder\fP +internal variable; see Internal +Variables in mailx . +.sp +.SH STDIN +.LP +When \fImailx\fP is invoked in Send Mode (the first synopsis line), +standard input shall be the message to be delivered to the +specified addresses. When in Receive Mode, user commands shall be +accepted from \fIstdin\fP. If the User Portability Utilities +option is not supported, standard input lines beginning with a tilde +( \fB'~'\fP ) character produce unspecified +results. +.LP +If the User Portability Utilities option is supported, then in both +Send and Receive Modes, standard input lines beginning with +the escape character (usually tilde ( \fB'~'\fP )) shall affect processing +as described in Command Escapes in mailx . +.SH INPUT FILES +.LP +When \fImailx\fP is used as described by this volume of IEEE\ Std\ 1003.1-2001, +the \fIfile\fP option-argument (see +the \fB-f\fP option) and the \fBmbox\fP shall be text files containing +mail messages, formatted as described in the OUTPUT FILES +section. The nature of the system mailbox is unspecified; it need +not be a file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fImailx\fP: +.TP 7 +\fIDEAD\fP +Determine the pathname of the file in which to save partial messages +in case of interrupts or delivery errors. The default +shall be \fBdead.letter\fP in the directory named by the \fIHOME\fP +variable. The behavior of \fImailx\fP in saving partial +messages is unspecified if the User Portability Utilities option is +not supported and \fIDEAD\fP is not defined with the value +\fB/dev/null\fP. +.TP 7 +\fIEDITOR\fP +Determine the name of a utility to invoke when the \fBedit\fP (see +Commands in mailx ) or +\fB~e\fP (see Command Escapes in mailx ) command is used. The default +editor is unspecified. +\ On XSI-conformant systems it is \fIed\fP. The effects of this variable +are unspecified if the User Portability Utilities option is not +supported. +.TP 7 +\fIHOME\fP +Determine the pathname of the user's home directory. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the handling of case-insensitive address and header-field +comparisons. +.TP 7 +\fILC_TIME\fP +Determine the format and contents of the date and time strings written +by \fImailx\fP. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fILISTER\fP +Determine a string representing the command for writing the contents +of the \fBfolder\fP directory to standard output when the +\fBfolders\fP command is given (see \fBfolders\fP in Commands in mailx +). Any string acceptable as +a \fIcommand_string\fP operand to the \fIsh\fP \fB-c\fP command shall +be valid. If this +variable is null or not set, the output command shall be \fIls\fP. +The effects of this variable +are unspecified if the User Portability Utilities option is not supported. +.TP 7 +\fIMAILRC\fP +Determine the pathname of the start-up file. The default shall be +\fB\&.mailrc\fP in the directory referred to by the +\fIHOME\fP environment variable. The behavior of \fImailx\fP is unspecified +if the User Portability Utilities option is not +supported and \fIMAILRC\fP is not defined with the value \fB/dev/null\fP. +.TP 7 +\fIMBOX\fP +Determine a pathname of the file to save messages from the system +mailbox that have been read. The \fBexit\fP command shall +override this function, as shall saving the message explicitly in +another file. The default shall be \fBmbox\fP in the directory +named by the \fIHOME\fP variable. The effects of this variable are +unspecified if the User Portability Utilities option is not +supported. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPAGER\fP +Determine a string representing an output filtering or pagination +command for writing the output to the terminal. Any string +acceptable as a \fIcommand_string\fP operand to the \fIsh\fP \fB-c\fP +command shall be valid. +When standard output is a terminal device, the message output shall +be piped through the command if the \fImailx\fP internal +variable \fBcrt\fP is set to a value less the number of lines in the +message; see Internal Variables in +mailx . If the \fIPAGER\fP variable is null or not set, the paginator +shall be either \fImore\fP or another paginator utility documented +in the system documentation. The effects of this +variable are unspecified if the User Portability Utilities option +is not supported. +.TP 7 +\fISHELL\fP +Determine the name of a preferred command interpreter. The default +shall be \fIsh\fP. The +effects of this variable are unspecified if the User Portability Utilities +option is not supported. +.TP 7 +\fITERM\fP +If the internal variable \fBscreen\fP is not specified, determine +the name of the terminal type to indicate in an unspecified +manner the number of lines in a screenful of headers. If \fITERM\fP +is not set or is set to null, an unspecified default terminal +type shall be used and the value of a screenful is unspecified. The +effects of this variable are unspecified if the User +Portability Utilities option is not supported. +.TP 7 +\fITZ\fP +This variable may determine the timezone used to calculate date and +time strings written by \fImailx\fP. If \fITZ\fP is unset +or null, an unspecified default timezone shall be used. +.TP 7 +\fIVISUAL\fP +Determine a pathname of a utility to invoke when the \fBvisual\fP +command (see Commands in +mailx ) or \fB~v\fP command-escape (see Command Escapes in mailx ) +is used. If this +variable is null or not set, the full-screen editor shall be \fIvi\fP. +The effects of this +variable are unspecified if the User Portability Utilities option +is not supported. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +When \fImailx\fP is in Send Mode and standard input is not a terminal, +it shall take the standard action for all signals. +.LP +In Receive Mode, or in Send Mode when standard input is a terminal, +if a SIGINT signal is received: +.IP " 1." 4 +If in command mode, the current command, if there is one, shall be +aborted, and a command-mode prompt shall be written. +.LP +.IP " 2." 4 +If in input mode: +.RS +.IP " a." 4 +If \fBignore\fP is set, \fImailx\fP shall write \fB"@\\n"\fP , discard +the current input line, and continue processing, +bypassing the message-abort mechanism described in item 2b. +.LP +.IP " b." 4 +If the interrupt was received while sending mail, either when in Receive +Mode or in Send Mode, a message shall be written, and +another subsequent interrupt, with no other intervening characters +typed, shall be required to abort the mail message. If in +Receive Mode and another interrupt is received, a command-mode prompt +shall be written. If in Send Mode and another interrupt is +received, \fImailx\fP shall terminate with a non-zero status. +.LP +In both cases listed in item b, if the message is not empty: +.RS +.IP "i. " 5 +If \fBsave\fP is enabled and the file named by \fIDEAD\fP can be created, +the message shall be written to the file named by +\fIDEAD .\fP If the file exists, the message shall be written to replace +the contents of the file. +.LP +.IP "ii." 5 +If \fBsave\fP is not enabled, or the file named by \fIDEAD\fP cannot +be created, the message shall not be saved. +.LP +.RE +.LP +.RE +.LP +.LP +The \fImailx\fP utility shall take the standard action for all other +signals. +.SH STDOUT +.LP +In command and input modes, all output, including prompts and messages, +shall be written to standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Various \fImailx\fP commands and command escapes can create or add +to files, including the \fBmbox\fP, the dead-letter file, +and secondary mailboxes. When \fImailx\fP is used as described in +this volume of IEEE\ Std\ 1003.1-2001, these files shall +be text files, formatted as follows: +\fBline beginning with\fP \fBFrom<space> +.br +[\fP\fBone or more\fP \fIheader-lines\fP; see Commands in mailx \fB] +.br +\fP \fIempty line +.br +\fP \fB[\fP\fBzero or more\fP \fIbody lines +.br +empty line\fP\fB] +.br +[\fP\fBline beginning with\fP \fBFrom<space>...]\fP +.LP +where each message begins with the \fBFrom\ <space>\fP line shown, +preceded by the beginning of the file or an empty +line. (The \fBFrom <space>\fP line is considered to be part of the +message header, but not one of the header-lines referred +to in Commands in mailx ; thus, it shall not be affected by the \fBdiscard\fP, +\fBignore\fP, or +\fBretain\fP commands.) The formats of the remainder of the \fBFrom +<space>\fP line and any additional header lines are +unspecified, except that none shall be empty. The format of a message +body line is also unspecified, except that no line following +an empty line shall start with \fBFrom <space>\fP; \fImailx\fP shall +modify any such user-entered message body lines +(following an empty line and beginning with \fBFrom <space>\fP) by +adding one or more characters to precede the \fB'F'\fP +; it may add these characters to \fBFrom <space>\fP lines that are +not preceded by an empty line. +.LP +When a message from the system mailbox or entered by the user is not +a text file, it is implementation-defined how such a +message is stored in files written by \fImailx\fP. +.SH EXTENDED DESCRIPTION +.LP +The entire EXTENDED DESCRIPTION section shall apply only to implementations +supporting the User Portability Utilities +option. +.LP +The \fImailx\fP utility cannot guarantee support for all character +encodings in all circumstances. For example, inter-system +mail may be restricted to 7-bit data by the underlying network, 8-bit +data need not be portable to non-internationalized systems, +and so on. Under these circumstances, it is recommended that only +characters defined in the ISO/IEC\ 646:1991 standard +International Reference Version (equivalent to ASCII) 7-bit range +of characters be used. +.LP +When \fImailx\fP is invoked using one of the Receive Mode synopsis +forms, it shall write a page of header-summary lines (if +\fB-N\fP was not specified and there are messages, see below), followed +by a prompt indicating that \fImailx\fP can accept +regular commands (see Commands in mailx ); this is termed \fIcommand +mode\fP. The page of +header-summary lines shall contain the first new message if there +are new messages, or the first unread message if there are unread +messages, or the first message. When \fImailx\fP is invoked using +the Send Mode synopsis and standard input is a terminal, if no +subject is specified on the command line and the \fBasksub\fP variable +is set, a prompt for the subject shall be written. At this +point, \fImailx\fP shall be in input mode. This input mode shall also +be entered when using one of the Receive Mode synopsis forms +and a reply or new message is composed using the \fBreply\fP, \fBReply\fP, +\fBfollowup\fP, \fBFollowup\fP, or \fBmail\fP +commands and standard input is a terminal. When the message is typed +and the end of the message is encountered, the message shall +be passed to the mail delivery software. Commands can be entered by +beginning a line with the escape character (by default, tilde ( +\fB'~'\fP )) followed by a single command letter and optional arguments. +See Commands in +mailx for a summary of these commands. It is unspecified what effect +these commands will have if standard input is not a +terminal when a message is entered using either the Send Mode synopsis, +or the Read Mode commands \fBreply\fP, \fBReply\fP, +\fBfollowup\fP, \fBFollowup\fP, or \fBmail\fP. +.TP 7 +\fBNote:\fP +For notational convenience, this section uses the default escape character, +tilde, in all references and examples. +.sp +.LP +At any time, the behavior of \fImailx\fP shall be governed by a set +of environmental and internal variables. These are flags +and valued parameters that can be set and cleared via the \fImailx\fP +\fBset\fP and \fBunset\fP commands. +.LP +Regular commands are of the form: +.sp +.RS +.nf + +\fB[\fP\fIcommand\fP\fB] [\fP\fImsglist\fP\fB] [\fP\fIargument\fP \fB...\fP\fB] +\fP +.fi +.RE +.LP +If no \fIcommand\fP is specified in command mode, \fBnext\fP shall +be assumed. In input mode, commands shall be recognized by +the escape character, and lines not treated as commands shall be taken +as input for the message. +.LP +In command mode, each message shall be assigned a sequential number, +starting with 1. +.LP +All messages have a state that shall affect how they are displayed +in the header summary and how they are retained or deleted +upon termination of \fImailx\fP. There is at any time the notion of +a \fIcurrent\fP message, which shall be marked by a +\fB'>'\fP at the beginning of a line in the header summary. When \fImailx\fP +is invoked using one of the Receive Mode +synopsis forms, the current message shall be the first new message, +if there is a new message, or the first unread message if there +is an unread message, or the first message if there are any messages, +or unspecified if there are no messages in the mailbox. Each +command that takes an optional list of messages (\fImsglist\fP) or +an optional single message (\fImessage\fP) on which to operate +shall leave the current message set to the highest-numbered message +of the messages specified, unless the command deletes messages, +in which case the current message shall be set to the first undeleted +message (that is, a message not in the deleted state) after +the highest-numbered message deleted by the command, if one exists, +or the first undeleted message before the highest-numbered +message deleted by the command, if one exists, or to an unspecified +value if there are no remaining undeleted messages. All +messages shall be in one of the following states: +.TP 7 +\fInew\fP +The message is present in the system mailbox and has not been viewed +by the user or moved to any other state. Messages in state +\fInew\fP when \fImailx\fP quits shall be retained in the system mailbox. +.TP 7 +\fIunread\fP +The message has been present in the system mailbox for more than one +invocation of \fImailx\fP and has not been viewed by the +user or moved to any other state. Messages in state \fIunread\fP when +\fImailx\fP quits shall be retained in the system +mailbox. +.TP 7 +\fIread\fP +The message has been processed by one of the following commands: \fB~f\fP, +\fB~m\fP, \fB~F\fP, +\fB~M\fP, \fBcopy\fP, \fBmbox\fP, \fBnext\fP, \fBpipe\fP, \fBprint\fP, +\fBPrint\fP, \fBtop\fP, \fBtype\fP, +\fBType\fP, \fBundelete\fP. The \fBdelete\fP, \fBdp\fP, and \fBdt\fP +commands may also cause the next message to be marked as +\fIread\fP, depending on the value of the \fBautoprint\fP variable. +Messages that are in the system mailbox and in state +\fIread\fP when \fImailx\fP quits shall be saved in the \fBmbox\fP, +unless the internal variable \fBhold\fP was set. Messages +that are in the \fBmbox\fP or in a secondary mailbox and in state +\fIread\fP when \fImailx\fP quits shall be retained in their +current location. +.TP 7 +\fIdeleted\fP +The message has been processed by one of the following commands: \fBdelete\fP, +\fBdp\fP, \fBdt\fP. Messages in state +\fIdeleted\fP when \fImailx\fP quits shall be deleted. Deleted messages +shall be ignored until \fImailx\fP quits or changes +mailboxes or they are specified to the undelete command; for example, +the message specification / \fIstring\fP shall only search +the subject lines of messages that have not yet been deleted, unless +the command operating on the list of messages is +\fBundelete\fP. No deleted message or deleted message header shall +be displayed by any \fImailx\fP command other than +\fBundelete\fP. +.TP 7 +\fIpreserved\fP +The message has been processed by a \fBpreserve\fP command. When \fImailx\fP +quits, the message shall be retained in its +current location. +.TP 7 +\fIsaved\fP +The message has been processed by one of the following commands: \fBsave\fP +or \fBwrite\fP. If the current mailbox is the +system mailbox, and the internal variable \fBkeepsave\fP is set, messages +in the state saved shall be saved to the file designated +by the \fIMBOX\fP variable (see the ENVIRONMENT VARIABLES section). +If the current mailbox is the system mailbox, messages in the +state \fIsaved\fP shall be deleted from the current mailbox, when +the \fBquit\fP or \fBfile\fP command is used to exit the +current mailbox. +.sp +.LP +The header-summary line for each message shall indicate the state +of the message. +.LP +Many commands take an optional list of messages ( \fImsglist\fP) on +which to operate, which defaults to the current message. A +\fImsglist\fP is a list of message specifications separated by <blank>s, +which can include: +.TP 7 +\fBn\fP +Message number \fIn\fP. +.TP 7 +\fB+\fP +The next undeleted message, or the next deleted message for the \fBundelete\fP +command. +.TP 7 +\fB-\fP +The next previous undeleted message, or the next previous deleted +message for the \fBundelete\fP command. +.TP 7 +\fB\&.\fP +The current message. +.TP 7 +\fB^\fP +The first undeleted message, or the first deleted message for the +\fBundelete\fP command. +.TP 7 +\fB$\fP +The last message. +.TP 7 +\fB*\fP +All messages. +.TP 7 +\fBn-m\fP +An inclusive range of message numbers. +.TP 7 +\fIaddress\fP +All messages from \fIaddress\fP; any address as shown in a header +summary shall be matchable in this form. +.TP 7 +/\fIstring\fP +All messages with \fIstring\fP in the subject line (case ignored). +.TP 7 +\fB:c\fP +All messages of type \fIc\fP, where \fIc\fP shall be one of: +.TP 7 +\fBd\fP +.RS +Deleted messages. +.RE +.TP 7 +\fBn\fP +.RS +New messages. +.RE +.TP 7 +\fBo\fP +.RS +Old messages (any not in state \fIread\fP or \fInew\fP). +.RE +.TP 7 +\fBr\fP +.RS +Read messages. +.RE +.TP 7 +\fBu\fP +.RS +Unread messages. +.RE +.sp +.sp +.LP +Other commands take an optional message ( \fImessage\fP) on which +to operate, which defaults to the current message. All of the +forms allowed for \fImsglist\fP are also allowed for \fImessage\fP, +but if more than one message is specified, only the first +shall be operated on. +.LP +Other arguments are usually arbitrary strings whose usage depends +on the command involved. +.SS Start-Up in mailx +.LP +At start-up time, \fImailx\fP shall take the following steps in sequence: +.IP " 1." 4 +Establish all variables at their stated default values. +.LP +.IP " 2." 4 +Process command line options, overriding corresponding default values. +.LP +.IP " 3." 4 +Import any of the \fIDEAD ,\fP \fIEDITOR ,\fP \fIMBOX ,\fP \fILISTER +,\fP \fIPAGER ,\fP \fISHELL ,\fP or \fIVISUAL\fP +variables that are present in the environment, overriding the corresponding +default values. +.LP +.IP " 4." 4 +Read \fImailx\fP commands from an unspecified system start-up file, +unless the \fB-n\fP option is given, to initialize any +internal \fImailx\fP variables and aliases. +.LP +.IP " 5." 4 +Process the start-up file of \fImailx\fP commands named in the user +\fIMAILRC\fP variable. +.LP +.LP +Most regular \fImailx\fP commands are valid inside start-up files, +the most common use being to set up initial display options +and alias lists. The following commands shall be invalid in the start-up +file: \fB!\fP, \fBedit\fP, \fBhold\fP, \fBmail\fP, +\fBpreserve\fP, \fBreply\fP, \fBReply\fP, \fBshell\fP, \fBvisual\fP, +\fBCopy\fP, \fBfollowup\fP, and \fBFollowup\fP. Any +errors in the start-up file shall either cause \fImailx\fP to terminate +with a diagnostic message and a non-zero status or to +continue after writing a diagnostic message, ignoring the remainder +of the lines in the start-up file. +.LP +A blank line in a start-up file shall be ignored. +.SS Internal Variables in mailx +.LP +The following variables are internal \fImailx\fP variables. Each internal +variable can be set via the \fImailx\fP \fBset\fP +command at any time. The \fBunset\fP and \fBset\ no\fP \fIname\fP +commands can be used to erase variables. +.LP +In the following list, variables shown as: +.sp +.RS +.nf + +\fBvariable +\fP +.fi +.RE +.LP +represent Boolean values. Variables shown as: +.sp +.RS +.nf + +\fBvariable=\fP\fIvalue\fP +.fi +.RE +.LP +shall be assigned string or numeric values. For string values, the +rules in Commands in mailx +concerning filenames and quoting shall also apply. +.LP +The defaults specified here may be changed by the implementation-defined +system start-up file unless the user specifies the +\fB-n\fP option. +.TP 7 +\fBallnet\fP +All network names whose login name components match shall be treated +as identical. This shall cause the \fImsglist\fP message +specifications to behave similarly. The default shall be \fBnoallnet\fP. +See also the \fBalternates\fP command and the +\fBmetoo\fP variable. +.TP 7 +\fBappend\fP +Append messages to the end of the \fBmbox\fP file upon termination +instead of placing them at the beginning. The default shall +be \fBnoappend\fP. This variable shall not affect the \fBsave\fP command +when saving to \fBmbox\fP. +.TP 7 +\fBask\fP,\ \fBasksub\fP +Prompt for a subject line on outgoing mail if one is not specified +on the command line with the \fB-s\fP option. The +\fBask\fP and \fBasksub\fP forms are synonyms; the system shall refer +to \fBasksub\fP and \fBnoasksub\fP in its messages, but +shall accept \fBask\fP and \fBnoask\fP as user input to mean \fBasksub\fP +and \fBnoasksub\fP. It shall not be possible to set +both \fBask\fP and \fBnoasksub\fP, or \fBnoask\fP and \fBasksub\fP. +The default shall be \fBasksub\fP, but no prompting shall +be done if standard input is not a terminal. +.TP 7 +\fBaskbcc\fP +Prompt for the blind copy list. The default shall be \fBnoaskbcc\fP. +.TP 7 +\fBaskcc\fP +Prompt for the copy list. The default shall be \fBnoaskcc\fP. +.TP 7 +\fBautoprint\fP +Enable automatic writing of messages after \fBdelete\fP and \fBundelete\fP +commands. The default shall be +\fBnoautoprint\fP. +.TP 7 +\fBbang\fP +Enable the special-case treatment of exclamation marks ( \fB'!'\fP +) in escape command lines; see the \fBescape\fP command +and Command Escapes in mailx . The default shall be \fBnobang\fP, +disabling the expansion of +\fB'!'\fP in the \fIcommand\fP argument to the \fB~!\fP command and +the \fB~<!\fP \fIcommand\fP escape. +.TP 7 +\fBcmd\fP=\fIcommand\fP +.sp +Set the default command to be invoked by the \fBpipe\fP command. The +default shall be \fBnocmd\fP. +.TP 7 +\fBcrt\fP=\fInumber\fP +Pipe messages having more than \fInumber\fP lines through the command +specified by the value of the \fIPAGER\fP variable. The +default shall be \fBnocrt\fP. If it is set to null, the value used +is implementation-defined. +.TP 7 +\fBdebug\fP +Enable verbose diagnostics for debugging. Messages are not delivered. +The default shall be \fBnodebug\fP. +.TP 7 +\fBdot\fP +When \fBdot\fP is set, a period on a line by itself during message +input from a terminal shall also signify end-of-file (in +addition to normal end-of-file). The default shall be \fBnodot\fP. +If \fBignoreeof\fP is set (see below), a setting of +\fBnodot\fP shall be ignored and the period is the only method to +terminate input mode. +.TP 7 +\fBescape\fP=\fIc\fP +Set the command escape character to be the character \fB'c'\fP . By +default, the command escape character shall be tilde. If +\fBescape\fP is unset, tilde shall be used; if it is set to null, +command escaping shall be disabled. +.TP 7 +\fBflipr\fP +Reverse the meanings of the \fBR\fP and \fBr\fP commands. The default +shall be \fBnoflipr\fP. +.TP 7 +\fBfolder\fP=\fIdirectory\fP +.sp +The default directory for saving mail files. User-specified filenames +beginning with a plus sign ( \fB'+'\fP ) shall be expanded +by preceding the filename with this directory name to obtain the real +pathname. If \fIdirectory\fP does not start with a slash ( +\fB'/'\fP ), the contents of \fIHOME\fP shall be prefixed to it. The +default shall be \fBnofolder\fP. If \fBfolder\fP is +unset or set to null, user-specified filenames beginning with \fB'+'\fP +shall refer to files in the current directory that begin +with the literal \fB'+'\fP character. See also \fBoutfolder\fP below. +The \fBfolder\fP value need not affect the processing of +the files named in \fIMBOX\fP and \fIDEAD .\fP +.TP 7 +\fBheader\fP +Enable writing of the header summary when entering \fImailx\fP in +Receive Mode. The default shall be \fBheader\fP. +.TP 7 +\fBhold\fP +Preserve all messages that are read in the system mailbox instead +of putting them in the \fBmbox\fP save file. The default +shall be \fBnohold\fP. +.TP 7 +\fBignore\fP +Ignore interrupts while entering messages. The default shall be \fBnoignore\fP. +.TP 7 +\fBignoreeof\fP +Ignore normal end-of-file during message input. Input can be terminated +only by entering a period ( \fB'.'\fP ) on a line by +itself or by the \fB~.\fP command escape. The default shall be \fBnoignoreeof\fP. +See also \fBdot\fP above. +.TP 7 +\fBindentprefix\fP=\fIstring\fP +.sp +A string that shall be added as a prefix to each line that is inserted +into the message by the \fB~m\fP command escape. This +variable shall default to one <tab>. +.TP 7 +\fBkeep\fP +When a system mailbox, secondary mailbox, or \fBmbox\fP is empty, +truncate it to zero length instead of removing it. The +default shall be \fBnokeep\fP. +.TP 7 +\fBkeepsave\fP +Keep the messages that have been saved from the system mailbox into +other files in the file designated by the variable \fIMBOX +,\fP instead of deleting them. The default shall be \fBnokeepsave\fP. +.TP 7 +\fBmetoo\fP +Suppress the deletion of the login name of the user from the recipient +list when replying to a message or sending to a group. +The default shall be \fBnometoo\fP. +.TP 7 +\fBonehop\fP +When responding to a message that was originally sent to several recipients, +the other recipient addresses are normally forced to +be relative to the originating author's machine for the response. +This flag disables alteration of the recipients' addresses, +improving efficiency in a network where all machines can send directly +to all other machines (that is, one hop away). The default +shall be \fBnoonehop\fP. +.TP 7 +\fBoutfolder\fP +Cause the files used to record outgoing messages to be located in +the directory specified by the \fBfolder\fP variable unless +the pathname is absolute. The default shall be \fBnooutfolder\fP. +See the \fBrecord\fP variable. +.TP 7 +\fBpage\fP +Insert a <form-feed> after each message sent through the pipe created +by the \fBpipe\fP command. The default shall be +\fBnopage\fP. +.TP 7 +\fBprompt\fP=\fIstring\fP +.sp +Set the command-mode prompt to \fIstring\fP. If \fIstring\fP is null +or if \fBnoprompt\fP is set, no prompting shall occur. The +default shall be to prompt with the string \fB"?\ "\fP . +.TP 7 +\fBquiet\fP +Refrain from writing the opening message and version when entering +\fImailx\fP. The default shall be \fBnoquiet\fP. +.TP 7 +\fBrecord\fP=\fIfile\fP +Record all outgoing mail in the file with the pathname \fIfile\fP. +The default shall be \fBnorecord\fP. See also +\fBoutfolder\fP above. +.TP 7 +\fBsave\fP +Enable saving of messages in the dead-letter file on interrupt or +delivery error. See the variable \fIDEAD\fP for the location +of the dead-letter file. The default shall be \fBsave\fP. +.TP 7 +\fBscreen\fP=\fInumber\fP +.sp +Set the number of lines in a screenful of headers for the \fBheaders\fP +and \fBz\fP commands. If \fBscreen\fP is not specified, +a value based on the terminal type identified by the \fITERM\fP environment +variable, the window size, the baud rate, or some +combination of these shall be used. +.TP 7 +\fBsendwait\fP +Wait for the background mailer to finish before returning. The default +shall be \fBnosendwait\fP. +.TP 7 +\fBshowto\fP +When the sender of the message was the user who is invoking \fImailx\fP, +write the information from the \fBTo:\fP line +instead of the \fBFrom:\fP line in the header summary. The default +shall be \fBnoshowto\fP. +.TP 7 +\fBsign\fP=\fIstring\fP +Set the variable inserted into the text of a message when the \fB~a\fP +command escape is given. The default shall be +\fBnosign\fP. The character sequences \fB'\\t'\fP and \fB'\\n'\fP +shall be recognized in the variable as <tab>s and +<newline>s, respectively. (See also \fB~i\fP in Command Escapes in +mailx .) +.TP 7 +\fBSign\fP=\fIstring\fP +Set the variable inserted into the text of a message when the \fB~A\fP +command escape is given. The default shall be +\fBnoSign\fP. The character sequences \fB'\\t'\fP and \fB'\\n'\fP +shall be recognized in the variable as <tab>s and +<newline>s, respectively. +.TP 7 +\fBtoplines\fP=\fInumber\fP +.sp +Set the number of lines of the message to write with the \fBtop\fP +command. The default shall be 5. +.sp +.SS Commands in mailx +.LP +The following \fImailx\fP commands shall be provided. In the following +list, header refers to lines from the message header, as +shown in the OUTPUT FILES section. Header-line refers to lines within +the header that begin with one or more non-white-space +characters, immediately followed by a colon and white space and continuing +until the next line beginning with a non-white-space +character or an empty line. Header-field refers to the portion of +a header line prior to the first colon in that line. +.LP +For each of the commands listed below, the command can be entered +as the abbreviation (those characters in the Synopsis command +word preceding the \fB'['\fP ), the full command (all characters shown +for the command word, omitting the \fB'['\fP and +\fB']'\fP ), or any truncation of the full command down to the abbreviation. +For example, the \fBexit\fP command (shown as +\fBex[it]\fP in the Synopsis) can be entered as \fBex\fP, \fBexi\fP, +or \fBexit\fP. +.LP +The arguments to commands can be quoted, using the following methods: +.IP " *" 3 +An argument can be enclosed between paired double-quotes ( \fB""\fP +) or single-quotes ( \fB''\fP ); any white space, +shell word expansion, or backslash characters within the quotes shall +be treated literally as part of the argument. A double-quote +shall be treated literally within single-quotes and \fIvice versa\fP. +These special properties of the quote marks shall occur only +when they are paired at the beginning and end of the argument. +.LP +.IP " *" 3 +A backslash outside of the enclosing quotes shall be discarded and +the following character treated literally as part of the +argument. +.LP +.IP " *" 3 +An unquoted backslash at the end of a command line shall be discarded +and the next line shall continue the command. +.LP +.LP +Filenames, where expected, shall be subjected to the following transformations, +in sequence: +.IP " *" 3 +If the filename begins with an unquoted plus sign, and the \fBfolder\fP +variable is defined (see the \fBfolder\fP variable), +the plus sign shall be replaced by the value of the \fBfolder\fP variable +followed by a slash. If the \fBfolder\fP variable is +unset or is set to null, the filename shall be unchanged. +.LP +.IP " *" 3 +Shell word expansions shall be applied to the filename (see \fIWord +Expansions\fP ). If +more than a single pathname results from this expansion and the command +is expecting one file, the effects are unspecified. +.LP +.SS Declare Aliases +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBa\fP\fB[\fP\fBlias\fP\fB] [\fP\fIalias\fP \fB[\fP\fIaddress\fP\fB...\fP\fB]]\fP\fBg\fP\fB[\fP\fBroup\fP\fB] [\fP\fIalias\fP \fB[\fP\fIaddress\fP\fB...\fP\fB]]\fP +.fi +.RE +.sp +.LP +Add the given addresses to the alias specified by \fIalias\fP. The +names shall be substituted when \fIalias\fP is used as a +recipient address specified by the user in an outgoing message (that +is, other recipients addressed indirectly through the +\fBreply\fP command shall not be substituted in this manner). Mail +address alias substitution shall apply only when the alias +string is used as a full address; for example, when \fBhlj\fP is an +alias, \fIhlj@posix.com\fP does not trigger the alias +substitution. If no arguments are given, write a listing of the current +aliases to standard output. If only an \fIalias\fP +argument is given, write a listing of the specified alias to standard +output. These listings need not reflect the same order of +addresses that were entered. +.SS Declare Alternatives +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBalt\fP\fB[\fP\fBernates\fP\fB]\fP \fIname\fP\fB... +\fP +.fi +.RE +.sp +.LP +(See also the \fBmetoo\fP command.) Declare a list of alternative +names for the user's login. When responding to a message, +these names shall be removed from the list of recipients for the response. +The comparison of names shall be in a case-insensitive +manner. With no arguments, \fBalternates\fP shall write the current +list of alternative names. +.SS Change Current Directory +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBcd\fP \fB[\fP\fIdirectory\fP\fB]\fP\fBch\fP\fB[\fP\fBdir\fP\fB] [\fP\fIdirectory\fP\fB]\fP +.fi +.RE +.sp +.LP +Change directory. If \fIdirectory\fP is not specified, the contents +of \fIHOME\fP shall be used. +.SS Copy Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBc\fP\fB[\fP\fBopy\fP\fB] [\fP\fIfile\fP\fB]\fP\fBc\fP\fB[\fP\fBopy\fP\fB] [\fP\fImsglist\fP\fB]\fP \fIfile\fP\fBC\fP\fB[\fP\fBopy\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Copy messages to the file named by the pathname \fIfile\fP without +marking the messages as saved. Otherwise, it shall be +equivalent to the \fBsave\fP command. +.LP +In the capitalized form, save the specified messages in a file whose +name is derived from the author of the message to be saved, +without marking the messages as saved. Otherwise, it shall be equivalent +to the \fBSave\fP command. +.SS Delete Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBd\fP\fB[\fP\fBelete\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Mark messages for deletion from the mailbox. The deletions shall not +occur until \fImailx\fP quits (see the \fBquit\fP +command) or changes mailboxes (see the \fBfolder\fP command). If \fBautoprint\fP +is set and there are messages remaining after +the \fBdelete\fP command, the current message shall be written as +described for the \fBprint\fP command (see the \fBprint\fP +command); otherwise, the \fImailx\fP prompt shall be written. +.SS Discard Header Fields +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBdi\fP\fB[\fP\fBscard\fP\fB] [\fP\fIheader-field\fP\fB...\fP\fB]\fP\fBig\fP\fB[\fP\fBnore\fP\fB] [\fP\fIheader-field\fP\fB...\fP\fB]\fP +.fi +.RE +.sp +.LP +Suppress the specified header fields when writing messages. Specified +\fIheader-fields\fP shall be added to the list of +suppressed header fields. Examples of header fields to ignore are +\fBstatus\fP and \fBcc\fP. The fields shall be included when +the message is saved. The \fBPrint\fP and \fBType\fP commands shall +override this command. The comparison of header fields shall +be in a case-insensitive manner. If no arguments are specified, write +a list of the currently suppressed header fields to standard +output; the listing need not reflect the same order of header fields +that were entered. +.LP +If both \fBretain\fP and \fBdiscard\fP commands are given, \fBdiscard\fP +commands shall be ignored. +.SS Delete Messages and Display +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBdp\fP \fB[\fP\fImsglist\fP\fB]\fP\fBdt\fP \fB[\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Delete the specified messages as described for the \fBdelete\fP command, +except that the \fBautoprint\fP variable shall have +no effect, and the current message shall be written only if it was +set to a message after the last message deleted by the command. +Otherwise, an informational message to the effect that there are no +further messages in the mailbox shall be written, followed by +the \fImailx\fP prompt. +.SS Echo a String +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBec\fP\fB[\fP\fBho\fP\fB]\fP \fIstring\fP \fB... +\fP +.fi +.RE +.sp +.LP +Echo the given strings, equivalent to the shell \fIecho\fP utility. +.SS Edit Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBe\fP\fB[\fP\fBdit\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Edit the given messages. The messages shall be placed in a temporary +file and the utility named by the \fIEDITOR\fP variable is +invoked to edit each file in sequence. The default \fIEDITOR\fP is +unspecified. +.LP +The \fBedit\fP command does not modify the contents of those messages +in the mailbox. +.SS Exit +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBex\fP\fB[\fP\fBit\fP\fB]\fP\fBx\fP\fB[\fP\fBit\fP\fB]\fP +.fi +.RE +.sp +.LP +Exit from \fImailx\fP without changing the mailbox. No messages shall +be saved in the \fBmbox\fP (see also \fBquit\fP). +.SS Change Folder +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBfi\fP\fB[\fP\fBle\fP\fB] [\fP\fIfile\fP\fB]\fP\fBfold\fP\fB[\fP\fBer\fP\fB] [\fP\fIfile\fP\fB]\fP +.fi +.RE +.sp +.LP +Quit (see the \fBquit\fP command) from the current file of messages +and read in the file named by the pathname \fIfile\fP. If +no argument is given, the name and status of the current mailbox shall +be written. +.LP +Several unquoted special characters shall be recognized when used +as \fIfile\fP names, with the following substitutions: +.TP 7 +\fB%\fP +The system mailbox for the invoking user. +.TP 7 +\fB%\fP\fIuser\fP +The system mailbox for \fIuser\fP. +.TP 7 +\fB#\fP +The previous file. +.TP 7 +\fB&\fP +The current \fBmbox\fP. +.TP 7 +\fB+\fP\fIfile\fP +The named file in the \fBfolder\fP directory. (See the \fBfolder\fP +variable.) +.sp +.LP +The default file shall be the current mailbox. +.SS Display List of Folders +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBfolders\fP +.fi +.RE +.sp +.LP +Write the names of the files in the directory set by the \fBfolder\fP +variable. The command specified by the \fILISTER\fP +environment variable shall be used (see the ENVIRONMENT VARIABLES +section). +.SS Follow Up Specified Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBfo\fP\fB[\fP\fBllowup\fP\fB] [\fP\fImessage\fP\fB]\fP\fBF\fP\fB[\fP\fBollowup\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +In the lowercase form, respond to a message, recording the response +in a file whose name is derived from the author of the +message. See also the \fBsave\fP and \fBcopy\fP commands and \fBoutfolder\fP. +.LP +In the capitalized form, respond to the first message in the \fImsglist\fP, +sending the message to the author of each message +in the \fImsglist\fP. The subject line shall be taken from the first +message and the response shall be recorded in a file whose +name is derived from the author of the first message. See also the +\fBSave\fP and \fBCopy\fP commands and \fBoutfolder\fP. +.LP +Both forms shall override the \fBrecord\fP variable, if set. +.SS Display Header Summary for Specified Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBf\fP\fB[\fP\fBrom\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the header summary for the specified messages. +.SS Display Header Summary +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBh\fP\fB[\fP\fBeaders\fP\fB] [\fP\fImessage\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the page of headers that includes the message specified. If +the \fImessage\fP argument is not specified, the current +message shall not change. However, if the \fImessage\fP argument is +specified, the current message shall become the message that +appears at the top of the page of headers that includes the message +specified. The \fBscreen\fP variable sets the number of +headers per page. See also the \fBz\fP command. +.SS Help +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBhel\fP\fB[\fP\fBp\fP\fB]\fP\fB? +\fP +.fi +.RE +.sp +.LP +Write a summary of commands. +.SS Hold Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBho\fP\fB[\fP\fBld\fP\fB] [\fP\fImsglist\fP\fB]\fP\fBpre\fP\fB[\fP\fBserve\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Mark the messages in \fImsglist\fP to be retained in the mailbox when +\fImailx\fP terminates. This shall override any commands +that might previously have marked the messages to be deleted. During +the current invocation of \fImailx\fP, only the +\fBdelete\fP, \fBdp\fP, or \fBdt\fP commands shall remove the \fIpreserve\fP +marking of a message. +.SS Execute Commands Conditionally +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBi\fP\fB[\fP\fBf\fP\fB]\fP \fBs|r +\fP\fImail-command\fP\fBs +el\fP\fB[\fP\fBse\fP\fB] +\fP\fImail-command\fP\fBs +en\fP\fB[\fP\fBdif\fP\fB]\fP +.fi +.RE +.sp +.LP +Execute commands conditionally, where \fBif\ s\fP executes the following +\fImail-command\fPs, up to an \fBelse\fP or +\fBendif\fP, if the program is in Send Mode, and \fBif\ r\fP shall +cause the \fImail-command\fPs to be executed only in +Receive Mode. +.SS List Available Commands +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBl\fP\fB[\fP\fBist\fP\fB]\fP +.fi +.RE +.sp +.LP +Write a list of all commands available. No explanation shall be given. +.SS Mail a Message +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBm\fP\fB[\fP\fBail\fP\fB]\fP \fIaddress\fP\fB... +\fP +.fi +.RE +.sp +.LP +Mail a message to the specified addresses or aliases. +.SS Direct Messages to mbox +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBmb\fP\fB[\fP\fBox\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Arrange for the given messages to end up in the \fBmbox\fP save file +when \fImailx\fP terminates normally. See \fIMBOX .\fP +See also the \fBexit\fP and \fBquit\fP commands. +.SS Process Next Specified Message +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBn\fP\fB[\fP\fBext\fP\fB] [\fP\fImessage\fP\fB]\fP +.fi +.RE +.sp +.LP +If the current message has not been written (for example, by the \fBprint\fP +command) since \fImailx\fP started or since any +other message was the current message, behave as if the \fBprint\fP +command was entered. Otherwise, if there is an undeleted +message after the current message, make it the current message and +behave as if the \fBprint\fP command was entered. Otherwise, an +informational message to the effect that there are no further messages +in the mailbox shall be written, followed by the +\fImailx\fP prompt. +.SS Pipe Message +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBpi\fP\fB[\fP\fBpe\fP\fB] [[\fP\fImsglist\fP\fB]\fP \fIcommand\fP\fB]\fP\fB|\fP \fB[[\fP\fImsglist\fP\fB]\fP \fIcommand\fP\fB]\fP +.fi +.RE +.sp +.LP +Pipe the messages through the given \fIcommand\fP by invoking the +command interpreter specified by \fISHELL\fP with two +arguments: \fB-c\fP and \fIcommand\fP. (See also \fIsh\fP \fB-c\fP.) +The application shall +ensure that the command is given as a single argument. Quoting, described +previously, can be used to accomplish this. If no +arguments are given, the current message shall be piped through the +command specified by the value of the \fBcmd\fP variable. If +the \fBpage\fP variable is set, a <form-feed> shall be inserted after +each message. +.SS Display Message with Headers +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBP\fP\fB[\fP\fBrint\fP\fB] [\fP\fImsglist\fP\fB]\fP\fBT\fP\fB[\fP\fBype\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the specified messages, including all header lines, to standard +output. Override suppression of lines by the +\fBdiscard\fP, \fBignore\fP, and \fBretain\fP commands. If \fBcrt\fP +is set, the messages longer than the number of lines +specified by the \fBcrt\fP variable shall be paged through the command +specified by the \fIPAGER\fP environment variable. +.SS Display Message +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBp\fP\fB[\fP\fBrint\fP\fB] [\fP\fImsglist\fP\fB]\fP\fBt\fP\fB[\fP\fBype\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the specified messages to standard output. If \fBcrt\fP is set, +the messages longer than the number of lines specified by +the \fBcrt\fP variable shall be paged through the command specified +by the \fIPAGER\fP environment variable. +.SS Quit +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBq\fP\fB[\fP\fBuit\fP\fB] +\fP\fIend-of-file\fP +.fi +.RE +.sp +.LP +Terminate \fImailx\fP, storing messages that were read in \fBmbox\fP +(if the current mailbox is the system mailbox and unless +\fBhold\fP is set), deleting messages that have been explicitly saved +(unless \fBkeepsave\fP is set), discarding messages that +have been deleted, and saving all remaining messages in the mailbox. +.SS Reply to a Message List +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBR\fP\fB[\fP\fBeply\fP\fB] [\fP\fImsglist\fP\fB]\fP\fBR\fP\fB[\fP\fBespond\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Mail a reply message to the sender of each message in the \fImsglist\fP. +The subject line shall be formed by concatenating +\fBRe:\fP <space> (unless it already begins with that string) and +the subject from the first message. If \fBrecord\fP is +set to a filename, the response shall be saved at the end of that +file. +.LP +See also the \fBflipr\fP variable. +.SS Reply to a Message +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBr\fP\fB[\fP\fBeply\fP\fB] [\fP\fImessage\fP\fB]\fP\fBr\fP\fB[\fP\fBespond\fP\fB] [\fP\fImessage\fP\fB]\fP +.fi +.RE +.sp +.LP +Mail a reply message to all recipients included in the header of the +message. The subject line shall be formed by concatenating +\fBRe:\fP <space> (unless it already begins with that string) and +the subject from the message. If \fBrecord\fP is set to a +filename, the response shall be saved at the end of that file. +.LP +See also the \fBflipr\fP variable. +.SS Retain Header Fields +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBret\fP\fB[\fP\fBain\fP\fB] [\fP\fIheader-field\fP\fB...\fP\fB]\fP +.fi +.RE +.sp +.LP +Retain the specified header fields when writing messages. This command +shall override all \fBdiscard\fP and \fBignore\fP +commands. The comparison of header fields shall be in a case-insensitive +manner. If no arguments are specified, write a list of the +currently retained header fields to standard output; the listing need +not reflect the same order of header fields that were +entered. +.SS Save Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBs\fP\fB[\fP\fBave\fP\fB] [\fP\fIfile\fP\fB]\fP\fBs\fP\fB[\fP\fBave\fP\fB] [\fP\fImsglist\fP\fB]\fP \fIfile\fP\fBS\fP\fB[\fP\fBave\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Save the specified messages in the file named by the pathname \fIfile\fP, +or the \fBmbox\fP if the \fIfile\fP argument is +omitted. The file shall be created if it does not exist; otherwise, +the messages shall be appended to the file. The message shall +be put in the state \fIsaved\fP, and shall behave as specified in +the description of the \fIsaved\fP state when the current +mailbox is exited by the \fBquit\fP or \fBfile\fP command. +.LP +In the capitalized form, save the specified messages in a file whose +name is derived from the author of the first message. The +name of the file shall be taken to be the author's name with all network +addressing stripped off. See also the \fBCopy\fP, +\fBfollowup\fP, and \fBFollowup\fP commands and \fBoutfolder\fP variable. +.SS Set Variables +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBse\fP\fB[\fP\fBt\fP\fB] [\fP\fIname\fP\fB[\fP\fB=\fP\fB[\fP\fIstring\fP\fB]]\fP \fB...\fP\fB] [\fP\fIname\fP\fB=\fP\fInumber\fP \fB...\fP\fB] [\fP\fBno\fP\fIname\fP \fB...\fP\fB]\fP +.fi +.RE +.sp +.LP +Define one or more variables called \fIname\fP. The variable can be +given a null, string, or numeric value. Quoting and +backslash escapes can occur anywhere in \fIstring\fP, as described +previously, as if the \fIstring\fP portion of the argument +were the entire argument. The forms \fIname\fP and \fIname\fP= shall +be equivalent to \fIname\fP="" for variables that take +string values. The \fBset\fP command without arguments shall write +a list of all defined variables and their values. The \fBno\fP +\fIname\fP form shall be equivalent to \fBunset\fP \fIname\fP. +.SS Invoke a Shell +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBsh\fP\fB[\fP\fBell\fP\fB]\fP +.fi +.RE +.sp +.LP +Invoke an interactive command interpreter (see also \fISHELL ).\fP +.SS Display Message Size +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBsi\fP\fB[\fP\fBze\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the size in bytes of each of the specified messages. +.SS Read mailx Commands From a File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBso\fP\fB[\fP\fBurce\fP\fB]\fP \fIfile\fP +.fi +.RE +.sp +.LP +Read and execute commands from the file named by the pathname \fIfile\fP +and return to command mode. +.SS Display Beginning of Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBto\fP\fB[\fP\fBp\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Write the top few lines of each of the specified messages. If the +\fBtoplines\fP variable is set, it is taken as the number of +lines to write. The default shall be 5. +.SS Touch Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBtou\fP\fB[\fP\fBch\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Touch the specified messages. If any message in \fImsglist\fP is not +specifically deleted nor saved in a file, it shall be +placed in the \fBmbox\fP upon normal termination. See \fBexit\fP and +\fBquit\fP. +.SS Delete Aliases +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBuna\fP\fB[\fP\fBlias\fP\fB] [\fP\fIalias\fP\fB]\fP\fB... +\fP +.fi +.RE +.sp +.LP +Delete the specified alias names. If a specified alias does not exist, +the results are unspecified. +.SS Undelete Messages +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBu\fP\fB[\fP\fBndelete\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Change the state of the specified messages from deleted to read. If +\fBautoprint\fP is set, the last message of those restored +shall be written. If \fImsglist\fP is not specified, the message shall +be selected as follows: +.IP " *" 3 +If there are any deleted messages that follow the current message, +the first of these shall be chosen. +.LP +.IP " *" 3 +Otherwise, the last deleted message that also precedes the current +message shall be chosen. +.LP +.SS Unset Variables +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBuns\fP\fB[\fP\fBet\fP\fB]\fP \fIname\fP\fB... +\fP +.fi +.RE +.sp +.LP +Cause the specified variables to be erased. +.SS Edit Message with Full-Screen Editor +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBv\fP\fB[\fP\fBisual\fP\fB] [\fP\fImsglist\fP\fB]\fP +.fi +.RE +.sp +.LP +Edit the given messages with a screen editor. Each message shall be +placed in a temporary file, and the utility named by the +\fIVISUAL\fP variable shall be invoked to edit each file in sequence. +The default editor shall be \fIvi\fP. +.LP +The \fBvisual\fP command does not modify the contents of those messages +in the mailbox. +.SS Write Messages to a File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBw\fP\fB[\fP\fBrite\fP\fB] [\fP\fImsglist\fP\fB]\fP \fIfile\fP +.fi +.RE +.sp +.LP +Write the given messages to the file specified by the pathname \fIfile\fP, +minus the message header. Otherwise, it shall be +equivalent to the \fBsave\fP command. +.SS Scroll Header Display +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBz\fP\fB[\fP\fB+|-\fP\fB]\fP +.fi +.RE +.sp +.LP +Scroll the header display forward (if \fB'+'\fP is specified or if +no option is specified) or backward (if \fB'-'\fP is +specified) one screenful. The number of headers written shall be set +by the \fBscreen\fP variable. +.SS Invoke Shell Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB!\fP\fIcommand\fP +.fi +.RE +.sp +.LP +Invoke the command interpreter specified by \fISHELL\fP with two arguments: +\fB-c\fP and \fIcommand\fP. (See also \fIsh\fP \fB-c\fP.) If the \fBbang\fP +variable is set, each unescaped occurrence of \fB'!'\fP in +\fIcommand\fP shall be replaced with the command executed by the previous +\fB!\fP command or \fB~!\fP command escape. +.SS Null Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB#\fP \fIcomment\fP +.fi +.RE +.sp +.LP +This null command (comment) shall be ignored by \fImailx\fP. +.SS Display Current Message Number +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB= +\fP +.fi +.RE +.sp +.LP +Write the current message number. +.SS Command Escapes in mailx +.LP +The following commands can be entered only from input mode, by beginning +a line with the escape character (by default, tilde ( +\fB'~'\fP )). See the \fBescape\fP variable description for changing +this special character. The format for the commands +shall be: +.sp +.RS +.nf + +\fB<\fP\fIescape-character\fP\fB><\fP\fIcommand-char\fP\fB><\fP\fIseparator\fP\fB>\fP\fB[\fP\fB<\fP\fIarguments\fP\fB>\fP\fB]\fP +.fi +.RE +.LP +where the <\fIseparator\fP> can be zero or more <blank>s. +.LP +In the following descriptions, the application shall ensure that the +argument \fIcommand\fP (but not \fImailx-command)\fP is a +shell command string. Any string acceptable to the command interpreter +specified by the \fISHELL\fP variable when it is invoked as +\fISHELL\fP \fB-c\fP \fIcommand_string\fP shall be valid. The command +can be presented as multiple arguments (that is, quoting +is not required). +.LP +Command escapes that are listed with \fImsglist\fP or \fImailx-command\fP +arguments are invalid in Send Mode and produce +unspecified results. +.TP 7 +\fB~!\ \fP \fIcommand\fP +Invoke the command interpreter specified by \fISHELL\fP with two arguments: +\fB-c\fP and \fIcommand\fP; and then return to +input mode. If the \fBbang\fP variable is set, each unescaped occurrence +of \fB'!'\fP in \fIcommand\fP shall be replaced with +the command executed by the previous \fB!\fP command or \fB~!\fP command +escape. +.TP 7 +\fB~.\fP +Simulate end-of-file (terminate message input). +.TP 7 +\fB~:\ \fP \fImailx-command\fP,\ \fB~_\ \fP \fImailx-command\fP +.sp +Perform the command-level request. +.TP 7 +\fB~?\fP +Write a summary of command escapes. +.TP 7 +\fB~A\fP +This shall be equivalent to \fB~i\ Sign\fP. +.TP 7 +\fB~a\fP +This shall be equivalent to \fB~i\ sign\fP. +.TP 7 +\fB~b\ \fP \fIname\fP... +Add the \fIname\fPs to the blind carbon copy ( \fBBcc\fP) list. +.TP 7 +\fB~c\ \fP \fIname\fP... +Add the \fIname\fPs to the carbon copy ( \fBCc\fP) list. +.TP 7 +\fB~d\fP +Read in the dead-letter file. See \fIDEAD\fP for a description of +this file. +.TP 7 +\fB~e\fP +Invoke the editor, as specified by the \fIEDITOR\fP environment variable, +on the partial message. +.TP 7 +\fB~f\ [\fP\fImsglist\fP\fB]\fP +Forward the specified messages. The specified messages shall be inserted +into the current message without alteration. This +command escape also shall insert message headers into the message +with field selection affected by the \fBdiscard\fP, +\fBignore\fP, and \fBretain\fP commands. +.TP 7 +\fB~F\ [\fP\fImsglist\fP\fB]\fP +This shall be the equivalent of the \fB~f\fP command escape, except +that all headers shall be included in the message, +regardless of previous \fBdiscard\fP, \fBignore\fP, and \fBretain\fP +commands. +.TP 7 +\fB~h\fP +If standard input is a terminal, prompt for a \fBSubject\fP line and +the \fBTo\fP, \fBCc\fP, and \fBBcc\fP lists. Other +implementation-defined headers may also be presented for editing. +If the field is written with an initial value, it can be edited +as if it had just been typed. +.TP 7 +\fB~i\ \fP \fIstring\fP +Insert the value of the named variable, followed by a <newline>, into +the text of the message. If the string is unset or +null, the message shall not be changed. +.TP 7 +\fB~m\ [\fP\fImsglist\fP\fB]\fP +Insert the specified messages into the message, prefixing non-empty +lines with the string in the \fBindentprefix\fP variable. +This command escape also shall insert message headers into the message, +with field selection affected by the \fBdiscard\fP, +\fBignore\fP, and \fBretain\fP commands. +.TP 7 +\fB~M\ [\fP\fImsglist\fP\fB]\fP +This shall be the equivalent of the \fB~m\fP command escape, except +that all headers shall be included in the message, +regardless of previous \fBdiscard\fP, \fBignore\fP, and \fBretain\fP +commands. +.TP 7 +\fB~p\fP +Write the message being entered. If the message is longer than \fBcrt\fP +lines (see Internal +Variables in mailx ), the output shall be paginated as described for +the \fIPAGER\fP variable. +.TP 7 +\fB~q\fP +Quit (see the \fBquit\fP command) from input mode by simulating an +interrupt. If the body of the message is not empty, the +partial message shall be saved in the dead-letter file. See \fIDEAD\fP +for a description of this file. +.TP 7 +\fB~r\ \fP \fIfile\fP,\ \fB~<\ \fP +\fIfile\fP,\ \fB~r\ !\fP\fIcommand\fP,\ \fB~<\ !\fP\fIcommand\fP +.sp +Read in the file specified by the pathname \fIfile\fP. If the argument +begins with an exclamation mark ( \fB'!'\fP ), the rest +of the string shall be taken as an arbitrary system command; the command +interpreter specified by \fISHELL\fP shall be invoked +with two arguments: \fB-c\fP and \fIcommand\fP. The standard output +of \fIcommand\fP shall be inserted into the message. +.TP 7 +\fB~s\ \fP \fIstring\fP +Set the subject line to \fIstring\fP. +.TP 7 +\fB~t\ \fP \fIname\fP... +Add the given \fIname\fPs to the \fBTo\fP list. +.TP 7 +\fB~v\fP +Invoke the full-screen editor, as specified by the \fIVISUAL\fP environment +variable, on the partial message. +.TP 7 +\fB~w\ \fP \fIfile\fP +Write the partial message, without the header, onto the file named +by the pathname \fIfile\fP. The file shall be created or +the message shall be appended to it if the file exists. +.TP 7 +\fB~x\fP +Exit as with \fB~q\fP, except the message shall not be saved in the +dead-letter file. +.TP 7 +\fB~|\ \fP \fIcommand\fP +Pipe the body of the message through the given \fIcommand\fP by invoking +the command interpreter specified by \fISHELL\fP +with two arguments: \fB-c\fP and \fIcommand\fP. If the \fIcommand\fP +returns a successful exit status, the standard output of +the command shall replace the message. Otherwise, the message shall +remain unchanged. If the \fIcommand\fP fails, an error message +giving the exit status shall be written. +.sp +.SH EXIT STATUS +.LP +When the \fB-e\fP option is specified, the following exit values are +returned: +.TP 7 +\ 0 +Mail was found. +.TP 7 +>0 +Mail was not found or an error occurred. +.sp +.LP +Otherwise, the following exit values are returned: +.TP 7 +\ 0 +Successful completion; note that this status implies that all messages +were \fIsent\fP, but it gives no assurances that any of +them were actually \fIdelivered\fP. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +When in input mode (Receive Mode) or Send Mode: +.IP " *" 3 +If an error is encountered processing a command escape (see Command +Escapes in mailx ), a +diagnostic message shall be written to standard error, and the message +being composed may be modified, but this condition shall not +prevent the message from being sent. +.LP +.IP " *" 3 +Other errors shall prevent the sending of the message. +.LP +.LP +When in command mode: +.IP " *" 3 +Default. +.LP +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Delivery of messages to remote systems requires the existence of communication +paths to such systems. These need not exist. +.LP +Input lines are limited to {LINE_MAX} bytes, but mailers between systems +may impose more severe line-length restrictions. This +volume of IEEE\ Std\ 1003.1-2001 does not place any restrictions on +the length of messages handled by \fImailx\fP, and for +delivery of local messages the only limitations should be the normal +problems of available disk space for the target mail file. +When sending messages to external machines, applications are advised +to limit messages to less than 100000 bytes because some mail +gateways impose message-length restrictions. +.LP +The format of the system mailbox is intentionally unspecified. Not +all systems implement system mailboxes as flat files, +particularly with the advent of multimedia mail messages. Some system +mailboxes may be multiple files, others records in a +database. The internal format of the messages themselves is specified +with the historical format from Version\ 7, but only +after the messages have been saved in some file other than the system +mailbox. This was done so that many historical applications +expecting text-file mailboxes are not broken. +.LP +Some new formats for messages can be expected in the future, probably +including binary data, bit maps, and various multimedia +objects. As described here, \fImailx\fP is not prohibited from handling +such messages, but it must store them as text files in +secondary mailboxes (unless some extension, such as a variable or +command line option, is used to change the stored format). Its +method of doing so is implementation-defined and might include translating +the data into text file-compatible or readable form or +omitting certain portions of the message from the stored output. +.LP +The \fBdiscard\fP and \fBignore\fP commands are not inverses of the +\fBretain\fP command. The \fBretain\fP command discards +all header-fields except those explicitly retained. The \fBdiscard\fP +command keeps all header-fields except those explicitly +discarded. If headers exist on the retained header list, \fBdiscard\fP +and \fBignore\fP commands are ignored. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The standard developers felt strongly that a method for applications +to send messages to specific users was necessary. The +obvious example is a batch utility, running non-interactively, that +wishes to communicate errors or results to a user. However, the +actual format, delivery mechanism, and method of reading the message +are clearly beyond the scope of this volume of +IEEE\ Std\ 1003.1-2001. +.LP +The intent of this command is to provide a simple, portable interface +for sending messages non-interactively. It merely defines +a "front-end" to the historical mail system. It is suggested that +implementations explicitly denote the sender and recipient in +the body of the delivered message. Further specification of formats +for either the message envelope or the message itself were +deliberately not made, as the industry is in the midst of changing +from the current standards to a more internationalized standard +and it is probably incorrect, at this time, to require either one. +.LP +Implementations are encouraged to conform to the various delivery +mechanisms described in the CCITT X.400 standards or to the +equivalent Internet standards, described in Internet Request for Comment +(RFC) documents RFC\ 819, RFC\ 822, RFC\ 920, +RFC\ 921, and RFC\ 1123. +.LP +Many historical systems modified each body line that started with +\fBFrom\ \fP by prefixing the \fB'F'\fP with +\fB'>'\fP . It is unnecessary, but allowed, to do that when the string +does not follow a blank line because it cannot be +confused with the next header. +.LP +The \fBedit\fP and \fBvisual\fP commands merely edit the specified +messages in a temporary file. They do not modify the +contents of those messages in the mailbox; such a capability could +be added as an extension, such as by using different command +names. +.LP +The restriction on a subject line being {LINE_MAX}-10 bytes is based +on the historical format that consumes 10 bytes for +\fBSubject:\ \fP and the trailing <newline>. Many historical mailers +that a message may encounter on other systems are +not able to handle lines that long, however. +.LP +Like the utilities \fIlogger\fP and \fIlp\fP, +\fImailx\fP admittedly is difficult to test. This was not deemed sufficient +justification to exclude this utility from this volume +of IEEE\ Std\ 1003.1-2001. It is also arguable that it is, in fact, +testable, but that the tests themselves are not +portable. +.LP +When \fImailx\fP is being used by an application that wishes to receive +the results as if none of the User Portability +Utilities option features were supported, the \fIDEAD\fP environment +variable must be set to \fB/dev/null\fP. Otherwise, it may +be subject to the file creations described in \fImailx\fP ASYNCHRONOUS +EVENTS. Similarly, if the \fIMAILRC\fP environment +variable is not set to \fB/dev/null\fP, historical versions of \fImailx\fP +and \fIMail\fP read initialization commands from a +file before processing begins. Since the initialization that a user +specifies could alter the contents of messages an application +is trying to send, such applications must set \fIMAILRC\fP to \fB/dev/null\fP. +.LP +The description of \fILC_TIME\fP uses "may affect" because many historical +implementations do not or cannot manipulate the +date and time strings in the incoming mail headers. Some headers found +in incoming mail do not have enough information to determine +the timezone in which the mail originated, and, therefore, \fImailx\fP +cannot convert the date and time strings into the internal +form that then is parsed by routines like \fIstrftime\fP() that can +take \fILC_TIME\fP +settings into account. Changing all these times to a user-specified +format is allowed, but not required. +.LP +The paginator selected when \fIPAGER\fP is null or unset is partially +unspecified to allow the System V historical practice of +using \fIpg\fP as the default. Bypassing the pagination function, +such as by declaring that \fIcat\fP is the paginator, would not meet +with the intended meaning of this description. However, any +"portable user" would have to set \fIPAGER\fP explicitly to get his +or her preferred paginator on all systems. The paginator +choice was made partially unspecified, unlike the \fIVISUAL\fP editor +choice (mandated to be \fIvi\fP) because most historical pagers follow +a common theme of user input, whereas editors differ +dramatically. +.LP +Options to specify addresses as \fBcc\fP (carbon copy) or \fBbcc\fP +(blind carbon copy) were considered to be format details +and were omitted. +.LP +A zero exit status implies that all messages were \fIsent\fP, but +it gives no assurances that any of them were actually +\fIdelivered\fP. The reliability of the delivery mechanism is unspecified +and is an appropriate marketing distinction between +systems. +.LP +In order to conform to the Utility Syntax Guidelines, a solution was +required to the optional \fIfile\fP option-argument to +\fB-f\fP. By making \fIfile\fP an operand, the guidelines are satisfied +and users remain portable. However, it does force +implementations to support usage such as: +.sp +.RS +.nf + +\fBmailx -fin mymail.box +\fP +.fi +.RE +.LP +The \fBno\fP \fIname\fP method of unsetting variables is not present +in all historical systems, but it is in System V and +provides a logical set of commands corresponding to the format of +the display of options from the \fImailx\fP \fIset\fP command without +arguments. +.LP +The \fBask\fP and \fBasksub\fP variables are the names selected by +BSD and System V, respectively, for the same feature. They +are synonyms in this volume of IEEE\ Std\ 1003.1-2001. +.LP +The \fImailx\fP \fIecho\fP command was not documented in the BSD version +and has been +omitted here because it is not obviously useful for interactive users. +.LP +The default prompt on the System V \fImailx\fP is a question mark, +on BSD \fIMail\fP an ampersand. Since this volume of +IEEE\ Std\ 1003.1-2001 chose the \fImailx\fP name, it kept the System +V default, assuming that BSD users would not have +difficulty with this minor incompatibility (that they can override). +.LP +The meanings of \fBr\fP and \fBR\fP are reversed between System V +\fImailx\fP and SunOS \fIMail\fP. Once again, since this +volume of IEEE\ Std\ 1003.1-2001 chose the \fImailx\fP name, it kept +the System V default, but allows the SunOS user to +achieve the desired results using \fBflipr\fP, an internal variable +in System V \fImailx\fP, although it has not been documented +in the SVID. +.LP +The \fBindentprefix\fP variable, the \fBretain\fP and \fBunalias\fP +commands, and the \fB~F\fP and \fB~M\fP +command escapes were adopted from 4.3 BSD \fIMail\fP. +.LP +The \fBversion\fP command was not included because no sufficiently +general specification of the version information could be +devised that would still be useful to a portable user. This command +name should be used by suppliers who wish to provide version +information about the \fImailx\fP command. +.LP +The "implementation-specific (unspecified) system start-up file" historically +has been named \fB/etc/mailx.rc\fP, but this +specific name and location are not required. +.LP +The intent of the wording for the \fBnext\fP command is that if any +command has already displayed the current message it should +display a following message, but, otherwise, it should display the +current message. Consider the command sequence: +.sp +.RS +.nf + +\fBnext 3 +delete 3 +next +\fP +.fi +.RE +.LP +where the \fBautoprint\fP option was not set. The normative text specifies +that the second \fBnext\fP command should display a +message following the third message, because even though the current +message has not been displayed since it was set by the +\fBdelete\fP command, it has been displayed since the current message +was anything other than message number 3. This does not +always match historical practice in some implementations, where the +command file address followed by \fBnext\fP (or the default +command) would skip the message for which the user had searched. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIed\fP , \fIls\fP , \fImore\fP , +\fIvi\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/make.1p b/man1p/make.1p new file mode 100644 index 000000000..1846bf842 --- /dev/null +++ b/man1p/make.1p @@ -0,0 +1,1753 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MAKE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" make +.SH NAME +make \- maintain, update, and regenerate groups of programs (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBmake\fP \fB[\fP\fB-einpqrst\fP\fB][\fP\fB-f\fP \fImakefile\fP\fB]\fP\fB...\fP\fB[\fP +\fB-k| -S\fP\fB][\fP\fImacro\fP\fB=\fP\fIvalue\fP\fB]\fP\fB... +.br +\ \ \ \ \ \ \fP \fB[\fP\fItarget_name\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fImake\fP utility shall update files that are derived from other +files. A typical case is one where object files are +derived from the corresponding source files. The \fImake\fP utility +examines time relationships and shall update those derived +files (called targets) that have modified times earlier than the modified +times of the files (called prerequisites) from which they +are derived. A description file (makefile) contains a description +of the relationships between files, and the commands that need to +be executed to update the targets to reflect changes in their prerequisites. +Each specification, or rule, shall consist of a +target, optional prerequisites, and optional commands to be executed +when a prerequisite is newer than the target. There are two +types of rule: +.IP " 1." 4 +\fIInference rules\fP, which have one target name with at least one +period ( \fB'.'\fP ) and no slash ( \fB'/'\fP ) +.LP +.IP " 2." 4 +\fITarget rules\fP, which can have more than one target name +.LP +.LP +In addition, \fImake\fP shall have a collection of built-in macros +and inference rules that infer prerequisite relationships to +simplify maintenance of programs. +.LP +To receive exactly the behavior described in this section, the user +shall ensure that a portable makefile shall: +.IP " *" 3 +Include the special target \fB.POSIX\fP +.LP +.IP " *" 3 +Omit any special target reserved for implementations (a leading period +followed by uppercase letters) that has not been +specified by this section +.LP +.LP +The behavior of \fImake\fP is unspecified if either or both of these +conditions are not met. +.SH OPTIONS +.LP +The \fImake\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-e\fP +Cause environment variables, including those with null values, to +override macro assignments within makefiles. +.TP 7 +\fB-f\ \fP \fImakefile\fP +Specify a different makefile. The argument \fImakefile\fP is a pathname +of a description file, which is also referred to as +the \fImakefile\fP. A pathname of \fB'-'\fP shall denote the standard +input. There can be multiple instances of this option, +and they shall be processed in the order specified. The effect of +specifying the same option-argument more than once is +unspecified. +.TP 7 +\fB-i\fP +Ignore error codes returned by invoked commands. This mode is the +same as if the special target \fB.IGNORE\fP were specified +without prerequisites. +.TP 7 +\fB-k\fP +Continue to update other targets that do not depend on the current +target if a non-ignored error occurs while executing the +commands to bring a target up-to-date. +.TP 7 +\fB-n\fP +Write commands that would be executed on standard output, but do not +execute them. However, lines with a plus sign ( +\fB'+'\fP ) prefix shall be executed. In this mode, lines with an +at sign ( \fB'@'\fP ) character prefix shall be written to +standard output. +.TP 7 +\fB-p\fP +Write to standard output the complete set of macro definitions and +target descriptions. The output format is unspecified. +.TP 7 +\fB-q\fP +Return a zero exit value if the target file is up-to-date; otherwise, +return an exit value of 1. Targets shall not be updated +if this option is specified. However, a makefile command line (associated +with the targets) with a plus sign ( \fB'+'\fP ) +prefix shall be executed. +.TP 7 +\fB-r\fP +Clear the suffix list and do not use the built-in rules. +.TP 7 +\fB-S\fP +Terminate \fImake\fP if an error occurs while executing the commands +to bring a target up-to-date. This shall be the default +and the opposite of \fB-k\fP. +.TP 7 +\fB-s\fP +Do not write makefile command lines or touch messages (see \fB-t\fP) +to standard output before executing. This mode shall be +the same as if the special target \fB.SILENT\fP were specified without +prerequisites. +.TP 7 +\fB-t\fP +Update the modification time of each target as though a \fItouch\fP +\fItarget\fP had +been executed. Targets that have prerequisites but no commands (see +Target Rules ), or that are +already up-to-date, shall not be touched in this manner. Write messages +to standard output for each target file indicating the name +of the file and that it was touched. Normally, the \fImakefile\fP +command lines associated with each target are not executed. +However, a command line with a plus sign ( \fB'+'\fP ) prefix shall +be executed. +.sp +.LP +Any options specified in the \fIMAKEFLAGS\fP environment variable +shall be evaluated before any options specified on the +\fImake\fP utility command line. If the \fB-k\fP and \fB-S\fP options +are both specified on the \fImake\fP utility command line +or by the \fIMAKEFLAGS\fP environment variable, the last option specified +shall take precedence. If the \fB-f\fP or \fB-p\fP +options appear in the \fIMAKEFLAGS\fP environment variable, the result +is undefined. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fItarget_name\fP +Target names, as defined in the EXTENDED DESCRIPTION section. If no +target is specified, while \fImake\fP is processing the +makefiles, the first target that \fImake\fP encounters that is not +a special target or an inference rule shall be used. +.TP 7 +\fImacro\fP=\fIvalue\fP +Macro definitions, as defined in Macros . +.sp +.LP +If the \fItarget_name\fP and \fImacro\fP= \fIvalue\fP operands are +intermixed on the \fImake\fP utility command line, the +results are unspecified. +.SH STDIN +.LP +The standard input shall be used only if the \fImakefile\fP option-argument +is \fB'-'\fP . See the INPUT FILES section. +.SH INPUT FILES +.LP +The input file, otherwise known as the makefile, is a text file containing +rules, macro definitions, and comments. See the +EXTENDED DESCRIPTION section. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fImake\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fIMAKEFLAGS\fP +.sp +This variable shall be interpreted as a character string representing +a series of option characters to be used as the default +options. The implementation shall accept both of the following formats +(but need not accept them when intermixed): +.RS +.IP " *" 3 +The characters are option letters without the leading hyphens or <blank> +separation used on a \fImake\fP utility command +line. +.LP +.IP " *" 3 +The characters are formatted in a manner similar to a portion of the +\fImake\fP utility command line: options are preceded by +hyphens and <blank>-separated as described in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +The \fImacro\fP= \fIvalue\fP macro +definition operands can also be included. The difference between the +contents of \fIMAKEFLAGS\fP and the \fImake\fP utility +command line is that the contents of the variable shall not be subjected +to the word expansions (see \fIWord Expansions\fP ) associated with +parsing the command line values. +.LP +.RE +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPROJECTDIR\fP +.sp +Provide a directory to be used to search for SCCS files not found +in the current directory. In all of the following cases, the +search for SCCS files is made in the directory \fBSCCS\fP in the identified +directory. If the value of \fIPROJECTDIR\fP begins +with a slash, it shall be considered an absolute pathname; otherwise, +the value of \fIPROJECTDIR\fP is treated as a user name and +that user's initial working directory shall be examined for a subdirectory +\fBsrc\fP or \fBsource\fP. If such a directory is +found, it shall be used. Otherwise, the value is used as a relative +pathname. +.LP +If \fIPROJECTDIR\fP is not set or has a null value, the search for +SCCS files shall be made in the directory \fBSCCS\fP in the +current directory. +.LP +The setting of \fIPROJECTDIR\fP affects all files listed in the remainder +of this utility description for files with a +component named \fBSCCS\fP. +.sp +.LP +The value of the \fISHELL\fP environment variable shall not be used +as a macro and shall not be modified by defining the +\fBSHELL\fP macro in a makefile or on the command line. All other +environment variables, including those with null values, shall +be used as macros, as defined in Macros . +.SH ASYNCHRONOUS EVENTS +.LP +If not already ignored, \fImake\fP shall trap SIGHUP, SIGTERM, SIGINT, +and SIGQUIT and remove the current target unless the +target is a directory or the target is a prerequisite of the special +target \fB.PRECIOUS\fP or unless one of the \fB-n\fP, +\fB-p\fP, or \fB-q\fP options was specified. Any targets removed in +this manner shall be reported in diagnostic messages of +unspecified format, written to standard error. After this cleanup +process, if any, \fImake\fP shall take the standard action for +all other signals. +.SH STDOUT +.LP +The \fImake\fP utility shall write all commands to be executed to +standard output unless the \fB-s\fP option was specified, +the command is prefixed with an at sign, or the special target \fB.SILENT\fP +has either the current target as a prerequisite or +has no prerequisites. If \fImake\fP is invoked without any work needing +to be done, it shall write a message to standard output +indicating that no action was taken. If the \fB-t\fP option is present +and a file is touched, \fImake\fP shall write to standard +output a message of unspecified format indicating that the file was +touched, including the filename of the file. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Files can be created when the \fB-t\fP option is present. Additional +files can also be created by the utilities invoked by +\fImake\fP. +.SH EXTENDED DESCRIPTION +.LP +The \fImake\fP utility attempts to perform the actions required to +ensure that the specified targets are up-to-date. A target +is considered out-of-date if it is older than any of its prerequisites +or if it does not exist. The \fImake\fP utility shall treat +all prerequisites as targets themselves and recursively ensure that +they are up-to-date, processing them in the order in which they +appear in the rule. The \fImake\fP utility shall use the modification +times of files to determine whether the corresponding +targets are out-of-date. +.LP +After \fImake\fP has ensured that all of the prerequisites of a target +are up-to-date and if the target is out-of-date, the +commands associated with the target entry shall be executed. If there +are no commands listed for the target, the target shall be +treated as up-to-date. +.SS Makefile Syntax +.LP +A makefile can contain rules, macro definitions (see Macros ), and +comments. There are two kinds +of rules: \fIinference rules\fP and \fItarget rules\fP. The \fImake\fP +utility shall contain a set of built-in inference rules. +If the \fB-r\fP option is present, the built-in rules shall not be +used and the suffix list shall be cleared. Additional rules of +both types can be specified in a makefile. If a rule is defined more +than once, the value of the rule shall be that of the last one +specified. Macros can also be defined more than once, and the value +of the macro is specified in Macros . Comments start with a number +sign ( \fB'#'\fP ) and continue until an unescaped <newline> +is reached. +.LP +By default, the following files shall be tried in sequence: \fB./makefile\fP +and \fB./Makefile\fP. If neither +\fB\&./makefile\fP or \fB./Makefile\fP are found, other implementation-defined +files may also be tried. \ On +XSI-conformant systems, the additional files \fB./s.makefile\fP, \fBSCCS/s.makefile\fP, +\fB\&./s.Makefile\fP, and +\fBSCCS/s.Makefile\fP shall also be tried. +.LP +The \fB-f\fP option shall direct \fImake\fP to ignore any of these +default files and use the specified argument as a makefile +instead. If the \fB'-'\fP argument is specified, standard input shall +be used. +.LP +The term \fImakefile\fP is used to refer to any rules provided by +the user, whether in \fB./makefile\fP or its variants, or +specified by the \fB-f\fP option. +.LP +The rules in makefiles shall consist of the following types of lines: +target rules, including special targets (see Target Rules ), inference +rules (see Inference Rules ), macro definitions +(see Macros ), empty lines, and comments. +.LP +When an escaped <newline> (one preceded by a backslash) is found anywhere +in the makefile except in a command line, it +shall be replaced, along with any leading white space on the following +line, with a single <space>. When an escaped +<newline> is found in a command line in a makefile, the command line +shall contain the backslash, the <newline>, and +the next line, except that the first character of the next line shall +not be included if it is a <tab>. +.SS Makefile Execution +.LP +Makefile command lines shall be processed one at a time by writing +the makefile command line to the standard output (unless one +of the conditions listed under \fB'@'\fP suppresses the writing) and +executing the command(s) in the line. A <tab> may +precede the command to standard output. Command execution shall be +as if the makefile command line were the argument to the \fIsystem\fP() +function. The environment for the command being executed shall contain +all of +the variables in the environment of \fImake\fP. +.LP +By default, when \fImake\fP receives a non-zero status from the execution +of a command, it shall terminate with an error +message to standard error. +.LP +Makefile command lines can have one or more of the following prefixes: +a hyphen ( \fB'-'\fP ), an at sign ( \fB'@'\fP ), +or a plus sign ( \fB'+'\fP ). These shall modify the way in which +\fImake\fP processes the command. When a command is written +to standard output, the prefix shall not be included in the output. +.TP 7 +\fB-\fP +If the command prefix contains a hyphen, or the \fB-i\fP option is +present, or the special target \fB.IGNORE\fP has either +the current target as a prerequisite or has no prerequisites, any +error found while executing the command shall be ignored. +.TP 7 +\fB@\fP +If the command prefix contains an at sign and the \fImake\fP utility +command line \fB-n\fP option is not specified, or the +\fB-s\fP option is present, or the special target \fB.SILENT\fP has +either the current target as a prerequisite or has no +prerequisites, the command shall not be written to standard output +before it is executed. +.TP 7 +\fB+\fP +If the command prefix contains a plus sign, this indicates a makefile +command line that shall be executed even if \fB-n\fP, +\fB-q\fP, or \fB-t\fP is specified. +.sp +.SS Target Rules +.LP +Target rules are formatted as follows: +.sp +.RS +.nf + +\fItarget\fP \fB[\fP\fItarget\fP\fB...\fP\fB]\fP\fB:\fP \fB[\fP\fIprerequisite\fP\fB...\fP\fB][;\fP\fIcommand\fP\fB] +[\fP\fB<tab>\fP\fIcommand\fP\fB<tab>\fP\fIcommand\fP\fB...\fP\fB]\fP\fB +.br + +\fP\fIline that does not begin with\fP \fB<tab> +\fP +.fi +.RE +.LP +Target entries are specified by a <blank>-separated, non-null list +of targets, then a colon, then a +<blank>-separated, possibly empty list of prerequisites. Text following +a semicolon, if any, and all following lines that +begin with a <tab>, are makefile command lines to be executed to update +the target. The first non-empty line that does not +begin with a <tab> or \fB'#'\fP shall begin a new entry. An empty +or blank line, or a line beginning with \fB'#'\fP , +may begin a new entry. +.LP +Applications shall select target names from the set of characters +consisting solely of periods, underscores, digits, and +alphabetics from the portable character set (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character +Set). Implementations may allow other characters in +target names as extensions. The interpretation of targets containing +the characters \fB'%'\fP and \fB''\fP is +implementation-defined. +.LP +A target that has prerequisites, but does not have any commands, can +be used to add to the prerequisite list for that target. +Only one target rule for any given target can contain commands. +.LP +Lines that begin with one of the following are called \fIspecial targets\fP +and control the operation of \fImake\fP: +.TP 7 +\fB\&.DEFAULT\fP +If the makefile uses this special target, the application shall ensure +that it is specified with commands, but without +prerequisites. The commands shall be used by \fImake\fP if there are +no other rules available to build a target. +.TP 7 +\fB\&.IGNORE\fP +Prerequisites of this special target are targets themselves; this +shall cause errors from commands associated with them to be +ignored in the same manner as specified by the \fB-i\fP option. Subsequent +occurrences of \fB.IGNORE\fP shall add to the list of +targets ignoring command errors. If no prerequisites are specified, +\fImake\fP shall behave as if the \fB-i\fP option had been +specified and errors from all commands associated with all targets +shall be ignored. +.TP 7 +\fB\&.POSIX\fP +The application shall ensure that this special target is specified +without prerequisites or commands. If it appears as the +first non-comment line in the makefile, \fImake\fP shall process the +makefile as specified by this section; otherwise, the +behavior of \fImake\fP is unspecified. +.TP 7 +\fB\&.PRECIOUS\fP +Prerequisites of this special target shall not be removed if \fImake\fP +receives one of the asynchronous events explicitly +described in the ASYNCHRONOUS EVENTS section. Subsequent occurrences +of \fB.PRECIOUS\fP shall add to the list of precious files. +If no prerequisites are specified, all targets in the makefile shall +be treated as if specified with \fB.PRECIOUS\fP. +.TP 7 +\fB\&.SCCS_GET\fP +The application shall ensure that this special target is specified +without prerequisites. If this special target is included in a +makefile, the commands specified with this target shall replace the +default commands associated with this special target (see Default +Rules ). The commands specified with this target are used to get all +SCCS files that are not +found in the current directory. +.LP +When source files are named in a dependency list, \fImake\fP shall +treat them just like any other target. Because the source +file is presumed to be present in the directory, there is no need +to add an entry for it to the makefile. When a target has no +dependencies, but is present in the directory, \fImake\fP shall assume +that that file is up-to-date. If, however, an SCCS file +named \fBSCCS/s.\fP \fIsource_file\fP is found for a target \fIsource_file\fP, +\fImake\fP compares the timestamp of the target +file with that of the \fBSCCS/s.source_file\fP to ensure the target +is up-to-date. If the target is missing, or if the SCCS file +is newer, \fImake\fP shall automatically issue the commands specified +for the \fB.SCCS_GET\fP special target to retrieve the most +recent version. However, if the target is writable by anyone, \fImake\fP +shall not retrieve a new version. +.TP 7 +\fB\&.SILENT\fP +Prerequisites of this special target are targets themselves; this +shall cause commands associated with them not to be written +to the standard output before they are executed. Subsequent occurrences +of \fB.SILENT\fP shall add to the list of targets with +silent commands. If no prerequisites are specified, \fImake\fP shall +behave as if the \fB-s\fP option had been specified and no +commands or touch messages associated with any target shall be written +to standard output. +.TP 7 +\fB\&.SUFFIXES\fP +Prerequisites of \fB.SUFFIXES\fP shall be appended to the list of +known suffixes and are used in conjunction with the +inference rules (see Inference Rules ). If \fB.SUFFIXES\fP does not +have any prerequisites, the +list of known suffixes shall be cleared. +.sp +.LP +The special targets \fB.IGNORE\fP, \fB.POSIX\fP, \fB.PRECIOUS\fP, +\fB\&.SILENT\fP, and \fB.SUFFIXES\fP shall be specified +without commands. +.LP +Targets with names consisting of a leading period followed by the +uppercase letters \fB"POSIX"\fP and then any other +characters are reserved for future standardization. Targets with names +consisting of a leading period followed by one or more +uppercase letters are reserved for implementation extensions. +.SS Macros +.LP +Macro definitions are in the form: +.sp +.RS +.nf + +\fIstring1\fP \fB=\fP \fB[\fP\fIstring2\fP\fB]\fP +.fi +.RE +.LP +The macro named \fIstring1\fP is defined as having the value of \fIstring2\fP, +where \fIstring2\fP is defined as all +characters, if any, after the equal sign, up to a comment character +( \fB'#'\fP ) or an unescaped <newline>. Any +<blank>s immediately before or after the equal sign shall be ignored. +.LP +Applications shall select macro names from the set of characters consisting +solely of periods, underscores, digits, and +alphabetics from the portable character set (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character +Set). A macro name shall not contain an equals sign. +Implementations may allow other characters in macro names as extensions. +.LP +Macros can appear anywhere in the makefile. Macro expansions using +the forms $( \fIstring1\fP) or ${ \fIstring1\fP} shall be +replaced by \fIstring2\fP, as follows: +.IP " *" 3 +Macros in target lines shall be evaluated when the target line is +read. +.LP +.IP " *" 3 +Macros in makefile command lines shall be evaluated when the command +is executed. +.LP +.IP " *" 3 +Macros in the string before the equals sign in a macro definition +shall be evaluated when the macro assignment is made. +.LP +.IP " *" 3 +Macros after the equals sign in a macro definition shall not be evaluated +until the defined macro is used in a rule or command, +or before the equals sign in a macro definition. +.LP +.LP +The parentheses or braces are optional if \fIstring1\fP is a single +character. The macro $$ shall be replaced by the single +character \fB'$'\fP . If \fIstring1\fP in a macro expansion contains +a macro expansion, the results are unspecified. +.LP +Macro expansions using the forms $( \fIstring1\fP \fB[:\fP \fIsubst1\fP +\fB=[\fP \fIsubst2\fP \fB]]\fP) or ${ +\fIstring1\fP \fB[:\fP \fIsubst1\fP \fB=[\fP \fIsubst2\fP \fB]]\fP} +can be used to replace all occurrences of \fIsubst1\fP +with \fIsubst2\fP when the macro substitution is performed. The \fIsubst1\fP +to be replaced shall be recognized when it is a +suffix at the end of a word in \fIstring1\fP (where a \fIword\fP, +in this context, is defined to be a string delimited by the +beginning of the line, a <blank>, or a <newline>). If \fIstring1\fP +in a macro expansion contains a macro expansion, +the results are unspecified. +.LP +Macro expansions in \fIstring1\fP of macro definition lines shall +be evaluated when read. Macro expansions in \fIstring2\fP of +macro definition lines shall be performed when the macro identified +by \fIstring1\fP is expanded in a rule or command. +.LP +Macro definitions shall be taken from the following sources, in the +following logical order, before the makefile(s) are +read. +.IP " 1." 4 +Macros specified on the \fImake\fP utility command line, in the order +specified on the command line. It is unspecified whether +the internal macros defined in Internal Macros are accepted from this +source. +.LP +.IP " 2." 4 +Macros defined by the \fIMAKEFLAGS\fP environment variable, in the +order specified in the environment variable. It is +unspecified whether the internal macros defined in Internal Macros +are accepted from this +source. +.LP +.IP " 3." 4 +The contents of the environment, excluding the \fIMAKEFLAGS\fP and +\fISHELL\fP variables and including the variables with null +values. +.LP +.IP " 4." 4 +Macros defined in the inference rules built into \fImake\fP. +.LP +.LP +Macro definitions from these sources shall not override macro definitions +from a lower-numbered source. Macro definitions from a +single source (for example, the \fImake\fP utility command line, the +\fIMAKEFLAGS\fP environment variable, or the other +environment variables) shall override previous macro definitions from +the same source. +.LP +Macros defined in the makefile(s) shall override macro definitions +that occur before them in the makefile(s) and macro +definitions from source 4. If the \fB-e\fP option is not specified, +macros defined in the makefile(s) shall override macro +definitions from source 3. Macros defined in the makefile(s) shall +not override macro definitions from source 1 or source 2. +.LP +Before the makefile(s) are read, all of the \fImake\fP utility command +line options (except \fB-f\fP and \fB-p\fP) and +\fImake\fP utility command line macro definitions (except any for +the \fIMAKEFLAGS\fP macro), not already included in the +\fIMAKEFLAGS\fP macro, shall be added to the \fIMAKEFLAGS\fP macro, +quoted in an implementation-defined manner such that when +\fIMAKEFLAGS\fP is read by another instance of the \fImake\fP command, +the original macro's value is recovered. Other +implementation-defined options and macros may also be added to the +\fIMAKEFLAGS\fP macro. If this modifies the value of the +\fIMAKEFLAGS\fP macro, or, if the \fIMAKEFLAGS\fP macro is modified +at any subsequent time, the \fIMAKEFLAGS\fP environment +variable shall be modified to match the new value of the \fIMAKEFLAGS\fP +macro. The result of setting \fIMAKEFLAGS\fP in the +Makefile is unspecified. +.LP +Before the makefile(s) are read, all of the \fImake\fP utility command +line macro definitions (except the \fIMAKEFLAGS\fP +macro or the \fISHELL\fP macro) shall be added to the environment +of \fImake\fP. Other implementation-defined variables may also +be added to the environment of \fImake\fP. +.LP +The \fBSHELL\fP macro shall be treated specially. It shall be provided +by \fImake\fP and set to the pathname of the shell +command language interpreter (see \fIsh\fP ). The \fISHELL\fP environment +variable shall not affect the +value of the \fBSHELL\fP macro. If \fBSHELL\fP is defined in the makefile +or is specified on the command line, it shall replace +the original value of the \fBSHELL\fP macro, but shall not affect +the \fISHELL\fP environment variable. Other effects of defining +\fBSHELL\fP in the makefile or on the command line are implementation-defined. +.SS Inference Rules +.LP +Inference rules are formatted as follows: +.sp +.RS +.nf + +\fItarget\fP\fB: +<tab>\fP\fIcommand +\fP\fB[\fP\fB<tab>\fP\fIcommand\fP\fB]\fP\fB... +.sp + +\fP\fIline that does not begin with\fP \fB<tab>\fP \fIor\fP \fB# +\fP +.fi +.RE +.LP +The application shall ensure that the \fItarget\fP portion is a valid +target name (see Target +Rules ) of the form \fB.s2\fP or \fB.s1.s2\fP (where \fB.s1\fP and +\fB\&.s2\fP are suffixes that have been given as +prerequisites of the \fB.SUFFIXES\fP special target and \fIs1\fP and +\fIs2\fP do not contain any slashes or periods.) If there +is only one period in the target, it is a single-suffix inference +rule. Targets with two periods are double-suffix inference rules. +Inference rules can have only one target before the colon. +.LP +The application shall ensure that the makefile does not specify prerequisites +for inference rules; no characters other than +white space shall follow the colon in the first line, except when +creating the \fIempty rule,\fP described below. Prerequisites +are inferred, as described below. +.LP +Inference rules can be redefined. A target that matches an existing +inference rule shall overwrite the old inference rule. An +empty rule can be created with a command consisting of simply a semicolon +(that is, the rule still exists and is found during +inference rule search, but since it is empty, execution has no effect). +The empty rule can also be formatted as follows: +.sp +.RS +.nf + +\fIrule\fP\fB: ; +\fP +.fi +.RE +.LP +where zero or more <blank>s separate the colon and semicolon. +.LP +The \fImake\fP utility uses the suffixes of targets and their prerequisites +to infer how a target can be made up-to-date. A +list of inference rules defines the commands to be executed. By default, +\fImake\fP contains a built-in set of inference rules. +Additional rules can be specified in the makefile. +.LP +The special target \fB.SUFFIXES\fP contains as its prerequisites a +list of suffixes that shall be used by the inference rules. +The order in which the suffixes are specified defines the order in +which the inference rules for the suffixes are used. New +suffixes shall be appended to the current list by specifying a \fB.SUFFIXES\fP +special target in the makefile. A \fB.SUFFIXES\fP +target with no prerequisites shall clear the list of suffixes. An +empty \fB.SUFFIXES\fP target followed by a new \fB.SUFFIXES\fP +list is required to change the order of the suffixes. +.LP +Normally, the user would provide an inference rule for each suffix. +The inference rule to update a target with a suffix +\fB\&.s1\fP from a prerequisite with a suffix \fB.s2\fP is specified +as a target \fB.s2.s1\fP. The internal macros provide the +means to specify general inference rules (see Internal Macros ). +.LP +When no target rule is found to update a target, the inference rules +shall be checked. The suffix of the target ( \fB.s1\fP) to +be built is compared to the list of suffixes specified by the \fB.SUFFIXES\fP +special targets. If the \fB.s1\fP suffix is found +in \fB.SUFFIXES\fP, the inference rules shall be searched in the order +defined for the first \fB.s2.s1\fP rule whose prerequisite +file ( \fB$*.s2\fP) exists. If the target is out-of-date with respect +to this prerequisite, the commands for that inference rule +shall be executed. +.LP +If the target to be built does not contain a suffix and there is no +rule for the target, the single suffix inference rules shall +be checked. The single-suffix inference rules define how to build +a target if a file is found with a name that matches the target +name with one of the single suffixes appended. A rule with one suffix +\fB\&.s2\fP is the definition of how to build \fItarget\fP +from \fBtarget.s2\fP. The other suffix ( \fB.s1\fP) is treated as +null. +.LP +A +tilde ( \fB'~'\fP ) in the above rules refers to an SCCS file in the +current directory. Thus, the rule \fB.c~.o\fP +would transform an SCCS C-language source file into an object file +( \fB.o\fP). Because the \fBs.\fP of the SCCS files is a +prefix, it is incompatible with \fImake\fP's suffix point of view. +Hence, the \fB'~'\fP is a way of changing any file +reference into an SCCS file reference. +.SS Libraries +.LP +If a target or prerequisite contains parentheses, it shall be treated +as a member of an archive library. For the \fIlib\fP( +\fImember\fP \fB.o\fP) expression \fIlib\fP refers to the name of +the archive library and \fImember\fP \fB.o\fP to the member +name. The application shall ensure that the member is an object file +with the \fB.o\fP suffix. The modification time of the +expression is the modification time for the member as kept in the +archive library; see \fIar\fP . The +\fB\&.a\fP suffix shall refer to an archive library. The \fB.s2.a\fP +rule shall be used to update a member in the library from a +file with a suffix \fB.s2\fP. +.SS Internal Macros +.LP +The \fImake\fP utility shall maintain five internal macros that can +be used in target and inference rules. In order to clearly +define the meaning of these macros, some clarification of the terms +\fItarget rule\fP, \fIinference rule\fP, \fItarget\fP, and +\fIprerequisite\fP is necessary. +.LP +Target rules are specified by the user in a makefile for a particular +target. Inference rules are user-specified or +\fImake\fP-specified rules for a particular class of target name. +Explicit prerequisites are those prerequisites specified in a +makefile on target lines. Implicit prerequisites are those prerequisites +that are generated when inference rules are used. +Inference rules are applied to implicit prerequisites or to explicit +prerequisites that do not have target rules defined for them +in the makefile. Target rules are applied to targets specified in +the makefile. +.LP +Before any target in the makefile is updated, each of its prerequisites +(both explicit and implicit) shall be updated. This +shall be accomplished by recursively processing each prerequisite. +Upon recursion, each prerequisite shall become a target itself. +Its prerequisites in turn shall be processed recursively until a target +is found that has no prerequisites, at which point the +recursion stops. The recursion shall then back up, updating each target +as it goes. +.LP +In the definitions that follow, the word \fItarget\fP refers to one +of: +.IP " *" 3 +A target specified in the makefile +.LP +.IP " *" 3 +An explicit prerequisite specified in the makefile that becomes the +target when \fImake\fP processes it during recursion +.LP +.IP " *" 3 +An implicit prerequisite that becomes a target when \fImake\fP processes +it during recursion +.LP +.LP +In the definitions that follow, the word \fIprerequisite\fP refers +to one of the following: +.IP " *" 3 +An explicit prerequisite specified in the makefile for a particular +target +.LP +.IP " *" 3 +An implicit prerequisite generated as a result of locating an appropriate +inference rule and corresponding file that matches the +suffix of the target +.LP +.LP +The five internal macros are: +.TP 7 +$@ +The $@ shall evaluate to the full target name of the current target, +or the archive filename part of a library archive target. +It shall be evaluated for both target and inference rules. +.LP +For example, in the \fB.c.a\fP inference rule, $@ represents the out-of-date +\fB\&.a\fP file to be built. Similarly, in a +makefile target rule to build \fBlib.a\fP from \fBfile.c\fP, $@ represents +the out-of-date \fBlib.a\fP. +.TP 7 +$% +The $% macro shall be evaluated only when the current target is an +archive library member of the form \fIlibname\fP( +\fImember\fP \fB.o\fP). In these cases, $@ shall evaluate to \fIlibname\fP +and $% shall evaluate to \fImember\fP \fB.o\fP. The +$% macro shall be evaluated for both target and inference rules. +.LP +For example, in a makefile target rule to build \fBlib.a\fP( \fBfile.o\fP), +$% represents \fBfile.o\fP, as opposed to $@, +which represents \fBlib.a\fP. +.TP 7 +$? +The $? macro shall evaluate to the list of prerequisites that are +newer than the current target. It shall be evaluated for both +target and inference rules. +.LP +For example, in a makefile target rule to build \fIprog\fP from \fBfile1.o\fP, +\fBfile2.o\fP, and \fBfile3.o\fP, and where +\fIprog\fP is not out-of-date with respect to \fBfile1.o\fP, but is +out-of-date with respect to \fBfile2.o\fP and +\fBfile3.o\fP, $? represents \fBfile2.o\fP and \fBfile3.o\fP. +.TP 7 +$< +In an inference rule, the $< macro shall evaluate to the filename +whose existence allowed the inference rule to be chosen +for the target. In the \fB.DEFAULT\fP rule, the $< macro shall evaluate +to the current target name. The meaning of the $< +macro shall be otherwise unspecified. +.LP +For example, in the \fB.c.a\fP inference rule, $< represents the prerequisite +\fB\&.c\fP file. +.TP 7 +$* +The $* macro shall evaluate to the current target name with its suffix +deleted. It shall be evaluated at least for inference +rules. +.LP +For example, in the \fB.c.a\fP inference rule, $*.o represents the +out-of-date \fB.o\fP file that corresponds to the +prerequisite \fB.c\fP file. +.sp +.LP +Each of the internal macros has an alternative form. When an uppercase +\fB'D'\fP or \fB'F'\fP is appended to any of the +macros, the meaning shall be changed to the \fIdirectory part\fP for +\fB'D'\fP and \fIfilename part\fP for \fB'F'\fP . The +directory part is the path prefix of the file without a trailing slash; +for the current directory, the directory part is +\fB'.'\fP . When the $? macro contains more than one prerequisite +filename, the $(?D) and $(?F) (or ${?D} and ${?F}) macros +expand to a list of directory name parts and filename parts respectively. +.LP +For the target \fIlib\fP( \fImember\fP \fB.o\fP) and the \fBs2.a\fP +rule, the internal macros shall be defined as: +.TP 7 +$< +\fImember\fP \fB.s2\fP +.TP 7 +$* +\fImember\fP +.TP 7 +$@ +\fIlib\fP +.TP 7 +$? +\fImember\fP \fB.s2\fP +.TP 7 +$% +\fImember\fP \fB.o\fP +.sp +.SS Default Rules +.LP +The default rules for \fImake\fP shall achieve results that are the +same as if the following were used. Implementations that do +not support the C-Language Development Utilities option may omit \fBCC\fP, +\fBCFLAGS\fP, \fBYACC\fP, \fBYFLAGS\fP, \fBLEX\fP, +\fBLFLAGS\fP, \fBLDFLAGS\fP, and the \fB.c\fP, \fB.y\fP, and \fB.l\fP +inference rules. Implementations that do not support +FORTRAN may omit \fBFC\fP, \fBFFLAGS\fP, and the \fB.f\fP inference +rules. Implementations may provide additional macros and +rules. +.sp +.RS +.nf + +\fISPECIAL TARGETS\fP\fB +.br + + +\&.SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@ + +.sp + + +\&.SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~ +.sp + +\fP\fIMACROS\fP\fB +.br + +MAKE=make +AR=ar +ARFLAGS=-rv +YACC=yacc +YFLAGS= +LEX=lex +LFLAGS= +LDFLAGS= +CC=c99 +CFLAGS=-O +FC=fort77 +FFLAGS=-O 1 + +GET=get +GFLAGS= +SCCSFLAGS= +SCCSGETFLAGS=-s + +.sp + +\fP\fISINGLE SUFFIX RULES\fP\fB +.br + +\&.c: + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< +.sp + +\&.f: + $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $< +.sp + +\&.sh: + cp $< $@ + chmod a+x $@ +.sp + + +\&.c~: + $(GET) $(GFLAGS) -p $< > $*.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.c +.sp + +\&.f~: + $(GET) $(GFLAGS) -p $< > $*.f + $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.f +.sp + +\&.sh~: + $(GET) $(GFLAGS) -p $< > $*.sh + cp $*.sh $@ + chmod a+x $@ + +.sp + +\fP\fIDOUBLE SUFFIX RULES\fP\fB +.br + +\&.c.o: + $(CC) $(CFLAGS) -c $< +.sp + +\&.f.o: + $(FC) $(FFLAGS) -c $< +.sp + +\&.y.o: + $(YACC) $(YFLAGS) $< + $(CC) $(CFLAGS) -c y.tab.c + rm -f y.tab.c + mv y.tab.o $@ +.sp + +\&.l.o: + $(LEX) $(LFLAGS) $< + $(CC) $(CFLAGS) -c lex.yy.c + rm -f lex.yy.c + mv lex.yy.o $@ +.sp + +\&.y.c: + $(YACC) $(YFLAGS) $< + mv y.tab.c $@ +.sp + +\&.l.c: + $(LEX) $(LFLAGS) $< + mv lex.yy.c $@ +.sp + + +\&.c~.o: + $(GET) $(GFLAGS) -p $< > $*.c + $(CC) $(CFLAGS) -c $*.c +.sp + +\&.f~.o: + $(GET) $(GFLAGS) -p $< > $*.f + $(FC) $(FFLAGS) -c $*.f +.sp + +\&.y~.o: + $(GET) $(GFLAGS) -p $< > $*.y + $(YACC) $(YFLAGS) $*.y + $(CC) $(CFLAGS) -c y.tab.c + rm -f y.tab.c + mv y.tab.o $@ +.sp + +\&.l~.o: + $(GET) $(GFLAGS) -p $< > $*.l + $(LEX) $(LFLAGS) $*.l + $(CC) $(CFLAGS) -c lex.yy.c + rm -f lex.yy.c + mv lex.yy.o $@ +.sp + +\&.y~.c: + $(GET) $(GFLAGS) -p $< > $*.y + $(YACC) $(YFLAGS) $*.y + mv y.tab.c $@ +.sp + +\&.l~.c: + $(GET) $(GFLAGS) -p $< > $*.l + $(LEX) $(LFLAGS) $*.l + mv lex.yy.c $@ + +.sp + +\&.c.a: + $(CC) -c $(CFLAGS) $< + $(AR) $(ARFLAGS) $@ $*.o + rm -f $*.o +.sp + +\&.f.a: + $(FC) -c $(FFLAGS) $< + $(AR) $(ARFLAGS) $@ $*.o + rm -f $*.o +\fP +.fi +.RE +.SH EXIT STATUS +.LP +When the \fB-q\fP option is specified, the \fImake\fP utility shall +exit with one of the following values: +.TP 7 +\ 0 +Successful completion. +.TP 7 +\ 1 +The target was not up-to-date. +.TP 7 +>1 +An error occurred. +.sp +.LP +When the \fB-q\fP option is not specified, the \fImake\fP utility +shall exit with one of the following values: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +If there is a source file (such as \fB./source.c\fP) and there are +two SCCS files corresponding to it ( \fB./s.source.c\fP and +\fB\&./SCCS/s.source.c\fP), on XSI-conformant systems \fImake\fP uses +the SCCS file in the current directory. However, users are +advised to use the underlying SCCS utilities ( \fIadmin\fP, \fIdelta\fP, +\fIget\fP, and so on) or the \fIsccs\fP utility for all source files +in a given directory. If both forms are used for a given +source file, future developers are very likely to be confused. +.LP +It is incumbent upon portable makefiles to specify the \fB.POSIX\fP +special target in order to guarantee that they are not +affected by local extensions. +.LP +The \fB-k\fP and \fB-S\fP options are both present so that the relationship +between the command line, the \fIMAKEFLAGS\fP +variable, and the makefile can be controlled precisely. If the \fBk\fP +flag is passed in \fIMAKEFLAGS\fP and a command is of the +form: +.sp +.RS +.nf + +\fB$(MAKE) -S foo +\fP +.fi +.RE +.LP +then the default behavior is restored for the child \fImake\fP. +.LP +When the \fB-n\fP option is specified, it is always added to \fIMAKEFLAGS +\&.\fP This allows a recursive \fImake\fP \fB-n\fP +\fItarget\fP to be used to see all of the action that would be taken +to update \fItarget\fP. +.LP +Because of widespread historical practice, interpreting a \fB'#'\fP +number sign inside a variable as the start of a comment +has the unfortunate side effect of making it impossible to place a +number sign in a variable, thus forbidding something like: +.sp +.RS +.nf + +\fBCFLAGS = "-D COMMENT_CHAR='#'" +\fP +.fi +.RE +.LP +Many historical \fImake\fP utilities stop chaining together inference +rules when an intermediate target is nonexistent. For +example, it might be possible for a \fImake\fP to determine that both +\fB\&.y.c\fP and \fB.c.o\fP could be used to convert a +\fB\&.y\fP to a \fB.o\fP. Instead, in this case, \fImake\fP requires +the use of a \fB.y.o\fP rule. +.LP +The best way to provide portable makefiles is to include all of the +rules needed in the makefile itself. The rules provided use +only features provided by other parts of this volume of IEEE\ Std\ 1003.1-2001. +The default rules include rules for +optional commands in this volume of IEEE\ Std\ 1003.1-2001. Only rules +pertaining to commands that are provided are needed +in an implementation's default set. +.LP +Macros used within other macros are evaluated when the new macro is +used rather than when the new macro is defined. +Therefore: +.sp +.RS +.nf + +\fBMACRO =\fP \fIvalue1\fP\fBNEW = $(MACRO) +MACRO =\fP \fIvalue2\fP\fB +.br + +target: + echo $(NEW) +\fP +.fi +.RE +.LP +would produce \fIvalue2\fP and not \fIvalue1\fP since \fBNEW\fP was +not expanded until it was needed in the \fIecho\fP command line. +.LP +Some historical applications have been known to intermix \fItarget_name\fP +and \fImacro=name\fP operands on the command line, +expecting that all of the macros are processed before any of the targets +are dealt with. Conforming applications do not do this, +although some backwards-compatibility support may be included in some +implementations. +.LP +The following characters in filenames may give trouble: \fB'='\fP +, \fB':'\fP , \fB'`'\fP , \fB'"\fP , and +\fB'@'\fP . For inference rules, the description of $< and $? seem +similar. However, an example shows the minor difference. +In a makefile containing: +.sp +.RS +.nf + +\fBfoo.o: foo.h +\fP +.fi +.RE +.LP +if \fBfoo.h\fP is newer than \fBfoo.o\fP, yet \fBfoo.c\fP is older +than \fBfoo.o\fP, the built-in rule to make \fBfoo.o\fP +from \fBfoo.c\fP is used, with $< equal to \fBfoo.c\fP and $? equal +to \fBfoo.h\fP. If \fBfoo.c\fP is also newer than +\fBfoo.o\fP, $< is equal to \fBfoo.c\fP and $? is equal to \fBfoo.h +foo.c\fP. +.SH EXAMPLES +.IP " 1." 4 +The following command: +.sp +.RS +.nf + +\fBmake +\fP +.fi +.RE +.LP +makes the first target found in the makefile. +.LP +.IP " 2." 4 +The following command: +.sp +.RS +.nf + +\fBmake junk +\fP +.fi +.RE +.LP +makes the target \fBjunk\fP. +.LP +.IP " 3." 4 +The following makefile says that \fBpgm\fP depends on two files, \fBa.o\fP +and \fBb.o\fP, and that they in turn depend on +their corresponding source files ( \fBa.c\fP and \fBb.c\fP), and a +common file \fBincl.h\fP: +.sp +.RS +.nf + +\fBpgm: a.o b.o + c99 a.o b.o -o pgm +a.o: incl.h a.c + c99 -c a.c +b.o: incl.h b.c + c99 -c b.c +\fP +.fi +.RE +.LP +.IP " 4." 4 +An example for making optimized \fB.o\fP files from \fB.c\fP files +is: +.sp +.RS +.nf + +\fB\&.c.o: + c99 -c -O $*.c +\fP +.fi +.RE +.LP +or: +.sp +.RS +.nf + +\fB\&.c.o: + c99 -c -O $< +\fP +.fi +.RE +.LP +.IP " 5." 4 +The most common use of the archive interface follows. Here, it is +assumed that the source files are all C-language source: +.sp +.RS +.nf + +\fBlib: lib(file1.o) lib(file2.o) lib(file3.o) + @echo lib is now up-to-date +\fP +.fi +.RE +.LP +The \fB.c.a\fP rule is used to make \fBfile1.o\fP, \fBfile2.o\fP, +and \fBfile3.o\fP and insert them into \fBlib\fP. +.LP +The treatment of escaped <newline>s throughout the makefile is historical +practice. For example, the inference rule: +.sp +.RS +.nf + +\fB\&.c.o\\ +: +\fP +.fi +.RE +.LP +works, and the macro: +.sp +.RS +.nf + +\fBf= bar baz\\ + biz +a: + echo ==$f== +\fP +.fi +.RE +.LP +echoes \fB"==bar\ baz\ biz=="\fP . +.LP +If $? were: +.sp +.RS +.nf + +\fB/usr/include/stdio.h /usr/include/unistd.h foo.h +\fP +.fi +.RE +.LP +then $(?D) would be: +.sp +.RS +.nf + +\fB/usr/include /usr/include . +\fP +.fi +.RE +.LP +and $(?F) would be: +.sp +.RS +.nf + +\fBstdio.h unistd.h foo.h +\fP +.fi +.RE +.LP +.IP " 6." 4 +The contents of the built-in rules can be viewed by running: +.sp +.RS +.nf + +\fBmake -p -f /dev/null 2>/dev/null +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fImake\fP utility described in this volume of IEEE\ Std\ 1003.1-2001 +is intended to provide the means for changing +portable source code into executables that can be run on an IEEE\ Std\ 1003.1-2001-conforming +system. It reflects the most +common features present in System V and BSD \fImake\fPs. +.LP +Historically, the \fImake\fP utility has been an especially fertile +ground for vendor and research organization-specific syntax +modifications and extensions. Examples include: +.IP " *" 3 +Syntax supporting parallel execution (such as from various multi-processor +vendors, GNU, and others) +.LP +.IP " *" 3 +Additional "operators" separating targets and their prerequisites +(System V, BSD, and others) +.LP +.IP " *" 3 +Specifying that command lines containing the strings \fB"${MAKE}"\fP +and \fB"$(MAKE)"\fP are executed when the \fB-n\fP +option is specified (GNU and System V) +.LP +.IP " *" 3 +Modifications of the meaning of internal macros when referencing libraries +(BSD and others) +.LP +.IP " *" 3 +Using a single instance of the shell for all of the command lines +of the target (BSD and others) +.LP +.IP " *" 3 +Allowing spaces as well as tabs to delimit command lines (BSD) +.LP +.IP " *" 3 +Adding C preprocessor-style "include" and "ifdef" constructs (System +V, GNU, BSD, and others) +.LP +.IP " *" 3 +Remote execution of command lines (Sprite and others) +.LP +.IP " *" 3 +Specifying additional special targets (BSD, System V, and most others) +.LP +.LP +Additionally, many vendors and research organizations have rethought +the basic concepts of \fImake\fP, creating vastly +extended, as well as completely new, syntaxes. Each of these versions +of \fImake\fP fulfills the needs of a different community of +users; it is unreasonable for this volume of IEEE\ Std\ 1003.1-2001 +to require behavior that would be incompatible (and +probably inferior) to historical practice for such a community. +.LP +In similar circumstances, when the industry has enough sufficiently +incompatible formats as to make them irreconcilable, this +volume of IEEE\ Std\ 1003.1-2001 has followed one or both of two courses +of action. Commands have been renamed ( \fIcksum\fP, \fIecho\fP, and +\fIpax\fP) and/or command line options have been provided to select +the desired behavior ( \fIgrep\fP, \fIod\fP, and \fIpax\fP). +.LP +Because the syntax specified for the \fImake\fP utility is, by and +large, a subset of the syntaxes accepted by almost all +versions of \fImake\fP, it was decided that it would be counter-productive +to change the name. And since the makefile itself is a +basic unit of portability, it would not be completely effective to +reserve a new option letter, such as \fImake\fP \fB-P\fP, to +achieve the portable behavior. Therefore, the special target \fB.POSIX\fP +was added to the makefile, allowing users to specify +"standard" behavior. This special target does not preclude extensions +in the \fImake\fP utility, nor does it preclude such +extensions being used by the makefile specifying the target; it does, +however, preclude any extensions from being applied that +could alter the behavior of previously valid syntax; such extensions +must be controlled via command line options or new special +targets. It is incumbent upon portable makefiles to specify the \fB.POSIX\fP +special target in order to guarantee that they are +not affected by local extensions. +.LP +The portable version of \fImake\fP described in this reference page +is not intended to be the state-of-the-art software +generation tool and, as such, some newer and more leading-edge features +have not been included. An attempt has been made to +describe the portable makefile in a manner that does not preclude +such extensions as long as they do not disturb the portable +behavior described here. +.LP +When the \fB-n\fP option is specified, it is always added to \fIMAKEFLAGS +\&.\fP This allows a recursive \fImake\fP \fB-n\fP +\fItarget\fP to be used to see all of the action that would be taken +to update \fItarget\fP. +.LP +The definition of \fIMAKEFLAGS\fP allows both the System V letter +string and the BSD command line formats. The two formats are +sufficiently different to allow implementations to support both without +ambiguity. +.LP +Early proposals stated that an "unquoted" number sign was treated +as the start of a comment. The \fImake\fP utility does not +pay any attention to quotes. A number sign starts a comment regardless +of its surroundings. +.LP +The text about "other implementation-defined pathnames may also be +tried" in addition to \fB./makefile\fP and +\fB\&./Makefile\fP is to allow such extensions as \fBSCCS/s.Makefile\fP +and other variations. It was made an implementation-defined +requirement (as opposed to unspecified behavior) to highlight surprising +implementations that might select something unexpected +like \fB/etc/Makefile\fP. XSI-conformant systems also try \fB./s.makefile\fP, +\fBSCCS/s.makefile\fP, \fB./s.Makefile\fP, and +\fBSCCS/s.Makefile\fP. +.LP +Early proposals contained the macro \fBNPROC\fP as a means of specifying +that \fImake\fP should use \fIn\fP processes to do +the work required. While this feature is a valuable extension for +many systems, it is not common usage and could require other +non-trivial extensions to makefile syntax. This extension is not required +by this volume of IEEE\ Std\ 1003.1-2001, but +could be provided as a compatible extension. The macro \fBPARALLEL\fP +is used by some historical systems with essentially the same +meaning (but without using a name that is a common system limit value). +It is suggested that implementors recognize the existing +use of \fBNPROC\fP and/or \fBPARALLEL\fP as extensions to \fImake\fP. +.LP +The default rules are based on System V. The default \fBCC=\fP value +is \fIc99\fP instead +of \fIcc\fP because this volume of IEEE\ Std\ 1003.1-2001 does not +standardize the utility named \fIcc\fP. Thus, every +conforming application would be required to define \fBCC=\fP \fIc99\fP +to expect to run. +There is no advantage conferred by the hope that the makefile might +hit the "preferred" compiler because this cannot be +guaranteed to work. Also, since the portable makescript can only use +the \fIc99\fP options, no +advantage is conferred in terms of what the script can do. It is a +quality-of-implementation issue as to whether \fIc99\fP is as valuable +as \fIcc\fP. +.LP +The \fB-d\fP option to \fImake\fP is frequently used to produce debugging +information, but is too implementation-defined to +add to this volume of IEEE\ Std\ 1003.1-2001. +.LP +The \fB-p\fP option is not passed in \fIMAKEFLAGS\fP on most historical +implementations and to change this would cause many +implementations to break without sufficiently increased portability. +.LP +Commands that begin with a plus sign ( \fB'+'\fP ) are executed even +if the \fB-n\fP option is present. Based on the GNU +version of \fImake\fP, the behavior of \fB-n\fP when the plus-sign +prefix is encountered has been extended to apply to \fB-q\fP +and \fB-t\fP as well. However, the System V convention of forcing +command execution with \fB-n\fP when the command line of a +target contains either of the strings \fB"$(MAKE)"\fP or \fB"${MAKE}"\fP +has not been adopted. This functionality appeared in +early proposals, but the danger of this approach was pointed out with +the following example of a portion of a makefile: +.sp +.RS +.nf + +\fBsubdir: + cd subdir; rm all_the_files; $(MAKE) +\fP +.fi +.RE +.LP +The loss of the System V behavior in this case is well-balanced by +the safety afforded to other makefiles that were not aware of +this situation. In any event, the command line plus-sign prefix can +provide the desired functionality. +.LP +The double colon in the target rule format is supported in BSD systems +to allow more than one target line containing the same +target name to have commands associated with it. Since this is not +functionality described in the SVID or XPG3 it has been allowed +as an extension, but not mandated. +.LP +The default rules are provided with text specifying that the built-in +rules shall be the same as if the listed set were used. +The intent is that implementations should be able to use the rules +without change, but will be allowed to alter them in ways that +do not affect the primary behavior. +.LP +The best way to provide portable makefiles is to include all of the +rules needed in the makefile itself. The rules provided use +only features provided by other portions of this volume of IEEE\ Std\ 1003.1-2001. +The default rules include rules for +optional commands in this volume of IEEE\ Std\ 1003.1-2001. Only rules +pertaining to commands that are provided are needed +in the default set of an implementation. +.LP +One point of discussion was whether to drop the default rules list +from this volume of IEEE\ Std\ 1003.1-2001. They +provide convenience, but do not enhance portability of applications. +The prime benefit is in portability of users who wish to type +\fImake\fP \fIcommand\fP and have the command build from a \fBcommand.c\fP +file. +.LP +The historical \fIMAKESHELL\fP feature was omitted. In some implementations +it is used to let a user override the shell to be +used to run \fImake\fP commands. This was confusing; for a portable +\fImake\fP, the shell should be chosen by the makefile writer +or specified on the \fImake\fP command line and not by a user running +\fImake\fP. +.LP +The \fImake\fP utilities in most historical implementations process +the prerequisites of a target in left-to-right order, and +the makefile format requires this. It supports the standard idiom +used in many makefiles that produce \fIyacc\fP programs; for example: +.sp +.RS +.nf + +\fBfoo: y.tab.o lex.o main.o + $(CC) $(CFLAGS) -o $\fP@ \fBt.tab.o lex.o main.o +\fP +.fi +.RE +.LP +In this example, if \fImake\fP chose any arbitrary order, the \fBlex.o\fP +might not be made with the correct \fBy.tab.h\fP. +Although there may be better ways to express this relationship, it +is widely used historically. Implementations that desire to +update prerequisites in parallel should require an explicit extension +to \fImake\fP or the makefile format to accomplish it, as +described previously. +.LP +The algorithm for determining a new entry for target rules is partially +unspecified. Some historical \fImake\fPs allow blank, +empty, or comment lines within the collection of commands marked by +leading <tab>s. A conforming makefile must ensure that +each command starts with a <tab>, but implementations are free to +ignore blank, empty, and comment lines without triggering +the start of a new entry. +.LP +The ASYNCHRONOUS EVENTS section includes having SIGTERM and SIGHUP, +along with the more traditional SIGINT and SIGQUIT, remove +the current target unless directed not to do so. SIGTERM and SIGHUP +were added to parallel other utilities that have historically +cleaned up their work as a result of these signals. When \fImake\fP +receives any signal other than SIGQUIT, it is required to +resend itself the signal it received so that it exits with a status +that reflects the signal. The results from SIGQUIT are +partially unspecified because, on systems that create \fBcore\fP files +upon receipt of SIGQUIT, the \fBcore\fP from \fImake\fP +would conflict with a \fBcore\fP file from the command that was running +when the SIGQUIT arrived. The main concern was to prevent +damaged files from appearing up-to-date when \fImake\fP is rerun. +.LP +The \fB.PRECIOUS\fP special target was extended to affect all targets +globally (by specifying no prerequisites). The +\fB\&.IGNORE\fP and \fB.SILENT\fP special targets were extended to allow +prerequisites; it was judged to be more useful in some +cases to be able to turn off errors or echoing for a list of targets +than for the entire makefile. These extensions to \fImake\fP +in System V were made to match historical practice from the BSD \fImake\fP. +.LP +Macros are not exported to the environment of commands to be run. +This was never the case in any historical \fImake\fP and +would have serious consequences. The environment is the same as the +environment to \fImake\fP except that \fIMAKEFLAGS\fP and +macros defined on the \fImake\fP command line are added. +.LP +Some implementations do not use \fIsystem\fP() for all command lines, +as required by the +portable makefile format; as a performance enhancement, they select +lines without shell metacharacters for direct execution by \fIexecve\fP(). +There is no requirement that \fIsystem\fP() be used specifically, +but merely that the same results be achieved. The +metacharacters typically used to bypass the direct \fIexecve\fP() +execution have been any +of: +.sp +.RS +.nf + +\fB= | ^ ( ) ; & < > * ? [ ] : $ ` ' " \\ \\n +\fP +.fi +.RE +.LP +The default in some advanced versions of \fImake\fP is to group all +the command lines for a target and execute them using a +single shell invocation; the System V method is to pass each line +individually to a separate shell. The single-shell method has the +advantages in performance and the lack of a requirement for many continued +lines. However, converting to this newer method has +caused portability problems with many historical makefiles, so the +behavior with the POSIX makefile is specified to be the same as +that of System V. It is suggested that the special target \fB.ONESHELL\fP +be used as an implementation extension to achieve the +single-shell grouping for a target or group of targets. +.LP +Novice users of \fImake\fP have had difficulty with the historical +need to start commands with a <tab>. Since it is often +difficult to discern differences between <tab>s and <space>s on terminals +or printed listings, confusing bugs can +arise. In early proposals, an attempt was made to correct this problem +by allowing leading <blank>s instead of <tab>s. +However, implementors reported many makefiles that failed in subtle +ways following this change, and it is difficult to implement a +\fImake\fP that unambiguously can differentiate between macro and +command lines. There is extensive historical practice of +allowing leading spaces before macro definitions. Forcing macro lines +into column 1 would be a significant backwards-compatibility +problem for some makefiles. Therefore, historical practice was restored. +.LP +The System V INCLUDE feature was considered, but not included. This +would treat a line that began in the first column and +contained INCLUDE <\fIfilename\fP> as an indication to read <\fIfilename\fP> +at that point in the makefile. This is +difficult to use in a portable way, and it raises concerns about nesting +levels and diagnostics. System V, BSD, GNU, and others +have used different methods for including files. +.LP +The System V dynamic dependency feature was not included. It would +support: +.sp +.RS +.nf + +\fBcat: $$@.c +\fP +.fi +.RE +.LP +that would expand to; +.sp +.RS +.nf + +\fBcat: cat.c +\fP +.fi +.RE +.LP +This feature exists only in the new version of System V \fImake\fP +and, while useful, is not in wide usage. This means that +macros are expanded twice for prerequisites: once at makefile parse +time and once at target update time. +.LP +Consideration was given to adding metarules to the POSIX \fImake\fP. +This would make \fB%.o:\ %.c\fP the same as +\fB\&.c.o:\fP. This is quite useful and available from some vendors, +but it would cause too many changes to this \fImake\fP to +support. It would have introduced rule chaining and new substitution +rules. However, the rules for target names have been set to +reserve the \fB'%'\fP and \fB''\fP characters. These are traditionally +used to implement metarules and quoting of target +names, respectively. Implementors are strongly encouraged to use these +characters only for these purposes. +.LP +A request was made to extend the suffix delimiter character from a +period to any character. The metarules feature in newer +\fImake\fPs solves this problem in a more general way. This volume +of IEEE\ Std\ 1003.1-2001 is staying with the more +conservative historical definition. +.LP +The standard output format for the \fB-p\fP option is not described +because it is primarily a debugging option and because the +format is not generally useful to programs. In historical implementations +the output is not suitable for use in generating +makefiles. The \fB-p\fP format has been variable across historical +implementations. Therefore, the definition of \fB-p\fP was +only to provide a consistently named option for obtaining \fImake\fP +script debugging information. +.LP +Some historical implementations have not cleared the suffix list with +\fB-r\fP. +.LP +Implementations should be aware that some historical applications +have intermixed \fItarget_name\fP and \fImacro\fP= +\fIvalue\fP operands on the command line, expecting that all of the +macros are processed before any of the targets are dealt with. +Conforming applications do not do this, but some backwards-compatibility +support may be warranted. +.LP +Empty inference rules are specified with a semicolon command rather +than omitting all commands, as described in an early +proposal. The latter case has no traditional meaning and is reserved +for implementation extensions, such as in GNU \fImake\fP. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIar\fP , \fIc99\fP , \fIget\fP , +\fIlex\fP , \fIsccs\fP , \fIsh\fP , \fIyacc\fP , the System Interfaces +volume +of IEEE\ Std\ 1003.1-2001, \fIexec\fP, \fIsystem\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/man.1p b/man1p/man.1p new file mode 100644 index 000000000..6a7558649 --- /dev/null +++ b/man1p/man.1p @@ -0,0 +1,244 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MAN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" man +.SH NAME +man \- display system documentation +.SH SYNOPSIS +.LP +\fBman\fP \fB[\fP\fB-k\fP\fB]\fP \fIname\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fIman\fP utility shall write information about each of the \fIname\fP +operands. If \fIname\fP is the name of a standard +utility, \fIman\fP at a minimum shall write a message describing the +syntax used by the standard utility, its options, and +operands. If more information is available, the \fIman\fP utility +shall provide it in an implementation-defined manner. +.LP +An implementation may provide information for values of \fIname\fP +other than the standard utilities. Standard utilities that +are listed as optional and that are not supported by the implementation +either shall cause a brief message indicating that fact to +be displayed or shall cause a full display of information as described +previously. +.SH OPTIONS +.LP +The \fIman\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-k\fP +Interpret \fIname\fP operands as keywords to be used in searching +a utilities summary database that contains a brief purpose +entry for each standard utility and write lines from the summary database +that match any of the keywords. The keyword search shall +produce results that are the equivalent of the output of the following +command: +.sp +.RS +.nf + +\fBgrep -Ei ' +\fP\fIname +name\fP\fB... +'\fP \fIsummary-database\fP +.fi +.RE +.LP +This assumes that the \fIsummary-database\fP is a text file with a +single entry per line; this organization is not required and +the example using \fIgrep\fP \fB-Ei\fP is merely illustrative of the +type of search +intended. The purpose entry to be included in the database shall consist +of a terse description of the purpose of the utility. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIname\fP +A keyword or the name of a standard utility. When \fB-k\fP is not +specified and \fIname\fP does not represent one of the +standard utilities, the results are unspecified. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIman\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and in the summary database). +The value of \fILC_CTYPE\fP need not affect the format +of the information written about the \fIname\fP operands. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPAGER\fP +Determine an output filtering command for writing the output to a +terminal. Any string acceptable as a \fIcommand_string\fP +operand to the \fIsh\fP \fB-c\fP command shall be valid. When standard +output is a terminal +device, the reference page output shall be piped through the command. +If the \fIPAGER\fP variable is null or not set, the command +shall be either \fImore\fP or another paginator utility documented +in the system +documentation. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIman\fP utility shall write text describing the syntax of the +utility \fIname\fP, its options and its operands, or, when +\fB-k\fP is specified, lines from the summary database. The format +of this text is implementation-defined. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +It is recognized that the \fIman\fP utility is only of minimal usefulness +as specified. The opinion of the standard developers +was strongly divided as to how much or how little information \fIman\fP +should be required to provide. They considered, however, +that the provision of some portable way of accessing documentation +would aid user portability. The arguments against a fuller +specification were: +.IP " *" 3 +Large quantities of documentation should not be required on a system +that does not have excess disk space. +.LP +.IP " *" 3 +The current manual system does not present information in a manner +that greatly aids user portability. +.LP +.IP " *" 3 +A "better help system" is currently an area in which vendors feel +that they can add value to their POSIX implementations. +.LP +.LP +The \fB-f\fP option was considered, but due to implementation differences, +it was not included in this volume of +IEEE\ Std\ 1003.1-2001. +.LP +The description was changed to be more specific about what has to +be displayed for a utility. The standard developers considered +it insufficient to allow a display of only the synopsis without giving +a short description of what each option and operand +does. +.LP +The "purpose" entry to be included in the database can be similar +to the section title (less the numeric prefix) from this +volume of IEEE\ Std\ 1003.1-2001 for each utility. These titles are +similar to those used in historical systems for this +purpose. +.LP +See \fImailx\fP for rationale concerning the default paginator. +.LP +The caveat in the \fILC_CTYPE\fP description was added because it +is not a requirement that an implementation provide reference +pages for all of its supported locales on each system; changing \fILC_CTYPE\fP +does not necessarily translate the reference page +into another language. This is equivalent to the current state of +\fILC_MESSAGES\fP in +IEEE\ Std\ 1003.1-2001-locale-specific messages are not yet a requirement. +.LP +The historical \fIMANPATH\fP variable is not included in POSIX because +no attempt is made to specify naming conventions for +reference page files, nor even to mandate that they are files at all. +On some implementations they could be a true database, a +hypertext file, or even fixed strings within the \fIman\fP executable. +The standard developers considered the portability of +reference pages to be outside their scope of work. However, users +should be aware that \fIMANPATH\fP is implemented on a number of +historical systems and that it can be used to tailor the search pattern +for reference pages from the various categories (utilities, +functions, file formats, and so on) when the system administrator +reveals the location and conventions for reference pages on the +system. +.LP +The keyword search can rely on at least the text of the section titles +from these utility descriptions, and the implementation +may add more keywords. The term "section titles" refers to the strings +such as: +.sp +.RS +.nf + +\fBman - Display system documentation +ps - Report process status +\fP +.fi +.RE +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fImore\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/mesg.1p b/man1p/mesg.1p new file mode 100644 index 000000000..c317150cf --- /dev/null +++ b/man1p/mesg.1p @@ -0,0 +1,160 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MESG" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" mesg +.SH NAME +mesg \- permit or deny messages +.SH SYNOPSIS +.LP +\fBmesg\fP \fB[\fP\fBy|n\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fImesg\fP utility shall control whether other users are allowed +to send messages via \fIwrite\fP, \fItalk\fP, or other utilities to +a terminal +device. The terminal device affected shall be determined by searching +for the first terminal in the sequence of devices associated +with standard input, standard output, and standard error, respectively. +With no arguments, \fImesg\fP shall report the current +state without changing it. Processes with appropriate privileges may +be able to send messages to the terminal independent of the +current state. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported in the POSIX locale: +.TP 7 +\fIy\fP +Grant permission to other users to send messages to the terminal device. +.TP 7 +\fIn\fP +Deny permission to other users to send messages to the terminal device. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fImesg\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written (by \fImesg\fP) to +standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If no operand is specified, \fImesg\fP shall display the current terminal +state in an unspecified format. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Receiving messages is allowed. +.TP 7 +\ 1 +Receiving messages is not allowed. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The mechanism by which the message status of the terminal is changed +is unspecified. Therefore, unspecified actions may cause +the status of the terminal to change after \fImesg\fP has successfully +completed. These actions may include, but are not limited +to: another invocation of the \fImesg\fP utility, login procedures; +invocation of the \fIstty\fP utility, invocation of the \fIchmod\fP +utility or +\fIchmod\fP() function, and so on. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The terminal changed by \fImesg\fP is that associated with the standard +input, output, or error, rather than the controlling +terminal for the session. This is because users logged in more than +once should be able to change any of their login terminals +without having to stop the job running in those sessions. This is +not a security problem involving the terminals of other users +because appropriate privileges would be required to affect the terminal +of another user. +.LP +The method of checking each of the first three file descriptors in +sequence until a terminal is found was adopted from System +V. +.LP +The file \fB/dev/tty\fP is not specified for the terminal device because +it was thought to be too restrictive. Typical +environment changes for the \fIn\fP operand are that write permissions +are removed for \fIothers\fP and \fIgroup\fP from the +appropriate device. It was decided to leave the actual description +of what is done as unspecified because of potential differences +between implementations. +.LP +The format for standard output is unspecified because of differences +between historical implementations. This output is +generally not useful to shell scripts (they can use the exit status), +so exact parsing of the output is unnecessary. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fItalk\fP , \fIwrite\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/mkdir.1p b/man1p/mkdir.1p new file mode 100644 index 000000000..57dd9bafc --- /dev/null +++ b/man1p/mkdir.1p @@ -0,0 +1,194 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MKDIR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" mkdir +.SH NAME +mkdir \- make directories +.SH SYNOPSIS +.LP +\fBmkdir\fP \fB[\fP\fB-p\fP\fB][\fP\fB-m\fP \fImode\fP\fB]\fP \fIdir\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fImkdir\fP utility shall create the directories specified by +the operands, in the order specified. +.LP +For each \fIdir\fP operand, the \fImkdir\fP utility shall perform +actions equivalent to the \fImkdir\fP() function defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, +called with the following arguments: +.IP " 1." 4 +The \fIdir\fP operand is used as the \fIpath\fP argument. +.LP +.IP " 2." 4 +The value of the bitwise-inclusive OR of S_IRWXU, S_IRWXG, and S_IRWXO +is used as the \fImode\fP argument. (If the \fB-m\fP +option is specified, the \fImode\fP option-argument overrides this +default.) +.LP +.SH OPTIONS +.LP +The \fImkdir\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-m\ \fP \fImode\fP +Set the file permission bits of the newly-created directory to the +specified \fImode\fP value. The \fImode\fP option-argument +shall be the same as the \fImode\fP operand defined for the \fIchmod\fP +utility. In the +\fIsymbolic_mode\fP strings, the \fIop\fP characters \fB'+'\fP and +\fB'-'\fP shall be interpreted relative to an assumed +initial mode of \fIa\fP= \fIrwx\fP; \fB'+'\fP shall add permissions +to the default mode, \fB'-'\fP shall delete permissions +from the default mode. +.TP 7 +\fB-p\fP +Create any missing intermediate pathname components. +.LP +For each \fIdir\fP operand that does not name an existing directory, +effects equivalent to those caused by the following +command shall occur: +.sp +.RS +.nf + +\fBmkdir -p -m $(umask -S),u+wx $(dirname\fP \fIdir\fP\fB) && +mkdir\fP \fB[\fP\fB-m\fP \fImode\fP\fB]\fP \fIdir\fP +.fi +.RE +.LP +where the \fB-m\fP \fImode\fP option represents that option supplied +to the original invocation of \fImkdir\fP, if any. +.LP +Each \fIdir\fP operand that names an existing directory shall be ignored +without error. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIdir\fP +A pathname of a directory to be created. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fImkdir\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All the specified directories were created successfully or the \fB-p\fP +option was specified and all the specified directories +now exist. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The default file mode for directories is \fIa\fP= \fIrwx\fP (777 on +most systems) with selected permissions removed in +accordance with the file mode creation mask. For intermediate pathname +components created by \fImkdir\fP, the mode is the default +modified by \fIu\fP+ \fIwx\fP so that the subdirectories can always +be created regardless of the file mode creation mask; if +different ultimate permissions are desired for the intermediate directories, +they can be changed afterwards with \fIchmod\fP. +.LP +Note that some of the requested directories may have been created +even if an error occurs. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The System V \fB-m\fP option was included to control the file mode. +.LP +The System V \fB-p\fP option was included to create any needed intermediate +directories and to complement the functionality +provided by \fIrmdir\fP for removing directories in the path prefix +as they become empty. +Because no error is produced if any path component already exists, +the \fB-p\fP option is also useful to ensure that a particular +directory exists. +.LP +The functionality of \fImkdir\fP is described substantially through +a reference to the \fImkdir\fP() function in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001. For +example, by default, the mode of the directory is affected by the +file mode creation mask in accordance with the specified behavior +of the \fImkdir\fP() function. In this way, there is less duplication +of effort required for +describing details of the directory creation. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIchmod\fP() , \fIrm\fP , \fIrmdir\fP() , \fIumask\fP() , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fImkdir\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/mkfifo.1p b/man1p/mkfifo.1p new file mode 100644 index 000000000..1f85385a9 --- /dev/null +++ b/man1p/mkfifo.1p @@ -0,0 +1,163 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MKFIFO" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" mkfifo +.SH NAME +mkfifo \- make FIFO special files +.SH SYNOPSIS +.LP +\fBmkfifo\fP \fB[\fP\fB-m\fP \fImode\fP\fB]\fP \fIfile\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fImkfifo\fP utility shall create the FIFO special files specified +by the operands, in the order specified. +.LP +For each \fIfile\fP operand, the \fImkfifo\fP utility shall perform +actions equivalent to the \fImkfifo\fP() function defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, +called with the following arguments: +.IP " 1." 4 +The \fIfile\fP operand is used as the \fIpath\fP argument. +.LP +.IP " 2." 4 +The value of the bitwise-inclusive OR of S_IRUSR, S_IWUSR, S_IRGRP, +S_IWGRP, S_IROTH, and S_IWOTH is used as the \fImode\fP +argument. (If the \fB-m\fP option is specified, the value of the \fImkfifo\fP() +\fImode\fP argument is unspecified, but the FIFO shall at no time +have permissions less restrictive than the \fB-m\fP \fImode\fP +option-argument.) +.LP +.SH OPTIONS +.LP +The \fImkfifo\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-m\ \fP \fImode\fP +Set the file permission bits of the newly-created FIFO to the specified +\fImode\fP value. The \fImode\fP option-argument +shall be the same as the \fImode\fP operand defined for the \fIchmod\fP +utility. In the +\fIsymbolic_mode\fP strings, the \fIop\fP characters \fB'+'\fP and +\fB'-'\fP shall be interpreted relative to an assumed +initial mode of \fIa\fP= \fIrw\fP. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of the FIFO special file to be created. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fImkfifo\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All the specified FIFO special files were created successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +This utility was added to permit shell applications to create FIFO +special files. +.LP +The \fB-m\fP option was added to control the file mode, for consistency +with the similar functionality provided by the \fImkdir\fP utility. +.LP +Early proposals included a \fB-p\fP option similar to the \fImkdir\fP +\fB-p\fP option +that created intermediate directories leading up to the FIFO specified +by the final component. This was removed because it is not +commonly needed and is not common practice with similar utilities. +.LP +The functionality of \fImkfifo\fP is described substantially through +a reference to the \fImkfifo\fP() function in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001. For +example, by default, the mode of the FIFO file is affected by the +file mode creation mask in accordance with the specified behavior +of the \fImkfifo\fP() function. In this way, there is less duplication +of effort required +for describing details of the file creation. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIchmod\fP() , \fIumask\fP() , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fImkfifo\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/more.1p b/man1p/more.1p new file mode 100644 index 000000000..22d9a6a7d --- /dev/null +++ b/man1p/more.1p @@ -0,0 +1,1069 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MORE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" more +.SH NAME +more \- display files on a page-by-page basis +.SH SYNOPSIS +.LP +\fBmore\fP \fB[\fP\fB-ceisu\fP\fB][\fP\fB-n\fP \fInumber\fP\fB][\fP\fB-p\fP +\fIcommand\fP\fB][\fP\fB-t\fP \fItagstring\fP\fB][\fP\fIfile\fP \fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fImore\fP utility shall read files and either write them to the +terminal on a page-by-page basis or filter them to +standard output. If standard output is not a terminal device, all +input files shall be copied to standard output in their entirety, +without modification, except as specified for the \fB-s\fP option. +If standard output is a terminal device, the files shall be +written a number of lines (one screenful) at a time under the control +of user commands. See the EXTENDED DESCRIPTION section. +.LP +Certain block-mode terminals do not have all the capabilities necessary +to support the complete \fImore\fP definition; they are +incapable of accepting commands that are not terminated with a <newline>. +Implementations that support such terminals shall +provide an operating mode to \fImore\fP in which all commands can +be terminated with a <newline> on those terminals. This +mode: +.IP " *" 3 +Shall be documented in the system documentation +.LP +.IP " *" 3 +Shall, at invocation, inform the user of the terminal deficiency that +requires the <newline> usage and provide +instructions on how this warning can be suppressed in future invocations +.LP +.IP " *" 3 +Shall not be required for implementations supporting only fully capable +terminals +.LP +.IP " *" 3 +Shall not affect commands already requiring <newline>s +.LP +.IP " *" 3 +Shall not affect users on the capable terminals from using \fImore\fP +as described in this volume of +IEEE\ Std\ 1003.1-2001 +.LP +.SH OPTIONS +.LP +The \fImore\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +If a screen is to be written that has no lines in common with the +current screen, or \fImore\fP is writing its first screen, +\fImore\fP shall not scroll the screen, but instead shall redraw each +line of the screen in turn, from the top of the screen to +the bottom. In addition, if \fImore\fP is writing its first screen, +the screen shall be cleared. This option may be silently +ignored on devices with insufficient terminal capabilities. +.TP 7 +\fB-e\fP +By default, \fImore\fP shall exit immediately after writing the last +line of the last file in the argument list. If the +\fB-e\fP option is specified: +.RS +.IP " 1." 4 +If there is only a single file in the argument list and that file +was completely displayed on a single screen, \fImore\fP shall +exit immediately after writing the last line of that file. +.LP +.IP " 2." 4 +Otherwise, \fImore\fP shall exit only after reaching end-of-file on +the last file in the argument list twice without an +intervening operation. See the EXTENDED DESCRIPTION section. +.LP +.RE +.TP 7 +\fB-i\fP +Perform pattern matching in searches without regard to case; see the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 9.2, Regular Expression General Requirements. +.TP 7 +\fB-n\ \fP \fInumber\fP +Specify the number of lines per screenful. The \fInumber\fP argument +is a positive decimal integer. The \fB-n\fP option shall +override any values obtained from any other source. +.TP 7 +\fB-p\ \fP \fIcommand\fP +Each time a screen from a new file is displayed or redisplayed (including +as a result of \fImore\fP commands; for example, +\fB:p\fP), execute the \fImore\fP command(s) in the command arguments +in the order specified, as if entered by the user after the +first screen has been displayed. No intermediate results shall be +displayed (that is, if the command is a movement to a screen +different from the normal first screen, only the screen resulting +from the command shall be displayed.) If any of the commands fail +for any reason, an informational message to this effect shall be written, +and no further commands specified using the \fB-p\fP +option shall be executed for this file. +.TP 7 +\fB-s\fP +Behave as if consecutive empty lines were a single empty line. +.TP 7 +\fB-t\ \fP \fItagstring\fP +Write the screenful of the file containing the tag named by the \fItagstring\fP +argument. See the \fIctags\fP utility. The tags feature represented +by \fB-t\fP \fItagstring\fP and the \fB:t\fP command is +optional. It shall be provided on any system that also provides a +conforming implementation of \fIctags\fP; otherwise, the use of \fB-t\fP +produces undefined results. +.LP +The filename resulting from the \fB-t\fP option shall be logically +added as a prefix to the list of command line files, as if +specified by the user. If the tag named by the \fItagstring\fP argument +is not found, it shall be an error, and \fImore\fP shall +take no further action. +.LP +If the tag specifies a line number, the first line of the display +shall contain the beginning of that line. If the tag specifies +a pattern, the first line of the display shall contain the beginning +of the matching text from the first line of the file that +contains that pattern. If the line does not exist in the file or matching +text is not found, an informational message to this +effect shall be displayed, and \fImore\fP shall display the default +screen as if \fB-t\fP had not been specified. +.LP +If both the \fB-t\fP \fItagstring\fP and \fB-p\fP \fIcommand\fP options +are given, the \fB-t\fP \fItagstring\fP shall be +processed first; that is, the file and starting line for the display +shall be as specified by \fB-t\fP, and then the \fB-p\fP +\fImore\fP command shall be executed. If the line (matching text) +specified by the \fB-t\fP command does not exist (is not +found), no \fB-p\fP \fImore\fP command shall be executed for this +file at any time. +.TP 7 +\fB-u\fP +Treat a <backspace> as a printable control character, displayed as +an implementation-defined character sequence (see the +EXTENDED DESCRIPTION section), suppressing backspacing and the special +handling that produces underlined or standout mode text on +some terminal types. Also, do not ignore a <carriage-return> at the +end of a line. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If no \fIfile\fP operands are specified, +the standard input shall be used. If a \fIfile\fP is +\fB'-'\fP , the standard input shall be read at that point in the +sequence. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP +\&. +.SH INPUT FILES +.LP +The input files being examined shall be text files. If standard output +is a terminal, standard error shall be used to read +commands from the user. If standard output is a terminal, standard +error is not readable, and command input is needed, \fImore\fP +may attempt to obtain user commands from the controlling terminal +(for example, \fB/dev/tty\fP); otherwise, \fImore\fP shall +terminate with an error indicating that it was unable to read user +commands. If standard output is not a terminal, no error shall +result if standard error cannot be opened for reading. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fImore\fP: +.TP 7 +\fICOLUMNS\fP +Override the system-selected horizontal display line size. See the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 8, Environment Variables for valid values and results when +it is unset or +null. +.TP 7 +\fIEDITOR\fP +Used by the \fBv\fP command to select an editor. See the EXTENDED +DESCRIPTION section. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classes within regular +expressions. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fILINES\fP +Override the system-selected vertical screen size, used as the number +of lines in a screenful. See the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables for valid +values and +results when it is unset or null. The \fB-n\fP option shall take precedence +over the \fILINES\fP variable for determining the +number of lines in a screenful. +.TP 7 +\fIMORE\fP +Determine a string containing options described in the OPTIONS section +preceded with hyphens and <blank>-separated as on +the command line. Any command line options shall be processed after +those in the \fIMORE\fP variable, as if the command line were: +.sp +.RS +.nf + +\fBmore $MORE\fP \fIoptions operands\fP +.fi +.RE +.LP +The \fIMORE\fP variable shall take precedence over the \fITERM\fP +and \fILINES\fP variables for determining the number of +lines in a screenful. +.TP 7 +\fITERM\fP +Determine the name of the terminal type. If this variable is unset +or null, an unspecified default terminal type is used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be used to write the contents of the input +files. +.SH STDERR +.LP +The standard error shall be used for diagnostic messages and user +commands (see the INPUT FILES section), and, if standard +output is a terminal device, to write a prompting string. The prompting +string shall appear on the screen line below the last line +of the file displayed in the current screenful. The prompt shall contain +the name of the file currently being examined and shall +contain an end-of-file indication and the name of the next file, if +any, when prompting at the end-of-file. If an error or +informational message is displayed, it is unspecified whether it is +contained in the prompt. If it is not contained in the prompt, +it shall be displayed and then the user shall be prompted for a continuation +character, at which point another message or the user +prompt may be displayed. The prompt is otherwise unspecified. It is +unspecified whether informational messages are written for +other user commands. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The following section describes the behavior of \fImore\fP when the +standard output is a terminal device. If the standard +output is not a terminal device, no options other than \fB-s\fP shall +have any effect, and all input files shall be copied to +standard output otherwise unmodified, at which time \fImore\fP shall +exit without further action. +.LP +The number of lines available per screen shall be determined by the +\fB-n\fP option, if present, or by examining values in the +environment (see the ENVIRONMENT VARIABLES section). If neither method +yields a number, an unspecified number of lines shall be +used. +.LP +The maximum number of lines written shall be one less than this number, +because the screen line after the last line written +shall be used to write a user prompt and user input. If the number +of lines in the screen is less than two, the results are +undefined. It is unspecified whether user input is permitted to be +longer than the remainder of the single line where the prompt +has been written. +.LP +The number of columns available per line shall be determined by examining +values in the environment (see the ENVIRONMENT +VARIABLES section), with a default value as described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables. +.LP +Lines that are longer than the display shall be folded; the length +at which folding occurs is unspecified, but should be +appropriate for the output device. Folding may occur between glyphs +of single characters that take up multiple display columns. +.LP +When standard output is a terminal and \fB-u\fP is not specified, +\fImore\fP shall treat <backspace>s and +<carriage-return>s specially: +.IP " *" 3 +A character, followed first by a sequence of \fIn\fP <backspace>s +(where \fIn\fP is the same as the number of column +positions that the character occupies), then by \fIn\fP underscore +characters ( \fB'_'\fP ), shall cause that character to be +written as underlined text, if the terminal type supports that. The +\fIn\fP underscore characters, followed first by \fIn\fP +<backspace>s, then any character with \fIn\fP column positions, shall +also cause that character to be written as underlined +text, if the terminal type supports that. +.LP +.IP " *" 3 +A sequence of \fIn\fP <backspace>s (where \fIn\fP is the same as the +number of column positions that the previous +character occupies) that appears between two identical printable characters +shall cause the first of those two characters to be +written as emboldened text (that is, visually brighter, standout mode, +or inverse-video mode), if the terminal type supports that, +and the second to be discarded. Immediately subsequent occurrences +of <backspace>/ character pairs for that same character +shall also be discarded. (For example, the sequence \fB"a\\ba\\ba\\ba"\fP +is interpreted as a single emboldened \fB'a'\fP .) +.LP +.IP " *" 3 +The \fImore\fP utility shall logically discard all other <backspace>s +from the line as well as the character which +precedes them, if any. +.LP +.IP " *" 3 +A <carriage-return> at the end of a line shall be ignored, rather +than being written as a non-printable character, as +described in the next paragraph. +.LP +.LP +It is implementation-defined how other non-printable characters are +written. Implementations should use the same format that +they use for the \fIex\fP \fBprint\fP command; see the OPTIONS section +within the \fIed\fP utility. It is unspecified whether a multi-column +character shall be separated if it crosses a +display line boundary; it shall not be discarded. The behavior is +unspecified if the number of columns on the display is less than +the number of columns any single character in the line being displayed +would occupy. +.LP +When each new file is displayed (or redisplayed), \fImore\fP shall +write the first screen of the file. Once the initial screen +has been written, \fImore\fP shall prompt for a user command. If the +execution of the user command results in a screen that has +lines in common with the current screen, and the device has sufficient +terminal capabilities, \fImore\fP shall scroll the screen; +otherwise, it is unspecified whether the screen is scrolled or redrawn. +.LP +For all files but the last (including standard input if no file was +specified, and for the last file as well, if the \fB-e\fP +option was not specified), when \fImore\fP has written the last line +in the file, \fImore\fP shall prompt for a user command. +This prompt shall contain the name of the next file as well as an +indication that \fImore\fP has reached end-of-file. If the user +command is \fBf\fP, <control>-F, <space>, \fBj\fP, <newline>, \fBd\fP, +<control>-D, or \fBs\fP, +\fImore\fP shall display the next file. Otherwise, if displaying the +last file, \fImore\fP shall exit. Otherwise, \fImore\fP +shall execute the user command specified. +.LP +Several of the commands described in this section display a previous +screen from the input stream. In the case that text is +being taken from a non-rewindable stream, such as a pipe, it is implementation-defined +how much backwards motion is supported. If a +command cannot be executed because of a limitation on backwards motion, +an error message to this effect shall be displayed, the +current screen shall not change, and the user shall be prompted for +another command. +.LP +If a command cannot be performed because there are insufficient lines +to display, \fImore\fP shall alert the terminal. If a +command cannot be performed because there are insufficient lines to +display or a \fB/\fP command fails: if the input is the +standard input, the last screen in the file may be displayed; otherwise, +the current file and screen shall not change, and the user +shall be prompted for another command. +.LP +The interactive commands in the following sections shall be supported. +Some commands can be preceded by a decimal integer, +called \fIcount\fP in the following descriptions. If not specified +with the command, \fIcount\fP shall default to 1. In the +following descriptions, \fIpattern\fP is a basic regular expression, +as described in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 9.3, Basic Regular Expressions. The +term "examine" is historical usage meaning "open the file for viewing''; +for example, \fImore\fP \fBfoo\fP would be expressed +as examining file \fBfoo\fP. +.LP +In the following descriptions, unless otherwise specified, \fIline\fP +is a line in the \fImore\fP display, not a line from the +file being examined. +.LP +In the following descriptions, the \fIcurrent position\fP refers to +two things: +.IP " 1." 4 +The position of the current line on the screen +.LP +.IP " 2." 4 +The line number (in the file) of the current line on the screen +.LP +.LP +Usually, the line on the screen corresponding to the current position +is the third line on the screen. If this is not possible +(there are fewer than three lines to display or this is the first +page of the file, or it is the last page of the file), then the +current position is either the first or last line on the screen as +described later. +.SS Help +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBh +\fP +.fi +.RE +.sp +.LP +Write a summary of these commands and other implementation-defined +commands. The behavior shall be as if the \fImore\fP utility +were executed with the \fB-e\fP option on a file that contained the +summary information. The user shall be prompted as described +earlier in this section when end-of-file is reached. If the user command +is one of those specified to continue to the next file, +\fImore\fP shall return to the file and screen state from which the +\fBh\fP command was executed. +.SS Scroll Forward One Screenful +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBf +\fP\fB[\fP\fIcount\fP\fB]\fP\fB<control>-F +\fP +.fi +.RE +.sp +.LP +Scroll forward \fIcount\fP lines, with a default of one screenful. +If \fIcount\fP is more than the screen size, only the final +screenful shall be written. +.SS Scroll Backward One Screenful +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBb +\fP\fB[\fP\fIcount\fP\fB]\fP\fB<control>-B +\fP +.fi +.RE +.sp +.LP +Scroll backward \fIcount\fP lines, with a default of one screenful +(see the \fB-n\fP option). If \fIcount\fP is more than the +screen size, only the final screenful shall be written. +.SS Scroll Forward One Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fB<space> +\fP\fB[\fP\fIcount\fP\fB]\fP\fBj +\fP\fB[\fP\fIcount\fP\fB]\fP\fB<newline> +\fP +.fi +.RE +.sp +.LP +Scroll forward \fIcount\fP lines. The default \fIcount\fP for the +<space> shall be one screenful; for \fBj\fP and +<newline>, one line. The entire \fIcount\fP lines shall be written, +even if \fIcount\fP is more than the screen size. +.SS Scroll Backward One Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBk +\fP +.fi +.RE +.sp +.LP +Scroll backward \fIcount\fP lines. The entire \fIcount\fP lines shall +be written, even if \fIcount\fP is more than the screen +size. +.SS Scroll Forward One Half Screenful +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBd +\fP\fB[\fP\fIcount\fP\fB]\fP\fB<control>-D +\fP +.fi +.RE +.sp +.LP +Scroll forward \fIcount\fP lines, with a default of one half of the +screen size. If \fIcount\fP is specified, it shall become +the new default for subsequent \fBd\fP, <control>-D, and \fBu\fP commands. +.SS Skip Forward One Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBs +\fP +.fi +.RE +.sp +.LP +Display the screenful beginning with the line \fIcount\fP lines after +the last line on the current screen. If \fIcount\fP +would cause the current position to be such that less than one screenful +would be written, the last screenful in the file shall be +written. +.SS Scroll Backward One Half Screenful +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBu +\fP\fB[\fP\fIcount\fP\fB]\fP\fB<control>-U +\fP +.fi +.RE +.sp +.LP +Scroll backward \fIcount\fP lines, with a default of one half of the +screen size. If \fIcount\fP is specified, it shall become +the new default for subsequent \fBd\fP, <control>-D, \fBu\fP, and +<control>-U commands. The entire \fIcount\fP lines +shall be written, even if \fIcount\fP is more than the screen size. +.SS Go to Beginning of File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBg +\fP +.fi +.RE +.sp +.LP +Display the screenful beginning with line \fIcount\fP. +.SS Go to End-of-File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBG +\fP +.fi +.RE +.sp +.LP +If \fIcount\fP is specified, display the screenful beginning with +the line \fIcount\fP. Otherwise, display the last screenful +of the file. +.SS Refresh the Screen +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBr +<control>-L +\fP +.fi +.RE +.sp +.LP +Refresh the screen. +.SS Discard and Refresh +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBR +\fP +.fi +.RE +.sp +.LP +Refresh the screen, discarding any buffered input. If the current +file is non-seekable, buffered input shall not be discarded +and the \fBR\fP command shall be equivalent to the \fBr\fP command. +.SS Mark Position +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBm\fP\fIletter\fP +.fi +.RE +.sp +.LP +Mark the current position with the letter named by \fIletter\fP, where +\fIletter\fP represents the name of one of the +lowercase letters of the portable character set. When a new file is +examined, all marks may be lost. +.SS Return to Mark +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB'\fP\fIletter\fP +.fi +.RE +.sp +.LP +Return to the position that was previously marked with the letter +named by \fIletter\fP, making that line the current +position. +.SS Return to Previous Position +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB'' +\fP +.fi +.RE +.sp +.LP +Return to the position from which the last large movement command +was executed (where a "large movement" is defined as any +movement of more than a screenful of lines). If no such movements +have been made, return to the beginning of the file. +.SS Search Forward for Pattern +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fB/\fP\fB[\fP\fB!\fP\fB]\fP\fIpattern\fP\fB<newline> +\fP +.fi +.RE +.sp +.LP +Display the screenful beginning with the \fIcount\fPth line containing +the pattern. The search shall start after the first line +currently displayed. The null regular expression ( \fB'/'\fP followed +by a <newline>) shall repeat the search using the +previous regular expression, with a default \fIcount\fP. If the character +\fB'!'\fP is included, the matching lines shall be +those that do not contain the \fIpattern\fP. If no match is found +for the \fIpattern\fP, a message to that effect shall be +displayed. +.SS Search Backward for Pattern +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fB?\fP\fB[\fP\fB!\fP\fB]\fP\fIpattern\fP\fB<newline> +\fP +.fi +.RE +.sp +.LP +Display the screenful beginning with the \fIcount\fPth previous line +containing the pattern. The search shall start on the last +line before the first line currently displayed. The null regular expression +( \fB'?'\fP followed by a <newline>) shall +repeat the search using the previous regular expression, with a default +\fIcount\fP. If the character \fB'!'\fP is included, +matching lines shall be those that do not contain the \fIpattern\fP. +If no match is found for the \fIpattern\fP, a message to +that effect shall be displayed. +.SS Repeat Search +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBn +\fP +.fi +.RE +.sp +.LP +Repeat the previous search for \fIcount\fPth line containing the last +\fIpattern\fP (or not containing the last +\fIpattern\fP, if the previous search was \fB"/!"\fP or \fB"?!"\fP +). +.SS Repeat Search in Reverse +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fBN +\fP +.fi +.RE +.sp +.LP +Repeat the search in the opposite direction of the previous search +for the \fIcount\fPth line containing the last +\fIpattern\fP (or not containing the last \fIpattern\fP, if the previous +search was \fB"/!"\fP or \fB"?!"\fP ). +.SS Examine New File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB:e\fP \fB[\fP\fIfilename\fP\fB]\fP\fB<newline> +\fP +.fi +.RE +.sp +.LP +Examine a new file. If the \fIfilename\fP argument is not specified, +the current file (see the \fB:n\fP and \fB:p\fP commands +below) shall be re-examined. The \fIfilename\fP shall be subjected +to the process of shell word expansions (see \fIWord Expansions\fP +); if more than a single pathname results, the effects are unspecified. +If +\fIfilename\fP is a number sign ( \fB'#'\fP ), the previously examined +file shall be re-examined. If \fIfilename\fP is not +accessible for any reason (including that it is a non-seekable file), +an error message to this effect shall be displayed and the +current file and screen shall not change. +.SS Examine Next File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fB:n +\fP +.fi +.RE +.sp +.LP +Examine the next file. If a number \fIcount\fP is specified, the \fIcount\fPth +next file shall be examined. If \fIfilename\fP +refers to a non-seekable file, the results are unspecified. +.SS Examine Previous File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP\fB:p +\fP +.fi +.RE +.sp +.LP +Examine the previous file. If a number \fIcount\fP is specified, the +\fIcount\fPth previous file shall be examined. If +\fIfilename\fP refers to a non-seekable file, the results are unspecified. +.SS Go to Tag +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB:t\fP \fItagstring\fP\fB<newline> +\fP +.fi +.RE +.sp +.LP +If the file containing the tag named by the \fItagstring\fP argument +is not the current file, examine the file, as if the +\fB:e\fP command was executed with that file as the argument. Otherwise, +or in addition, display the screenful beginning with the +tag, as described for the \fB-t\fP option (see the OPTIONS section). +If the \fIctags\fP +utility is not supported by the system, the use of \fB:t\fP produces +undefined results. +.SS Invoke Editor +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBv +\fP +.fi +.RE +.sp +.LP +Invoke an editor to edit the current file being examined. If standard +input is being examined, the results are unspecified. The +name of the editor shall be taken from the environment variable \fIEDITOR +,\fP or shall default to \fIvi\fP. If the last pathname component +in \fIEDITOR\fP is either \fIvi\fP or \fIex\fP, the editor shall be +invoked with a \fB-c\fP +\fIlinenumber\fP command line argument, where \fIlinenumber\fP is +the line number of the file line containing the display line +currently displayed as the first line of the screen. It is implementation-defined +whether line-setting options are passed to +editors other than \fIvi\fP and \fIex\fP. +.LP +When the editor exits, \fImore\fP shall resume with the same file +and screen as when the editor was invoked. +.SS Display Position +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB= +<control>-G +\fP +.fi +.RE +.sp +.LP +Write a message for which the information references the first byte +of the line after the last line of the file on the screen. +This message shall include the name of the file currently being examined, +its number relative to the total number of files there +are to examine, the line number in the file, the byte number and the +total bytes in the file, and what percentage of the file +precedes the current position. If \fImore\fP is reading from standard +input, or the file is shorter than a single screen, the line +number, the byte number, the total bytes, and the percentage need +not be written. +.SS Quit +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBq +:q +ZZ +\fP +.fi +.RE +.sp +.LP +Exit \fImore\fP. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If an error is encountered accessing a file when using the \fB:n\fP +command, \fImore\fP shall attempt to examine the next file +in the argument list, but the final exit status shall be affected. +If an error is encountered accessing a file via the \fB:p\fP +command, \fImore\fP shall attempt to examine the previous file in +the argument list, but the final exit status shall be affected. +If an error is encountered accessing a file via the \fB:e\fP command, +\fImore\fP shall remain in the current file and the final +exit status shall not be affected. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +When the standard output is not a terminal, only the \fB-s\fP filter-modification +option is effective. This is based on +historical practice. For example, a typical implementation of \fIman\fP +pipes its output +through \fImore\fP \fB-s\fP to squeeze excess white space for terminal +users. When \fIman\fP +is piped to \fIlp\fP, however, it is undesirable for this squeezing +to happen. +.SH EXAMPLES +.LP +The \fB-p\fP allows arbitrary commands to be executed at the start +of each file. Examples are: +.TP 7 +\fImore\ \fP \fB-p\ G\ \fP \fIfile1\ file2\fP +.sp +Examine each file starting with its last screenful. +.TP 7 +\fImore\ \fP \fB-p\ \fP 100\ \fIfile1\ file2\fP +.sp +Examine each file starting with line 100 in the current position (usually +the third line, so line 98 would be the first line +written). +.TP 7 +\fImore\ \fP \fB-p\ \fP /100\ \fIfile1\ file2\fP +.sp +Examine each file starting with the first line containing the string +\fB"100"\fP in the current position +.sp +.SH RATIONALE +.LP +The \fImore\fP utility, available in BSD and BSD-derived systems, +was chosen as the prototype for the POSIX file display +program since it is more widely available than either the public-domain +program \fIless\fP or than \fIpg\fP, a pager provided in +System V. The 4.4 BSD \fImore\fP is the model for the features selected; +it is almost fully upwards-compatible from the 4.3 BSD +version in wide use and has become more amenable for \fIvi\fP users. +Several features +originally derived from various file editors, found in both \fIless\fP +and \fIpg\fP, have been added to this volume of +IEEE\ Std\ 1003.1-2001 as they have proved extremely popular with +users. +.LP +There are inconsistencies between \fImore\fP and \fIvi\fP that result +from historical +practice. For example, the single-character commands \fBh\fP, \fBf\fP, +\fBb\fP, and <space> are screen movers in +\fImore\fP, but cursor movers in \fIvi\fP. These inconsistencies were +maintained because the +cursor movements are not applicable to \fImore\fP and the powerful +functionality achieved without the use of the control key +justifies the differences. +.LP +The tags interface has been included in a program that is not a text +editor because it promotes another degree of consistent +operation with \fIvi\fP. It is conceivable that the paging environment +of \fImore\fP would be +superior for browsing source code files in some circumstances. +.LP +The operating mode referred to for block-mode terminals effectively +adds a <newline> to each Synopsis line that currently +has none. So, for example, \fBd\fP <newline> would page one screenful. +The mode could be triggered by a command line option, +environment variable, or some other method. The details are not imposed +by this volume of IEEE\ Std\ 1003.1-2001 because +there are so few systems known to support such terminals. Nevertheless, +it was considered that all systems should be able to +support \fImore\fP given the exception cited for this small community +of terminals because, in comparison to \fIvi\fP, the cursor movements +are few and the command set relatively amenable to the optional +<newline>s. +.LP +Some versions of \fImore\fP provide a shell escaping mechanism similar +to the \fIex\fP +\fB!\fP command. The standard developers did not consider that this +was necessary in a paginator, particularly given the wide +acceptance of multiple window terminals and job control features. +(They chose to retain such features in the editors and \fImailx\fP +because the shell interaction also gives an opportunity to modify +the editing buffer, +which is not applicable to \fImore\fP.) +.LP +The \fB-p\fP (position) option replaces the \fB+\fP command because +of the Utility Syntax Guidelines. In early proposals, it +took a \fIpattern\fP argument, but historical \fIless\fP provided +the \fImore\fP general facility of a command. It would have +been desirable to use the same \fB-c\fP as \fIex\fP and \fIvi\fP, +but the letter was already in use. +.LP +The text stating "from a non-rewindable stream ... implementations +may limit the amount of backwards motion supported" would +allow an implementation that permitted no backwards motion beyond +text already on the screen. It was not possible to require a +minimum amount of backwards motion that would be effective for all +conceivable device types. The implementation should allow the +user to back up as far as possible, within device and reasonable memory +allocation constraints. +.LP +Historically, non-printable characters were displayed using the ARPA +standard mappings, which are as follows: +.IP " 1." 4 +Printable characters are left alone. +.LP +.IP " 2." 4 +Control characters less than \\177 are represented as followed by +the character offset from the \fB'@'\fP character in the +ASCII map; for example, \\007 is represented as \fB'G'\fP . +.LP +.IP " 3." 4 +\\177 is represented as followed by \fB'?'\fP . +.LP +.LP +The display of characters having their eighth bit set was less standard. +Existing implementations use hex (0x00), octal (\\000), +and a meta-bit display. (The latter displayed characters with their +eighth bit set as the two characters \fB"M-"\fP , followed +by the seven-bit display as described previously.) The latter probably +has the best claim to historical practice because it was +used with the \fB-v\fP option of 4 BSD and 4 BSD-derived versions +of the \fIcat\fP utility +since 1980. +.LP +No specific display format is required by IEEE\ Std\ 1003.1-2001. +Implementations are encouraged to conform to historic +practice in the absence of any strong reason to diverge. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIctags\fP , \fIed\fP , \fIex\fP , +\fIvi\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/mv.1p b/man1p/mv.1p new file mode 100644 index 000000000..e01faddf6 --- /dev/null +++ b/man1p/mv.1p @@ -0,0 +1,376 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "MV" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" mv +.SH NAME +mv \- move files +.SH SYNOPSIS +.LP +\fBmv\fP \fB[\fP\fB-fi\fP\fB]\fP \fIsource_file target_file\fP\fB +.br +.sp +mv\fP \fB[\fP\fB-fi\fP\fB]\fP \fIsource_file\fP\fB...\fP \fItarget_file\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +In the first synopsis form, the \fImv\fP utility shall move the file +named by the \fIsource_file\fP operand to the destination +specified by the \fItarget_file\fP. This first synopsis form is assumed +when the final operand does not name an existing directory +and is not a symbolic link referring to an existing directory. +.LP +In the second synopsis form, \fImv\fP shall move each file named by +a \fIsource_file\fP operand to a destination file in the +existing directory named by the \fItarget_dir\fP operand, or referenced +if \fItarget_dir\fP is a symbolic link referring to an +existing directory. The destination path for each \fIsource_file\fP +shall be the concatenation of the target directory, a single +slash character, and the last pathname component of the \fIsource_file\fP. +This second form is assumed when the final operand +names an existing directory. +.LP +If any operand specifies an existing file of a type not specified +by the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, the behavior is implementation-defined. +.LP +For each \fIsource_file\fP the following steps shall be taken: +.IP " 1." 4 +If the destination path exists, the \fB-f\fP option is not specified, +and either of the following conditions is true: +.RS +.IP " a." 4 +The permissions of the destination path do not permit writing and +the standard input is a terminal. +.LP +.IP " b." 4 +The \fB-i\fP option is specified. +.LP +.RE +.LP +the \fImv\fP utility shall write a prompt to standard error and read +a line from standard input. If the response is not +affirmative, \fImv\fP shall do nothing more with the current \fIsource_file\fP +and go on to any remaining +\fIsource_file\fPs. +.LP +.IP " 2." 4 +The \fImv\fP utility shall perform actions equivalent to the \fIrename\fP() +function +defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +called with the following arguments: +.RS +.IP " a." 4 +The \fIsource_file\fP operand is used as the \fIold\fP argument. +.LP +.IP " b." 4 +The destination path is used as the \fInew\fP argument. +.LP +.RE +.LP +If this succeeds, \fImv\fP shall do nothing more with the current +\fIsource_file\fP and go on to any remaining +\fIsource_file\fPs. If this fails for any reasons other than those +described for the \fIerrno\fP [EXDEV] in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, \fImv\fP shall write a diagnostic +message to standard error, do nothing more with the +current \fIsource_file\fP, and go on to any remaining \fIsource_file\fPs. +.LP +.IP " 3." 4 +If the destination path exists, and it is a file of type directory +and \fIsource_file\fP is not a file of type directory, or it +is a file not of type directory and \fIsource_file\fP is a file of +type directory, \fImv\fP shall write a diagnostic message to +standard error, do nothing more with the current \fIsource_file\fP, +and go on to any remaining \fIsource_file\fPs. +.LP +.IP " 4." 4 +If the destination path exists, \fImv\fP shall attempt to remove it. +If this fails for any reason, \fImv\fP shall write a +diagnostic message to standard error, do nothing more with the current +\fIsource_file\fP, and go on to any remaining +\fIsource_file\fPs. +.LP +.IP " 5." 4 +The file hierarchy rooted in \fIsource_file\fP shall be duplicated +as a file hierarchy rooted in the destination path. If +\fIsource_file\fP or any of the files below it in the hierarchy are +symbolic links, the links themselves shall be duplicated, +including their contents, rather than any files to which they refer. +The following characteristics of each file in the file +hierarchy shall be duplicated: +.RS +.IP " *" 3 +The time of last data modification and time of last access +.LP +.IP " *" 3 +The user ID and group ID +.LP +.IP " *" 3 +The file mode +.LP +.RE +.LP +If the user ID, group ID, or file mode of a regular file cannot be +duplicated, the file mode bits S_ISUID and S_ISGID shall not +be duplicated. +.LP +When files are duplicated to another file system, the implementation +may require that the process invoking \fImv\fP has read +access to each file being duplicated. +.LP +If the duplication of the file hierarchy fails for any reason, \fImv\fP +shall write a diagnostic message to standard error, do +nothing more with the current \fIsource_file\fP, and go on to any +remaining \fIsource_file\fPs. +.LP +If the duplication of the file characteristics fails for any reason, +\fImv\fP shall write a diagnostic message to standard +error, but this failure shall not cause \fImv\fP to modify its exit +status. +.LP +.IP " 6." 4 +The file hierarchy rooted in \fIsource_file\fP shall be removed. If +this fails for any reason, \fImv\fP shall write a +diagnostic message to the standard error, do nothing more with the +current \fIsource_file\fP, and go on to any remaining +\fIsource_file\fPs. +.LP +.SH OPTIONS +.LP +The \fImv\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-f\fP +Do not prompt for confirmation if the destination path exists. Any +previous occurrence of the \fB-i\fP option is ignored. +.TP 7 +\fB-i\fP +Prompt for confirmation if the destination path exists. Any previous +occurrence of the \fB-f\fP option is ignored. +.sp +.LP +Specifying more than one of the \fB-f\fP or \fB-i\fP options shall +not be considered an error. The last option specified shall +determine the behavior of \fImv\fP. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIsource_file\fP +A pathname of a file or directory to be moved. +.TP 7 +\fItarget_file\fP +A new pathname for the file or directory being moved. +.TP 7 +\fItarget_dir\fP +A pathname of an existing directory into which to move the input files. +.sp +.SH STDIN +.LP +The standard input shall be used to read an input line in response +to each prompt specified in the STDERR section. Otherwise, +the standard input shall not be used. +.SH INPUT FILES +.LP +The input files specified by each \fIsource_file\fP operand can be +of any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fImv\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements used in the extended +regular expression defined for the \fByesexpr\fP locale keyword in +the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +behavior of character classes used in the extended regular +expression defined for the \fByesexpr\fP locale keyword in the \fILC_MESSAGES\fP +category. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale for the processing of affirmative responses that +should be used to affect the format and contents of +diagnostic messages written to standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +Prompts shall be written to the standard error under the conditions +specified in the DESCRIPTION section. The prompts shall +contain the destination pathname, but their format is otherwise unspecified. +Otherwise, the standard error shall be used only for +diagnostic messages. +.SH OUTPUT FILES +.LP +The output files may be of any file type. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were moved successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If the copying or removal of \fIsource_file\fP is prematurely terminated +by a signal or error, \fImv\fP may leave a partial +copy of \fIsource_file\fP at the source or destination. The \fImv\fP +utility shall not modify both \fIsource_file\fP and the +destination path simultaneously; termination at any point shall leave +either \fIsource_file\fP or the destination path +complete. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Some implementations mark for update the \fIst_ctime\fP field of renamed +files and some do not. Applications which make use of +the \fIst_ctime\fP field may behave differently with respect to renamed +files unless they are designed to allow for either +behavior. +.SH EXAMPLES +.LP +If the current directory contains only files \fBa\fP (of any type +defined by the System Interfaces volume of +IEEE\ Std\ 1003.1-2001), \fBb\fP (also of any type), and a directory +\fBc\fP: +.sp +.RS +.nf + +\fBmv a b c +mv c d +\fP +.fi +.RE +.LP +results with the original files \fBa\fP and \fBb\fP residing in the +directory \fBd\fP in the current directory. +.SH RATIONALE +.LP +Early proposals diverged from the SVID and BSD historical practice +in that they required that when the destination path exists, +the \fB-f\fP option is not specified, and input is not a terminal, +\fImv\fP fails. This was done for compatibility with \fIcp\fP. The +current text returns to historical practice. It should be noted that +this is consistent +with the \fIrename\fP() function defined in the System Interfaces +volume of +IEEE\ Std\ 1003.1-2001, which does not require write permission on +the target. +.LP +For absolute clarity, paragraph (1), describing the behavior of \fImv\fP +when prompting for confirmation, should be interpreted +in the following manner: +.sp +.RS +.nf + +\fBif (exists AND (NOT f_option) AND + ((not_writable AND input_is_terminal) OR i_option)) +\fP +.fi +.RE +.LP +The \fB-i\fP option exists on BSD systems, giving applications and +users a way to avoid accidentally unlinking files when +moving others. When the standard input is not a terminal, the 4.3 +BSD \fImv\fP deletes all existing destination paths without +prompting, even when \fB-i\fP is specified; this is inconsistent with +the behavior of the 4.3 BSD \fIcp\fP utility, which always generates +an error when the file is unwritable and the standard input is +not a terminal. The standard developers decided that use of \fB-i\fP +is a request for interaction, so when the destination path +exists, the utility takes instructions from whatever responds to standard +input. +.LP +The \fIrename\fP() function is able to move directories within the +same file system. +Some historical versions of \fImv\fP have been able to move directories, +but not to a different file system. The standard +developers considered that this was an annoying inconsistency, so +this volume of IEEE\ Std\ 1003.1-2001 requires +directories to be able to be moved even across file systems. There +is no \fB-R\fP option to confirm that moving a directory is +actually intended, since such an option was not required for moving +directories in historical practice. Requiring the application +to specify it sometimes, depending on the destination, seemed just +as inconsistent. The semantics of the \fIrename\fP() function were +preserved as much as possible. For example, \fImv\fP is not permitted +to "rename" files to or from directories, even though they might be +empty and removable. +.LP +Historic implementations of \fImv\fP did not exit with a non-zero +exit status if they were unable to duplicate any file +characteristics when moving a file across file systems, nor did they +write a diagnostic message for the user. The former behavior +has been preserved to prevent scripts from breaking; a diagnostic +message is now required, however, so that users are alerted that +the file characteristics have changed. +.LP +The exact format of the interactive prompts is unspecified. Only the +general nature of the contents of prompts are specified +because implementations may desire more descriptive prompts than those +used on historical implementations. Therefore, an +application not using the \fB-f\fP option or using the \fB-i\fP option +relies on the system to provide the most suitable dialog +directly with the user, based on the behavior specified. +.LP +When \fImv\fP is dealing with a single file system and \fIsource_file\fP +is a symbolic link, the link itself is moved as a +consequence of the dependence on the \fIrename\fP() functionality, +per the DESCRIPTION. +Across file systems, this has to be made explicit. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcp\fP , \fIln\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIrename\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/newgrp.1p b/man1p/newgrp.1p new file mode 100644 index 000000000..3452c6d78 --- /dev/null +++ b/man1p/newgrp.1p @@ -0,0 +1,267 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "NEWGRP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" newgrp +.SH NAME +newgrp \- change to a new group +.SH SYNOPSIS +.LP +\fBnewgrp\fP \fB[\fP\fB-l\fP\fB][\fP\fIgroup\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fInewgrp\fP utility shall create a new shell execution environment +with a new real and effective group identification. Of +the attributes listed in \fIShell Execution Environment\fP , the new +shell execution +environment shall retain the working directory, file creation mask, +and exported variables from the previous environment (that is, +open files, traps, unexported variables, alias definitions, shell +functions, and \fIset\fP options may be lost). All other aspects of +the process environment that are +preserved by the \fIexec\fP family of functions defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001 shall +also be preserved by \fInewgrp\fP; whether other aspects are preserved +is unspecified. +.LP +A failure to assign the new group identifications (for example, for +security or password-related reasons) shall not prevent the +new shell execution environment from being created. +.LP +The \fInewgrp\fP utility shall affect the supplemental groups for +the process as follows: +.IP " *" 3 +On systems where the effective group ID is normally in the supplementary +group list (or whenever the old effective group ID +actually is in the supplementary group list): +.RS +.IP " *" 3 +If the new effective group ID is also in the supplementary group list, +\fInewgrp\fP shall change the effective group ID. +.LP +.IP " *" 3 +If the new effective group ID is not in the supplementary group list, +\fInewgrp\fP shall add the new effective group ID to the +list, if there is room to add it. +.LP +.RE +.LP +.IP " *" 3 +On systems where the effective group ID is not normally in the supplementary +group list (or whenever the old effective group ID +is not in the supplementary group list): +.RS +.IP " *" 3 +If the new effective group ID is in the supplementary group list, +\fInewgrp\fP shall delete it. +.LP +.IP " *" 3 +If the old effective group ID is not in the supplementary list, \fInewgrp\fP +shall add it if there is room. +.LP +.RE +.LP +.TP 7 +\fBNote:\fP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001 does not specify +whether the effective group ID of a process is +included in its supplementary group list. +.sp +.LP +With no operands, \fInewgrp\fP shall change the effective group back +to the groups identified in the user's user entry, and +shall set the list of supplementary groups to that set in the user's +group database entries. +.LP +If a password is required for the specified group, and the user is +not listed as a member of that group in the group database, +the user shall be prompted to enter the correct password for that +group. If the user is listed as a member of that group, no +password shall be requested. If no password is required for the specified +group, it is implementation-defined whether users not +listed as members of that group can change to that group. Whether +or not a password is required, implementation-defined system +accounting or security mechanisms may impose additional authorization +restrictions that may cause \fInewgrp\fP to write a +diagnostic message and suppress the changing of the group identification. +.SH OPTIONS +.LP +The \fInewgrp\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-l\fP +(The letter ell.) Change the environment to what would be expected +if the user actually logged in again. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIgroup\fP +A group name from the group database or a non-negative numeric group +ID. Specifies the group ID to which the real and effective +group IDs shall be set. If \fIgroup\fP is a non-negative numeric string +and exists in the group database as a group name (see \fIgetgrnam\fP()), +the numeric group ID associated with that group name shall be used +as the +group ID. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The file \fB/dev/tty\fP shall be used to read a single line of text +for password checking, when one is required. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fInewgrp\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used for diagnostic messages and a prompt +string for a password, if one is required. Diagnostic +messages may be written in cases where the exit status is not available. +See the EXIT STATUS section. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If \fInewgrp\fP succeeds in creating a new shell execution environment, +whether or not the group identification was changed +successfully, the exit status shall be the exit status of the shell. +Otherwise, the following exit value shall be returned: +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The invoking shell may terminate. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +There is no convenient way to enter a password into the group database. +Use of group passwords is not encouraged, because by +their very nature they encourage poor security practices. Group passwords +may disappear in the future. +.LP +A common implementation of \fInewgrp\fP is that the current shell +uses \fIexec\fP to overlay itself with \fInewgrp\fP, which +in turn overlays itself with a new shell after changing group. On +some implementations, however, this may not occur and +\fInewgrp\fP may be invoked as a subprocess. +.LP +The \fInewgrp\fP command is intended only for use from an interactive +terminal. It does not offer a useful interface for the +support of applications. +.LP +The exit status of \fInewgrp\fP is generally inapplicable. If \fInewgrp\fP +is used in a script, in most cases it successfully +invokes a new shell and the rest of the original shell script is bypassed +when the new shell exits. Used interactively, +\fInewgrp\fP displays diagnostic messages to indicate problems. But +usage such as: +.sp +.RS +.nf + +\fBnewgrp foo +echo $? +\fP +.fi +.RE +.LP +is not useful because the new shell might not have access to any status +\fInewgrp\fP may have generated (and most historical +systems do not provide this status). A zero status echoed here does +not necessarily indicate that the user has changed to the new +group successfully. Following \fInewgrp\fP with the \fIid\fP command +provides a portable means +of determining whether the group change was successful or not. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Most historical implementations use one of the \fIexec\fP functions +to implement the behavior of \fInewgrp\fP. Errors detected +before the \fIexec\fP leave the environment unchanged, while errors +detected after the \fIexec\fP leave the user in a changed +environment. While it would be useful to have \fInewgrp\fP issue a +diagnostic message to tell the user that the environment +changed, it would be inappropriate to require this change to some +historical implementations. +.LP +The password mechanism is allowed in the group database, but how this +would be implemented is not specified. +.LP +The \fInewgrp\fP utility was retained in this volume of IEEE\ Std\ 1003.1-2001, +even given the existence of the +multiple group permissions feature in the System Interfaces volume +of IEEE\ Std\ 1003.1-2001, for several reasons. First, +in some implementations, the group ownership of a newly created file +is determined by the group of the directory in which the file +is created, as allowed by the System Interfaces volume of IEEE\ Std\ 1003.1-2001; +on other implementations, the group +ownership of a newly created file is determined by the effective group +ID. On implementations of the latter type, \fInewgrp\fP +allows files to be created with a specific group ownership. Finally, +many implementations use the real group ID in accounting, and +on such systems, \fInewgrp\fP allows the accounting identity of the +user to be changed. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIsh\fP , the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, \fIexec\fP, \fIgetgrnam\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/nice.1p b/man1p/nice.1p new file mode 100644 index 000000000..adcd4f46a --- /dev/null +++ b/man1p/nice.1p @@ -0,0 +1,253 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "NICE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" nice +.SH NAME +nice \- invoke a utility with an altered nice value +.SH SYNOPSIS +.LP +\fBnice\fP \fB[\fP\fB-n\fP \fIincrement\fP\fB]\fP \fIutility\fP +\fB[\fP\fIargument\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fInice\fP utility shall invoke a utility, requesting that it +be run with a different nice value (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 3.239, Nice Value). With +no +options and only if the user has appropriate privileges, the executed +utility shall be run with a nice value that is some +implementation-defined quantity less than or equal to the nice value +of the current process. If the user lacks appropriate +privileges to affect the nice value in the requested manner, the \fInice\fP +utility shall not affect the nice value; in this case, +a warning message may be written to standard error, but this shall +not prevent the invocation of \fIutility\fP or affect the exit +status. +.SH OPTIONS +.LP +The \fInice\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option is supported: +.TP 7 +\fB-n\ \fP \fIincrement\fP +A positive or negative decimal integer which shall have the same effect +on the execution of the utility as if the utility had +called the \fInice\fP() function with the numeric value of the \fIincrement\fP +option-argument. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIutility\fP +The name of a utility that is to be invoked. If the \fIutility\fP +operand names any of the special built-in utilities in \fISpecial +Built-In Utilities\fP , the results are undefined. +.TP 7 +\fIargument\fP +Any string to be supplied as an argument when invoking the utility +named by the \fIutility\fP operand. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fInice\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the search path used to locate the utility to be invoked. +See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If \fIutility\fP is invoked, the exit status of \fInice\fP shall be +the exit status of \fIutility\fP; otherwise, the +\fInice\fP utility shall exit with one of the following values: +.TP 7 +1-125 +An error occurred in the \fInice\fP utility. +.TP 7 +\ \ 126 +The utility specified by \fIutility\fP was found but could not be +invoked. +.TP 7 +\ \ 127 +The utility specified by \fIutility\fP could not be found. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The only guaranteed portable uses of this utility are: +.TP 7 +\fInice\ utility\fP +.sp +Run \fIutility\fP with the default lower nice value. +.TP 7 +\fInice\ \fP \fB-n\ \fP <\fIpositive\ integer\fP>\fI\ utility\fP +.sp +Run \fIutility\fP with a lower nice value. +.sp +.LP +On some implementations they have no discernible effect on the invoked +utility and on some others they are exactly +equivalent. +.LP +Historical systems have frequently supported the <\fIpositive integer\fP> +up to 20. Since there is no error penalty +associated with guessing a number that is too high, users without +access to the system conformance document (to see what limits are +actually in place) could use the historical 1 to 20 range or attempt +to use very large numbers if the job should be truly low +priority. +.LP +The nice value of a process can be displayed using the command: +.sp +.RS +.nf + +\fBps -o nice +\fP +.fi +.RE +.LP +The \fIcommand\fP, \fIenv\fP, \fInice\fP, \fInohup\fP, \fItime\fP, +and \fIxargs\fP utilities have been specified to use exit code 127 +if an error occurs so that +applications can distinguish "failure to find a utility" from "invoked +utility exited with an error indication". The value 127 +was chosen because it is not commonly used for other meanings; most +utilities use small values for "normal error conditions" and +the values above 128 can be confused with termination due to receipt +of a signal. The value 126 was chosen in a similar manner to +indicate that the utility could be found, but not invoked. Some scripts +produce meaningful error messages differentiating the 126 +and 127 cases. The distinction between exit codes 126 and 127 is based +on KornShell practice that uses 127 when all attempts to +\fIexec\fP the utility fail with [ENOENT], and uses 126 when any attempt +to \fIexec\fP the utility fails for any other +reason. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Due to the text about the limits of the nice value being implementation-defined, +\fInice\fP is not actually required to change +the nice value of the executed command; the limits could be zero differences +from the system default, although the implementor is +required to document this fact in the conformance document. +.LP +The 4.3 BSD version of \fInice\fP does not check whether \fIincrement\fP +is a valid decimal integer. The command \fInice\fP +\fB-x\fP \fIutility\fP, for example, would be treated the same as +the command \fInice\fP \fB--1\fP \fIutility\fP. If the user +does not have appropriate privileges, this results in a "permission +denied" error. This is considered a bug. +.LP +When a user without appropriate privileges gives a negative \fIincrement\fP, +System V treats it like the command \fInice\fP +\fB-0\fP \fIutility\fP, while 4.3 BSD writes a "permission denied" +message and does not run the utility. Neither was considered +clearly superior, so the behavior was left unspecified. +.LP +The C shell has a built-in version of \fInice\fP that has a different +interface from the one described in this volume of +IEEE\ Std\ 1003.1-2001. +.LP +The term "utility" is used, rather than "command", to highlight the +fact that shell compound commands, pipelines, and so on, +cannot be used. Special built-ins also cannot be used. However, "utility" +includes user application programs and shell scripts, +not just utilities defined in this volume of IEEE\ Std\ 1003.1-2001. +.LP +Historical implementations of \fInice\fP provide a nice value range +of 40 or 41 discrete steps, with the default nice value +being the midpoint of that range. By default, they lower the nice +value of the executed utility by 10. +.LP +Some historical documentation states that the \fIincrement\fP value +must be within a fixed range. This is misleading; the valid +\fIincrement\fP values on any invocation are determined by the current +process nice value, which is not always the default. +.LP +The definition of nice value is not intended to suggest that all processes +in a system have priorities that are comparable. +Scheduling policy extensions such as the realtime priorities in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001 make +the notion of a single underlying priority for all scheduling policies +problematic. Some implementations may implement the +\fInice\fP-related features to affect all processes on the system, +others to affect just the general time-sharing activities +implied by this volume of IEEE\ Std\ 1003.1-2001, and others may have +no effect at all. Because of the use of +"implementation-defined" in \fInice\fP and \fIrenice\fP, a wide range +of implementation +strategies are possible. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIrenice\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fInice\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/nl.1p b/man1p/nl.1p new file mode 100644 index 000000000..5a76eb1c6 --- /dev/null +++ b/man1p/nl.1p @@ -0,0 +1,285 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "NL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" nl +.SH NAME +nl \- line numbering filter +.SH SYNOPSIS +.LP +\fBnl\fP \fB[\fP\fB-p\fP\fB][\fP\fB-b\fP \fItype\fP\fB][\fP\fB-d\fP +\fIdelim\fP\fB][\fP\fB-f\fP \fItype\fP\fB][\fP\fB-h\fP \fItype\fP\fB][\fP\fB-i\fP +\fIincr\fP\fB][\fP\fB-l\fP +\fInum\fP\fB][\fP\fB-n\fP \fIformat\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-s\fP \fIsep\fP\fB][\fP\fB-v\fP +\fIstartnum\fP\fB][\fP\fB-w\fP \fIwidth\fP\fB][\fP\fIfile\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fInl\fP utility shall read lines from the named \fIfile\fP or +the standard input if no \fIfile\fP is named and shall +reproduce the lines to standard output. Lines shall be numbered on +the left. Additional functionality may be provided in accordance +with the command options in effect. +.LP +The \fInl\fP utility views the text it reads in terms of logical pages. +Line numbering shall be reset at the start of each +logical page. A logical page consists of a header, a body, and a footer +section. Empty sections are valid. Different line numbering +options are independently available for header, body, and footer (for +example, no numbering of header and footer lines while +numbering blank lines only in the body). +.LP +The starts of logical page sections shall be signaled by input lines +containing nothing but the following delimiter +characters: +.TS C +center; l l. +\fBLine\fP \fBStart of\fP +\\:\\:\\: Header +\\:\\: Body +\\: Footer +.TE +.LP +Unless otherwise specified, \fInl\fP shall assume the text being read +is in a single logical page body. +.SH OPTIONS +.LP +The \fInl\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +Only one file can be named. +.LP +The following options shall be supported: +.TP 7 +\fB-b\ \fP \fItype\fP +Specify which logical page body lines shall be numbered. Recognized +\fItypes\fP and their meaning are: +.TP 7 +\fBa\fP +.RS +Number all lines. +.RE +.TP 7 +\fBt\fP +.RS +Number only non-empty lines. +.RE +.TP 7 +\fBn\fP +.RS +No line numbering. +.RE +.TP 7 +\fBp\fP\fIstring\fP +.RS +Number only lines that contain the basic regular expression specified +in \fIstring\fP. +.RE +.sp +.LP +The default \fItype\fP for logical page body shall be \fBt\fP (text +lines numbered). +.TP 7 +\fB-d\ \fP \fIdelim\fP +Specify the delimiter characters that indicate the start of a logical +page section. These can be changed from the default +characters \fB"\\:"\fP to two user-specified characters. If only one +character is entered, the second character shall remain the +default character \fB':'\fP . +.TP 7 +\fB-f\ \fP \fItype\fP +Specify the same as \fBb\fP \fItype\fP except for footer. The default +for logical page footer shall be \fBn\fP (no lines +numbered). +.TP 7 +\fB-h\ \fP \fItype\fP +Specify the same as \fBb\fP \fItype\fP except for header. The default +\fItype\fP for logical page header shall be \fBn\fP +(no lines numbered). +.TP 7 +\fB-i\ \fP \fIincr\fP +Specify the increment value used to number logical page lines. The +default shall be 1. +.TP 7 +\fB-l\ \fP \fInum\fP +Specify the number of blank lines to be considered as one. For example, +\fB-l\ 2\fP results in only the second adjacent +blank line being numbered (if the appropriate \fB-h\ a\fP, \fB-b\ a\fP, +or \fB-f\ a\fP option is set). The default +shall be 1. +.TP 7 +\fB-n\ \fP \fIformat\fP +Specify the line numbering format. Recognized values are: \fBln\fP, +left justified, leading zeros suppressed; \fBrn\fP, right +justified, leading zeros suppressed; \fBrz\fP, right justified, leading +zeros kept. The default \fIformat\fP shall be \fBrn\fP +(right justified). +.TP 7 +\fB-p\fP +Specify that numbering should not be restarted at logical page delimiters. +.TP 7 +\fB-s\ \fP \fIsep\fP +Specify the characters used in separating the line number and the +corresponding text line. The default \fIsep\fP shall be a +<tab>. +.TP 7 +\fB-v\ \fP \fIstartnum\fP +Specify the initial value used to number logical page lines. The default +shall be 1. +.TP 7 +\fB-w\ \fP \fIwidth\fP +Specify the number of characters to be used for the line number. The +default \fIwidth\fP shall be 6. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a text file to be line-numbered. +.sp +.SH STDIN +.LP +The standard input is a text file that is used if no \fIfile\fP operand +is given. +.SH INPUT FILES +.LP +The input file named by the \fIfile\fP operand is a text file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fInl\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +behavior of character classes within regular expressions, and +for deciding which characters are in character class \fBgraph\fP (for +the \fB-b\ t\fP, \fB-f\ t\fP, and \fB-h\ t\fP +options). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be a text file in the following format: +.sp +.RS +.nf + +\fB"%s%s%s", <\fP\fIline number\fP\fB>, <\fP\fIseparator\fP\fB>, <\fP\fIinput line\fP\fB> +\fP +.fi +.RE +.LP +where <\fIline\ number\fP> is one of the following numeric formats: +.TP 7 +\fB%6d\fP +When the \fBrn\fP format is used (the default; see \fB-n\fP). +.TP 7 +\fB%06d\fP +When the \fBrz\fP format is used. +.TP 7 +\fB%-6d\fP +When the \fBln\fP format is used. +.TP 7 +<empty> +When line numbers are suppressed for a portion of the page; the <\fIseparator\fP> +is also suppressed. +.sp +.LP +In the preceding list, the number 6 is the default width; the \fB-w\fP +option can change this value. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +In using the \fB-d\fP \fIdelim\fP option, care should be taken to +escape characters that have special meaning to the command +interpreter. +.SH EXAMPLES +.LP +The command: +.sp +.RS +.nf + +\fBnl -v 10 -i 10 -d \\!+ file1 +\fP +.fi +.RE +.LP +numbers \fIfile1\fP starting at line number 10 with an increment of +10. The logical page delimiter is \fB"!+"\fP . Note that +the \fB'!'\fP has to be escaped when using \fIcsh\fP as a command +interpreter because of its history substitution syntax. For +\fIksh\fP and \fIsh\fP the escape is not necessary, but does not do +any harm. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIpr\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/nm.1p b/man1p/nm.1p new file mode 100644 index 000000000..20a1dbb64 --- /dev/null +++ b/man1p/nm.1p @@ -0,0 +1,392 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "NM" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" nm +.SH NAME +nm \- write the name list of an object file (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBnm\fP \fB[\fP\fB-APv\fP\fB][\fP\fB-efox\fP\fB][\fP \fB-g| -u\fP\fB][\fP\fB-t\fP +\fIformat\fP\fB]\fP \fIfile\fP\fB... \fP +.SH DESCRIPTION +.LP +This utility shall be provided on systems that support both the User +Portability Utilities option and the Software Development +Utilities option. On other systems it is optional. Certain options +are only available on XSI-conformant systems. +.LP +The \fInm\fP utility shall display symbolic information appearing +in the object file, executable file, or object-file library +named by \fIfile\fP. If no symbolic information is available for a +valid input file, the \fInm\fP utility shall report that fact, +but not consider it an error condition. +.LP +The default base used when numeric values are written is unspecified. +\ On XSI-conformant systems, it shall be decimal. +.SH OPTIONS +.LP +The \fInm\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-A\fP +Write the full pathname or library name of an object on each line. +.TP 7 +\fB-e\fP +Write only external (global) and static symbol information. +.TP 7 +\fB-f\fP +Produce full output. Write redundant symbols ( \fB.text\fP, \fB.data\fP, +and \fB.bss\fP), normally suppressed. +.TP 7 +\fB-g\fP +Write only external (global) symbol information. +.TP 7 +\fB-o\fP +Write numeric values in octal (equivalent to \fB-t\ o\fP). +.TP 7 +\fB-P\fP +Write information in a portable output format, as specified in the +STDOUT section. +.TP 7 +\fB-t\ \fP \fIformat\fP +Write each numeric value in the specified format. The format shall +be dependent on the single character used as the +\fIformat\fP option-argument: +.TP 7 +\fBd\fP +.RS +The offset is written in decimal \ (default). +.RE +.TP 7 +\fBo\fP +.RS +The offset is written in octal. +.RE +.TP 7 +\fBx\fP +.RS +The offset is written in hexadecimal. +.RE +.sp +.TP 7 +\fB-u\fP +Write only undefined symbols. +.TP 7 +\fB-v\fP +Sort output by value instead of alphabetically. +.TP 7 +\fB-x\fP +Write numeric values in hexadecimal (equivalent to \fB-t\ x\fP). +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an object file, executable file, or object-file library. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input file shall be an object file, an object-file library whose +format is the same as those produced by the \fIar\fP utility for link +editing, or an executable file. The \fInm\fP utility may accept additional +implementation-defined object library formats for the input file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fInm\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for character collation information for the symbol-name +and symbol-value collation sequences. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If symbolic information is present in the input files, then for each +file or for each member of an archive, the \fInm\fP +utility shall write the following information to standard output. +By default, the format is unspecified, but the output shall be +sorted alphabetically by symbol name: +.IP " *" 3 +Library or object name, if \fB-A\fP is specified +.LP +.IP " *" 3 +Symbol name +.LP +.IP " *" 3 +Symbol type, which shall either be one of the following single characters +or an implementation-defined type represented by a +single character: +.TP 7 +\fBA\fP +.RS +Global absolute symbol. +.RE +.TP 7 +\fBa\fP +.RS +Local absolute symbol. +.RE +.TP 7 +\fBB\fP +.RS +Global "bss" (that is, uninitialized data space) symbol. +.RE +.TP 7 +\fBb\fP +.RS +Local bss symbol. +.RE +.TP 7 +\fBD\fP +.RS +Global data symbol. +.RE +.TP 7 +\fBd\fP +.RS +Local data symbol. +.RE +.TP 7 +\fBT\fP +.RS +Global text symbol. +.RE +.TP 7 +\fBt\fP +.RS +Local text symbol. +.RE +.TP 7 +\fBU\fP +.RS +Undefined symbol. +.RE +.sp +.LP +.IP " *" 3 +Value of the symbol +.LP +.IP " *" 3 +The size associated with the symbol, if applicable +.LP +.LP +This information may be supplemented by additional information specific +to the implementation. +.LP +If the \fB-P\fP option is specified, the previous information shall +be displayed using the following portable format. The three +versions differ depending on whether \fB-t\ d\fP, \fB-t\ o\fP, or +\fB-t\ x\fP was specified, respectively: +.sp +.RS +.nf + +\fB"%s%s %s %d %d\\n", <\fP\fIlibrary/object name\fP\fB>, <\fP\fIname\fP\fB>, <\fP\fItype\fP\fB>, + <\fP\fIvalue\fP\fB>, <\fP\fIsize\fP\fB> +.sp + +"%s%s %s %o %o\\n", <\fP\fIlibrary/object name\fP\fB>, <\fP\fIname\fP\fB>, <\fP\fItype\fP\fB>, + <\fP\fIvalue\fP\fB>, <\fP\fIsize\fP\fB> +.sp + +"%s%s %s %x %x\\n", <\fP\fIlibrary/object name\fP\fB>, <\fP\fIname\fP\fB>, <\fP\fItype\fP\fB>, + <\fP\fIvalue\fP\fB>, <\fP\fIsize\fP\fB> +\fP +.fi +.RE +where <\fIlibrary/object\ name\fP> shall be formatted as follows: +.IP " *" 3 +If \fB-A\fP is not specified, <\fIlibrary/object\ name\fP> shall be +an empty string. +.LP +.IP " *" 3 +If \fB-A\fP is specified and the corresponding \fIfile\fP operand +does not name a library: +.sp +.RS +.nf + +\fB"%s: ", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +.IP " *" 3 +If \fB-A\fP is specified and the corresponding \fIfile\fP operand +names a library. In this case, +<\fIobject\ file\fP> shall name the object file in the library containing +the symbol being described: +.sp +.RS +.nf + +\fB"%s[%s]: ", <\fP\fIfile\fP\fB>, <\fP\fIobject file\fP\fB> +\fP +.fi +.RE +.LP +.LP +If \fB-A\fP is not specified, then if more than one \fIfile\fP operand +is specified or if only one \fIfile\fP operand is +specified and it names a library, \fInm\fP shall write a line identifying +the object containing the following symbols before the +lines containing those symbols, in the form: +.IP " *" 3 +If the corresponding \fIfile\fP operand does not name a library: +.sp +.RS +.nf + +\fB"%s:\\n", <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +.IP " *" 3 +If the corresponding \fIfile\fP operand names a library; in this case, +<\fIobject\ file\fP> shall be the name of the +file in the library containing the following symbols: +.sp +.RS +.nf + +\fB"%s[%s]:\\n", <\fP\fIfile\fP\fB>, <\fP\fIobject file\fP\fB> +\fP +.fi +.RE +.LP +.LP +If \fB-P\fP is specified, but \fB-t\fP is not, the format shall be +as if \fB-t\ x\fP had been specified. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Mechanisms for dynamic linking make this utility less meaningful when +applied to an executable file because a dynamically linked +executable may omit numerous library routines that would be found +in a statically linked executable. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Historical implementations of \fInm\fP have used different bases for +numeric output and supplied different default types of +symbols that were reported. The \fB-t\fP \fIformat\fP option, similar +to that used in \fIod\fP and \fIstrings\fP, can be used to specify +the numeric +base; \fB-g\fP and \fB-u\fP can be used to restrict the amount of +output or the types of symbols included in the output. +.LP +The compromise of using \fB-t\fP \fIformat\fP \fIversus\fP using \fB-d\fP, +\fB-o\fP, and other similar options was +necessary because of differences in the meaning of \fB-o\fP between +implementations. The \fB-o\fP option from BSD has been +provided here as \fB-A\fP to avoid confusion with the \fB-o\fP from +System V (which has been provided here as \fB-t\fP and as +\fB-o\fP on XSI-conformant systems). +.LP +The option list was significantly reduced from that provided by historical +implementations. +.LP +The \fInm\fP description is a subset of both the System V and BSD +\fInm\fP utilities with no specified default output. +.LP +It was recognized that mechanisms for dynamic linking make this utility +less meaningful when applied to an executable file +(because a dynamically linked executable file may omit numerous library +routines that would be found in a statically linked +executable file), but the value of \fInm\fP during software development +was judged to outweigh other limitations. +.LP +The default output format of \fInm\fP is not specified because of +differences in historical implementations. The \fB-P\fP +option was added to allow some type of portable output format. After +a comparison of the different formats used in SunOS, BSD, +SVR3, and SVR4, it was decided to create one that did not match the +current format of any of these four systems. The format devised +is easy to parse by humans, easy to parse in shell scripts, and does +not need to vary depending on locale (because no English +descriptions are included). All of the systems currently have the +information available to use this format. +.LP +The format given in \fInm\fP STDOUT uses spaces between the fields, +which may be any number of <blank>s required to align +the columns. The single-character types were selected to match historical +practice, and the requirement that implementation +additions also be single characters made parsing the information easier +for shell scripts. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIar\fP , \fIc99\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/nohup.1p b/man1p/nohup.1p new file mode 100644 index 000000000..893218fd9 --- /dev/null +++ b/man1p/nohup.1p @@ -0,0 +1,215 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "NOHUP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" nohup +.SH NAME +nohup \- invoke a utility immune to hangups +.SH SYNOPSIS +.LP +\fBnohup\fP \fIutility\fP \fB[\fP\fIargument\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fInohup\fP utility shall invoke the utility named by the \fIutility\fP +operand with arguments supplied as the +\fIargument\fP operands. At the time the named \fIutility\fP is invoked, +the SIGHUP signal shall be set to be ignored. +.LP +If the standard output is a terminal, all output written by the named +\fIutility\fP to its standard output shall be appended to +the end of the file \fBnohup.out\fP in the current directory. If \fBnohup.out\fP +cannot be created or opened for appending, the +output shall be appended to the end of the file \fBnohup.out\fP in +the directory specified by the \fIHOME\fP environment +variable. If neither file can be created or opened for appending, +\fIutility\fP shall not be invoked. If a file is created, the +file's permission bits shall be set to S_IRUSR | S_IWUSR. +.LP +If the standard error is a terminal, all output written by the named +\fIutility\fP to its standard error shall be redirected to +the same file descriptor as the standard output. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIutility\fP +The name of a utility that is to be invoked. If the \fIutility\fP +operand names any of the special built-in utilities in \fISpecial +Built-In Utilities\fP , the results are undefined. +.TP 7 +\fIargument\fP +Any string to be supplied as an argument when invoking the utility +named by the \fIutility\fP operand. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fInohup\fP: +.TP 7 +\fIHOME\fP +Determine the pathname of the user's home directory: if the output +file \fBnohup.out\fP cannot be created in the current +directory, the \fInohup\fP utility shall use the directory named by +\fIHOME\fP to create the file. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the search path that is used to locate the utility to be +invoked. See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +The \fInohup\fP utility shall take the standard action for all signals +except that SIGHUP shall be ignored. +.SH STDOUT +.LP +If the standard output is not a terminal, the standard output of \fInohup\fP +shall be the standard output generated by the +execution of the \fIutility\fP specified by the operands. Otherwise, +nothing shall be written to the standard output. +.SH STDERR +.LP +If the standard output is a terminal, a message shall be written to +the standard error, indicating the name of the file to which +the output is being appended. The name of the file shall be either +\fBnohup.out\fP or \fB$HOME/nohup.out\fP. +.SH OUTPUT FILES +.LP +If the standard output is a terminal, all output written by the named +\fIutility\fP to the standard output and standard error +is appended to the file \fBnohup.out\fP, which is created if it does +not already exist. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +126 +The utility specified by \fIutility\fP was found but could not be +invoked. +.TP 7 +127 +An error occurred in the \fInohup\fP utility or the utility specified +by \fIutility\fP could not be found. +.sp +.LP +Otherwise, the exit status of \fInohup\fP shall be that of the utility +specified by the \fIutility\fP operand. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIcommand\fP, \fIenv\fP, \fInice\fP, \fInohup\fP, \fItime\fP, +and \fIxargs\fP utilities have been specified to use exit code 127 +if an error occurs so that +applications can distinguish "failure to find a utility" from "invoked +utility exited with an error indication". The value 127 +was chosen because it is not commonly used for other meanings; most +utilities use small values for "normal error conditions" and +the values above 128 can be confused with termination due to receipt +of a signal. The value 126 was chosen in a similar manner to +indicate that the utility could be found, but not invoked. Some scripts +produce meaningful error messages differentiating the 126 +and 127 cases. The distinction between exit codes 126 and 127 is based +on KornShell practice that uses 127 when all attempts to +\fIexec\fP the utility fail with [ENOENT], and uses 126 when any attempt +to \fIexec\fP the utility fails for any other +reason. +.SH EXAMPLES +.LP +It is frequently desirable to apply \fInohup\fP to pipelines or lists +of commands. This can be done by placing pipelines and +command lists in a single file; this file can then be invoked as a +utility, and the \fInohup\fP applies to everything in the +file. +.LP +Alternatively, the following command can be used to apply \fInohup\fP +to a complex command: +.sp +.RS +.nf + +\fBnohup sh -c '\fP\fIcomplex-command-line\fP\fB' +\fP +.fi +.RE +.SH RATIONALE +.LP +The 4.3 BSD version ignores SIGTERM and SIGHUP, and if \fB./nohup.out\fP +cannot be used, it fails instead of trying to use +\fB$HOME/nohup.out\fP. +.LP +The \fIcsh\fP utility has a built-in version of \fInohup\fP that acts +differently from the \fInohup\fP defined in this volume +of IEEE\ Std\ 1003.1-2001. +.LP +The term \fIutility\fP is used, rather than \fIcommand\fP, to highlight +the fact that shell compound commands, pipelines, +special built-ins, and so on, cannot be used directly. However, \fIutility\fP +includes user application programs and shell +scripts, not just the standard utilities. +.LP +Historical versions of the \fInohup\fP utility use default file creation +semantics. Some more recent versions use the +permissions specified here as an added security precaution. +.LP +Some historical implementations ignore SIGQUIT in addition to SIGHUP; +others ignore SIGTERM. An early proposal allowed, but did +not require, SIGQUIT to be ignored. Several reviewers objected that +\fInohup\fP should only modify the handling of SIGHUP as +required by this volume of IEEE\ Std\ 1003.1-2001. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIsh\fP , the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, \fIsignal\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/od.1p b/man1p/od.1p new file mode 100644 index 000000000..dcd16d6b8 --- /dev/null +++ b/man1p/od.1p @@ -0,0 +1,642 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "OD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" od +.SH NAME +od \- dump files in various formats +.SH SYNOPSIS +.LP +\fBod\fP \fB[\fP\fB-v\fP\fB][\fP\fB-A\fP \fIaddress_base\fP\fB][\fP\fB-j\fP +\fIskip\fP\fB][\fP\fB-N\fP +\fIcount\fP\fB][\fP\fB-t\fP \fItype_string\fP\fB]\fP\fB... +.br +\ \ \ \ \ \ \fP \fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +.sp +\fP +.LP +\fBod\fP \fB[\fP\fB-bcdosx\fP\fB][\fP\fIfile\fP\fB] +[[\fP\fB+\fP\fB]\fP\fIoffset\fP\fB[\fP\fB.\fP\fB][\fP\fBb\fP\fB]]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIod\fP utility shall write the contents of its input files to +standard output in a user-specified format. +.SH OPTIONS +.LP +The \fIod\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the order of presentation of the +\fB-t\fP options \ and the \fB-bcdosx\fP options +is significant. +.LP +The following options shall be supported: +.TP 7 +\fB-A\ \fP \fIaddress_base\fP +.sp +Specify the input offset base. See the EXTENDED DESCRIPTION section. +The application shall ensure that the \fIaddress_base\fP +option-argument is a character. The characters \fB'd'\fP , \fB'o'\fP +, and \fB'x'\fP specify that the offset base shall be +written in decimal, octal, or hexadecimal, respectively. The character +\fB'n'\fP specifies that the offset shall not be +written. +.TP 7 +\fB-b\fP +Interpret bytes in octal. This shall be equivalent to \fB-t\ o1\fP. +.TP 7 +\fB-c\fP +Interpret bytes as characters specified by the current setting of +the \fILC_CTYPE\fP category. Certain non-graphic characters +appear as C escapes: \fB"NUL=\\0"\fP , \fB"BS=\\b"\fP , \fB"FF=\\f"\fP +, \fB"NL=\\n"\fP , \fB"CR=\\r"\fP , +\fB"HT=\\t"\fP ; others appear as 3-digit octal numbers. +.TP 7 +\fB-d\fP +Interpret \fIword\fPs (two-byte units) in unsigned decimal. This shall +be equivalent to \fB-t\ u2\fP. +.TP 7 +\fB-j\ \fP \fIskip\fP +Jump over \fIskip\fP bytes from the beginning of the input. The \fIod\fP +utility shall read or seek past the first +\fIskip\fP bytes in the concatenated input files. If the combined +input is not at least \fIskip\fP bytes long, the \fIod\fP +utility shall write a diagnostic message to standard error and exit +with a non-zero exit status. +.LP +By default, the \fIskip\fP option-argument shall be interpreted as +a decimal number. With a leading 0x or 0X, the offset shall +be interpreted as a hexadecimal number; otherwise, with a leading +\fB'0'\fP , the offset shall be interpreted as an octal +number. Appending the character \fB'b'\fP , \fB'k'\fP , or \fB'm'\fP +to offset shall cause it to be interpreted as a +multiple of 512, 1024, or 1048576 bytes, respectively. If the \fIskip\fP +number is hexadecimal, any appended \fB'b'\fP shall be +considered to be the final hexadecimal digit. +.TP 7 +\fB-N\ \fP \fIcount\fP +Format no more than \fIcount\fP bytes of input. By default, \fIcount\fP +shall be interpreted as a decimal number. With a +leading 0x or 0X, \fIcount\fP shall be interpreted as a hexadecimal +number; otherwise, with a leading \fB'0'\fP , it shall be +interpreted as an octal number. If \fIcount\fP bytes of input (after +successfully skipping, if \fB-j\fP \fIskip\fP is specified) +are not available, it shall not be considered an error; the \fIod\fP +utility shall format the input that is available. +.TP 7 +\fB-o\fP +Interpret \fIword\fPs (two-byte units) in octal. This shall be equivalent +to \fB-t\ o2\fP. +.TP 7 +\fB-s\fP +Interpret \fIword\fPs (two-byte units) in signed decimal. This shall +be equivalent to \fB-t\ d2\fP. +.TP 7 +\fB-t\ \fP \fItype_string\fP +.sp +Specify one or more output types. See the EXTENDED DESCRIPTION section. +The application shall ensure that the \fItype_string\fP +option-argument is a string specifying the types to be used when writing +the input data. The string shall consist of the type +specification characters \fBa\fP , \fBc\fP , \fBd\fP , \fBf\fP , \fBo\fP +, \fBu\fP , and \fBx\fP , specifying +named character, character, signed decimal, floating point, octal, +unsigned decimal, and hexadecimal, respectively. The type +specification characters \fBd\fP , \fBf\fP , \fBo\fP , \fBu\fP , and +\fBx\fP can be followed by an optional unsigned +decimal integer that specifies the number of bytes to be transformed +by each instance of the output type. The type specification +character \fBf\fP can be followed by an optional \fBF\fP , \fBD\fP +, or \fBL\fP indicating that the conversion should +be applied to an item of type \fBfloat\fP, \fBdouble\fP, or \fBlong +double\fP, respectively. The type specification characters +\fBd\fP , \fBo\fP , \fBu\fP , and \fBx\fP can be followed by an optional +\fBC\fP , \fBS\fP , \fBI\fP , or +\fBL\fP indicating that the conversion should be applied to an item +of type \fBchar\fP, \fBshort\fP, \fBint\fP, or +\fBlong\fP, respectively. Multiple types can be concatenated within +the same \fItype_string\fP and multiple \fB-t\fP options can +be specified. Output lines shall be written for each type specified +in the order in which the type specification characters are +specified. +.TP 7 +\fB-v\fP +Write all input data. Without the \fB-v\fP option, any number of groups +of output lines, which would be identical to the +immediately preceding group of output lines (except for the byte offsets), +shall be replaced with a line containing only an +asterisk ( \fB'*'\fP ). +.TP 7 +\fB-x\fP +Interpret \fIword\fPs (two-byte units) in hexadecimal. This shall +be equivalent to \fB-t\ x2\fP. +.sp +.LP +Multiple types can be specified by using multiple \fB-bcdostx\fP options. +Output lines are written for each type specified in the +order in which the types are specified. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be read. If no \fIfile\fP operands are specified, +the standard input shall be used. +.LP +If there are no more than two operands, none of the \fB-A\fP, \fB-j\fP, +\fB-N\fP, or \fB-t\fP options is specified, and +either of the following is true: the first character of the last operand +is a plus sign ( \fB'+'\fP ), or there are two operands +and the first character of the last operand is numeric; \ the last +operand shall be interpreted as an offset operand on +XSI-conformant systems. Under these conditions, the results are +unspecified on systems that are not XSI-conformant systems. +.TP 7 +\fB[+]\fP\fIoffset\fP\fB[.][b]\fP +The \fIoffset\fP operand specifies the offset in the file where dumping +is to commence. This operand is normally interpreted as +octal bytes. If \fB'.'\fP is appended, the offset shall be interpreted +in decimal. If \fB'b'\fP is appended, the offset shall +be interpreted in units of 512 bytes. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files can be any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIod\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_NUMERIC\fP +.sp +Determine the locale for selecting the radix character used when writing +floating-point formatted output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the EXTENDED DESCRIPTION section. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The \fIod\fP utility shall copy sequentially each input file to standard +output, transforming the input data according to the +output types specified by the \fB-t\fP option \ or the \fB-bcdosx\fP +options. If no output type is specified, the default output shall +be as if \fB-t\ oS\fP had been +specified. +.LP +The number of bytes transformed by the output type specifier \fBc\fP +may be variable depending on the \fILC_CTYPE\fP +category. +.LP +The default number of bytes transformed by output type specifiers +\fBd\fP , \fBf\fP , \fBo\fP , \fBu\fP , and +\fBx\fP corresponds to the various C-language types as follows. If +the \fIc99\fP compiler +is present on the system, these specifiers shall correspond to the +sizes used by default in that compiler. Otherwise, these sizes +may vary among systems that conform to IEEE\ Std\ 1003.1-2001. +.IP " *" 3 +For the type specifier characters \fBd\fP , \fBo\fP , \fBu\fP , and +\fBx\fP , the default number of bytes shall +correspond to the size of the underlying implementation's basic integer +type. For these specifier characters, the implementation +shall support values of the optional number of bytes to be converted +corresponding to the number of bytes in the C-language types +\fBchar\fP, \fBshort\fP, \fBint\fP, and \fBlong\fP. These numbers +can also be specified by an application as the characters +\fB'C'\fP , \fB'S'\fP , \fB'I'\fP , and \fB'L'\fP , respectively. +The implementation shall also support the values 1, +2, 4, and 8, even if it provides no C-Language types of those sizes. +The implementation shall support the decimal value +corresponding to the C-language type \fBlong long\fP. The byte order +used when interpreting numeric values is +implementation-defined, but shall correspond to the order in which +a constant of the corresponding type is stored in memory on the +system. +.LP +.IP " *" 3 +For the type specifier character \fBf\fP , the default number of bytes +shall correspond to the number of bytes in the +underlying implementation's basic double precision floating-point +data type. The implementation shall support values of the +optional number of bytes to be converted corresponding to the number +of bytes in the C-language types \fBfloat,\fP \fBdouble\fP, +and \fBlong double\fP. These numbers can also be specified by an application +as the characters \fB'F'\fP , \fB'D'\fP , and +\fB'L'\fP , respectively. +.LP +.LP +The type specifier character \fBa\fP specifies that bytes shall be +interpreted as named characters from the International +Reference Version (IRV) of the ISO/IEC\ 646:1991 standard. Only the +least significant seven bits of each byte shall be used for +this type specification. Bytes with the values listed in the following +table shall be written using the corresponding names for +those characters. +.br +.sp +.ce 1 +\fBTable: Named Characters in \fIod\fP\fP +.TS C +center; l2 l2 l2 l2 l2 l2 l2 l. +\fBValue\fP \fBName\fP \fBValue\fP \fBName\fP \fBValue\fP \fBName\fP \fBValue\fP \fBName\fP +\\000 \fBnul\fP \\001 \fBsoh\fP \\002 \fBstx\fP \\003 \fBetx\fP +\\004 \fBeot\fP \\005 \fBenq\fP \\006 \fBack\fP \\007 \fBbel\fP +\\010 \fBbs\fP \\011 \fBht\fP \\012 \fBlf or nl\fP \\013 \fBvt\fP +\\014 \fBff\fP \\015 \fBcr\fP \\016 \fBso\fP \\017 \fBsi\fP +\\020 \fBdle\fP \\021 \fBdc1\fP \\022 \fBdc2\fP \\023 \fBdc3\fP +\\024 \fBdc4\fP \\025 \fBnak\fP \\026 \fBsyn\fP \\027 \fBetb\fP +\\030 \fBcan\fP \\031 \fBem\fP \\032 \fBsub\fP \\033 \fBesc\fP +\\034 \fBfs\fP \\035 \fBgs\fP \\036 \fBrs\fP \\037 \fBus\fP +\\040 \fBsp\fP \\177 \fBdel\fP \ \fB\ \fP \ \fB\ \fP +.TE +.TP 7 +\fBNote:\fP +The \fB"\\012"\fP value may be written either as \fBlf\fP or \fBnl\fP. +.sp +.LP +The type specifier character \fBc\fP specifies that bytes shall be +interpreted as characters specified by the current setting +of the \fILC_CTYPE\fP locale category. Characters listed in the table +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation ( \fB'\\\\'\fP +, +\fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , \fB'\\n'\fP , \fB'\\r'\fP +, \fB'\\t'\fP , \fB'\\v'\fP ) shall be written as +the corresponding escape sequences, except that backslash shall be +written as a single backslash and a NUL shall be written as +\fB'\\0'\fP . Other non-printable characters shall be written as one +three-digit octal number for each byte in the character. If +the size of a byte on the system is greater than nine bits, the format +used for non-printable characters is implementation-defined. +Printable multi-byte characters shall be written in the area corresponding +to the first byte of the character; the two-character +sequence \fB"**"\fP shall be written in the area corresponding to +each remaining byte in the character, as an indication that +the character is continued. When either the \fB-j\fP \fIskip\fP or +\fB-N\fP \fIcount\fP option is specified along with the +\fBc\fP type specifier, and this results in an attempt to start or +finish in the middle of a multi-byte character, the result is +implementation-defined. +.LP +The input data shall be manipulated in blocks, where a block is defined +as a multiple of the least common multiple of the number +of bytes transformed by the specified output types. If the least common +multiple is greater than 16, the results are unspecified. +Each input block shall be written as transformed by each output type, +one per written line, in the order that the output types were +specified. If the input block size is larger than the number of bytes +transformed by the output type, the output type shall +sequentially transform the parts of the input block, and the output +from each of the transformations shall be separated by one or +more <blank>s. +.LP +If, as a result of the specification of the \fB-N\fP option or end-of-file +being reached on the last input file, input data +only partially satisfies an output type, the input shall be extended +sufficiently with null bytes to write the last byte of the +input. +.LP +Unless \fB-A\ n\fP is specified, the first output line produced for +each input block shall be preceded by the input offset, +cumulative across input files, of the next byte to be written. The +format of the input offset is unspecified; however, it shall not +contain any <blank>s, shall start at the first character of the output +line, and shall be followed by one or more +<blank>s. In addition, the offset of the byte following the last byte +written shall be written after all the input data has +been processed, but shall not be followed by any <blank>s. +.LP +If no \fB-A\fP option is specified, the input offset base is unspecified. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were processed successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +XSI-conformant applications are warned not to use filenames starting +with \fB'+'\fP or a first operand starting with a +numeric character so that the old functionality can be maintained +by implementations, unless they specify one of the \fB-A\fP, +\fB-j\fP, or \fB-N\fP options. To guarantee that one of these filenames +is always interpreted as a filename, an application could +always specify the address base format with the \fB-A\fP option. +.SH EXAMPLES +.LP +If a file containing 128 bytes with decimal values zero to 127, in +increasing order, is supplied as standard input to the +command: +.sp +.RS +.nf + +\fBod -A d -t a +\fP +.fi +.RE +.LP +on an implementation using an input block size of 16 bytes, the standard +output, independent of the current locale setting, +would be similar to: +.sp +.RS +.nf + +\fB0000000 nul soh stx etx eot enq ack bel bs ht nl vt ff cr so si +0000016 dle dc1 dc2 dc3 dc4 nak syn etb can em sub esc fs gs rs us +0000032 sp ! " # $ % & ' ( ) * + , - . / +0000048 0 1 2 3 4 5 6 7 8 9 : ; < = > ? +0000064 @ A B C D E F G H I J K L M N O +0000080 P Q R S T U V W X Y Z [ \\ ] ^ _ +0000096 ` a b c d e f g h i j k l m n o +0000112 p q r s t u v w x y z { | } ~ del +0000128 +\fP +.fi +.RE +.LP +Note that this volume of IEEE\ Std\ 1003.1-2001 allows \fBnl\fP or +\fBlf\fP to be used as the name for the +ISO/IEC\ 646:1991 standard IRV character with decimal value 10. The +IRV names this character \fBlf\fP (line feed), but +traditional implementations have referred to this character as newline +( \fBnl\fP) and the POSIX locale character set symbolic +name for the corresponding character is a <newline>. +.LP +The command: +.sp +.RS +.nf + +\fBod -A o -t o2x2x -N 18 +\fP +.fi +.RE +.LP +on a system with 32-bit words and an implementation using an input +block size of 16 bytes could write 18 bytes in approximately +the following format: +.sp +.RS +.nf + +\fB0000000 032056 031440 041123 042040 052516 044530 020043 031464 + 342e 3320 4253 4420 554e 4958 2023 3334 + 342e3320 42534420 554e4958 20233334 +0000020 032472 + 353a + 353a0000 +0000022 +\fP +.fi +.RE +.LP +The command: +.sp +.RS +.nf + +\fBod -A d -t f -t o4 -t x4 -N 24 -j 0x15 +\fP +.fi +.RE +.LP +on a system with 64-bit doubles (for example, IEEE\ Std\ 754-1985 +double precision floating-point format) would skip 21 +bytes of input data and then write 24 bytes in approximately the following +format: +.sp +.RS +.nf + +\fB0000000 1.00000000000000e+00 1.57350000000000e+01 + 07774000000 00000000000 10013674121 35341217270 + 3ff00000 00000000 402f3851 eb851eb8 +0000016 1.40668230000000e+02 + 10030312542 04370303230 + 40619562 23e18698 +0000024 +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fIod\fP utility went through several names in early proposals, +including \fIhd\fP, \fIxd\fP, and most recently +\fIhexdump\fP. There were several objections to all of these based +on the following reasons: +.IP " *" 3 +The \fIhd\fP and \fIxd\fP names conflicted with historical utilities +that behaved differently. +.LP +.IP " *" 3 +The \fIhexdump\fP description was much more complex than needed for +a simple dump utility. +.LP +.IP " *" 3 +The \fIod\fP utility has been available on all historical implementations +and there was no need to create a new name for a +utility so similar to the historical \fIod\fP utility. +.LP +.LP +The original reasons for not standardizing historical \fIod\fP were +also fairly widespread. Those reasons are given below along +with rationale explaining why the standard developers believe that +this version does not suffer from the indicated problem: +.IP " *" 3 +The BSD and System V versions of \fIod\fP have diverged, and the intersection +of features provided by both does not meet the +needs of the user community. In fact, the System V version only provides +a mechanism for dumping octal bytes and \fBshort\fPs, +signed and unsigned decimal \fBshort\fPs, hexadecimal \fBshort\fPs, +and ASCII characters. BSD added the ability to dump +\fBfloat\fPs, \fBdouble\fPs, named ASCII characters, and octal, signed +decimal, unsigned decimal, and hexadecimal \fBlong\fPs. +The version presented here provides more normalized forms for dumping +bytes, \fBshort\fPs, \fBint\fPs, and \fBlong\fPs in octal, +signed decimal, unsigned decimal, and hexadecimal; \fBfloat\fP, \fBdouble\fP, +and \fBlong double\fP; and named ASCII as well as +current locale characters. +.LP +.IP " *" 3 +It would not be possible to come up with a compatible superset of +the BSD and System V flags that met the requirements of the +standard developers. The historical default \fIod\fP output is the +specified default output of this utility. None of the option +letters chosen for this version of \fIod\fP conflict with any of the +options to historical versions of \fIod\fP. +.LP +.IP " *" 3 +On systems with different sizes for \fBshort\fP, \fBint\fP, and \fBlong\fP, +there was no way to ask for dumps of \fBint\fPs, +even in the BSD version. Because of the way options are named, the +name space could not be extended to solve these problems. This +is why the \fB-t\fP option was added (with type specifiers more closely +matched to the \fIprintf\fP() formats used in the rest of this volume +of IEEE\ Std\ 1003.1-2001) and the +optional field sizes were added to the \fBd\fP , \fBf\fP , \fBo\fP +, \fBu\fP , and \fBx\fP type specifiers. It is +also one of the reasons why the historical practice was not mandated +as a required obsolescent form of \fIod\fP. (Although the old +versions of \fIod\fP are not listed as an obsolescent form, implementations +are urged to continue to recognize the older forms for +several more years.) The \fBa\fP , \fBc\fP , \fBf\fP , \fBo\fP , and +\fBx\fP types match the meaning of the +corresponding format characters in the historical implementations +of \fIod\fP except for the default sizes of the fields +converted. The \fBd\fP format is signed in this volume of IEEE\ Std\ 1003.1-2001 +to match the \fIprintf\fP() notation. (Historical versions of \fIod\fP +used \fBd\fP as a synonym for +\fBu\fP in this version. The System V implementation uses \fBs\fP +for signed decimal; BSD uses \fBi\fP for signed decimal +and \fBs\fP for null-terminated strings.) Other than \fBd\fP and \fBu\fP +, all of the type specifiers match format +characters in the historical BSD version of \fBod\fP. +.LP +The sizes of the C-language types \fBchar\fP, \fBshort\fP, \fBint\fP, +\fBlong\fP, \fBfloat\fP, \fBdouble\fP, and \fBlong +double\fP are used even though it is recognized that there may be +zero or more than one compiler for the C language on an +implementation and that they may use different sizes for some of these +types. (For example, one compiler might use 2 bytes +\fBshort\fPs, 2 bytes \fBint\fPs, and 4 bytes \fBlong\fPs, while another +compiler (or an option to the same compiler) uses 2 +bytes \fBshort\fPs, 4 bytes \fBint\fPs, and 4 bytes \fBlong\fPs.) +Nonetheless, there has to be a basic size known by the +implementation for these types, corresponding to the values reported +by invocations of the \fIgetconf\fP utility when called with \fIsystem_var\fP +operands {UCHAR_MAX}, {USHORT_MAX}, +{UINT_MAX}, and {ULONG_MAX} for the types \fBchar\fP, \fBshort\fP, +\fBint\fP, and \fBlong\fP, respectively. There are similar +constants required by the ISO\ C standard, but not required by the +System Interfaces volume of IEEE\ Std\ 1003.1-2001 +or this volume of IEEE\ Std\ 1003.1-2001. They are {FLT_MANT_DIG}, +{DBL_MANT_DIG}, and {LDBL_MANT_DIG} for the types +\fBfloat\fP, \fBdouble\fP, and \fBlong double\fP, respectively. If +the optional \fIc99\fP +utility is provided by the implementation and used as specified by +this volume of IEEE\ Std\ 1003.1-2001, these are the +sizes that would be provided. If an option is used that specifies +different sizes for these types, there is no guarantee that the +\fIod\fP utility is able to interpret binary data output by such a +program correctly. +.LP +This volume of IEEE\ Std\ 1003.1-2001 requires that the numeric values +of these lengths be recognized by the \fIod\fP +utility and that symbolic forms also be recognized. Thus, a conforming +application can always look at an array of \fBunsigned +long\fP data elements using \fIod\fP \fB-t\fP \fIuL\fP. +.LP +.IP " *" 3 +The method of specifying the format for the address field based on +specifying a starting offset in a file unnecessarily tied the +two together. The \fB-A\fP option now specifies the address base and +the \fB-S\fP option specifies a starting offset. +.LP +.IP " *" 3 +It would be difficult to break the dependence on U.S. ASCII to achieve +an internationalized utility. It does not seem to be any +harder for \fIod\fP to dump characters in the current locale than +it is for the \fIed\fP or \fIsed\fP \fBl\fP commands. The \fBc\fP +type specifier does this without difficulty and is +completely compatible with the historical implementations of the \fBc\fP +format character when the current locale uses a superset +of the ISO/IEC\ 646:1991 standard as a codeset. The \fBa\fP type specifier +(from the BSD \fBa\fP format character) was left +as a portable means to dump ASCII (or more correctly ISO/IEC\ 646:1991 +standard (IRV)) so that headers produced by \fIpax\fP could be deciphered +even on systems that do not use the ISO/IEC\ 646:1991 standard as +a +subset of their base codeset. +.LP +.LP +The use of \fB"**"\fP as an indication of continuation of a multi-byte +character in \fBc\fP specifier output was chosen +based on seeing an implementation that uses this method. The continuation +bytes have to be marked in a way that is not ambiguous +with another single-byte or multi-byte character. +.LP +An early proposal used \fB-S\fP and \fB-n\fP, respectively, for the +\fB-j\fP and \fB-N\fP options eventually selected. These +were changed to avoid conflicts with historical implementations. +.LP +The original standard specified \fB-t o2\fP as the default when no +output type was given. This was changed to \fB-t oS\fP (the +length of a \fBshort\fP) to accommodate a supercomputer implementation +that historically used 64 bits as its default (and that +defined shorts as 64 bits). This change should not affect conforming +applications. The requirement to support lengths of 1, 2, and +4 was added at the same time to address an historical implementation +that had no two-byte data types in its C compiler. +.LP +The use of a basic integer data type is intended to allow the implementation +to choose a word size commonly used by applications +on that architecture. +.SH FUTURE DIRECTIONS +.LP +All option and operand interfaces marked as extensions may be withdrawn +in a future version. +.SH SEE ALSO +.LP +\fIc99\fP , \fIsed\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/paste.1p b/man1p/paste.1p new file mode 100644 index 000000000..de6c38b39 --- /dev/null +++ b/man1p/paste.1p @@ -0,0 +1,300 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PASTE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" paste +.SH NAME +paste \- merge corresponding or subsequent lines of files +.SH SYNOPSIS +.LP +\fBpaste\fP \fB[\fP\fB-s\fP\fB][\fP\fB-d\fP \fIlist\fP\fB]\fP \fIfile\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fIpaste\fP utility shall concatenate the corresponding lines +of the given input files, and write the resulting lines to +standard output. +.LP +The default operation of \fIpaste\fP shall concatenate the corresponding +lines of the input files. The <newline> of every +line except the line from the last input file shall be replaced with +a <tab>. +.LP +If an end-of-file condition is detected on one or more input files, +but not all input files, \fIpaste\fP shall behave as though +empty lines were read from the files on which end-of-file was detected, +unless the \fB-s\fP option is specified. +.SH OPTIONS +.LP +The \fIpaste\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-d\ \fP \fIlist\fP +Unless a backslash character appears in \fIlist\fP, each character +in \fIlist\fP is an element specifying a delimiter +character. If a backslash character appears in \fIlist\fP, the backslash +character and one or more characters following it are an +element specifying a delimiter character as described below. These +elements specify one or more delimiters to use, instead of the +default <tab>, to replace the <newline> of the input lines. The elements +in \fIlist\fP shall be used circularly; that +is, when the list is exhausted the first element from the list is +reused. When the \fB-s\fP option is specified: +.RS +.IP " *" 3 +The last <newline> in a file shall not be modified. +.LP +.IP " *" 3 +The delimiter shall be reset to the first element of \fIlist\fP after +each \fIfile\fP operand is processed. +.LP +.RE +.LP +When the \fB-s\fP option is not specified: +.RS +.IP " *" 3 +The <newline>s in the file specified by the last \fIfile\fP operand +shall not be modified. +.LP +.IP " *" 3 +The delimiter shall be reset to the first element of list each time +a line is processed from each file. +.LP +.RE +.LP +If a backslash character appears in \fIlist\fP, it and the character +following it shall be used to represent the following +delimiter characters: +.TP 7 +\fB\\n\fP +.RS +<newline>. +.RE +.TP 7 +\fB\\t\fP +.RS +<tab>. +.RE +.TP 7 +\fB\\\\\fP +.RS +Backslash character. +.RE +.TP 7 +\fB\\0\fP +.RS +Empty string (not a null character). If \fB'\\0'\fP is immediately +followed by the character \fB'x'\fP , the character +\fB'X'\fP , or any character defined by the \fILC_CTYPE\fP \fBdigit\fP +keyword (see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 7, Locale), the results are unspecified. +.RE +.sp +.LP +If any other characters follow the backslash, the results are unspecified. +.TP 7 +\fB-s\fP +Concatenate all of the lines of each separate input file in command +line order. The <newline> of every line except the +last line in each input file shall be replaced with the <tab>, unless +otherwise specified by the \fB-d\fP option. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If \fB'-'\fP is specified for one or +more of the \fIfile\fPs, the standard input shall be +used; the standard input shall be read one line at a time, circularly, +for each instance of \fB'-'\fP . Implementations shall +support pasting of at least 12 \fIfile\fP operands. +.sp +.SH STDIN +.LP +The standard input shall be used only if one or more \fIfile\fP operands +is \fB'-'\fP . See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files, except that line lengths shall +be unlimited. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIpaste\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Concatenated lines of input files shall be separated by the <tab> +(or other characters under the control of the \fB-d\fP +option) and terminated by a <newline>. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If one or more input files cannot be opened when the \fB-s\fP option +is not specified, a diagnostic message shall be written to +standard error, but no output is written to standard output. If the +\fB-s\fP option is specified, the \fIpaste\fP utility shall +provide the default behavior described in \fIUtility Description Defaults\fP +\&. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +When the escape sequences of the \fIlist\fP option-argument are used +in a shell script, they must be quoted; otherwise, the +shell treats the \fB'\\'\fP as a special character. +.LP +Conforming applications should only use the specific backslash escaped +delimiters presented in this volume of +IEEE\ Std\ 1003.1-2001. Historical implementations treat \fB'\\x'\fP +, where \fB'x'\fP is not in this list, as +\fB'x'\fP , but future implementations are free to expand this list +to recognize other common escapes similar to those accepted +by \fIprintf\fP and other standard utilities. +.LP +Most of the standard utilities work on text files. The \fIcut\fP utility +can be used to +turn files with arbitrary line lengths into a set of text files containing +the same data. The \fIpaste\fP utility can be used to +create (or recreate) files with arbitrary line lengths. For example, +if \fIfile\fP contains long lines: +.sp +.RS +.nf + +\fBcut -b 1-500 -n file > file1 +cut -b 501- -n file > file2 +\fP +.fi +.RE +.LP +creates \fBfile1\fP (a text file) with lines no longer than 500 bytes +(plus the <newline>) and \fBfile2\fP that contains +the remainder of the data from \fIfile\fP. Note that \fBfile2\fP is +not a text file if there are lines in \fIfile\fP that are +longer than 500 + {LINE_MAX} bytes. The original file can be recreated +from \fBfile1\fP and \fBfile2\fP using the command: +.sp +.RS +.nf + +\fBpaste -d "\\0" file1 file2 > file +\fP +.fi +.RE +.LP +The commands: +.sp +.RS +.nf + +\fBpaste -d "\\0" ... +paste -d "" ... +\fP +.fi +.RE +.LP +are not necessarily equivalent; the latter is not specified by this +volume of IEEE\ Std\ 1003.1-2001 and may result in +an error. The construct \fB'\\0'\fP is used to mean "no separator" +because historical versions of \fIpaste\fP did not follow +the syntax guidelines, and the command: +.sp +.RS +.nf + +\fBpaste -d"" ... +\fP +.fi +.RE +.LP +could not be handled properly by \fIgetopt\fP(). +.SH EXAMPLES +.IP " 1." 4 +Write out a directory in four columns: +.sp +.RS +.nf + +\fBls | paste - - - - +\fP +.fi +.RE +.LP +.IP " 2." 4 +Combine pairs of lines from a file into single lines: +.sp +.RS +.nf + +\fBpaste -s -d "\\t\\n" file +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIUtility Description Defaults\fP , \fIcut\fP , \fIgrep\fP , \fIpr\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/patch.1p b/man1p/patch.1p new file mode 100644 index 000000000..7bd5bc260 --- /dev/null +++ b/man1p/patch.1p @@ -0,0 +1,509 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PATCH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" patch +.SH NAME +patch \- apply changes to files +.SH SYNOPSIS +.LP +\fBpatch\fP \fB[\fP\fB-blNR\fP\fB][\fP \fB-c| -e| -n\fP\fB][\fP\fB-d\fP +\fIdir\fP\fB][\fP\fB-D\fP \fIdefine\fP\fB][\fP\fB-i\fP \fIpatchfile\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-o\fP \fIoutfile\fP\fB][\fP\fB-p\fP +\fInum\fP\fB][\fP\fB-r\fP \fIrejectfile\fP\fB][\fP\fIfile\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIpatch\fP utility shall read a source (patch) file containing +any of the three forms of difference (diff) listings +produced by the \fIdiff\fP utility (normal, context, or in the style +of \fIed\fP) and apply those differences to a file. By default, \fIpatch\fP +shall read from the standard +input. +.LP +The \fIpatch\fP utility shall attempt to determine the type of the +\fIdiff\fP listing, +unless overruled by a \fB-c\fP, \fB-e\fP, or \fB-n\fP option. +.LP +If the patch file contains more than one patch, \fIpatch\fP shall +attempt to apply each of them as if they came from separate +patch files. (In this case, the application shall ensure that the +name of the patch file is determinable for each \fIdiff\fP listing.) +.SH OPTIONS +.LP +The \fIpatch\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-b\fP +Save a copy of the original contents of each modified file, before +the differences are applied, in a file of the same name with +the suffix \fB.orig\fP appended to it. If the file already exists, +it shall be overwritten; if multiple patches are applied to the +same file, the \fB.orig\fP file shall be written only for the first +patch. When the \fB-o\fP \fIoutfile\fP option is also +specified, \fIfile\fP \fB.orig\fP shall not be created but, if \fIoutfile\fP +already exists, \fIoutfile\fP \fB.orig\fP shall +be created. +.TP 7 +\fB-c\fP +Interpret the patch file as a context difference (the output of the +utility \fIdiff\fP +when the \fB-c\fP or \fB-C\fP options are specified). +.TP 7 +\fB-d\ \fP \fIdir\fP +Change the current directory to \fIdir\fP before processing as described +in the EXTENDED DESCRIPTION section. +.TP 7 +\fB-D\ \fP \fIdefine\fP +Mark changes with one of the following C preprocessor constructs: +.sp +.RS +.nf + +\fB#ifdef define +\&... +#endif +.sp + +#ifndef define +\&... +#endif +\fP +.fi +.RE +.LP +optionally combined with the C preprocessor construct \fB#else\fP. +If the patched file is processed with the C preprocessor, +where the macro \fIdefine\fP is defined, the output shall contain +the changes from the patch file; otherwise, the output shall not +contain the patches specified in the patch file. +.TP 7 +\fB-e\fP +Interpret the patch file as an \fIed\fP script, rather than a \fIdiff\fP +script. +.TP 7 +\fB-i\ \fP \fIpatchfile\fP +Read the patch information from the file named by the pathname \fIpatchfile\fP, +rather than the standard input. +.TP 7 +\fB-l\fP +(The letter ell.) Cause any sequence of <blank>s in the difference +script to match any sequence of <blank>s in the +input file. Other characters shall be matched exactly. +.TP 7 +\fB-n\fP +Interpret the script as a normal difference. +.TP 7 +\fB-N\fP +Ignore patches where the differences have already been applied to +the file; by default, already-applied patches shall be +rejected. +.TP 7 +\fB-o\ \fP \fIoutfile\fP +Instead of modifying the files (specified by the \fIfile\fP operand +or the difference listings) directly, write a copy of the +file referenced by each patch, with the appropriate differences applied, +to \fIoutfile\fP. Multiple patches for a single file +shall be applied to the intermediate versions of the file created +by any previous patches, and shall result in multiple, +concatenated versions of the file being written to \fIoutfile\fP. +.TP 7 +\fB-p\ \fP \fInum\fP +For all pathnames in the patch file that indicate the names of files +to be patched, delete \fInum\fP pathname components from +the beginning of each pathname. If the pathname in the patch file +is absolute, any leading slashes shall be considered the first +component (that is, \fB-p\ 1\fP shall remove the leading slashes). +Specifying \fB-p\ 0\fP shall cause the full pathname +to be used. If \fB-p\fP is not specified, only the basename (the final +pathname component) shall be used. +.TP 7 +\fB-R\fP +Reverse the sense of the patch script; that is, assume that the difference +script was created from the new version to the old +version. The \fB-R\fP option cannot be used with \fIed\fP scripts. +The \fIpatch\fP utility +shall attempt to reverse each portion of the script before applying +it. Rejected differences shall be saved in swapped format. If +this option is not specified, and until a portion of the patch file +is successfully applied, \fIpatch\fP attempts to apply each +portion in its reversed sense as well as in its normal sense. If the +attempt is successful, the user shall be prompted to determine +whether the \fB-R\fP option should be set. +.TP 7 +\fB-r\ \fP \fIrejectfile\fP +Override the default reject filename. In the default case, the reject +file shall have the same name as the output file, with +the suffix \fB.rej\fP appended to it; see Patch Application . +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to patch. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +Input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIpatch\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fILC_TIME\fP +Determine the locale for recognizing the format of file timestamps +written by the \fIdiff\fP utility in a context-difference input file. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used for diagnostic and informational +messages. +.SH OUTPUT FILES +.LP +The output of the \fIpatch\fP utility, the save files ( \fB.orig\fP +suffixes), and the reject files ( \fB.rej\fP suffixes) +shall be text files. +.SH EXTENDED DESCRIPTION +.LP +A patch file may contain patching instructions for more than one file; +filenames shall be determined as specified in Filename Determination +\&. When the \fB-b\fP option is specified, for each patched file, the +original shall +be saved in a file of the same name with the suffix \fB.orig\fP appended +to it. +.LP +For each patched file, a reject file may also be created as noted +in Patch Application . In the +absence of a \fB-r\fP option, the name of this file shall be formed +by appending the suffix \fB.rej\fP to the original +filename. +.SS Patch File Format +.LP +The patch file shall contain zero or more lines of header information +followed by one or more patches. Each patch shall contain +zero or more lines of filename identification in the format produced +by \fIdiff\fP \fB-c\fP, +and one or more sets of \fIdiff\fP output, which are customarily called +\fIhunks\fP. +.LP +The \fIpatch\fP utility shall recognize the following expression in +the header information: +.TP 7 +\fBIndex:\ \fP \fIpathname\fP +.sp +The file to be patched is named \fIpathname\fP. +.sp +.LP +If all lines (including headers) within a patch begin with the same +leading sequence of <blank>s, the \fIpatch\fP utility +shall remove this sequence before proceeding. Within each patch, if +the type of difference is context, the \fIpatch\fP utility +shall recognize the following expressions: +.TP 7 +***\ \fIfilename\ timestamp\fP +.sp +The patches arose from \fIfilename\fP. +.TP 7 +---\ \fIfilename\ timestamp\fP +.sp +The patches should be applied to \fIfilename\fP. +.sp +.LP +Each hunk within a patch shall be the \fIdiff\fP output to change +a line range within the +original file. The line numbers for successive hunks within a patch +shall occur in ascending order. +.SS Filename Determination +.LP +If no \fIfile\fP operand is specified, \fIpatch\fP shall perform the +following steps to determine the filename to use: +.IP " 1." 4 +If the type of \fIdiff\fP is context, the \fIpatch\fP utility shall +delete pathname +components (as specified by the \fB-p\fP option) from the filename +on the line beginning with \fB"***"\fP , then test for the +existence of this file relative to the current directory (or the directory +specified with the \fB-d\fP option). If the file +exists, the \fIpatch\fP utility shall use this filename. +.LP +.IP " 2." 4 +If the type of \fIdiff\fP is context, the \fIpatch\fP utility shall +delete the pathname +components (as specified by the \fB-p\fP option) from the filename +on the line beginning with \fB"---"\fP , then test for the +existence of this file relative to the current directory (or the directory +specified with the \fB-d\fP option). If the file +exists, the \fIpatch\fP utility shall use this filename. +.LP +.IP " 3." 4 +If the header information contains a line beginning with the string +\fBIndex:\fP, the \fIpatch\fP utility shall delete +pathname components (as specified by the \fB-p\fP option) from this +line, then test for the existence of this file relative to the +current directory (or the directory specified with the \fB-d\fP option). +If the file exists, the \fIpatch\fP utility shall use +this filename. +.LP +.IP " 4." 4 +If an \fBSCCS\fP directory exists in the current directory, \fIpatch\fP +shall attempt to perform a \fIget\fP \fB-e\fP \fBSCCS/s.\fP \fIfilename\fP +command to retrieve an editable version of the +file. If the file exists, the \fIpatch\fP utility shall use this filename. +.LP +.IP " 5." 4 +The \fIpatch\fP utility shall write a prompt to standard output and +request a filename interactively from the controlling +terminal (for example, \fB/dev/tty\fP). +.LP +.SS Patch Application +.LP +If the \fB-c\fP, \fB-e\fP, or \fB-n\fP option is present, the \fIpatch\fP +utility shall interpret information within each +hunk as a context difference, an \fIed\fP difference, or a normal +difference, respectively. In +the absence of any of these options, the \fIpatch\fP utility shall +determine the type of difference based on the format of +information within the hunk. +.LP +For each hunk, the \fIpatch\fP utility shall begin to search for the +place to apply the patch at the line number at the +beginning of the hunk, plus or minus any offset used in applying the +previous hunk. If lines matching the hunk context are not +found, \fIpatch\fP shall scan both forwards and backwards at least +1000 bytes for a set of lines that match the hunk context. +.LP +If no such place is found and it is a context difference, then another +scan shall take place, ignoring the first and last line +of context. If that fails, the first two and last two lines of context +shall be ignored and another scan shall be made. +Implementations may search more extensively for installation locations. +.LP +If no location can be found, the \fIpatch\fP utility shall append +the hunk to the reject file. The rejected hunk shall be +written in context-difference format regardless of the format of the +patch file. If the input was a normal or \fIed\fP-style difference, +the reject file may contain differences with zero lines of context. +The line +numbers on the hunks in the reject file may be different from the +line numbers in the patch file since they shall reflect the +approximate locations for the failed hunks in the new file rather +than the old one. +.LP +If the type of patch is an \fIed\fP diff, the implementation may accomplish +the patching by +invoking the \fIed\fP utility. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +\ 1 +One or more lines were written to a reject file. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Patches that cannot be correctly placed in the file shall be written +to a reject file. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-R\fP option does not work with \fIed\fP scripts because there +is too little +information to reconstruct the reverse operation. +.LP +The \fB-p\fP option makes it possible to customize a patch file to +local user directory structures without manually editing the +patch file. For example, if the filename in the patch file was: +.sp +.RS +.nf + +\fB/curds/whey/src/blurfl/blurfl.c +\fP +.fi +.RE +.LP +Setting \fB-p\ 0\fP gives the entire pathname unmodified; \fB-p\ 1\fP +gives: +.sp +.RS +.nf + +\fBcurds/whey/src/blurfl/blurfl.c +\fP +.fi +.RE +.LP +without the leading slash, \fB-p\ 4\fP gives: +.sp +.RS +.nf + +\fBblurfl/blurfl.c +\fP +.fi +.RE +.LP +and not specifying \fB-p\fP at all gives: +.sp +.RS +.nf + +\fBblurfl.c . +\fP +.fi +.RE +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Some of the functionality in historical \fIpatch\fP implementations +was not specified. The following documents those features +present in historical implementations that have not been specified. +.LP +A deleted piece of functionality was the \fB'+'\fP pseudo-option allowing +an additional set of options and a patch file +operand to be given. This was seen as being insufficiently useful +to standardize. +.LP +In historical implementations, if the string \fB"Prereq:"\fP appeared +in the header, the \fIpatch\fP utility would search +for the corresponding version information (the string specified in +the header, delimited by <blank>s or the beginning or end +of a line or the file) anywhere in the original file. This was deleted +as too simplistic and insufficiently trustworthy a mechanism +to standardize. For example, if: +.sp +.RS +.nf + +\fBPrereq: 1.2 +\fP +.fi +.RE +.LP +were in the header, the presence of a delimited 1.2 anywhere in the +file would satisfy the prerequisite. +.LP +The following options were dropped from historical implementations +of \fIpatch\fP as insufficiently useful to standardize: +.TP 7 +\fB-b\fP +The \fB-b\fP option historically provided a method for changing the +name extension of the backup file from the default +\fB\&.orig\fP. This option has been modified and retained in this volume +of IEEE\ Std\ 1003.1-2001. +.TP 7 +\fB-F\fP +The \fB-F\fP option specified the number of lines of a context diff +to ignore when searching for a place to install a +patch. +.TP 7 +\fB-f\fP +The \fB-f\fP option historically caused \fIpatch\fP not to request +additional information from the user. +.TP 7 +\fB-r\fP +The \fB-r\fP option historically provided a method of overriding the +extension of the reject file from the default +\fB\&.rej\fP. +.TP 7 +\fB-s\fP +The \fB-s\fP option historically caused \fIpatch\fP to work silently +unless an error occurred. +.TP 7 +\fB-x\fP +The \fB-x\fP option historically set internal debugging flags. +.sp +.LP +In some file system implementations, the saving of a \fB.orig\fP file +may produce unwanted results. In the case of 12, 13, or +14-character filenames (on file systems supporting 14-character maximum +filenames), the \fB.orig\fP file overwrites the new file. +The reject file may also exceed this filename limit. It was suggested, +due to some historical practice, that a tilde ( +\fB'~'\fP ) suffix be used instead of \fB.orig\fP and some other character +instead of the \fB.rej\fP suffix. This was +rejected because it is not obvious to the user which file is which. +The suffixes \fB.orig\fP and \fB.rej\fP are clearer and more +understandable. +.LP +The \fB-b\fP option has the opposite sense in some historical implementations-do +not save the \fB.orig\fP file. The default +case here is not to save the files, making \fIpatch\fP behave more +consistently with the other standard utilities. +.LP +The \fB-w\fP option in early proposals was changed to \fB-l\fP to +match historical practice. +.LP +The \fB-N\fP option was included because without it, a non-interactive +application cannot reject previously applied patches. +For example, if a user is piping the output of \fIdiff\fP into the +\fIpatch\fP utility, and +the user only wants to patch a file to a newer version non-interactively, +the \fB-N\fP option is required. +.LP +Changes to the \fB-l\fP option description were proposed to allow +matching across <newline>s in addition to just +<blank>s. Since this is not historical practice, and since some ambiguities +could result, it is suggested that future +developments in this area utilize another option letter, such as \fB-L\fP. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIed\fP , \fIdiff\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/pathchk.1p b/man1p/pathchk.1p new file mode 100644 index 000000000..394f47d1e --- /dev/null +++ b/man1p/pathchk.1p @@ -0,0 +1,358 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PATHCHK" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" pathchk +.SH NAME +pathchk \- check pathnames +.SH SYNOPSIS +.LP +\fBpathchk\fP \fB[\fP\fB-p\fP\fB]\fP \fIpathname\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fIpathchk\fP utility shall check that one or more pathnames are +valid (that is, they could be used to access or create a +file without causing syntax errors) and portable (that is, no filename +truncation results). More extensive portability checks are +provided by the \fB-p\fP option. +.LP +By default, the \fIpathchk\fP utility shall check each component of +each \fIpathname\fP operand based on the underlying file +system. A diagnostic shall be written for each \fIpathname\fP operand +that: +.IP " *" 3 +Is longer than {PATH_MAX} bytes (see \fBPathname Variable Values\fP +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 13, Headers, \fI<limits.h>\fP) +.LP +.IP " *" 3 +Contains any component longer than {NAME_MAX} bytes in its containing +directory +.LP +.IP " *" 3 +Contains any component in a directory that is not searchable +.LP +.IP " *" 3 +Contains any character in any component that is not valid in its containing +directory +.LP +.LP +The format of the diagnostic message is not specified, but shall indicate +the error detected and the corresponding +\fIpathname\fP operand. +.LP +It shall not be considered an error if one or more components of a +\fIpathname\fP operand do not exist as long as a file +matching the pathname specified by the missing components could be +created that does not violate any of the checks specified +above. +.SH OPTIONS +.LP +The \fIpathchk\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-p\fP +Instead of performing checks based on the underlying file system, +write a diagnostic for each \fIpathname\fP operand that: +.RS +.IP " *" 3 +Is longer than {_POSIX_PATH_MAX} bytes (see \fBMinimum Values\fP in +the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 13, Headers, \fI<limits.h>\fP) +.LP +.IP " *" 3 +Contains any component longer than {_POSIX_NAME_MAX} bytes +.LP +.IP " *" 3 +Contains any character in any component that is not in the portable +filename character set +.LP +.RE +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIpathname\fP +A pathname to be checked. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIpathchk\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All \fIpathname\fP operands passed all of the checks. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fItest\fP utility can be used to determine whether a given pathname +names an existing +file; it does not, however, give any indication of whether or not +any component of the pathname was truncated in a directory where +the _POSIX_NO_TRUNC feature is not in effect. The \fIpathchk\fP utility +does not check for file existence; it performs checks to +determine whether a pathname does exist or could be created with no +pathname component truncation. +.LP +The \fInoclobber\fP option in the shell (see the \fIset\fP special +built-in) can be used to +atomically create a file. As with all file creation semantics in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001, it +guarantees atomic creation, but still depends on applications to agree +on conventions and cooperate on the use of files after they +have been created. +.SH EXAMPLES +.LP +To verify that all pathnames in an imported data interchange archive +are legitimate and unambiguous on the current system: +.sp +.RS +.nf + +\fBpax -f archive | sed -e '/ == .*/s///' | xargs pathchk +if [ $? -eq 0 ] +then + pax -r -f archive +else + echo Investigate problems before importing files. + exit 1 +fi +\fP +.fi +.RE +.LP +To verify that all files in the current directory hierarchy could +be moved to any system conforming to the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 that also supports the \fIpax\fP +utility: +.sp +.RS +.nf + +\fBfind . -print | xargs pathchk -p +if [ $? -eq 0 ] +then + pax -w -f archive . +else + echo Portable archive cannot be created. + exit 1 +fi +\fP +.fi +.RE +.LP +To verify that a user-supplied pathname names a readable file and +that the application can create a file extending the given +path without truncation and without overwriting any existing file: +.sp +.RS +.nf + +\fBcase $- in + *C*) reset="";; + *) reset="set +C" + set -C;; +esac +test -r "$path" && pathchk "$path.out" && + rm "$path.out" > "$path.out" +if [ $? -ne 0 ]; then + printf "%s: %s not found or %s.out fails \\ +creation checks.\\n" $0 "$path" "$path" + $reset # Reset the noclobber option in case a trap + # on EXIT depends on it. + exit 1 +fi +$reset +PROCESSING < "$path" > "$path.out" +\fP +.fi +.RE +.LP +The following assumptions are made in this example: +.IP " 1." 4 +\fBPROCESSING\fP represents the code that is used by the application +to use \fB$path\fP once it is verified that +\fB$path.out\fP works as intended. +.LP +.IP " 2." 4 +The state of the \fInoclobber\fP option is unknown when this code +is invoked and should be set on exit to the state it was in +when this code was invoked. (The \fBreset\fP variable is used in this +example to restore the initial state.) +.LP +.IP " 3." 4 +Note the usage of: +.sp +.RS +.nf + +\fBrm "$path.out" > "$path.out" +\fP +.fi +.RE +.RS +.IP " a." 4 +The \fIpathchk\fP command has already verified, at this point, that +\fB$path.out\fP is not truncated. +.LP +.IP " b." 4 +With the \fInoclobber\fP option set, the shell verifies that \fB$path.out\fP +does not already exist before invoking \fIrm\fP. +.LP +.IP " c." 4 +If the shell succeeded in creating \fB$path.out\fP, \fIrm\fP removes +it so that the +application can create the file again in the \fBPROCESSING\fP step. +.LP +.IP " d." 4 +If the \fBPROCESSING\fP step wants the file to exist already when +it is invoked, the: +.sp +.RS +.nf + +\fBrm "$path.out" > "$path.out" +\fP +.fi +.RE +.LP +should be replaced with: +.sp +.RS +.nf + +\fB> "$path.out" +\fP +.fi +.RE +.LP +which verifies that the file did not already exist, but leaves \fB$path.out\fP +in place for use by \fBPROCESSING\fP. +.LP +.RE +.LP +.SH RATIONALE +.LP +The \fIpathchk\fP utility was new for the ISO\ POSIX-2:1993 standard. +It, along with the \fIset\fP \fB-C\fP( \fInoclobber\fP) option added +to the shell, replaces the +\fImktemp\fP, \fIvalidfnam\fP, and \fIcreate\fP utilities that appeared +in early proposals. All of these utilities were attempts +to solve several common problems: +.IP " *" 3 +Verify the validity (for several different definitions of "valid") +of a pathname supplied by a user, generated by an +application, or imported from an external source. +.LP +.IP " *" 3 +Atomically create a file. +.LP +.IP " *" 3 +Perform various string handling functions to generate a temporary +filename. +.LP +.LP +The \fIcreate\fP utility, included in an early proposal, provided +checking and atomic creation in a single invocation of the +utility; these are orthogonal issues and need not be grouped into +a single utility. Note that the \fInoclobber\fP option also +provides a way of creating a lock for process synchronization; since +it provides an atomic \fIcreate\fP, there is no race between +a test for existence and the following creation if it did not exist. +.LP +Having a function like \fItmpnam\fP() in the ISO\ C standard is important +in many +high-level languages. The shell programming language, however, has +built-in string manipulation facilities, making it very easy to +construct temporary filenames. The names needed obviously depend on +the application, but are frequently of a form similar to: +.sp +.RS +.nf + +\fB$TMPDIR/\fP\fIapplication_abbreviation\fP\fB$$.\fP\fIsuffix\fP +.fi +.RE +.LP +In cases where there is likely to be contention for a given suffix, +a simple shell \fBfor\fP or \fBwhile\fP loop can be used +with the shell \fInoclobber\fP option to create a file without risk +of collisions, as long as applications trying to use the same +filename name space are cooperating on the use of files after they +have been created. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIRedirection\fP , \fIset\fP , \fItest\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/pax.1p b/man1p/pax.1p new file mode 100644 index 000000000..8db9e2388 --- /dev/null +++ b/man1p/pax.1p @@ -0,0 +1,2952 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PAX" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" pax +.SH NAME +pax \- portable archive interchange +.SH SYNOPSIS +.LP +\fBpax\fP \fB[\fP\fB-cdnv\fP\fB][\fP\fB-H|-L\fP\fB][\fP\fB-f\fP \fIarchive\fP\fB][\fP\fB-s\fP +\fIreplstr\fP\fB]\fP\fB...\fP\fB[\fP\fIpattern\fP\fB...\fP\fB]\fP\fB +.br +.sp +pax -r\fP\fB[\fP\fB-cdiknuv\fP\fB][\fP\fB-H|-L\fP\fB][\fP\fB-f\fP +\fIarchive\fP\fB][\fP\fB-o\fP +\fIoptions\fP\fB]\fP\fB...\fP\fB[\fP\fB-p\fP \fIstring\fP\fB]\fP\fB... +.br +\ \ \ \ \ \ \fP \fB[\fP\fB-s\fP +\fIreplstr\fP\fB]\fP\fB...\fP\fB[\fP\fIpattern\fP\fB...\fP\fB]\fP\fB +.br +.sp +pax -w\fP\fB[\fP\fB-dituvX\fP\fB][\fP\fB-H|-L\fP\fB][\fP\fB-b\fP +\fIblocksize\fP\fB][[\fP\fB-a\fP\fB][\fP\fB-f\fP \fIarchive\fP\fB][\fP\fB-o\fP +\fIoptions\fP\fB]\fP\fB... +.br +\ \ \ \ \ \ \fP \fB[\fP\fB-s\fP \fIreplstr\fP\fB]\fP\fB...\fP\fB[\fP\fB-x\fP +\fIformat\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +.sp +pax -r -w\fP\fB[\fP\fB-diklntuvX\fP\fB][\fP\fB-H|-L\fP\fB][\fP\fB-p\fP +\fIstring\fP\fB]\fP\fB...\fP\fB[\fP\fB-s\fP \fIreplstr\fP\fB]\fP\fB... +.br +\ \ \ \ \ \ \fP \fB[\fP\fIfile\fP\fB...\fP\fB]\fP \fIdirectory\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIpax\fP utility shall read, write, and write lists of the members +of archive files and copy directory hierarchies. A +variety of archive formats shall be supported; see the \fB-x\fP \fIformat\fP +option. +.LP +The action to be taken depends on the presence of the \fB-r\fP and +\fB-w\fP options. The four combinations of \fB-r\fP and +\fB-w\fP are referred to as the four modes of operation: \fBlist\fP, +\fBread\fP, \fBwrite\fP, and \fBcopy\fP modes, +corresponding respectively to the four forms shown in the SYNOPSIS +section. +.TP 7 +\fBlist\fP +In \fBlist\fP mode (when neither \fB-r\fP nor \fB-w\fP are specified), +\fIpax\fP shall write the names of the members of +the archive file read from the standard input, with pathnames matching +the specified patterns, to standard output. If a named file +is of type directory, the file hierarchy rooted at that file shall +be listed as well. +.TP 7 +\fBread\fP +In \fBread\fP mode (when \fB-r\fP is specified, but \fB-w\fP is not), +\fIpax\fP shall extract the members of the archive +file read from the standard input, with pathnames matching the specified +patterns. If an extracted file is of type directory, the +file hierarchy rooted at that file shall be extracted as well. The +extracted files shall be created performing pathname resolution +with the directory in which \fIpax\fP was invoked as the current working +directory. +.LP +If an attempt is made to extract a directory when the directory already +exists, this shall not be considered an error. If an +attempt is made to extract a FIFO when the FIFO already exists, this +shall not be considered an error. +.LP +The ownership, access, and modification times, and file mode of the +restored files are discussed under the \fB-p\fP option. +.TP 7 +\fBwrite\fP +In \fBwrite\fP mode (when \fB-w\fP is specified, but \fB-r\fP is not), +\fIpax\fP shall write the contents of the +\fIfile\fP operands to the standard output in an archive format. If +no \fIfile\fP operands are specified, a list of files to +copy, one per line, shall be read from the standard input. A file +of type directory shall include all of the files in the file +hierarchy rooted at the file. +.TP 7 +\fBcopy\fP +In \fBcopy\fP mode (when both \fB-r\fP and \fB-w\fP are specified), +\fIpax\fP shall copy the \fIfile\fP operands to the +destination directory. +.LP +If no \fIfile\fP operands are specified, a list of files to copy, +one per line, shall be read from the standard input. A file +of type directory shall include all of the files in the file hierarchy +rooted at the file. +.LP +The effect of the \fBcopy\fP shall be as if the copied files were +written to an archive file and then subsequently extracted, +except that there may be hard links between the original and the copied +files. If the destination directory is a subdirectory of +one of the files to be copied, the results are unspecified. If the +destination directory is a file of a type not defined by the +System Interfaces volume of IEEE\ Std\ 1003.1-2001, the results are +implementation-defined; otherwise, it shall be an error +for the file named by the \fIdirectory\fP operand not to exist, not +be writable by the user, or not be a file of type +directory. +.sp +.LP +In \fBread\fP or \fBcopy\fP modes, if intermediate directories are +necessary to extract an archive member, \fIpax\fP shall +perform actions equivalent to the \fImkdir\fP() function defined in +the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, called with the following arguments: +.IP " *" 3 +The intermediate directory used as the \fIpath\fP argument +.LP +.IP " *" 3 +The value of the bitwise-inclusive OR of S_IRWXU, S_IRWXG, and S_IRWXO +as the \fImode\fP argument +.LP +.LP +If any specified \fIpattern\fP or \fIfile\fP operands are not matched +by at least one file or archive member, \fIpax\fP shall +write a diagnostic message to standard error for each one that did +not match and exit with a non-zero exit status. +.LP +The archive formats described in the EXTENDED DESCRIPTION section +shall be automatically detected on input. The default output +archive format shall be implementation-defined. +.LP +A single archive can span multiple files. The \fIpax\fP utility shall +determine, in an implementation-defined manner, what file +to read or write as the next file. +.LP +If the selected archive format supports the specification of linked +files, it shall be an error if these files cannot be linked +when the archive is extracted. For archive formats that do not store +file contents with each name that causes a hard link, if the +file that contains the data is not extracted during this \fIpax\fP +session, either the data shall be restored from the original +file, or a diagnostic message shall be displayed with the name of +a file that can be used to extract the data. In traversing +directories, \fIpax\fP shall detect infinite loops; that is, entering +a previously visited directory that is an ancestor of the +last file visited. When it detects an infinite loop, \fIpax\fP shall +write a diagnostic message to standard error and shall +terminate. +.SH OPTIONS +.LP +The \fIpax\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the order of presentation of the +\fB-o\fP, \fB-p\fP, and \fB-s\fP options is significant. +.LP +The following options shall be supported: +.TP 7 +\fB-r\fP +Read an archive file from standard input. +.TP 7 +\fB-w\fP +Write files to the standard output in the specified archive format. +.TP 7 +\fB-a\fP +Append files to the end of the archive. It is implementation-defined +which devices on the system support appending. Additional +file formats unspecified by this volume of IEEE\ Std\ 1003.1-2001 +may impose restrictions on appending. +.TP 7 +\fB-b\ \fP \fIblocksize\fP +Block the output at a positive decimal integer number of bytes per +write to the archive file. Devices and archive formats may +impose restrictions on blocking. Blocking shall be automatically determined +on input. Conforming applications shall not specify a +\fIblocksize\fP value larger than 32256. Default blocking when creating +archives depends on the archive format. (See the \fB-x\fP +option below.) +.TP 7 +\fB-c\fP +Match all file or archive members except those specified by the \fIpattern\fP +or \fIfile\fP operands. +.TP 7 +\fB-d\fP +Cause files of type directory being copied or archived or archive +members of type directory being extracted or listed to match +only the file or archive member itself and not the file hierarchy +rooted at the file. +.TP 7 +\fB-f\ \fP \fIarchive\fP +Specify the pathname of the input or output archive, overriding the +default standard input (in \fBlist\fP or \fBread\fP +modes) or standard output ( \fBwrite\fP mode). +.TP 7 +\fB-H\fP +If a symbolic link referencing a file of type directory is specified +on the command line, \fIpax\fP shall archive the file +hierarchy rooted in the file referenced by the link, using the name +of the link as the root of the file hierarchy. Otherwise, if a +symbolic link referencing a file of any other file type which \fIpax\fP +can normally archive is specified on the command line, +then \fIpax\fP shall archive the file referenced by the link, using +the name of the link. The default behavior shall be to archive +the symbolic link itself. +.TP 7 +\fB-i\fP +Interactively rename files or archive members. For each archive member +matching a \fIpattern\fP operand or file matching a +\fIfile\fP operand, a prompt shall be written to the file \fB/dev/tty\fP. +The prompt shall contain the name of the file or +archive member, but the format is otherwise unspecified. A line shall +then be read from \fB/dev/tty\fP. If this line is blank, the +file or archive member shall be skipped. If this line consists of +a single period, the file or archive member shall be processed +with no modification to its name. Otherwise, its name shall be replaced +with the contents of the line. The \fIpax\fP utility shall +immediately exit with a non-zero exit status if end-of-file is encountered +when reading a response or if \fB/dev/tty\fP cannot be +opened for reading and writing. +.LP +The results of extracting a hard link to a file that has been renamed +during extraction are unspecified. +.TP 7 +\fB-k\fP +Prevent the overwriting of existing files. +.TP 7 +\fB-l\fP +(The letter ell.) In \fBcopy\fP mode, hard links shall be made between +the source and destination file hierarchies whenever +possible. If specified in conjunction with \fB-H\fP or \fB-L\fP, when +a symbolic link is encountered, the hard link created in +the destination file hierarchy shall be to the file referenced by +the symbolic link. If specified when neither \fB-H\fP nor +\fB-L\fP is specified, when a symbolic link is encountered, the implementation +shall create a hard link to the symbolic link in +the source file hierarchy or copy the symbolic link to the destination. +.TP 7 +\fB-L\fP +If a symbolic link referencing a file of type directory is specified +on the command line or encountered during the traversal of +a file hierarchy, \fIpax\fP shall archive the file hierarchy rooted +in the file referenced by the link, using the name of the link +as the root of the file hierarchy. Otherwise, if a symbolic link referencing +a file of any other file type which \fIpax\fP can +normally archive is specified on the command line or encountered during +the traversal of a file hierarchy, \fIpax\fP shall archive +the file referenced by the link, using the name of the link. The default +behavior shall be to archive the symbolic link +itself. +.TP 7 +\fB-n\fP +Select the first archive member that matches each \fIpattern\fP operand. +No more than one archive member shall be matched for +each pattern (although members of type directory shall still match +the file hierarchy rooted at that file). +.TP 7 +\fB-o\ \fP \fIoptions\fP +Provide information to the implementation to modify the algorithm +for extracting or writing files. The value of \fIoptions\fP +shall consist of one or more comma-separated keywords of the form: +.sp +.RS +.nf + +\fIkeyword\fP\fB[[\fP\fB:\fP\fB]\fP\fB=\fP\fIvalue\fP\fB][\fP\fB,\fP\fIkeyword\fP\fB[[\fP\fB:\fP\fB]\fP\fB=\fP\fIvalue\fP\fB]\fP\fB, ...\fP\fB]\fP +.fi +.RE +.LP +Some keywords apply only to certain file formats, as indicated with +each description. Use of keywords that are inapplicable to +the file format being processed produces undefined results. +.LP +Keywords in the \fIoptions\fP argument shall be a string that would +be a valid portable filename as described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 3.276, Portable +Filename Character Set. +.TP 7 +\fBNote:\fP +.RS +Keywords are not expected to be filenames, merely to follow the same +character composition rules as portable filenames. +.RE +.sp +.LP +Keywords can be preceded with white space. The \fIvalue\fP field shall +consist of zero or more characters; within \fIvalue\fP, +the application shall precede any literal comma with a backslash, +which shall be ignored, but preserves the comma as part of +\fIvalue\fP. A comma as the final character, or a comma followed solely +by white space as the final characters, in \fIoptions\fP +shall be ignored. Multiple \fB-o\fP options can be specified; if keywords +given to these multiple \fB-o\fP options conflict, the +keywords and values appearing later in command line sequence shall +take precedence and the earlier shall be silently ignored. The +following keyword values of \fIoptions\fP shall be supported for the +file formats as indicated: +.TP 7 +\fBdelete\fP=\fIpattern\fP +.RS +.sp +(Applicable only to the \fB-x\fP \fBpax\fP format.) When used in \fBwrite\fP +or \fBcopy\fP mode, \fIpax\fP shall omit from +extended header records that it produces any keywords matching the +string pattern. When used in \fBread\fP or \fBlist\fP mode, +\fIpax\fP shall ignore any keywords matching the string pattern in +the extended header records. In both cases, matching shall be +performed using the pattern matching notation described in \fIPatterns +Matching a Single +Character\fP and \fIPatterns Matching Multiple Characters\fP . For +example: +.sp +.RS +.nf + +\fB-o\fP \fBdelete\fP\fB=\fP\fIsecurity\fP\fB.* +\fP +.fi +.RE +.LP +would suppress security-related information. See pax Extended Header +for extended header record +keyword usage. +.RE +.TP 7 +\fBexthdr.name\fP=\fIstring\fP +.RS +.sp +(Applicable only to the \fB-x\fP \fBpax\fP format.) This keyword allows +user control over the name that is written into the +\fBustar\fP header blocks for the extended header produced under the +circumstances described in pax +Header Block . The name shall be the contents of \fIstring\fP, after +the following character substitutions have been made: +.TS C +center; l lw(40). +\fB\fIstring\fP\fP T{ +.na +\fB\ \fP +.ad +T} +\fBIncludes:\fP T{ +.na +\fBReplaced By:\fP +.ad +T} +%d T{ +.na +The directory name of the file, equivalent to the result of the \fIdirname\fP utility on the translated pathname. +.ad +T} +%f T{ +.na +The filename of the file, equivalent to the result of the \fIbasename\fP utility on the translated pathname. +.ad +T} +%p T{ +.na +The process ID of the \fIpax\fP process. +.ad +T} +%% T{ +.na +A \fB'%'\fP character. +.ad +T} +.TE +.LP +Any other \fB'%'\fP characters in \fIstring\fP produce undefined results. +.LP +If no \fB-o\fP \fBexthdr.name=\fP \fIstring\fP is specified, \fIpax\fP +shall use the following default value: +.sp +.RS +.nf + +\fB%d/PaxHeaders.%p/%f +\fP +.fi +.RE +.RE +.TP 7 +\fBglobexthdr.name\fP=\fIstring\fP +.RS +.sp +(Applicable only to the \fB-x\fP \fBpax\fP format.) When used in \fBwrite\fP +or \fBcopy\fP mode with the appropriate options, +\fIpax\fP shall create global extended header records with \fBustar\fP +header blocks that will be treated as regular files by +previous versions of \fIpax\fP. This keyword allows user control over +the name that is written into the \fBustar\fP header blocks +for global extended header records. The name shall be the contents +of string, after the following character substitutions have been +made: +.TS C +center; l lw(40). +\fB\fIstring\fP\fP T{ +.na +\fB\ \fP +.ad +T} +\fBIncludes:\fP T{ +.na +\fBReplaced By:\fP +.ad +T} +%n T{ +.na +An integer that represents the sequence number of the global extended header record in the archive, starting at 1. +.ad +T} +%p T{ +.na +The process ID of the \fIpax\fP process. +.ad +T} +%% T{ +.na +A \fB'%'\fP character. +.ad +T} +.TE +.LP +Any other \fB'%'\fP characters in \fIstring\fP produce undefined results. +.LP +If no \fB-o\fP \fBglobexthdr.name=\fP \fIstring\fP is specified, \fIpax\fP +shall use the following default value: +.sp +.RS +.nf + +\fB$TMPDIR/GlobalHead.%p.%n +\fP +.fi +.RE +.LP +where $ \fITMPDIR\fP represents the value of the \fITMPDIR\fP environment +variable. If \fITMPDIR\fP is not set, \fIpax\fP +shall use \fB/tmp\fP. +.RE +.TP 7 +\fBinvalid\fP=\fIaction\fP +.RS +.sp +(Applicable only to the \fB-x\fP \fBpax\fP format.) This keyword allows +user control over the action \fIpax\fP takes upon +encountering values in an extended header record that, in \fBread\fP +or \fBcopy\fP mode, are invalid in the destination hierarchy +or, in \fBlist\fP mode, cannot be written in the codeset and current +locale of the implementation. The following are invalid +values that shall be recognized by \fIpax\fP: +.RS +.IP " *" 3 +In \fBread\fP or \fBcopy\fP mode, a filename or link name that contains +character encodings invalid in the destination +hierarchy. (For example, the name may contain embedded NULs.) +.LP +.IP " *" 3 +In \fBread\fP or \fBcopy\fP mode, a filename or link name that is +longer than the maximum allowed in the destination hierarchy +(for either a pathname component or the entire pathname). +.LP +.IP " *" 3 +In \fBlist\fP mode, any character string value (filename, link name, +user name, and so on) that cannot be written in the +codeset and current locale of the implementation. +.LP +.RE +.LP +The following mutually-exclusive values of the \fIaction\fP argument +are supported: +.TP 7 +\fBbypass\fP +.RS +In \fBread\fP or \fBcopy\fP mode, \fIpax\fP shall bypass the file, +causing no change to the destination hierarchy. In +\fBlist\fP mode, \fIpax\fP shall write all requested valid values +for the file, but its method for writing invalid values is +unspecified. +.RE +.TP 7 +\fBrename\fP +.RS +In \fBread\fP or \fBcopy\fP mode, \fIpax\fP shall act as if the \fB-i\fP +option were in effect for each file with invalid +filename or link name values, allowing the user to provide a replacement +name interactively. In \fBlist\fP mode, \fIpax\fP shall +behave identically to the \fBbypass\fP action. +.RE +.TP 7 +\fBUTF-8\fP +.RS +When used in \fBread\fP, \fBcopy\fP, or \fBlist\fP mode and a filename, +link name, owner name, or any other field in an +extended header record cannot be translated from the \fBpax\fP UTF-8 +codeset format to the codeset and current locale of the +implementation, \fIpax\fP shall use the actual UTF-8 encoding for +the name. +.RE +.TP 7 +\fBwrite\fP +.RS +In \fBread\fP or \fBcopy\fP mode, \fIpax\fP shall write the file, +translating or truncating the name, regardless of whether +this may overwrite an existing file with a valid name. In \fBlist\fP +mode, \fIpax\fP shall behave identically to the +\fBbypass\fP action. +.RE +.sp +.LP +If no \fB-o\fP \fBinvalid=\fP option is specified, \fIpax\fP shall +act as if \fB-o\fP \fBinvalid=\fP \fBbypass\fP were +specified. Any overwriting of existing files that may be allowed by +the \fB-o\fP \fBinvalid=\fP actions shall be subject to +permission ( \fB-p\fP) and modification time ( \fB-u\fP) restrictions, +and shall be suppressed if the \fB-k\fP option is also +specified. +.RE +.TP 7 +\fBlinkdata\fP +.RS +.sp +(Applicable only to the \fB-x\fP \fBpax\fP format.) In \fBwrite\fP +mode, \fIpax\fP shall write the contents of a file to the +archive even when that file is merely a hard link to a file whose +contents have already been written to the archive. +.RE +.TP 7 +\fBlistopt\fP=\fIformat\fP +.RS +.sp +This keyword specifies the output format of the table of contents +produced when the \fB-v\fP option is specified in \fBlist\fP +mode. See List Mode Format Specifications . To avoid ambiguity, the +\fBlistopt=\fP \fIformat\fP +shall be the only or final \fBkeyword=\fP \fIvalue\fP pair in a \fB-o\fP +option-argument; all characters in the remainder of the +option-argument shall be considered part of the format string. When +multiple \fB-o\fP \fBlistopt=\fP \fIformat\fP options are +specified, the format strings shall be considered a single, concatenated +string, evaluated in command line order. +.RE +.TP 7 +\fBtimes\fP +.RS +.sp +(Applicable only to the \fB-x\fP \fIpax\fP format.) When used in \fBwrite\fP +or \fBcopy\fP mode, \fIpax\fP shall include +\fBatime\fP, \fBctime\fP, and \fBmtime\fP extended header records +for each file. See pax Extended +Header File Times . +.RE +.sp +.LP +In addition to these keywords, if the \fB-x\fP \fIpax\fP format is +specified, any of the keywords and values defined in pax Extended +Header , including implementation extensions, can be used in \fB-o\fP +option-arguments, +in either of two modes: +.TP 7 +\fBkeyword\fP=\fIvalue\fP +.RS +.sp +When used in \fBwrite\fP or \fBcopy\fP mode, these keyword/value pairs +shall be included at the beginning of the archive as +\fBtypeflag\fP \fBg\fP global extended header records. When used in +\fBread\fP or \fBlist\fP mode, these keyword/value pairs +shall act as if they had been at the beginning of the archive as \fBtypeflag\fP +\fBg\fP global extended header records. +.RE +.TP 7 +\fBkeyword\fP:=\fIvalue\fP +.RS +.sp +When used in \fBwrite\fP or \fBcopy\fP mode, these keyword/value pairs +shall be included as records at the beginning of a +\fBtypeflag\fP \fBx\fP extended header for each file. (This shall +be equivalent to the equal-sign form except that it creates no +\fBtypeflag\fP \fBg\fP global extended header records.) When used +in \fBread\fP or \fBlist\fP mode, these keyword/value pairs +shall act as if they were included as records at the end of each extended +header; thus, they shall override any global or +file-specific extended header record keywords of the same names. For +example, in the command: +.sp +.RS +.nf + +\fBpax -r -o " +gname:=mygroup, +" <archive +\fP +.fi +.RE +.LP +the group name will be forced to a new value for all files read from +the archive. +.RE +.sp +.LP +The precedence of \fB-o\fP keywords over various fields in the archive +is described in pax Extended +Header Keyword Precedence . +.TP 7 +\fB-p\ \fP \fIstring\fP +Specify one or more file characteristic options (privileges). The +\fIstring\fP option-argument shall be a string specifying +file characteristics to be retained or discarded on extraction. The +string shall consist of the specification characters \fBa\fP +, \fBe\fP , \fBm\fP , \fBo\fP , and \fBp\fP . Other implementation-defined +characters can be included. Multiple +characteristics can be concatenated within the same string and multiple +\fB-p\fP options can be specified. The meaning of the +specification characters are as follows: +.TP 7 +\fBa\fP +.RS +Do not preserve file access times. +.RE +.TP 7 +\fBe\fP +.RS +Preserve the user ID, group ID, file mode bits (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 3.168, File Mode Bits), +access time, modification time, and any other +implementation-defined file characteristics. +.RE +.TP 7 +\fBm\fP +.RS +Do not preserve file modification times. +.RE +.TP 7 +\fBo\fP +.RS +Preserve the user ID and group ID. +.RE +.TP 7 +\fBp\fP +.RS +Preserve the file mode bits. Other implementation-defined file mode +attributes may be preserved. +.RE +.sp +.LP +In the preceding list, "preserve" indicates that an attribute stored +in the archive shall be given to the extracted file, +subject to the permissions of the invoking process. The access and +modification times of the file shall be preserved unless +otherwise specified with the \fB-p\fP option or not stored in the +archive. All attributes that are not preserved shall be +determined as part of the normal file creation action (see \fIFile +Read, Write, and +Creation\fP ). +.LP +If neither the \fBe\fP nor the \fBo\fP specification character is +specified, or the user ID and group ID are not preserved +for any reason, \fIpax\fP shall not set the S_ISUID and S_ISGID bits +of the file mode. +.LP +If the preservation of any of these items fails for any reason, \fIpax\fP +shall write a diagnostic message to standard error. +Failure to preserve these items shall affect the final exit status, +but shall not cause the extracted file to be deleted. +.LP +If file characteristic letters in any of the \fIstring\fP option-arguments +are duplicated or conflict with each other, the ones +given last shall take precedence. For example, if \fB-p\fP \fBeme\fP +is specified, file modification times are preserved. +.TP 7 +\fB-s\ \fP \fIreplstr\fP +Modify file or archive member names named by \fIpattern\fP or \fIfile\fP +operands according to the substitution expression +\fIreplstr\fP, using the syntax of the \fIed\fP utility. The concepts +of "address" and +"line" are meaningless in the context of the \fIpax\fP utility, and +shall not be supplied. The format shall be: +.sp +.RS +.nf + +\fB-s /\fP\fIold\fP\fB/\fP\fInew\fP\fB/\fP\fB[\fP\fBgp\fP\fB]\fP +.fi +.RE +.LP +where as in \fIed\fP, \fIold\fP is a basic regular expression and +\fInew\fP can contain an +ampersand, \fB'\\n'\fP (where \fIn\fP is a digit) backreferences, +or subexpression matching. The \fIold\fP string shall also be +permitted to contain <newline>s. +.LP +Any non-null character can be used as a delimiter ( \fB'/'\fP shown +here). Multiple \fB-s\fP expressions can be specified; +the expressions shall be applied in the order specified, terminating +with the first successful substitution. The optional trailing +\fB'g'\fP is as defined in the \fIed\fP utility. The optional trailing +\fB'p'\fP shall +cause successful substitutions to be written to standard error. File +or archive member names that substitute to the empty string +shall be ignored when reading and writing archives. +.TP 7 +\fB-t\fP +When reading files from the file system, and if the user has the permissions +required by \fIutime\fP() to do so, set the access time of each file +read to the access time that it had before +being read by \fIpax\fP. +.TP 7 +\fB-u\fP +Ignore files that are older (having a less recent file modification +time) than a pre-existing file or archive member with the +same name. In \fBread\fP mode, an archive member with the same name +as a file in the file system shall be extracted if the archive +member is newer than the file. In \fBwrite\fP mode, an archive file +member with the same name as a file in the file system shall +be superseded if the file is newer than the archive member. If \fB-a\fP +is also specified, this is accomplished by appending to +the archive; otherwise, it is unspecified whether this is accomplished +by actual replacement in the archive or by appending to the +archive. In \fBcopy\fP mode, the file in the destination hierarchy +shall be replaced by the file in the source hierarchy or by a +link to the file in the source hierarchy if the file in the source +hierarchy is newer. +.TP 7 +\fB-v\fP +In \fBlist\fP mode, produce a verbose table of contents (see the STDOUT +section). Otherwise, write archive member pathnames to +standard error (see the STDERR section). +.TP 7 +\fB-x\ \fP \fIformat\fP +Specify the output archive format. The \fIpax\fP utility shall support +the following formats: +.TP 7 +\fBcpio\fP +.RS +The \fBcpio\fP interchange format; see the EXTENDED DESCRIPTION section. +The default \fIblocksize\fP for this format for +character special archive files shall be 5120. Implementations shall +support all \fIblocksize\fP values less than or equal to +32256 that are multiples of 512. +.RE +.TP 7 +\fBpax\fP +.RS +The \fBpax\fP interchange format; see the EXTENDED DESCRIPTION section. +The default \fIblocksize\fP for this format for +character special archive files shall be 5120. Implementations shall +support all \fIblocksize\fP values less than or equal to +32256 that are multiples of 512. +.RE +.TP 7 +\fBustar\fP +.RS +The \fBtar\fP interchange format; see the EXTENDED DESCRIPTION section. +The default \fIblocksize\fP for this format for +character special archive files shall be 10240. Implementations shall +support all \fIblocksize\fP values less than or equal to +32256 that are multiples of 512. +.RE +.sp +.LP +Implementation-defined formats shall specify a default block size +as well as any other block sizes supported for character +special archive files. +.LP +Any attempt to append to an archive file in a format different from +the existing archive format shall cause \fIpax\fP to exit +immediately with a non-zero exit status. +.LP +In \fBcopy\fP mode, if no \fB-x\fP format is specified, \fIpax\fP +shall behave as if \fB-x\fP \fIpax\fP were specified. +.TP 7 +\fB-X\fP +When traversing the file hierarchy specified by a pathname, \fIpax\fP +shall not descend into directories that have a different +device ID ( \fIst_dev\fP; see the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIstat\fP()). +.sp +.LP +The options that operate on the names of files or archive members +( \fB-c\fP, \fB-i\fP, \fB-n\fP, \fB-s\fP, \fB-u\fP, and +\fB-v\fP) shall interact as follows. In \fBread\fP mode, the archive +members shall be selected based on the user-specified +\fIpattern\fP operands as modified by the \fB-c\fP, \fB-n\fP, and +\fB-u\fP options. Then, any \fB-s\fP and \fB-i\fP options +shall modify, in that order, the names of the selected files. The +\fB-v\fP option shall write names resulting from these +modifications. +.LP +In \fBwrite\fP mode, the files shall be selected based on the user-specified +pathnames as modified by the \fB-n\fP and +\fB-u\fP options. Then, any \fB-s\fP and \fB-i\fP options shall modify, +in that order, the names of these selected files. The +\fB-v\fP option shall write names resulting from these modifications. +.LP +If both the \fB-u\fP and \fB-n\fP options are specified, \fIpax\fP +shall not consider a file selected unless it is newer than +the file to which it is compared. +.SS List Mode Format Specifications +.LP +In \fBlist\fP mode with the \fB-o\fP \fBlistopt=\fP \fIformat\fP option, +the \fIformat\fP argument shall be applied for +each selected file. The \fIpax\fP utility shall append a <newline> +to the \fBlistopt\fP output for each selected file. The +\fIformat\fP argument shall be used as the \fIformat\fP string described +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation, with the +exceptions 1. +through 5. defined in the EXTENDED DESCRIPTION section of \fIprintf\fP, +plus the following +exceptions: +.TP 7 +6. +The sequence ( \fIkeyword\fP) can occur before a format conversion +specifier. The conversion argument is defined by the value +of \fIkeyword\fP. The implementation shall support the following keywords: +.RS +.IP " *" 3 +Any of the Field Name entries in ustar Header Block and Octet-Oriented +cpio +Archive Entry . The implementation may support the \fIcpio\fP keywords +without the leading \fBc_\fP in addition to the form +required by Values for cpio c_mode Field . +.LP +.IP " *" 3 +Any keyword defined for the extended header in pax Extended Header +\&. +.LP +.IP " *" 3 +Any keyword provided as an implementation-defined extension within +the extended header defined in pax Extended Header . +.LP +.RE +.LP +For example, the sequence \fB"%(charset)s"\fP is the string value +of the name of the character set in the extended +header. +.LP +The result of the keyword conversion argument shall be the value from +the applicable header field or extended header, without +any trailing NULs. +.LP +All keyword values used as conversion arguments shall be translated +from the UTF-8 encoding to the character set appropriate for +the local file system, user database, and so on, as applicable. +.TP 7 +7. +An additional conversion specifier character, \fBT\fP , shall be used +to specify time formats. The \fBT\fP conversion +specifier character can be preceded by the sequence ( \fIkeyword=\fP +\fIsubformat\fP), where \fIsubformat\fP is a date format as +defined by \fIdate\fP operands. The default \fIkeyword\fP shall be +\fBmtime\fP and the +default subformat shall be: +.sp +.RS +.nf + +\fB%b %e %H:%M %Y +\fP +.fi +.RE +.TP 7 +8. +An additional conversion specifier character, \fBM\fP , shall be used +to specify the file mode string as defined in \fIls\fP Standard Output. +If ( \fIkeyword\fP) is omitted, the \fBmode\fP keyword shall be used. +For +example, \fB%.1M\fP writes the single character corresponding to the +<\fIentry\ type\fP> field of the \fIls\fP \fB-l\fP command. +.TP 7 +9. +An additional conversion specifier character, \fBD\fP , shall be used +to specify the device for block or special files, if +applicable, in an implementation-defined format. If not applicable, +and ( \fIkeyword\fP) is specified, then this conversion shall +be equivalent to \fB%(\fP\fIkeyword\fP\fB)u\fP. If not applicable, +and ( \fIkeyword\fP) is omitted, then this conversion +shall be equivalent to <space>. +.TP 7 +10. +An additional conversion specifier character, \fBF\fP , shall be used +to specify a pathname. The \fBF\fP conversion +character can be preceded by a sequence of comma-separated keywords: +.sp +.RS +.nf + +\fB(\fP\fIkeyword\fP\fB[\fP\fB,\fP\fIkeyword\fP\fB]\fP \fB... ) +\fP +.fi +.RE +.LP +The values for all the keywords that are non-null shall be concatenated +together, each separated by a \fB'/'\fP . The default +shall be ( \fBpath\fP) if the keyword \fBpath\fP is defined; otherwise, +the default shall be ( \fBprefix\fP, \fBname\fP). +.TP 7 +11. +An additional conversion specifier character, \fBL\fP , shall be used +to specify a symbolic line expansion. If the current +file is a symbolic link, then \fB%L\fP shall expand to: +.sp +.RS +.nf + +\fB"%s -> %s", <\fP\fIvalue of keyword\fP\fB>, <\fP\fIcontents of link\fP\fB> +\fP +.fi +.RE +.LP +Otherwise, the \fB%L\fP conversion specification shall be the equivalent +of \fB%F\fP . +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIdirectory\fP +The destination directory pathname for \fBcopy\fP mode. +.TP 7 +\fIfile\fP +A pathname of a file to be copied or archived. +.TP 7 +\fIpattern\fP +A pattern matching one or more pathnames of archive members. A pattern +must be given in the name-generating notation of the +pattern matching notation in \fIPattern Matching Notation\fP , including +the filename +expansion rules in \fIPatterns Used for Filename Expansion\fP . The +default, if no +\fIpattern\fP is specified, is to select all members in the archive. +.sp +.SH STDIN +.LP +In \fBwrite\fP mode, the standard input shall be used only if no \fIfile\fP +operands are specified. It shall be a text file +containing a list of pathnames, one per line, without leading or trailing +<blank>s. +.LP +In \fBlist\fP and \fBread\fP modes, if \fB-f\fP is not specified, +the standard input shall be an archive file. +.LP +Otherwise, the standard input shall not be used. +.SH INPUT FILES +.LP +The input file named by the \fIarchive\fP option-argument, or standard +input when the archive is read from there, shall be a +file formatted according to one of the specifications in the EXTENDED +DESCRIPTION section or some other implementation-defined +format. +.LP +The file \fB/dev/tty\fP shall be used to write prompts and read responses. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIpax\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements used in the pattern +matching expressions for the \fIpattern\fP operand, the basic regular +expression for the \fB-s\fP option, and the extended +regular expression defined for the \fByesexpr\fP locale keyword in +the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +behavior of character classes used in the extended regular +expression defined for the \fByesexpr\fP locale keyword in the \fILC_MESSAGES\fP +category, and pattern matching. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale for the processing of affirmative responses that +should be used to affect the format and contents of +diagnostic messages written to standard error. +.TP 7 +\fILC_TIME\fP +Determine the format and contents of date and time strings when the +\fB-v\fP option is specified. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITMPDIR\fP +Determine the pathname that provides part of the default global extended +header record file, as described for the \fB-o\fP +\fBglobexthdr=\fP keyword in the OPTIONS section. +.TP 7 +\fITZ\fP +Determine the timezone used to calculate date and time strings when +the \fB-v\fP option is specified. If \fITZ\fP is unset or +null, an unspecified default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +In \fBwrite\fP mode, if \fB-f\fP is not specified, the standard output +shall be the archive formatted according to one of the +specifications in the EXTENDED DESCRIPTION section, or some other +implementation-defined format (see \fB-x\fP \fIformat\fP). +.LP +In \fBlist\fP mode, when the \fB-o\fP \fBlistopt\fP= \fIformat\fP +has been specified, the selected archive members shall be +written to standard output using the format described under List Mode +Format Specifications . In +\fBlist\fP mode without the \fB-o\fP \fBlistopt\fP= \fIformat\fP option, +the table of contents of the selected archive members +shall be written to standard output using the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +If the \fB-v\fP option is specified in \fBlist\fP mode, the table +of contents of the selected archive members shall be written +to standard output using the following formats. +.LP +For pathnames representing hard links to previous members of the archive: +.sp +.RS +.nf + +\fB"%s == %s\\n", <\fP\fIls\fP \fB-l\fP \fIlisting\fP\fB>, <\fP\fIlinkname\fP\fB> +\fP +.fi +.RE +.LP +For all other pathnames: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIls\fP \fB-l\fP \fIlisting\fP\fB> +\fP +.fi +.RE +.LP +where <\fIls\ \fP -l\ \fIlisting\fP> shall be the format specified +by the \fIls\fP utility with the \fB-l\fP option. When writing pathnames +in this format, it is unspecified +what is written for fields for which the underlying archive format +does not have the correct information, although the correct +number of <blank>-separated fields shall be written. +.LP +In \fBlist\fP mode, standard output shall not be buffered more than +a line at a time. +.SH STDERR +.LP +If \fB-v\fP is specified in \fBread\fP, \fBwrite\fP, or \fBcopy\fP +modes, \fIpax\fP shall write the pathnames it processes +to the standard error output using the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +These pathnames shall be written as soon as processing is begun on +the file or archive member, and shall be flushed to standard +error. The trailing <newline>, which shall not be buffered, is written +when the file has been read or written. +.LP +If the \fB-s\fP option is specified, and the replacement string has +a trailing \fB'p'\fP , substitutions shall be written to +standard error in the following format: +.sp +.RS +.nf + +\fB"%s >> %s\\n", <\fP\fIoriginal pathname\fP\fB>, <\fP\fInew pathname\fP\fB> +\fP +.fi +.RE +.LP +In all operating modes of \fIpax\fP, optional messages of unspecified +format concerning the input archive format and volume +number, the number of files, blocks, volumes, and media parts as well +as other diagnostic messages may be written to standard +error. +.LP +In all formats, for both standard output and standard error, it is +unspecified how non-printable characters in pathnames or link +names are written. +.LP +When \fIpax\fP is in \fBread\fP mode or \fBlist\fP mode, using the +\fB-x\fP \fBpax\fP archive format, and a filename, link +name, owner name, or any other field in an extended header record +cannot be translated from the \fBpax\fP UTF-8 codeset format to +the codeset and current locale of the implementation, \fIpax\fP shall +write a diagnostic message to standard error, shall process +the file as described for the \fB-o\fP \fBinvalid=\fP option, and +then shall process the next file in the archive. +.SH OUTPUT FILES +.LP +In \fBread\fP mode, the extracted output files shall be of the archived +file type. In \fBcopy\fP mode, the copied output files +shall be the type of the file being copied. In either mode, existing +files in the destination hierarchy shall be overwritten only +when all permission ( \fB-p\fP), modification time ( \fB-u\fP), and +invalid-value ( \fB-o\fP \fBinvalid\fP=) tests allow +it. +.LP +In \fBwrite\fP mode, the output file named by the \fB-f\fP option-argument +shall be a file formatted according to one of the +specifications in the EXTENDED DESCRIPTION section, or some other +implementation-defined format. +.SH EXTENDED DESCRIPTION +.SS pax Interchange Format +.LP +A \fIpax\fP archive tape or file produced in the \fB-x\fP \fBpax\fP +format shall contain a series of blocks. The physical +layout of the archive shall be identical to the \fBustar\fP format +described in ustar Interchange +Format . Each file archived shall be represented by the following +sequence: +.IP " *" 3 +An optional header block with extended header records. This header +block is of the form described in pax Header Block , with a \fItypeflag\fP +value of \fBx\fP or \fBg\fP. The extended header records, +described in pax Extended Header , shall be included as the data for +this header block. +.LP +.IP " *" 3 +A header block that describes the file. Any fields in the preceding +optional extended header shall override the associated +fields in this header block for this file. +.LP +.IP " *" 3 +Zero or more blocks that contain the contents of the file. +.LP +.LP +At the end of the archive file there shall be two 512-byte blocks +filled with binary zeros, interpreted as an end-of-archive +indicator. +.LP +A schematic of an example archive with global extended header records +and two actual files is shown in pax +Format Archive Example . In the example, the second file in the archive +has no extended header preceding it, presumably because +it has no need for extended attributes. +.TP 7 +.sp +.sp +.ce 1 +\fBFigure: pax Format Archive Example\fP +.SS pax Header Block +.LP +The \fBpax\fP header block shall be identical to the \fBustar\fP header +block described in ustar +Interchange Format , except that two additional \fItypeflag\fP values +are defined: +.TP 7 +\fBx\fP +Represents extended header records for the following file in the archive +(which shall have its own \fBustar\fP header block). +The format of these extended header records shall be as described +in pax Extended Header . +.TP 7 +\fBg\fP +Represents global extended header records for the following files +in the archive. The format of these extended header records +shall be as described in pax Extended Header . Each value shall affect +all subsequent files that do +not override that value in their own extended header record and until +another global extended header record is reached that +provides another value for the same field. The \fItypeflag\fP \fBg\fP +global headers should not be used with interchange media +that could suffer partial data loss in transporting the archive. +.sp +.LP +For both of these types, the \fIsize\fP field shall be the size of +the extended header records in octets. The other fields in +the header block are not meaningful to this version of the \fIpax\fP +utility. However, if this archive is read by a \fIpax\fP +utility conforming to the ISO\ POSIX-2:1993 standard, the header block +fields are used to create a regular file that contains +the extended header records as data. Therefore, header block field +values should be selected to provide reasonable file access to +this regular file. +.LP +A further difference from the \fBustar\fP header block is that data +blocks for files of \fItypeflag\fP 1 (the digit one) (hard +link) may be included, which means that the size field may be greater +than zero. Archives created by \fIpax\fP \fB-o\fP +\fBlinkdata\fP shall include these data blocks with the hard links. +.SS pax Extended Header +.LP +A \fBpax\fP extended header contains values that are inappropriate +for the \fBustar\fP header block because of limitations in +that format: fields requiring a character encoding other than that +described in the ISO/IEC\ 646:1991 standard, fields +representing file attributes not described in the \fBustar\fP header, +and fields whose format or length do not fit the +requirements of the \fBustar\fP header. The values in an extended +header add attributes to the following file (or files; see the +description of the \fItypeflag\fP \fBg\fP header block) or override +values in the following header block(s), as indicated in the +following list of keywords. +.LP +An extended header shall consist of one or more records, each constructed +as follows: +.sp +.RS +.nf + +\fB"%d %s=%s\\n", <\fP\fIlength\fP\fB>, <\fP\fIkeyword\fP\fB>, <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +The extended header records shall be encoded according to the ISO/IEC\ 10646-1:2000 +standard (UTF-8). The +<\fIlength\fP> field, <blank>, equals sign, and <newline> shown shall +be limited to the portable character set, +as encoded in UTF-8. The <\fIkeyword\fP> and <\fIvalue\fP> fields +can be any UTF-8 characters. The +<\fIlength\fP> field shall be the decimal length of the extended header +record in octets, including the trailing +<newline>. +.LP +The <\fIkeyword\fP> field shall be one of the entries from the following +list or a keyword provided as an implementation +extension. Keywords consisting entirely of lowercase letters, digits, +and periods are reserved for future standardization. A +keyword shall not include an equals sign. (In the following list, +the notations "file(s)" or "block(s)" is used to acknowledge +that a keyword affects the following single file after a \fItypeflag\fP +\fBx\fP extended header, but possibly multiple files +after \fItypeflag\fP \fBg\fP. Any requirements in the list for \fIpax\fP +to include a record when in \fBwrite\fP or \fBcopy\fP +mode shall apply only when such a record has not already been provided +through the use of the \fB-o\fP option. When used in +\fBcopy\fP mode, \fIpax\fP shall behave as if an archive had been +created with applicable extended header records and then +extracted.) +.TP 7 +\fBatime\fP +The file access time for the following file(s), equivalent to the +value of the \fIst_atime\fP member of the \fBstat\fP +structure for a file, as described by the \fIstat\fP() function. The +access time shall be +restored if the process has the appropriate privilege required to +do so. The format of the <\fIvalue\fP> shall be as +described in pax Extended Header File Times . +.TP 7 +\fBcharset\fP +The name of the character set used to encode the data in the following +file(s). The entries in the following table are defined +to refer to known standards; additional names may be agreed on between +the originator and recipient. +.TS C +center; l2 l. +\fB<value>\fP \fBFormal Standard\fP +ISO-IR 646 1990 ISO/IEC 646:1990 +ISO-IR 8859 1 1998 ISO/IEC 8859-1:1998 +ISO-IR 8859 2 1999 ISO/IEC 8859-2:1999 +ISO-IR 8859 3 1999 ISO/IEC 8859-3:1999 +ISO-IR 8859 4 1998 ISO/IEC 8859-4:1998 +ISO-IR 8859 5 1999 ISO/IEC 8859-5:1999 +ISO-IR 8859 6 1999 ISO/IEC 8859-6:1999 +ISO-IR 8859 7 1987 ISO/IEC 8859-7:1987 +ISO-IR 8859 8 1999 ISO/IEC 8859-8:1999 +ISO-IR 8859 9 1999 ISO/IEC 8859-9:1999 +ISO-IR 8859 10 1998 ISO/IEC 8859-10:1998 +ISO-IR 8859 13 1998 ISO/IEC 8859-13:1998 +ISO-IR 8859 14 1998 ISO/IEC 8859-14:1998 +ISO-IR 8859 15 1999 ISO/IEC 8859-15:1999 +ISO-IR 10646 2000 ISO/IEC 10646:2000 +ISO-IR 10646 2000 UTF-8 ISO/IEC 10646, UTF-8 encoding +BINARY None. +.TE +.LP +The encoding is included in an extended header for information only; +when \fIpax\fP is used as described in +IEEE\ Std\ 1003.1-2001, it shall not translate the file data into +any other encoding. The \fBBINARY\fP entry indicates +unencoded binary data. +.LP +When used in \fBwrite\fP or \fBcopy\fP mode, it is implementation-defined +whether \fIpax\fP includes a \fBcharset\fP +extended header record for a file. +.TP 7 +\fBcomment\fP +A series of characters used as a comment. All characters in the <\fIvalue\fP> +field shall be ignored by \fIpax\fP. +.TP 7 +\fBctime\fP +The file creation time for the following file(s), equivalent to the +value of the \fIst_ctime\fP member of the \fBstat\fP +structure for a file, as described by the \fIstat\fP() function. The +creation time shall be +restored if the process has the appropriate privilege required to +do so. The format of the <\fIvalue\fP> shall be as +described in pax Extended Header File Times . +.TP 7 +\fBgid\fP +The group ID of the group that owns the file, expressed as a decimal +number using digits from the ISO/IEC\ 646:1991 +standard. This record shall override the \fIgid\fP field in the following +header block(s). When used in \fBwrite\fP or +\fBcopy\fP mode, \fIpax\fP shall include a \fIgid\fP extended header +record for each file whose group ID is greater than 2097151 +(octal 7777777). +.TP 7 +\fBgname\fP +The group of the file(s), formatted as a group name in the group database. +This record shall override the \fIgid\fP and +\fIgname\fP fields in the following header block(s), and any \fIgid\fP +extended header record. When used in \fBread\fP, +\fBcopy\fP, or \fBlist\fP mode, \fIpax\fP shall translate the name +from the UTF-8 encoding in the header record to the character +set appropriate for the group database on the receiving system. If +any of the UTF-8 characters cannot be translated, and if the +\fB-o\fP \fBinvalid=\fP UTF-8 option is not specified, the results +are implementation-defined. When used in \fBwrite\fP or +\fBcopy\fP mode, \fIpax\fP shall include a \fBgname\fP extended header +record for each file whose group name cannot be +represented entirely with the letters and digits of the portable character +set. +.TP 7 +\fBlinkpath\fP +The pathname of a link being created to another file, of any type, +previously archived. This record shall override the +\fIlinkname\fP field in the following \fBustar\fP header block(s). +The following \fBustar\fP header block shall determine the +type of link created. If \fItypeflag\fP of the following header block +is 1, it shall be a hard link. If \fItypeflag\fP is 2, it +shall be a symbolic link and the \fBlinkpath\fP value shall be the +contents of the symbolic link. The \fIpax\fP utility shall +translate the name of the link (contents of the symbolic link) from +the UTF-8 encoding to the character set appropriate for the +local file system. When used in \fBwrite\fP or \fBcopy\fP mode, \fIpax\fP +shall include a \fBlinkpath\fP extended header record +for each link whose pathname cannot be represented entirely with the +members of the portable character set other than NUL. +.TP 7 +\fBmtime\fP +The file modification time of the following file(s), equivalent to +the value of the \fIst_mtime\fP member of the \fBstat\fP +structure for a file, as described in the \fIstat\fP() function. This +record shall override +the \fImtime\fP field in the following header block(s). The modification +time shall be restored if the process has the appropriate +privilege required to do so. The format of the <\fIvalue\fP> shall +be as described in pax +Extended Header File Times . +.TP 7 +\fBpath\fP +The pathname of the following file(s). This record shall override +the \fIname\fP and \fIprefix\fP fields in the following +header block(s). The \fIpax\fP utility shall translate the pathname +of the file from the UTF-8 encoding to the character set +appropriate for the local file system. +.LP +When used in \fBwrite\fP or \fBcopy\fP mode, \fIpax\fP shall include +a \fIpath\fP extended header record for each file whose +pathname cannot be represented entirely with the members of the portable +character set other than NUL. +.TP 7 +\fBrealtime.\fP\fIany\fP +The keywords prefixed by "realtime." are reserved for future standardization. +.TP 7 +\fBsecurity.\fP\fIany\fP +The keywords prefixed by "security." are reserved for future standardization. +.TP 7 +\fBsize\fP +The size of the file in octets, expressed as a decimal number using +digits from the ISO/IEC\ 646:1991 standard. This record +shall override the \fIsize\fP field in the following header block(s). +When used in \fBwrite\fP or \fBcopy\fP mode, \fIpax\fP +shall include a \fIsize\fP extended header record for each file with +a size value greater than 8589934591 (octal +77777777777). +.TP 7 +\fBuid\fP +The user ID of the file owner, expressed as a decimal number using +digits from the ISO/IEC\ 646:1991 standard. This record +shall override the \fIuid\fP field in the following header block(s). +When used in \fBwrite\fP or \fBcopy\fP mode, \fIpax\fP +shall include a \fIuid\fP extended header record for each file whose +owner ID is greater than 2097151 (octal 7777777). +.TP 7 +\fBuname\fP +The owner of the following file(s), formatted as a user name in the +user database. This record shall override the \fIuid\fP +and \fIuname\fP fields in the following header block(s), and any \fIuid\fP +extended header record. When used in \fBread\fP, +\fBcopy\fP, or \fBlist\fP mode, \fIpax\fP shall translate the name +from the UTF-8 encoding in the header record to the character +set appropriate for the user database on the receiving system. If +any of the UTF-8 characters cannot be translated, and if the +\fB-o\fP \fBinvalid=\fP UTF-8 option is not specified, the results +are implementation-defined. When used in \fBwrite\fP or +\fBcopy\fP mode, \fIpax\fP shall include a \fBuname\fP extended header +record for each file whose user name cannot be +represented entirely with the letters and digits of the portable character +set. +.sp +.LP +If the <\fIvalue\fP> field is zero length, it shall delete any header +block field, previously entered extended header +value, or global extended header value of the same name. +.LP +If a keyword in an extended header record (or in a \fB-o\fP option-argument) +overrides or deletes a corresponding field in the +\fBustar\fP header block, \fIpax\fP shall ignore the contents of that +header block field. +.LP +Unlike the \fBustar\fP header block fields, NULs shall not delimit +<\fIvalue\fP>s; all characters within the +<\fIvalue\fP> field shall be considered data for the field. None of +the length limitations of the \fBustar\fP header block +fields in ustar Header Block shall apply to the extended header records. +.SS pax Extended Header Keyword Precedence +.LP +This section describes the precedence in which the various header +records and fields and command line options are selected to +apply to a file in the archive. When \fIpax\fP is used in \fBread\fP +or \fBlist\fP modes, it shall determine a file attribute in +the following sequence: +.IP " 1." 4 +If \fB-o\fP \fBdelete=\fP \fIkeyword-prefix\fP is used, the affected +attributes shall be determined from step 7., if +applicable, or ignored otherwise. +.LP +.IP " 2." 4 +If \fB-o\fP \fIkeyword\fP:= is used, the affected attributes shall +be ignored. +.LP +.IP " 3." 4 +If \fB-o\fP \fIkeyword\fP \fB:=\fP \fIvalue\fP is used, the affected +attribute shall be assigned the value. +.LP +.IP " 4." 4 +If there is a \fItypeflag\fP \fBx\fP extended header record, the affected +attribute shall be assigned the +<\fIvalue\fP>. When extended header records conflict, the last one +given in the header shall take precedence. +.LP +.IP " 5." 4 +If \fB-o\fP \fIkeyword\fP \fB=\fP \fIvalue\fP is used, the affected +attribute shall be assigned the value. +.LP +.IP " 6." 4 +If there is a \fItypeflag\fP \fBg\fP global extended header record, +the affected attribute shall be assigned the +<\fIvalue\fP>. When global extended header records conflict, the last +one given in the global header shall take +precedence. +.LP +.IP " 7." 4 +Otherwise, the attribute shall be determined from the \fBustar\fP +header block. +.LP +.SS pax Extended Header File Times +.LP +The \fIpax\fP utility shall write an \fBmtime\fP record for each file +in \fBwrite\fP or \fBcopy\fP modes if the file's +modification time cannot be represented exactly in the \fBustar\fP +header logical record described in ustar Interchange Format . This +can occur if the time is out of \fBustar\fP range, or if the file +system +of the underlying implementation supports non-integer time granularities +and the time is not an integer. All of these time records +shall be formatted as a decimal representation of the time in seconds +since the Epoch. If a period ( \fB'.'\fP ) decimal point +character is present, the digits to the right of the point shall represent +the units of a subsecond timing granularity, where the +first digit is tenths of a second and each subsequent digit is a tenth +of the previous digit. In \fBread\fP or \fBcopy\fP mode, +the \fIpax\fP utility shall truncate the time of a file to the greatest +value that is not greater than the input header file time. +In \fBwrite\fP or \fBcopy\fP mode, the \fIpax\fP utility shall output +a time exactly if it can be represented exactly as a +decimal number, and otherwise shall generate only enough digits so +that the same time shall be recovered if the file is extracted +on a system whose underlying implementation supports the same time +granularity. +.SS ustar Interchange Format +.LP +A \fBustar\fP archive tape or file shall contain a series of logical +records. Each logical record shall be a fixed-size logical +record of 512 octets (see below). Although this format may be thought +of as being stored on 9-track industry-standard 12.7 mm (0.5 +in) magnetic tape, other types of transportable media are not excluded. +Each file archived shall be represented by a header logical +record that describes the file, followed by zero or more logical records +that give the contents of the file. At the end of the +archive file there shall be two 512-octet logical records filled with +binary zeros, interpreted as an end-of-archive indicator. +.LP +The logical records may be grouped for physical I/O operations, as +described under the \fB-b\fP \fIblocksize\fP and \fB-x\fP +\fBustar\fP options. Each group of logical records may be written +with a single operation equivalent to the \fIwrite\fP() function. +On magnetic tape, the result of this write shall be a single tape +physical +block. The last physical block shall always be the full size, so logical +records after the two zero logical records may contain +undefined data. +.LP +The header logical record shall be structured as shown in the following +table. All lengths and offsets are in decimal. +.br +.sp +.ce 1 +\fBTable: ustar Header Block\fP +.TS C +center; l l l. +\fBField Name\fP \fBOctet Offset\fP \fBLength (in Octets)\fP +\fIname\fP 0 100 +\fImode\fP 100 8 +\fIuid\fP 108 8 +\fIgid\fP 116 8 +\fIsize\fP 124 12 +\fImtime\fP 136 12 +\fIchksum\fP 148 8 +\fItypeflag\fP 156 1 +\fIlinkname\fP 157 100 +\fImagic\fP 257 6 +\fIversion\fP 263 2 +\fIuname\fP 265 32 +\fIgname\fP 297 32 +\fIdevmajor\fP 329 8 +\fIdevminor\fP 337 8 +\fIprefix\fP 345 155 +.TE +.LP +All characters in the header logical record shall be represented in +the coded character set of the ISO/IEC\ 646:1991 +standard. For maximum portability between implementations, names should +be selected from characters represented by the portable +filename character set as octets with the most significant bit zero. +If an implementation supports the use of characters outside of +slash and the portable filename character set in names for files, +users, and groups, one or more implementation-defined encodings +of these characters shall be provided for interchange purposes. +.LP +However, the \fIpax\fP utility shall never create filenames on the +local system that cannot be accessed via the procedures +described in IEEE\ Std\ 1003.1-2001. If a filename is found on the +medium that would create an invalid filename, it is +implementation-defined whether the data from the file is stored on +the file hierarchy and under what name it is stored. The +\fIpax\fP utility may choose to ignore these files as long as it produces +an error indicating that the file is being ignored. +.LP +Each field within the header logical record is contiguous; that is, +there is no padding used. Each character on the archive +medium shall be stored contiguously. +.LP +The fields \fImagic\fP, \fIuname\fP, and \fIgname\fP are character +strings each terminated by a NUL character. The fields +\fIname\fP, \fIlinkname\fP, and \fIprefix\fP are NUL-terminated character +strings except when all characters in the array +contain non-NUL characters including the last character. The \fIversion\fP +field is two octets containing the characters +\fB"00"\fP (zero-zero). The \fItypeflag\fP contains a single character. +All other fields are leading zero-filled octal numbers +using digits from the ISO/IEC\ 646:1991 standard IRV. Each numeric +field is terminated by one or more <space> or NUL +characters. +.LP +The \fIname\fP and the \fIprefix\fP fields shall produce the pathname +of the file. A new pathname shall be formed, if +\fIprefix\fP is not an empty string (its first character is not NUL), +by concatenating \fIprefix\fP (up to the first NUL +character), a slash character, and \fIname\fP; otherwise, \fIname\fP +is used alone. In either case, \fIname\fP is terminated at +the first NUL character. If \fIprefix\fP begins with a NUL character, +it shall be ignored. In this manner, pathnames of at most +256 characters can be supported. If a pathname does not fit in the +space provided, \fIpax\fP shall notify the user of the error, +and shall not store any part of the file-header or data-on the medium. +.LP +The \fIlinkname\fP field, described below, shall not use the \fIprefix\fP +to produce a pathname. As such, a \fIlinkname\fP is +limited to 100 characters. If the name does not fit in the space provided, +\fIpax\fP shall notify the user of the error, and shall +not attempt to store the link on the medium. +.LP +The \fImode\fP field provides 12 bits encoded in the ISO/IEC\ 646:1991 +standard octal digit representation. The encoded +bits shall represent the following values: +.br +.sp +.ce 1 +\fBTable: ustar \fImode\fP Field\fP +.TS C +center; l1 l1 lw(37). +\fBBit Value\fP \fBIEEE\ Std\ 1003.1-2001 Bit\fP T{ +.na +\fBDescription\fP +.ad +T} +04000 S_ISUID T{ +.na +Set UID on execution. +.ad +T} +02000 S_ISGID T{ +.na +Set GID on execution. +.ad +T} +01000 <reserved> T{ +.na +Reserved for future standardization. +.ad +T} +00400 S_IRUSR T{ +.na +Read permission for file owner class. +.ad +T} +00200 S_IWUSR T{ +.na +Write permission for file owner class. +.ad +T} +00100 S_IXUSR T{ +.na +Execute/search permission for file owner class. +.ad +T} +00040 S_IRGRP T{ +.na +Read permission for file group class. +.ad +T} +00020 S_IWGRP T{ +.na +Write permission for file group class. +.ad +T} +00010 S_IXGRP T{ +.na +Execute/search permission for file group class. +.ad +T} +00004 S_IROTH T{ +.na +Read permission for file other class. +.ad +T} +00002 S_IWOTH T{ +.na +Write permission for file other class. +.ad +T} +00001 S_IXOTH T{ +.na +Execute/search permission for file other class. +.ad +T} +.TE +.LP +When appropriate privilege is required to set one of these mode bits, +and the user restoring the files from the archive does not +have the appropriate privilege, the mode bits for which the user does +not have appropriate privilege shall be ignored. Some of the +mode bits in the archive format are not mentioned elsewhere in this +volume of IEEE\ Std\ 1003.1-2001. If the implementation +does not support those bits, they may be ignored. +.LP +The \fIuid\fP and \fIgid\fP fields are the user and group ID of the +owner and group of the file, respectively. +.LP +The \fIsize\fP field is the size of the file in octets. If the \fItypeflag\fP +field is set to specify a file to be of type 1 +(a link) or 2 (a symbolic link), the \fIsize\fP field shall be specified +as zero. If the \fItypeflag\fP field is set to specify a +file of type 5 (directory), the \fIsize\fP field shall be interpreted +as described under the definition of that record type. No +data logical records are stored for types 1, 2, or 5. If the \fItypeflag\fP +field is set to 3 (character special file), 4 (block +special file), or 6 (FIFO), the meaning of the \fIsize\fP field is +unspecified by this volume of IEEE\ Std\ 1003.1-2001, +and no data logical records shall be stored on the medium. Additionally, +for type 6, the \fIsize\fP field shall be ignored when +reading. If the \fItypeflag\fP field is set to any other value, the +number of logical records written following the header shall +be ( \fIsize\fP+511)/512, ignoring any fraction in the result of the +division. +.LP +The \fImtime\fP field shall be the modification time of the file at +the time it was archived. It is the ISO/IEC\ 646:1991 +standard representation of the octal value of the modification time +obtained from the \fIstat\fP() function. +.LP +The \fIchksum\fP field shall be the ISO/IEC\ 646:1991 standard IRV +representation of the octal value of the simple sum of +all octets in the header logical record. Each octet in the header +shall be treated as an unsigned value. These values shall be +added to an unsigned integer, initialized to zero, the precision of +which is not less than 17 bits. When calculating the checksum, +the \fIchksum\fP field is treated as if it were all spaces. +.LP +The \fItypeflag\fP field specifies the type of file archived. If a +particular implementation does not recognize the type, or +the user does not have appropriate privilege to create that type, +the file shall be extracted as if it were a regular file if the +file type is defined to have a meaning for the \fIsize\fP field that +could cause data logical records to be written on the medium +(see the previous description for \fIsize\fP). If conversion to a +regular file occurs, the \fIpax\fP utility shall produce an +error indicating that the conversion took place. All of the \fItypeflag\fP +fields shall be coded in the ISO/IEC\ 646:1991 +standard IRV: +.TP 7 +\fB0\fP +Represents a regular file. For backwards-compatibility, a \fItypeflag\fP +value of binary zero ( \fB'\\0'\fP ) should be +recognized as meaning a regular file when extracting files from the +archive. Archives written with this version of the archive file +format create regular files with a \fItypeflag\fP value of the ISO/IEC\ 646:1991 +standard IRV \fB'0'\fP . +.TP 7 +\fB1\fP +Represents a file linked to another file, of any type, previously +archived. Such files are identified by each file having the +same device and file serial number. The linked-to name is specified +in the \fIlinkname\fP field with a NUL-character terminator if +it is less than 100 octets in length. +.TP 7 +\fB2\fP +Represents a symbolic link. The contents of the symbolic link shall +be stored in the \fIlinkname\fP field. +.TP 7 +\fB3,4\fP +Represent character special files and block special files respectively. +In this case the \fIdevmajor\fP and \fIdevminor\fP +fields shall contain information defining the device, the format of +which is unspecified by this volume of +IEEE\ Std\ 1003.1-2001. Implementations may map the device specifications +to their own local specification or may ignore +the entry. +.TP 7 +\fB5\fP +Specifies a directory or subdirectory. On systems where disk allocation +is performed on a directory basis, the \fIsize\fP +field shall contain the maximum number of octets (which may be rounded +to the nearest disk block allocation unit) that the +directory may hold. A \fIsize\fP field of zero indicates no such limiting. +Systems that do not support limiting in this manner +should ignore the \fIsize\fP field. +.TP 7 +\fB6\fP +Specifies a FIFO special file. Note that the archiving of a FIFO file +archives the existence of this file and not its +contents. +.TP 7 +\fB7\fP +Reserved to represent a file to which an implementation has associated +some high-performance attribute. Implementations without +such extensions should treat this file as a regular file (type 0). +.TP 7 +\fBA-Z\fP +The letters \fB'A'\fP to \fB'Z'\fP , inclusive, are reserved for custom +implementations. All other values are reserved +for future versions of IEEE\ Std\ 1003.1-2001. +.sp +.LP +Attempts to archive a socket using \fBustar\fP interchange format +shall produce a diagnostic message. Handling of other file +types is implementation-defined. +.LP +The \fImagic\fP field is the specification that this archive was output +in this archive format. If this field contains +\fBustar\fP (the five characters from the ISO/IEC\ 646:1991 standard +IRV shown followed by NUL), the \fIuname\fP and +\fIgname\fP fields shall contain the ISO/IEC\ 646:1991 standard IRV +representation of the owner and group of the file, +respectively (truncated to fit, if necessary). When the file is restored +by a privileged, protection-preserving version of the +utility, the user and group databases shall be scanned for these names. +If found, the user and group IDs contained within these +files shall be used rather than the values contained within the \fIuid\fP +and \fIgid\fP fields. +.SS cpio Interchange Format +.LP +The octet-oriented \fBcpio\fP archive format shall be a series of +entries, each comprising a header that describes the file, +the name of the file, and then the contents of the file. +.LP +An archive may be recorded as a series of fixed-size blocks of octets. +This blocking shall be used only to make physical I/O +more efficient. The last group of blocks shall always be at the full +size. +.LP +For the octet-oriented \fBcpio\fP archive format, the individual entry +information shall be in the order indicated and +described by the following table; see also the \fI<cpio.h>\fP header. +.br +.sp +.ce 1 +\fBTable: Octet-Oriented cpio Archive Entry\fP +.TS C +center; l2 l2 l. +\fBHeader Field Name\fP \fBLength (in Octets)\fP \fBInterpreted as\fP +\fIc_magic\fP 6 Octal number +\fIc_dev\fP 6 Octal number +\fIc_ino\fP 6 Octal number +\fIc_mode\fP 6 Octal number +\fIc_uid\fP 6 Octal number +\fIc_gid\fP 6 Octal number +\fIc_nlink\fP 6 Octal number +\fIc_rdev\fP 6 Octal number +\fIc_mtime\fP 11 Octal number +\fIc_namesize\fP 6 Octal number +\fIc_filesize\fP 11 Octal number +\fBFilename Field Name\fP \fBLength\fP \fBInterpreted as\fP +\fIc_name\fP \fIc_namesize\fP Pathname string +\fBFile Data Field Name\fP \fBLength\fP \fBInterpreted as\fP +\fIc_filedata\fP \fIc_filesize\fP Data +.TE +.SS cpio Header +.LP +For each file in the archive, a header as defined previously shall +be written. The information in the header fields is written +as streams of the ISO/IEC\ 646:1991 standard characters interpreted +as octal numbers. The octal numbers shall be extended to +the necessary length by appending the ISO/IEC\ 646:1991 standard IRV +zeros at the most-significant-digit end of the number; the +result is written to the most-significant digit of the stream of octets +first. The fields shall be interpreted as follows: +.TP 7 +\fIc_magic\fP +Identify the archive as being a transportable archive by containing +the identifying value \fB"070707"\fP . +.TP 7 +\fIc_dev\fP,\ \fIc_ino\fP +Contains values that uniquely identify the file within the archive +(that is, no files contain the same pair of \fIc_dev\fP and +\fIc_ino\fP values unless they are links to the same file). The values +shall be determined in an unspecified manner. +.TP 7 +\fIc_mode\fP +Contains the file type and access permissions as defined in the following +table. +.br +.sp +.ce 1 +\fBTable: Values for cpio c_mode Field\fP +.TS C +center; l2 l2 l. +\fBFile Permissions Name\fP \fBValue\fP \fBIndicates\fP +C_IRUSR 000400 Read by owner +C_IWUSR 000200 Write by owner +C_IXUSR 000100 Execute by owner +C_IRGRP 000040 Read by group +C_IWGRP 000020 Write by group +C_IXGRP 000010 Execute by group +C_IROTH 000004 Read by others +C_IWOTH 000002 Write by others +C_IXOTH 000001 Execute by others +C_ISUID 004000 Set \fIuid\fP +C_ISGID 002000 Set \fIgid\fP +C_ISVTX 001000 Reserved +\fBFile Type Name\fP \fBValue\fP \fBIndicates\fP +C_ISDIR 040000 Directory +C_ISFIFO 010000 FIFO +C_ISREG 0100000 Regular file +C_ISLNK 0120000 Symbolic link +C_ISBLK 060000 Block special file +C_ISCHR 020000 Character special file +C_ISSOCK 0140000 Socket +C_ISCTG 0110000 Reserved +.TE +.LP +Directories, FIFOs, symbolic links, and regular files shall be supported +on a system conforming to this volume of +IEEE\ Std\ 1003.1-2001; additional values defined previously are reserved +for compatibility with existing systems. +Additional file types may be supported; however, such files should +not be written to archives intended to be transported to other +systems. +.TP 7 +\fIc_uid\fP +Contains the user ID of the owner. +.TP 7 +\fIc_gid\fP +Contains the group ID of the group. +.TP 7 +\fIc_nlink\fP +Contains the number of links referencing the file at the time the +archive was created. +.TP 7 +\fIc_rdev\fP +Contains implementation-defined information for character or block +special files. +.TP 7 +\fIc_mtime\fP +Contains the latest time of modification of the file at the time the +archive was created. +.TP 7 +\fIc_namesize\fP +Contains the length of the pathname, including the terminating NUL +character. +.TP 7 +\fIc_filesize\fP +Contains the length of the file in octets. This shall be the length +of the data section following the header structure. +.sp +.SS cpio Filename +.LP +The \fIc_name\fP field shall contain the pathname of the file. The +length of this field in octets is the value of +\fIc_namesize\fP. +.LP +If a filename is found on the medium that would create an invalid +pathname, it is implementation-defined whether the data from +the file is stored on the file hierarchy and under what name it is +stored. +.LP +All characters shall be represented in the ISO/IEC\ 646:1991 standard +IRV. For maximum portability between implementations, +names should be selected from characters represented by the portable +filename character set as octets with the most significant bit +zero. If an implementation supports the use of characters outside +the portable filename character set in names for files, users, +and groups, one or more implementation-defined encodings of these +characters shall be provided for interchange purposes. However, +the \fIpax\fP utility shall never create filenames on the local system +that cannot be accessed via the procedures described +previously in this volume of IEEE\ Std\ 1003.1-2001. If a filename +is found on the medium that would create an invalid +filename, it is implementation-defined whether the data from the file +is stored on the local file system and under what name it is +stored. The \fIpax\fP utility may choose to ignore these files as +long as it produces an error indicating that the file is being +ignored. +.SS cpio File Data +.LP +Following \fIc_name\fP, there shall be \fIc_filesize\fP octets of +data. Interpretation of such data occurs in a manner +dependent on the file. If \fIc_filesize\fP is zero, no data shall +be contained in \fIc_filedata\fP. +.LP +When restoring from an archive: +.IP " *" 3 +If the user does not have the appropriate privilege to create a file +of the specified type, \fIpax\fP shall ignore the entry +and write an error message to standard error. +.LP +.IP " *" 3 +Only regular files have data to be restored. Presuming a regular file +meets any selection criteria that might be imposed on the +format-reading utility by the user, such data shall be restored. +.LP +.IP " *" 3 +If a user does not have appropriate privilege to set a particular +mode flag, the flag shall be ignored. Some of the mode flags +in the archive format are not mentioned elsewhere in this volume of +IEEE\ Std\ 1003.1-2001. If the implementation does not +support those flags, they may be ignored. +.LP +.SS cpio Special Entries +.LP +FIFO special files, directories, and the trailer shall be recorded +with \fIc_filesize\fP equal to zero. For other special +files, \fIc_filesize\fP is unspecified by this volume of IEEE\ Std\ 1003.1-2001. +The header for the next file entry in the +archive shall be written directly after the last octet of the file +entry preceding it. A header denoting the filename +\fBTRAILER!!!\fP shall indicate the end of the archive; the contents +of octets in the last block of the archive following such a +header are undefined. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All files were processed successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If \fIpax\fP cannot create a file or a link when reading an archive +or cannot find a file when writing an archive, or cannot +preserve the user ID, group ID, or file mode when the \fB-p\fP option +is specified, a diagnostic message shall be written to +standard error and a non-zero exit status shall be returned, but processing +shall continue. In the case where \fIpax\fP cannot +create a link to a file, \fIpax\fP shall not, by default, create a +second copy of the file. +.LP +If the extraction of a file from an archive is prematurely terminated +by a signal or error, \fIpax\fP may have only partially +extracted the file or (if the \fB-n\fP option was not specified) may +have extracted a file of the same name as that specified by +the user, but which is not the file the user wanted. Additionally, +the file modes of extracted directories may have additional bits +from the S_IRWXU mask set as well as incorrect modification and access +times. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-p\fP (privileges) option was invented to reconcile differences +between historical \fItar\fP and \fIcpio\fP +implementations. In particular, the two utilities use \fB-m\fP in +diametrically opposed ways. The \fB-p\fP option also provides a +consistent means of extending the ways in which future file attributes +can be addressed, such as for enhanced security systems or +high-performance files. Although it may seem complex, there are really +two modes that are most commonly used: +.TP 7 +\fB-p\ e\fP +``Preserve everything". This would be used by the historical superuser, +someone with all the appropriate privileges, to +preserve all aspects of the files as they are recorded in the archive. +The \fBe\fP flag is the sum of \fBo\fP and \fBp\fP, and +other implementation-defined attributes. +.TP 7 +\fB-p\ p\fP +``Preserve" the file mode bits. This would be used by the user with +regular privileges who wished to preserve aspects of the +file other than the ownership. The file times are preserved by default, +but two other flags are offered to disable these and use +the time of extraction. +.sp +.LP +The one pathname per line format of standard input precludes pathnames +containing <newline>s. Although such pathnames +violate the portable filename guidelines, they may exist and their +presence may inhibit usage of \fIpax\fP within shell scripts. +This problem is inherited from historical archive programs. The problem +can be avoided by listing filename arguments on the command +line instead of on standard input. +.LP +It is almost certain that appropriate privileges are required for +\fIpax\fP to accomplish parts of this volume of +IEEE\ Std\ 1003.1-2001. Specifically, creating files of type block +special or character special, restoring file access +times unless the files are owned by the user (the \fB-t\fP option), +or preserving file owner, group, and mode (the \fB-p\fP +option) all probably require appropriate privileges. +.LP +In \fBread\fP mode, implementations are permitted to overwrite files +when the archive has multiple members with the same name. +This may fail if permissions on the first version of the file do not +permit it to be overwritten. +.LP +The \fBcpio\fP and \fBustar\fP formats can only support files up to +8589934592 bytes (8 * 2^30) in size. +.SH EXAMPLES +.LP +The following command: +.sp +.RS +.nf + +\fBpax -w -f /dev/rmt/1m . +\fP +.fi +.RE +.LP +copies the contents of the current directory to tape drive 1, medium +density (assuming historical System V device naming +procedures-the historical BSD device name would be \fB/dev/rmt9\fP). +.LP +The following commands: +.sp +.RS +.nf + +\fBmkdir\fP \fInewdir\fP\fBpax -rw\fP \fIolddir newdir\fP +.fi +.RE +.LP +copy the \fIolddir\fP directory hierarchy to \fInewdir\fP. +.sp +.RS +.nf + +\fBpax -r -s ',^//*usr//*,,' -f a.pax +\fP +.fi +.RE +.LP +reads the archive \fBa.pax\fP, with all files rooted in \fB/usr\fP +in the archive extracted relative to the current +directory. +.LP +Using the option: +.sp +.RS +.nf + +\fB-o listopt="%M %(atime)T %(size)D %(name)s" +\fP +.fi +.RE +.LP +overrides the default output description in Standard Output and instead +writes: +.sp +.RS +.nf + +\fB-rw-rw--- Jan 12 15:53 1492 /usr/foo/bar +\fP +.fi +.RE +.LP +Using the options: +.sp +.RS +.nf + +\fB-o listopt='%L\\t%(size)D\\n%.7' \\ +-o listopt='(name)s\\n%(ctime)T\\n%T' +\fP +.fi +.RE +.LP +overrides the default output description in Standard Output and instead +writes: +.sp +.RS +.nf + +\fB/usr/foo/bar -> /tmp 1492 +/usr/fo +Jan 12 1991 +Jan 31 15:53 +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fIpax\fP utility was new for the ISO\ POSIX-2:1993 standard. +It represents a peaceful compromise between advocates of +the historical \fItar\fP and \fIcpio\fP utilities. +.LP +A fundamental difference between \fIcpio\fP and \fItar\fP was in the +way directories were treated. The \fIcpio\fP utility did +not treat directories differently from other files, and to select +a directory and its contents required that each file in the +hierarchy be explicitly specified. For \fItar\fP, a directory matched +every file in the file hierarchy it rooted. +.LP +The \fIpax\fP utility offers both interfaces; by default, directories +map into the file hierarchy they root. The \fB-d\fP +option causes \fIpax\fP to skip any file not explicitly referenced, +as \fIcpio\fP historically did. The \fItar\fP \fB-\fP +\fIstyle\fP behavior was chosen as the default because it was believed +that this was the more common usage and because \fItar\fP +is the more commonly available interface, as it was historically provided +on both System V and BSD implementations. +.LP +The data interchange format specification in this volume of IEEE\ Std\ 1003.1-2001 +requires that processes with +"appropriate privileges" shall always restore the ownership and permissions +of extracted files exactly as archived. If viewed +from the historic equivalence between superuser and "appropriate privileges", +there are two problems with this requirement. +First, users running as superusers may unknowingly set dangerous permissions +on extracted files. Second, it is needlessly limiting, +in that superusers cannot extract files and own them as superuser +unless the archive was created by the superuser. (It should be +noted that restoration of ownerships and permissions for the superuser, +by default, is historical practice in \fIcpio\fP, but not +in \fItar\fP.) In order to avoid these two problems, the \fIpax\fP +specification has an additional "privilege" mechanism, the +\fB-p\fP option. Only a \fIpax\fP invocation with the privileges needed, +and which has the \fB-p\fP option set using the +\fBe\fP specification character, has the "appropriate privilege" to +restore full ownership and permission information. +.LP +Note also that this volume of IEEE\ Std\ 1003.1-2001 requires that +the file ownership and access permissions shall be +set, on extraction, in the same fashion as the \fIcreat\fP() function +when provided with the +mode stored in the archive. This means that the file creation mask +of the user is applied to the file permissions. +.LP +Users should note that directories may be created by \fIpax\fP while +extracting files with permissions that are different from +those that existed at the time the archive was created. When extracting +sensitive information into a directory hierarchy that no +longer exists, users are encouraged to set their file creation mask +appropriately to protect these files during extraction. +.LP +The table of contents output is written to standard output to facilitate +pipeline processing. +.LP +An early proposal had hard links displaying for all pathnames. This +was removed because it complicates the output of the case +where \fB-v\fP is not specified and does not match historical \fIcpio\fP +usage. The hard-link information is available in the +\fB-v\fP display. +.LP +The description of the \fB-l\fP option allows implementations to make +hard links to symbolic links. +IEEE\ Std\ 1003.1-2001 does not specify any way to create a hard link +to a symbolic link, but many implementations provide +this capability as an extension. If there are hard links to symbolic +links when an archive is created, the implementation is +required to archive the hard link in the archive (unless \fB-H\fP +or \fB-L\fP is specified). When in \fBread\fP mode and in +\fBcopy\fP mode, implementations supporting hard links to symbolic +links should use them when appropriate. +.LP +The archive formats inherited from the POSIX.1-1990 standard have +certain restrictions that have been brought along from +historical usage. For example, there are restrictions on the length +of pathnames stored in the archive. When \fIpax\fP is used in +\fBcopy\fP( \fB-rw\fP) mode (copying directory hierarchies), the ability +to use extensions from the \fB-x\fP \fBpax\fP format +overcomes these restrictions. +.LP +The default \fIblocksize\fP value of 5120 bytes for \fIcpio\fP was +selected because it is one of the standard block-size +values for \fIcpio\fP, set when the \fB-B\fP option is specified. +(The other default block-size value for \fIcpio\fP is 512 +bytes, and this was considered to be too small.) The default block +value of 10240 bytes for \fItar\fP was selected because that is +the standard block-size value for BSD \fItar\fP. The maximum block +size of 32256 bytes (2**15-512 bytes) +is the largest multiple of 512 bytes that fits into a signed 16-bit +tape controller transfer register. There are known limitations +in some historical systems that would prevent larger blocks from being +accepted. Historical values were chosen to improve +compatibility with historical scripts using \fIdd\fP or similar utilities +to manipulate +archives. Also, default block sizes for any file type other than character +special file has been deleted from this volume of +IEEE\ Std\ 1003.1-2001 as unimportant and not likely to affect the +structure of the resulting archive. +.LP +Implementations are permitted to modify the block-size value based +on the archive format or the device to which the archive is +being written. This is to provide implementations with the opportunity +to take advantage of special types of devices, and it should +not be used without a great deal of consideration as it almost certainly +decreases archive portability. +.LP +The intended use of the \fB-n\fP option was to permit extraction of +one or more files from the archive without processing the +entire archive. This was viewed by the standard developers as offering +significant performance advantages over historical +implementations. The \fB-n\fP option in early proposals had three +effects; the first was to cause special characters in patterns +to not be treated specially. The second was to cause only the first +file that matched a pattern to be extracted. The third was to +cause \fIpax\fP to write a diagnostic message to standard error when +no file was found matching a specified pattern. Only the +second behavior is retained by this volume of IEEE\ Std\ 1003.1-2001, +for many reasons. First, it is in general not +acceptable for a single option to have multiple effects. Second, the +ability to make pattern matching characters act as normal +characters is useful for parts of \fIpax\fP other than file extraction. +Third, a finer degree of control over the special +characters is useful because users may wish to normalize only a single +special character in a single filename. Fourth, given a more +general escape mechanism, the previous behavior of the \fB-n\fP option +can be easily obtained using the \fB-s\fP option or a \fIsed\fP script. +Finally, writing a diagnostic message when a pattern specified by +the user is +unmatched by any file is useful behavior in all cases. +.LP +In this version, the \fB-n\fP was removed from the \fBcopy\fP mode +synopsis of \fIpax\fP; it is inapplicable because there +are no pattern operands specified in this mode. +.LP +There is another method than \fIpax\fP for copying subtrees in IEEE\ Std\ 1003.1-2001 +described as part of the \fIcp\fP utility. Both methods are historical +practice: \fIcp\fP +provides a simpler, more intuitive interface, while \fIpax\fP offers +a finer granularity of control. Each provides additional +functionality to the other; in particular, \fIpax\fP maintains the +hard-link structure of the hierarchy while \fIcp\fP does not. It is +the intention of the standard developers that the results be similar +(using +appropriate option combinations in both utilities). The results are +not required to be identical; there seemed insufficient gain to +applications to balance the difficulty of implementations having to +guarantee that the results would be exactly identical. +.LP +A single archive may span more than one file. It is suggested that +implementations provide informative messages to the user on +standard error whenever the archive file is changed. +.LP +The \fB-d\fP option (do not create intermediate directories not listed +in the archive) found in early proposals was originally +provided as a complement to the historic \fB-d\fP option of \fIcpio\fP. +It has been deleted. +.LP +The \fB-s\fP option in early proposals specified a subset of the substitution +command from the \fIed\fP utility. As there was no reason for only +a subset to be supported, the \fB-s\fP option is now +compatible with the current \fIed\fP specification. Since the delimiter +can be any non-null +character, the following usage with single spaces is valid: +.sp +.RS +.nf + +\fBpax -s " foo bar " ... +\fP +.fi +.RE +.LP +The \fB-t\fP description is worded so as to note that this may cause +the access time update caused by some other activity +(which occurs while the file is being read) to be overwritten. +.LP +The default behavior of \fIpax\fP with regard to file modification +times is the same as historical implementations of +\fItar\fP. It is not the historical behavior of \fIcpio\fP. +.LP +Because the \fB-i\fP option uses \fB/dev/tty\fP, utilities without +a controlling terminal are not able to use this option. +.LP +The \fB-y\fP option, found in early proposals, has been deleted because +a line containing a single period for the \fB-i\fP +option has equivalent functionality. The special lines for the \fB-i\fP +option (a single period and the empty line) are historical +practice in \fIcpio\fP. +.LP +In early drafts, a \fB-e\fP \fIcharmap\fP option was included to increase +portability of files between systems using different +coded character sets. This option was omitted because it was apparent +that consensus could not be formed for it. In this version, +the use of UTF-8 should be an adequate substitute. +.LP +The \fB-k\fP option was added to address international concerns about +the dangers involved in the character set transformations +of \fB-e\fP (if the target character set were different from the source, +the filenames might be transformed into names matching +existing files) and also was made more general to protect files transferred +between file systems with different {NAME_MAX} values +(truncating a filename on a smaller system might also inadvertently +overwrite existing files). As stated, it prevents any +overwriting, even if the target file is older than the source. This +version adds more granularity of options to solve this problem +by introducing the \fB-o\fP \fBinvalid=\fP option-specifically the +UTF-8 action. (Note that an existing file that is named with a +UTF-8 encoding is still subject to overwriting in this case. The \fB-k\fP +option closes that loophole.) +.LP +Some of the file characteristics referenced in this volume of IEEE\ Std\ 1003.1-2001 +might not be supported by some +archive formats. For example, neither the \fBtar\fP nor \fBcpio\fP +formats contain the file access time. For this reason, the +\fBe\fP specification character has been provided, intended to cause +all file characteristics specified in the archive to be +retained. +.LP +It is required that extracted directories, by default, have their +access and modification times and permissions set to the +values specified in the archive. This has obvious problems in that +the directories are almost certainly modified after being +extracted and that directory permissions may not permit file creation. +One possible solution is to create directories with the mode +specified in the archive, as modified by the \fIumask\fP of the user, +with sufficient +permissions to allow file creation. After all files have been extracted, +\fIpax\fP would then reset the access and modification +times and permissions as necessary. +.LP +The list-mode formatting description borrows heavily from the one +defined by the \fIprintf\fP utility. However, since there is no separate +operand list to get conversion arguments, +the format was extended to allow specifying the name of the conversion +argument as part of the conversion specification. +.LP +The \fBT\fP conversion specifier allows time fields to be displayed +in any of the date formats. Unlike the \fIls\fP utility, \fIpax\fP +does not adjust the format when the date is less than six months in +the +past. This makes parsing the output more predictable. +.LP +The \fBD\fP conversion specifier handles the ability to display the +major/minor or file size, as with \fIls\fP, by using \fB%-8(\fP\fIsize\fP\fB)D\fP. +.LP +The \fBL\fP conversion specifier handles the \fIls\fP display for +symbolic links. +.LP +Conversion specifiers were added to generate existing known types +used for \fIls\fP. +.SS pax Interchange Format +.LP +The new POSIX data interchange format was developed primarily to satisfy +international concerns that the \fBustar\fP and +\fBcpio\fP formats did not provide for file, user, and group names +encoded in characters outside a subset of the +ISO/IEC\ 646:1991 standard. The standard developers realized that +this new POSIX data interchange format should be very +extensible because there were other requirements they foresaw in the +near future: +.IP " *" 3 +Support international character encodings and locale information +.LP +.IP " *" 3 +Support security information (ACLs, and so on) +.LP +.IP " *" 3 +Support future file types, such as realtime or contiguous files +.LP +.IP " *" 3 +Include data areas for implementation use +.LP +.IP " *" 3 +Support systems with words larger than 32 bits and timers with subsecond +granularity +.LP +.LP +The following were not goals for this format because these are better +handled by separate utilities or are inappropriate for a +portable format: +.IP " *" 3 +Encryption +.LP +.IP " *" 3 +Compression +.LP +.IP " *" 3 +Data translation between locales and codesets +.LP +.IP " *" 3 +\fIinode\fP storage +.LP +.LP +The format chosen to support the goals is an extension of the \fBustar\fP +format. Of the two formats previously available, only +the \fBustar\fP format was selected for extensions because: +.IP " *" 3 +It was easier to extend in an upwards-compatible way. It offered version +flags and header block type fields with room for future +standardization. The \fBcpio\fP format, while possessing a more flexible +file naming methodology, could not be extended without +breaking some theoretical implementation or using a dummy filename +that could be a legitimate filename. +.LP +.IP " *" 3 +Industry experience since the original " \fItar\fP wars" fought in +developing the ISO\ POSIX-1 standard has clearly been +in favor of the \fBustar\fP format, which is generally the default +output format selected for \fIpax\fP implementations on new +systems. +.LP +.LP +The new format was designed with one additional goal in mind: reasonable +behavior when an older \fItar\fP or \fIpax\fP utility +happened to read an archive. Since the POSIX.1-1990 standard mandated +that a "format-reading utility" had to treat unrecognized +\fItypeflag\fP values as regular files, this allowed the format to +include all the extended information in a pseudo-regular file +that preceded each real file. An option is given that allows the archive +creator to set up reasonable names for these files on the +older systems. Also, the normative text suggests that reasonable file +access values be used for this \fBustar\fP header block. +Making these header files inaccessible for convenient reading and +deleting would not be reasonable. File permissions of 600 or 700 +are suggested. +.LP +The \fBustar\fP \fItypeflag\fP field was used to accommodate the additional +functionality of the new format rather than magic +or version because the POSIX.1-1990 standard (and, by reference, the +previous version of \fIpax\fP), mandated the behavior of the +format-reading utility when it encountered an unknown \fItypeflag\fP, +but was silent about the other two fields. +.LP +Early proposals of the first revision to IEEE\ Std\ 1003.1-2001 contained +a proposed archive format that was based on +compatibility with the standard for tape files (ISO\ 1001, similar +to the format used historically on many mainframes and +minicomputers). This format was overly complex and required considerable +overhead in volume and header records. Furthermore, the +standard developers felt that it would not be acceptable to the community +of POSIX developers, so it was later changed to be a +format more closely related to historical practice on POSIX systems. +.LP +The prefix and name split of pathnames in \fBustar\fP was replaced +by the single path extended header record for +simplicity. +.LP +The concept of a global extended header ( \fItypeflag\fP \fBg\fP) +was controversial. If this were applied to an archive being +recorded on magnetic tape, a few unreadable blocks at the beginning +of the tape could be a serious problem; a utility attempting to +extract as many files as possible from a damaged archive could lose +a large percentage of file header information in this case. +However, if the archive were on a reliable medium, such as a CD-ROM, +the global extended header offers considerable potential size +reductions by eliminating redundant information. Thus, the text warns +against using the global method for unreliable media and +provides a method for implanting global information in the extended +header for each file, rather than in the \fItypeflag\fP +\fBg\fP records. +.LP +No facility for data translation or filtering on a per-file basis +is included because the standard developers could not invent +an interface that would allow this in an efficient manner. If a filter, +such as encryption or compression, is to be applied to all +the files, it is more efficient to apply the filter to the entire +archive as a single file. The standard developers considered +interfaces that would invoke a shell script for each file going into +or out of the archive, but the system overhead in this +approach was considered to be too high. +.LP +One such approach would be to have \fBfilter=\fP records that give +a pathname for an executable. When the program is invoked, +the file and archive would be open for standard input/output and all +the header fields would be available as environment variables +or command-line arguments. The standard developers did discuss such +schemes, but they were omitted from +IEEE\ Std\ 1003.1-2001 due to concerns about excessive overhead. Also, +the program itself would need to be in the archive +if it were to be used portably. +.LP +There is currently no portable means of identifying the character +set(s) used for a file in the file system. Therefore, +\fIpax\fP has not been given a mechanism to generate charset records +automatically. The only portable means of doing this is for +the user to write the archive using the \fB-o\fP \fBcharset=\fP \fIstring\fP +command line option. This assumes that all of the +files in the archive use the same encoding. The "implementation-defined" +text is included to allow for a system that can identify +the encodings used for each of its files. +.LP +The table of standards that accompanies the charset record description +is acknowledged to be very limited. Only a limited number +of character set standards is reasonable for maximal interchange. +Any character set is, of course, possible by prior agreement. It +was suggested that EBCDIC be listed, but it was omitted because it +is not defined by a formal standard. Formal standards, and then +only those with reasonably large followings, can be included here, +simply as a matter of practicality. The <\fIvalue\fP>s +represent names of officially registered character sets in the format +required by the ISO\ 2375:1985 standard. +.LP +The normal comma or <blank>-separated list rules are not followed +in the case of keyword options to allow ease of argument +parsing for \fIgetopts\fP. +.LP +Further information on character encodings is in pax Archive Character +Set Encoding/Decoding +\&. +.LP +The standard developers have reserved keyword name space for vendor +extensions. It is suggested that the format to be used +is: +.sp +.RS +.nf + +\fIVENDOR.keyword\fP +.fi +.RE +.LP +where \fIVENDOR\fP is the name of the vendor or organization in all +uppercase letters. It is further suggested that the keyword +following the period be named differently than any of the standard +keywords so that it could be used for future standardization, if +appropriate, by omitting the \fIVENDOR\fP prefix. +.LP +The <\fIlength\fP> field in the extended header record was included +to make it simpler to step through the records, even +if a record contains an unknown format (to a particular \fIpax\fP) +with complex interactions of special characters. It also +provides a minor integrity checkpoint within the records to aid a +program attempting to recover files from a damaged archive. +.LP +There are no extended header versions of the \fIdevmajor\fP and \fIdevminor\fP +fields because the unspecified format +\fBustar\fP header field should be sufficient. If they are not, vendor-specific +extended keywords (such as \fIVENDOR.devmajor\fP) +should be used. +.LP +Device and \fIi\fP-number labeling of files was not adopted from \fIcpio\fP; +files are interchanged strictly on a symbolic +name basis, as in \fBustar\fP. +.LP +Just as with the \fBustar\fP format descriptions, the new format makes +no special arrangements for multi-volume archives. Each +of the \fIpax\fP archive types is assumed to be inside a single POSIX +file and splitting that file over multiple volumes +(diskettes, tape cartridges, and so on), processing their labels, +and mounting each in the proper sequence are considered to be +implementation details that cannot be described portably. +.LP +The \fBpax\fP format is intended for interchange, not only for backup +on a single (family of) systems. It is not as densely +packed as might be possible for backup: +.IP " *" 3 +It contains information as coded characters that could be coded in +binary. +.LP +.IP " *" 3 +It identifies extended records with name fields that could be omitted +in favor of a fixed-field layout. +.LP +.IP " *" 3 +It translates names into a portable character set and identifies locale-related +information, both of which are probably +unnecessary for backup. +.LP +.LP +The requirements on restoring from an archive are slightly different +from the historical wording, allowing for non-monolithic +privilege to bring forward as much as possible. In particular, attributes +such as "high performance file" might be broadly but +not universally granted while set-user-ID or \fIchown\fP() might be +much more restricted. +There is no implication in IEEE\ Std\ 1003.1-2001 that the security +information be honored after it is restored to the file +hierarchy, in spite of what might be improperly inferred by the silence +on that topic. That is a topic for another standard. +.LP +Links are recorded in the fashion described here because a link can +be to any file type. It is desirable in general to be able +to restore part of an archive selectively and restore all of those +files completely. If the data is not associated with each link, +it is not possible to do this. However, the data associated with a +file can be large, and when selective restoration is not needed, +this can be a significant burden. The archive is structured so that +files that have no associated data can always be restored by +the name of any link name of any link, and the user may choose whether +data is recorded with each instance of a file that contains +data. The format permits mixing of both types of links in a single +archive; this can be done for special needs, and \fIpax\fP is +expected to interpret such archives on input properly, despite the +fact that there is no \fIpax\fP option that would force this +mixed case on output. (When \fB-o\fP \fBlinkdata\fP is used, the output +must contain the duplicate data, but the implementation +is free to include it or omit it when \fB-o\fP \fBlinkdata\fP is not +used.) +.LP +The time values are included as extended header records for those +implementations needing more than the eleven octal digits +allowed by the \fBustar\fP format. Portable file timestamps cannot +be negative. If \fIpax\fP encounters a file with a negative +timestamp in \fBcopy\fP or \fBwrite\fP mode, it can reject the file, +substitute a non-negative timestamp, or generate a +non-portable timestamp with a leading \fB'-'\fP . Even though some +implementations can support finer file-time granularities +than seconds, the normative text requires support only for seconds +since the Epoch because the ISO\ POSIX-1 standard states +them that way. The \fBustar\fP format includes only \fImtime\fP; the +new format adds \fIatime\fP and \fIctime\fP for symmetry. +The \fIatime\fP access time restored to the file system will be affected +by the \fB-p\fP \fBa\fP and \fB-p\fP \fBe\fP options. +The \fIctime\fP creation time (actually \fIinode\fP modification time) +is described with "appropriate privilege" so that it can +be ignored when writing to the file system. POSIX does not provide +a portable means to change file creation time. Nothing is +intended to prevent a non-portable implementation of \fIpax\fP from +restoring the value. +.LP +The \fIgid\fP, \fIsize\fP, and \fIuid\fP extended header records were +included to allow expansion beyond the sizes specified +in the regular \fItar\fP header. New file system architectures are +emerging that will exhaust the 12-digit size field. There are +probably not many systems requiring more than 8 digits for user and +group IDs, but the extended header values were included for +completeness, allowing overrides for all of the decimal values in +the \fItar\fP header. +.LP +The standard developers intended to describe the effective results +of \fIpax\fP with regard to file ownerships and permissions; +implementations are not restricted in timing or sequencing the restoration +of such, provided the results are as specified. +.LP +Much of the text describing the extended headers refers to use in +" \fBwrite\fP or \fBcopy\fP modes". The \fBcopy\fP mode +references are due to the normative text: "The effect of the copy +shall be as if the copied files were written to an archive file +and then subsequently extracted ...". There is certainly no way to +test whether \fIpax\fP is actually generating the extended +headers in \fBcopy\fP mode, but the effects must be as if it had. +.SS pax Archive Character Set Encoding/Decoding +.LP +There is a need to exchange archives of files between systems of different +native codesets. Filenames, group names, and user +names must be preserved to the fullest extent possible when an archive +is read on the receiving platform. Translation of the +contents of files is not within the scope of the \fIpax\fP utility. +.LP +There will also be the need to represent characters that are not available +on the receiving platform. These unsupported +characters cannot be automatically folded to the local set of characters +due to the chance of collisions. This could result in +overwriting previous extracted files from the archive or pre-existing +files on the system. +.LP +For these reasons, the codeset used to represent characters within +the extended header records of the \fIpax\fP archive must be +sufficiently rich to handle all commonly used character sets. The +fields requiring translation include, at a minimum, filenames, +user names, group names, and link pathnames. Implementations may wish +to have localized extended keywords that use non-portable +characters. +.LP +The standard developers considered the following options: +.IP " *" 3 +The archive creator specifies the well-defined name of the source +codeset. The receiver must then recognize the codeset name and +perform the appropriate translations to the destination codeset. +.LP +.IP " *" 3 +The archive creator includes within the archive the character mapping +table for the source codeset used to encode extended +header records. The receiver must then read the character mapping +table and perform the appropriate translations to the destination +codeset. +.LP +.IP " *" 3 +The archive creator translates the extended header records in the +source codeset into a canonical form. The receiver must then +perform the appropriate translations to the destination codeset. +.LP +.LP +The approach that incorporates the name of the source codeset poses +the problem of codeset name registration, and makes the +archive useless to \fIpax\fP archive decoders that do not recognize +that codeset. +.LP +Because parts of an archive may be corrupted, the standard developers +felt that including the character map of the source +codeset was too fragile. The loss of this one key component could +result in making the entire archive useless. (The difference +between this and the global extended header decision was that the +latter has a workaround-duplicating extended header records on +unreliable media-but this would be too burdensome for large character +set maps.) +.LP +Both of the above approaches also put an undue burden on the \fIpax\fP +archive receiver to handle the cross-product of all +source and destination codesets. +.LP +To simplify the translation from the source codeset to the canonical +form and from the canonical form to the destination +codeset, the standard developers decided that the internal representation +should be a stateless encoding. A stateless encoding is +one where each codepoint has the same meaning, without regard to the +decoder being in a specific state. An example of a stateful +encoding would be the Japanese Shift-JIS; an example of a stateless +encoding would be the ISO/IEC\ 646:1991 standard +(equivalent to 7-bit ASCII). +.LP +For these reasons, the standard developers decided to adopt a canonical +format for the representation of file information +strings. The obvious, well-endorsed candidate is the ISO/IEC\ 10646-1:2000 +standard (based in part on Unicode), which can be +used to represent the characters of virtually all standardized character +sets. The standard developers initially agreed upon using +UCS2 (16-bit Unicode) as the internal representation. This repertoire +of characters provides a sufficiently rich set to represent +all commonly-used codesets. +.LP +However, the standard developers found that the 16-bit Unicode representation +had some problems. It forced the issue of +standardizing byte ordering. The 2-byte length of each character made +the extended header records twice as long for the case of +strings coded entirely from historical 7-bit ASCII. For these reasons, +the standard developers chose the UTF-8 defined in the +ISO/IEC\ 10646-1:2000 standard. This multi-byte representation encodes +UCS2 or UCS4 characters reliably and deterministically, +eliminating the need for a canonical byte ordering. In addition, NUL +octets and other characters possibly confusing to POSIX file +systems do not appear, except to represent themselves. It was realized +that certain national codesets take up more space after the +encoding, due to their placement within the UCS range; it was felt +that the usefulness of the encoding of the names outweighs the +disadvantage of size increase for file, user, and group names. +.LP +The encoding of UTF-8 is as follows: +.sp +.RS +.nf + +\fBUCS4 Hex Encoding UTF-8 Binary Encoding +.sp + +00000000-0000007F 0xxxxxxx +00000080-000007FF 110xxxxx 10xxxxxx +00000800-0000FFFF 1110xxxx 10xxxxxx 10xxxxxx +00010000-001FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx +00200000-03FFFFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx +04000000-7FFFFFFF 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx +\fP +.fi +.RE +.LP +where each \fB'x'\fP represents a bit value from the character being +translated. +.SS ustar Interchange Format +.LP +The description of the \fBustar\fP format reflects numerous enhancements +over pre-1988 versions of the historical \fItar\fP +utility. The goal of these changes was not only to provide the functional +enhancements desired, but also to retain compatibility +between new and old versions. This compatibility has been retained. +Archives written using the old archive format are compatible +with the new format. +.LP +Implementors should be aware that the previous file format did not +include a mechanism to archive directory type files. For this +reason, the convention of using a filename ending with slash was adopted +to specify a directory on the archive. +.LP +The total size of the \fIname\fP and \fIprefix\fP fields have been +set to meet the minimum requirements for {PATH_MAX}. If a +pathname will fit within the \fIname\fP field, it is recommended that +the pathname be stored there without the use of the +\fIprefix\fP field. Although the name field is known to be too small +to contain {PATH_MAX} characters, the value was not changed +in this version of the archive file format to retain backwards-compatibility, +and instead the prefix was introduced. Also, because +of the earlier version of the format, there is no way to remove the +restriction on the \fIlinkname\fP field being limited in size +to just that of the \fIname\fP field. +.LP +The \fIsize\fP field is required to be meaningful in all implementation +extensions, although it could be zero. This is required +so that the data blocks can always be properly counted. +.LP +It is suggested that if device special files need to be represented +that cannot be represented in the standard format, that one +of the extension types ( \fBA\fP- \fBZ\fP) be used, and that the additional +information for the special file be represented as +data and be reflected in the \fIsize\fP field. +.LP +Attempting to restore a special file type, where it is converted to +ordinary data and conflicts with an existing filename, need +not be specially detected by the utility. If run as an ordinary user, +\fIpax\fP should not be able to overwrite the entries in, +for example, \fB/dev\fP in any case (whether the file is converted +to another type or not). If run as a privileged user, it should +be able to do so, and it would be considered a bug if it did not. +The same is true of ordinary data files and similarly named +special files; it is impossible to anticipate the needs of the user +(who could really intend to overwrite the file), so the +behavior should be predictable (and thus regular) and rely on the +protection system as required. +.LP +The value 7 in the \fItypeflag\fP field is intended to define how +contiguous files can be stored in a \fBustar\fP archive. +IEEE\ Std\ 1003.1-2001 does not require the contiguous file extension, +but does define a standard way of archiving such +files so that all conforming systems can interpret these file types +in a meaningful and consistent manner. On a system that does +not support extended file types, the \fIpax\fP utility should do the +best it can with the file and go on to the next. +.LP +The file protection modes are those conventionally used by the \fIls\fP +utility. This is +extended beyond the usage in the ISO\ POSIX-2 standard to support +the "shared text" or "sticky" bit. It is intended that +the conformance document should not document anything beyond the existence +of and support of such a mode. Further extensions are +expected to these bits, particularly with overloading the set-user-ID +and set-group-ID flags. +.SS cpio Interchange Format +.LP +The reference to appropriate privilege in the \fBcpio\fP format refers +to an error on standard output; the \fBustar\fP format +does not make comparable statements. +.LP +The model for this format was the historical System V \fIcpio\fP \fB-c\fP +data interchange format. This model documents the +portable version of the \fBcpio\fP format and not the binary version. +It has the flexibility to transfer data of any type +described within IEEE\ Std\ 1003.1-2001, yet is extensible to transfer +data types specific to extensions beyond +IEEE\ Std\ 1003.1-2001 (for example, contiguous files). Because it +describes existing practice, there is no question of +maintaining upwards-compatibility. +.SS cpio Header +.LP +There has been some concern that the size of the \fIc_ino\fP field +of the header is too small to handle those systems that have +very large \fIinode\fP numbers. However, the \fIc_ino\fP field in +the header is used strictly as a hard-link resolution mechanism +for archives. It is not necessarily the same value as the \fIinode\fP +number of the file in the location from which that file is +extracted. +.LP +The name \fIc_magic\fP is based on historical usage. +.SS cpio Filename +.LP +For most historical implementations of the \fIcpio\fP utility, {PATH_MAX} +octets can be used to describe the pathname without +the addition of any other header fields (the NUL character would be +included in this count). {PATH_MAX} is the minimum value for +pathname size, documented as 256 bytes. However, an implementation +may use \fIc_namesize\fP to determine the exact length of the +pathname. With the current description of the \fI<cpio.h>\fP header, +this pathname +size can be as large as a number that is described in six octal digits. +.LP +Two values are documented under the \fIc_mode\fP field values to provide +for extensibility for known file types: +.TP 7 +\fB0110\ 000\fP +Reserved for contiguous files. The implementation may treat the rest +of the information for this archive like a regular file. +If this file type is undefined, the implementation may create the +file as a regular file. +.sp +.LP +This provides for extensibility of the \fBcpio\fP format while allowing +for the ability to read old archives. Files of an +unknown type may be read as "regular files" on some implementations. +On a system that does not support extended file types, the +\fIpax\fP utility should do the best it can with the file and go on +to the next. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIcp\fP , \fIed\fP , \fIgetopts\fP +, \fIls\fP , \fIprintf\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +\fI<cpio.h>\fP, the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIchown\fP(), \fIcreat\fP(), \fImkdir\fP(), \fImkfifo\fP(), \fIstat\fP(), +\fIutime\fP(), \fIwrite\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/pr.1p b/man1p/pr.1p new file mode 100644 index 000000000..0adef1175 --- /dev/null +++ b/man1p/pr.1p @@ -0,0 +1,414 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" pr +.SH NAME +pr \- print files +.SH SYNOPSIS +.LP +\fBpr\fP +\fB[\fP\fB+\fP\fIpage\fP\fB][\fP\fB-\fP\fIcolumn\fP\fB][\fP\fB-adFmrt\fP\fB][\fP\fB-e\fP\fB[\fP\fIchar\fP\fB][\fP\fI +gap\fP\fB]][\fP\fB-h\fP \fIheader\fP\fB][\fP\fB-i\fP\fB[\fP\fIchar\fP\fB][\fP\fIgap\fP\fB]] +.sp +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-l\fP +\fIlines\fP\fB][\fP\fB-n\fP\fB[\fP\fIchar\fP\fB][\fP\fIwidth\fP\fB]][\fP\fB-o\fP +\fIoffset\fP\fB][\fP\fB-s\fP\fB[\fP\fIchar\fP\fB]][\fP\fB-w\fP \fIwidth\fP\fB][\fP\fB-fp\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fIfile\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIpr\fP utility is a printing and pagination filter. If multiple +input files are specified, each shall be read, formatted, +and written to standard output. By default, the input shall be separated +into 66-line pages, each with: +.IP " *" 3 +A 5-line header that includes the page number, date, time, and the +pathname of the file +.LP +.IP " *" 3 +A 5-line trailer consisting of blank lines +.LP +.LP +If standard output is associated with a terminal, diagnostic messages +shall be deferred until the \fIpr\fP utility has +completed processing. +.LP +When options specifying multi-column output are specified, output +text columns shall be of equal width; input lines that do not +fit into a text column shall be truncated. By default, text columns +shall be separated with at least one <blank>. +.SH OPTIONS +.LP +The \fIpr\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that: the \fIpage\fP option has a +\fB'+'\fP delimiter; \fIpage\fP and \fIcolumn\fP can be multi-digit +numbers; some of the option-arguments are optional; and +some of the option-arguments cannot be specified as separate arguments +from the preceding option letter. In particular, the +\fB-s\fP option does not allow the option letter to be separated from +its argument, and the options \fB-e\fP, \fB-i\fP, and +\fB-n\fP require that both arguments, if present, not be separated +from the option letter. +.LP +The following options shall be supported. In the following option +descriptions, \fIcolumn\fP, \fIlines\fP, \fIoffset\fP, +\fIpage\fP, and \fIwidth\fP are positive decimal integers; \fIgap\fP +is a non-negative decimal integer. +.TP 7 +\fB+\fP\fIpage\fP +Begin output at page number \fIpage\fP of the formatted input. +.TP 7 +\fB-\fP\fIcolumn\fP +Produce multi-column output that is arranged in \fIcolumn\fP columns +(the default shall be 1) and is written down each column +in the order in which the text is received from the input file. This +option should not be used with \fB-m\fP. The options +\fB-e\fP and \fB-i\fP shall be assumed for multiple text-column output. +Whether or not text columns are produced with identical +vertical lengths is unspecified, but a text column shall never exceed +the length of the page (see the \fB-l\fP option). When used +with \fB-t\fP, use the minimum number of lines to write the output. +.TP 7 +\fB-a\fP +Modify the effect of the \fB-\fP \fIcolumn\fP option so that the columns +are filled across the page in a round-robin order +(for example, when \fIcolumn\fP is 2, the first input line heads column +1, the second heads column 2, the third is the second line +in column 1, and so on). +.TP 7 +\fB-d\fP +Produce output that is double-spaced; append an extra <newline> following +every <newline> found in the input. +.TP 7 +\fB-e[\fP\fIchar\fP\fB][\fP\fIgap\fP\fB]\fP +.sp +Expand each input <tab> to the next greater column position specified +by the formula \fIn\fP* \fIgap\fP+1, where \fIn\fP +is an integer > 0. If \fIgap\fP is zero or is omitted, it shall default +to 8. All <tab>s in the input shall be expanded +into the appropriate number of <space>s. If any non-digit character, +\fIchar\fP, is specified, it shall be used as the input +<tab>. +.TP 7 +\fB-f\fP +Use a <form-feed> for new pages, instead of the default behavior that +uses a sequence of <newline>s. Pause before +beginning the first page if the standard output is associated with +a terminal. +.TP 7 +\fB-F\fP +Use a <form-feed> for new pages, instead of the default behavior that +uses a sequence of <newline>s. +.TP 7 +\fB-h\ \fP \fIheader\fP +Use the string \fIheader\fP to replace the contents of the \fIfile\fP +operand in the page header. +.TP 7 +\fB-i[\fP\fIchar\fP\fB][\fP\fIgap\fP\fB]\fP +In output, replace multiple <space>s with <tab>s wherever two or more +adjacent <space>s reach column +positions \fIgap\fP+1, 2* \fIgap\fP+1, 3* \fIgap\fP+1, and so on. +If \fIgap\fP is zero or is omitted, default tab settings at +every eighth column position shall be assumed. If any non-digit character, +\fIchar\fP, is specified, it shall be used as the +output <tab>. +.TP 7 +\fB-l\ \fP \fIlines\fP +Override the 66-line default and reset the page length to \fIlines\fP. +If \fIlines\fP is not greater than the sum of both the +header and trailer depths (in lines), the \fIpr\fP utility shall suppress +both the header and trailer, as if the \fB-t\fP option +were in effect. +.TP 7 +\fB-m\fP +Merge files. Standard output shall be formatted so the \fIpr\fP utility +writes one line from each file specified by a +\fIfile\fP operand, side by side into text columns of equal fixed +widths, in terms of the number of column positions. +Implementations shall support merging of at least nine \fIfile\fP +operands. +.TP 7 +\fB-n[\fP\fIchar\fP\fB][\fP\fIwidth\fP\fB]\fP +.sp +Provide \fIwidth\fP-digit line numbering (default for \fIwidth\fP +shall be 5). The number shall occupy the first \fIwidth\fP +column positions of each text column of default output or each line +of \fB-m\fP output. If \fIchar\fP (any non-digit character) +is given, it shall be appended to the line number to separate it from +whatever follows (default for \fIchar\fP is a +<tab>). +.TP 7 +\fB-o\ \fP \fIoffset\fP +Each line of output shall be preceded by offset <space>s. If the \fB-o\fP +option is not specified, the default offset +shall be zero. The space taken is in addition to the output line width +(see the \fB-w\fP option below). +.TP 7 +\fB-p\fP +Pause before beginning each page if the standard output is directed +to a terminal ( \fIpr\fP shall write an <alert> to +standard error and wait for a <carriage-return> to be read on \fB/dev/tty\fP). +.TP 7 +\fB-r\fP +Write no diagnostic reports on failure to open files. +.TP 7 +\fB-s[\fP\fIchar\fP\fB]\fP +Separate text columns by the single character \fIchar\fP instead of +by the appropriate number of <space>s (default for +\fIchar\fP shall be <tab>). +.TP 7 +\fB-t\fP +Write neither the five-line identifying header nor the five-line trailer +usually supplied for each page. Quit writing after the +last line of each file without spacing to the end of the page. +.TP 7 +\fB-w\ \fP \fIwidth\fP +Set the width of the line to \fIwidth\fP column positions for multiple +text-column output only. If the \fB-w\fP option is not +specified and the \fB-s\fP option is not specified, the default width +shall be 72. If the \fB-w\fP option is not specified and +the \fB-s\fP option is specified, the default width shall be 512. +.LP +For single column output, input lines shall not be truncated. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be written. If no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP , the +standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP . +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files. +.LP +The file \fB/dev/tty\fP shall be used to read responses required by +the \fB-p\fP option. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIpr\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +which characters are defined as printable (character class +\fBprint\fP). Non-printable characters are still written to standard +output, but are not counted for the purpose for column-width +and line-length calculations. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_TIME\fP +Determine the format of the date and time for use in writing header +lines. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone used to calculate date and time strings written +in header lines. If \fITZ\fP is unset or null, an +unspecified default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +If \fIpr\fP receives an interrupt while writing to a terminal, it +shall flush all accumulated error messages to the screen +before terminating. +.SH STDOUT +.LP +The \fIpr\fP utility output shall be a paginated version of the original +file (or files). This pagination shall be accomplished +using either <form-feed>s or a sequence of <newline>s, as controlled +by the \fB-F\fP \ or \fB-f\fP +option. Page headers shall be generated unless the \fB-t\fP option +is specified. The page headers shall be of the form: +.sp +.RS +.nf + +\fB"\\n\\n%s %s Page %d\\n\\n\\n", <\fP\fIoutput of date\fP\fB>, <\fP\fIfile\fP\fB>, <\fP\fIpage number\fP\fB> +\fP +.fi +.RE +.LP +In the POSIX locale, the <\fIoutput\ of\ date\fP> field, representing +the date and time of last modification of +the input file (or the current date and time if the input file is +standard input), shall be equivalent to the output of the +following command as it would appear if executed at the given time: +.sp +.RS +.nf + +\fBdate "+%b %e %H:%M %Y" +\fP +.fi +.RE +.LP +without the trailing <newline>, if the page being written is from +standard input. If the page being written is not from +standard input, in the POSIX locale, the same format shall be used, +but the time used shall be the modification time of the file +corresponding to \fIfile\fP instead of the current time. When the +\fILC_TIME\fP locale category is not set to the POSIX locale, a +different format and order of presentation of this field may be used. +.LP +If the standard input is used instead of a \fIfile\fP operand, the +<\fIfile\fP> field shall be replaced by a null +string. +.LP +If the \fB-h\fP option is specified, the <\fIfile\fP> field shall +be replaced by the \fIheader\fP argument. +.SH STDERR +.LP +The standard error shall be used for diagnostic messages and for alerting +the terminal when \fB-p\fP is specified. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.IP " 1." 4 +Print a numbered list of all files in the current directory: +.sp +.RS +.nf + +\fBls -a | pr -n -h "Files in $(pwd)." +\fP +.fi +.RE +.LP +.IP " 2." 4 +Print \fBfile1\fP and \fBfile2\fP as a double-spaced, three-column +listing headed by "file list'': +.sp +.RS +.nf + +\fBpr -3d -h "file list" file1 file2 +\fP +.fi +.RE +.LP +.IP " 3." 4 +Write \fBfile1\fP on \fBfile2\fP, expanding tabs to columns 10, 19, +28, ...: +.sp +.RS +.nf + +\fBpr -e9 -t <file1 >file2 +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +This utility is one of those that does not follow the Utility Syntax +Guidelines because of its historical origins. The standard +developers could have added new options that obeyed the guidelines +(and marked the old options obsolescent) or devised an entirely +new utility; there are examples of both actions in this volume of +IEEE\ Std\ 1003.1-2001. Because of its widespread use by +historical applications, the standard developers decided to exempt +this version of \fIpr\fP from many of the guidelines. +.LP +Implementations are required to accept option-arguments to the \fB-h\fP, +\fB-l\fP, \fB-o\fP, and \fB-w\fP options whether +presented as part of the same argument or as a separate argument to +\fIpr\fP, as suggested by the Utility Syntax Guidelines. The +\fB-n\fP and \fB-s\fP options, however, are specified as in historical +practice because they are frequently specified without +their optional arguments. If a <blank> were allowed before the option-argument +in these cases, a \fIfile\fP operand could +mistakenly be interpreted as an option-argument in historical applications. +.LP +The text about the minimum number of lines in multi-column output +was included to ensure that a best effort is made in balancing +the length of the columns. There are known historical implementations +in which, for example, 60-line files are listed by \fIpr\fP +-2 as one column of 56 lines and a second of 4. Although this is not +a problem when a full page with headers and trailers is +produced, it would be relatively useless when used with \fB-t\fP. +.LP +Historical implementations of the \fIpr\fP utility have differed in +the action taken for the \fB-f\fP option. BSD uses it as +described here for the \fB-F\fP option; System V uses it to change +trailing <newline>s on each page to a <form-feed> +and, if standard output is a TTY device, sends an <alert> to standard +error and reads a line from \fB/dev/tty\fP before the +first page. There were strong arguments from both sides of this issue +concerning historical practice and as a result the \fB-F\fP +option was added. XSI-conformant systems support the System V historical +actions for the \fB-f\fP option. +.LP +The <\fIoutput\ of\ date\fP> field in the \fB-l\fP format is specified +only for the POSIX locale. As noted, the +format can be different in other locales. No mechanism for defining +this is present in this volume of +IEEE\ Std\ 1003.1-2001, as the appropriate vehicle is a message catalog; +that is, the format should be specified as a +"message". +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIexpand\fP , \fIlp\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/printf.1p b/man1p/printf.1p new file mode 100644 index 000000000..6be3a2459 --- /dev/null +++ b/man1p/printf.1p @@ -0,0 +1,426 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PRINTF" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" printf +.SH NAME +printf \- write formatted output +.SH SYNOPSIS +.LP +\fBprintf\fP \fIformat\fP\fB[\fP\fIargument\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIprintf\fP utility shall write formatted operands to the standard +output. The \fIargument\fP operands shall be formatted +under control of the \fIformat\fP operand. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIformat\fP +A string describing the format to use to write the remaining operands. +See the EXTENDED DESCRIPTION section. +.TP 7 +\fIargument\fP +The strings to be written to standard output, under the control of +\fIformat\fP. See the EXTENDED DESCRIPTION section. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIprintf\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_NUMERIC\fP +.sp +Determine the locale for numeric formatting. It shall affect the format +of numbers written using the \fBe\fP , \fBE\fP , +\fBf\fP , \fBg\fP , and \fBG\fP conversion specifier characters (if +supported). +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the EXTENDED DESCRIPTION section. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The \fIformat\fP operand shall be used as the \fIformat\fP string +described in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation with the following +exceptions: +.IP " 1." 4 +A <space> in the format string, in any context other than a flag of +a conversion specification, shall be treated as an +ordinary character that is copied to the output. +.LP +.IP " 2." 4 +A \fB' '\fP character in the format string shall be treated as a \fB' '\fP +character, not as a <space>. +.LP +.IP " 3." 4 +In addition to the escape sequences shown in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation +( \fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , +\fB'\\n'\fP , \fB'\\r'\fP , \fB'\\t'\fP , \fB'\\v'\fP ), \fB"\\ddd"\fP +, where \fIddd\fP is a one, two, or three-digit +octal number, shall be written as a byte with the numeric value specified +by the octal number. +.LP +.IP " 4." 4 +The implementation shall not precede or follow output from the \fBd\fP +or \fBu\fP conversion specifiers with +<blank>s not specified by the \fIformat\fP operand. +.LP +.IP " 5." 4 +The implementation shall not precede output from the \fBo\fP conversion +specifier with zeros not specified by the +\fIformat\fP operand. +.LP +.IP " 6." 4 +The \fBe\fP , \fBE\fP , \fBf\fP , \fBg\fP , and \fBG\fP conversion +specifiers need not be supported. +.LP +.IP " 7." 4 +An additional conversion specifier character, \fBb\fP , shall be supported +as follows. The argument shall be taken to be a +string that may contain backslash-escape sequences. The following +backslash-escape sequences shall be supported: +.RS +.IP " *" 3 +The escape sequences listed in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 5, File Format Notation ( \fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP +, \fB'\\f'\fP , +\fB'\\n'\fP , \fB'\\r'\fP , \fB'\\t'\fP , \fB'\\v'\fP ), which shall +be converted to the characters they represent +.LP +.IP " *" 3 +\fB"\\0ddd"\fP , where \fIddd\fP is a zero, one, two, or three-digit +octal number that shall be converted to a byte with the +numeric value specified by the octal number +.LP +.IP " *" 3 +\fB'\\c'\fP , which shall not be written and shall cause \fIprintf\fP +to ignore any remaining characters in the string +operand containing it, any remaining string operands, and any additional +characters in the \fIformat\fP operand +.LP +.RE +.LP +The interpretation of a backslash followed by any other sequence of +characters is unspecified. +.LP +Bytes from the converted string shall be written until the end of +the string or the number of bytes indicated by the precision +specification is reached. If the precision is omitted, it shall be +taken to be infinite, so all bytes up to the end of the +converted string shall be written. +.LP +.IP " 8." 4 +For each conversion specification that consumes an argument, the next +argument operand shall be evaluated and converted to the +appropriate type for the conversion as specified below. +.LP +.IP " 9." 4 +The \fIformat\fP operand shall be reused as often as necessary to +satisfy the argument operands. Any extra \fBc\fP or +\fBs\fP conversion specifiers shall be evaluated as if a null string +argument were supplied; other extra conversion +specifications shall be evaluated as if a zero argument were supplied. +If the \fIformat\fP operand contains no conversion +specifications and \fIargument\fP operands are present, the results +are unspecified. +.LP +.IP "10." 4 +If a character sequence in the \fIformat\fP operand begins with a +\fB'%'\fP character, but does not form a valid conversion +specification, the behavior is unspecified. +.LP +.LP +The \fIargument\fP operands shall be treated as strings if the corresponding +conversion specifier is \fBb\fP , \fBc\fP , +or \fBs\fP ; otherwise, it shall be evaluated as a C constant, as +described by the ISO\ C standard, with the following +extensions: +.IP " *" 3 +A leading plus or minus sign shall be allowed. +.LP +.IP " *" 3 +If the leading character is a single-quote or double-quote, the value +shall be the numeric value in the underlying codeset of +the character following the single-quote or double-quote. +.LP +.LP +If an argument operand cannot be completely converted into an internal +value appropriate to the corresponding conversion +specification, a diagnostic message shall be written to standard error +and the utility shall not exit with a zero exit status, but +shall continue processing any remaining operands and shall write the +value accumulated at the time the error was detected to +standard output. +.LP +It is not considered an error if an argument operand is not completely +used for a \fBc\fP or \fBs\fP conversion or if a +string operand's first or second character is used to get the numeric +value of a character. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The floating-point formatting conversion specifications of \fIprintf\fP() +are not +required because all arithmetic in the shell is integer arithmetic. +The \fIawk\fP utility +performs floating-point calculations and provides its own \fBprintf\fP +function. The \fIbc\fP +utility can perform arbitrary-precision floating-point arithmetic, +but does not provide extensive formatting capabilities. (This +\fIprintf\fP utility cannot really be used to format \fIbc\fP output; +it does not support +arbitrary precision.) Implementations are encouraged to support the +floating-point conversions as an extension. +.LP +Note that this \fIprintf\fP utility, like the \fIprintf\fP() function +defined in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001 on which it is +based, makes no special provision for dealing with +multi-byte characters when using the \fB%c\fP conversion specification +or when a precision is specified in a \fB%b\fP or +\fB%s\fP conversion specification. Applications should be extremely +cautious using either of these features when there are +multi-byte characters in the character set. +.LP +No provision is made in this volume of IEEE\ Std\ 1003.1-2001 which +allows field widths and precisions to be specified +as \fB'*'\fP since the \fB'*'\fP can be replaced directly in the \fIformat\fP +operand using shell variable substitution. +Implementations can also provide this feature as an extension if they +so choose. +.LP +Hexadecimal character constants as defined in the ISO\ C standard +are not recognized in the \fIformat\fP operand because +there is no consistent way to detect the end of the constant. Octal +character constants are limited to, at most, three octal +digits, but hexadecimal character constants are only terminated by +a non-hex-digit character. In the ISO\ C standard, the +\fB"##"\fP concatenation operator can be used to terminate a constant +and follow it with a hexadecimal character to be written. +In the shell, concatenation occurs before the \fIprintf\fP utility +has a chance to parse the end of the hexadecimal constant. +.LP +The \fB%b\fP conversion specification is not part of the ISO\ C standard; +it has been added here as a portable way to +process backslash escapes expanded in string operands as provided +by the \fIecho\fP utility. +See also the APPLICATION USAGE section of \fIecho\fP for ways to use +\fIprintf\fP as a replacement for +all of the traditional versions of the \fIecho\fP utility. +.LP +If an argument cannot be parsed correctly for the corresponding conversion +specification, the \fIprintf\fP utility is required +to report an error. Thus, overflow and extraneous characters at the +end of an argument being used for a numeric conversion shall be +reported as errors. +.SH EXAMPLES +.LP +To alert the user and then print and read a series of prompts: +.sp +.RS +.nf + +\fBprintf "\\aPlease fill in the following: \\nName: " +read name +printf "Phone number: " +read phone +\fP +.fi +.RE +.LP +To read out a list of right and wrong answers from a file, calculate +the percentage correctly, and print them out. The numbers +are right-justified and separated by a single <tab>. The percentage +is written to one decimal place of accuracy: +.sp +.RS +.nf + +\fBwhile read right wrong ; do + percent=$(echo "scale=1;($right*100)/($right+$wrong)" | bc) + printf "%2d right\\t%2d wrong\\t(%s%%)\\n" \\ + $right $wrong $percent +done < database_file +\fP +.fi +.RE +The command: +.sp +.RS +.nf + +\fBprintf "%5d%4d\\n" 1 21 321 4321 54321 +\fP +.fi +.RE +.LP +produces: +.sp +.RS +.nf + +\fB 1 21 + 3214321 +54321 0 +\fP +.fi +.RE +.LP +Note that the \fIformat\fP operand is used three times to print all +of the given strings and that a \fB'0'\fP was supplied +by \fIprintf\fP to satisfy the last \fB%4d\fP conversion specification. +.LP +The \fIprintf\fP utility is required to notify the user when conversion +errors are detected while producing numeric output; +thus, the following results would be expected on an implementation +with 32-bit twos-complement integers when \fB%d\fP is +specified as the \fIformat\fP operand: +.TS C +center; l1 l1 l. +\fB\ \fP \fBStandard\fP \fB\ \fP +\fBArgument\fP \fBOutput\fP \fBDiagnostic Output\fP +5a 5 printf: "5a" not completely converted +9999999999 2147483647 printf: "9999999999" arithmetic overflow +-9999999999 -2147483648 printf: "-9999999999" arithmetic overflow +ABC 0 printf: "ABC" expected numeric value +.TE +.LP +The diagnostic message format is not specified, but these examples +convey the type of information that should be reported. Note +that the value shown on standard output is what would be expected +as the return value from the \fIstrtol\fP() function as defined in +the System Interfaces volume of +IEEE\ Std\ 1003.1-2001. A similar correspondence exists between \fB%u\fP +and \fIstrtoul\fP() and \fB%e\fP , \fB%f\fP , and \fB%g\fP (if the +implementation supports +floating-point conversions) and \fIstrtod\fP(). +.LP +In a locale using the ISO/IEC\ 646:1991 standard as the underlying +codeset, the command: +.sp +.RS +.nf + +\fBprintf "%d\\n" 3 +3 -3 \\'3 \\"+3 "'-3" +\fP +.fi +.RE +.LP +produces: +.TP 7 +3 +Numeric value of constant 3 +.TP 7 +3 +Numeric value of constant 3 +.TP 7 +-3 +Numeric value of constant -3 +.TP 7 +51 +Numeric value of the character \fB'3'\fP in the ISO/IEC\ 646:1991 +standard codeset +.TP 7 +43 +Numeric value of the character \fB'+'\fP in the ISO/IEC\ 646:1991 +standard codeset +.TP 7 +45 +Numeric value of the character \fB'-'\fP in the ISO/IEC\ 646:1991 +standard codeset +.sp +.LP +Note that in a locale with multi-byte characters, the value of a character +is intended to be the value of the equivalent of the +\fBwchar_t\fP representation of the character as described in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001. +.SH RATIONALE +.LP +The \fIprintf\fP utility was added to provide functionality that has +historically been provided by \fIecho\fP. However, due to irreconcilable +differences in the various versions of \fIecho\fP extant, the version +has few special features, leaving those to this new \fIprintf\fP +utility, which is based on one in the Ninth Edition system. +.LP +The EXTENDED DESCRIPTION section almost exactly matches the \fIprintf\fP() +function in +the ISO\ C standard, although it is described in terms of the file +format notation in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 5, File Format Notation. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIawk\fP , \fIbc\fP , \fIecho\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIprintf\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/prs.1p b/man1p/prs.1p new file mode 100644 index 000000000..fba4d034c --- /dev/null +++ b/man1p/prs.1p @@ -0,0 +1,401 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PRS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" prs +.SH NAME +prs \- print an SCCS file (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBprs\fP \fB[\fP\fB-a\fP\fB][\fP\fB-d\fP +\fIdataspec\fP\fB][\fP\fB-r\fP\fB[\fP\fISID\fP\fB]]\fP \fIfile\fP\fB... +.br +.sp +\fP +.LP +\fBprs\fP \fB[\fP \fB-e| -l\fP\fB]\fP \fB-c\fP \fIcutoff\fP \fB[\fP\fB-d\fP +\fIdataspec\fP\fB]\fP \fIfile\fP\fB... +.br +.sp +\fP +.LP +\fBprs\fP \fB[\fP \fB-e| -l\fP\fB]\fP \fB-r\fP\fB[\fP\fISID\fP\fB][\fP\fB-d\fP +\fIdataspec\fP\fB]\fP\fIfile\fP\fB... +.br +\fP +.SH DESCRIPTION +.LP +The \fIprs\fP utility shall write to standard output parts or all +of an SCCS file in a user-supplied format. +.SH OPTIONS +.LP +The \fIprs\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the \fB-r\fP option has an +optional option-argument. This optional option-argument cannot be +presented as a separate argument. The following options shall be +supported: +.TP 7 +\fB-d\ \fP \fIdataspec\fP +Specify the output data specification. The \fIdataspec\fP shall be +a string consisting of SCCS file \fIdata\fP +\fIkeywords\fP (see Data Keywords ) interspersed with optional user-supplied +text. +.TP 7 +\fB-r[\fP\fISID\fP\fB]\fP +Specify the SCCS identification string (SID) of a delta for which +information is desired. If no \fISID\fP option-argument is +specified, the SID of the most recently created delta shall be assumed. +.TP 7 +\fB-e\fP +Request information for all deltas created earlier than and including +the delta designated via the \fB-r\fP option or the +date-time given by the \fB-c\fP option. +.TP 7 +\fB-l\fP +Request information for all deltas created later than and including +the delta designated via the \fB-r\fP option or the +date-time given by the \fB-c\fP option. +.TP 7 +\fB-c\ \fP \fIcutoff\fP +Indicate the \fIcutoff\fP date-time, in the form: +.sp +.RS +.nf + +\fIYY\fP\fB[\fP\fIMM\fP\fB[\fP\fIDD\fP\fB[\fP\fIHH\fP\fB[\fP\fIMM\fP\fB[\fP\fISS\fP\fB]]]]]\fP +.fi +.RE +.LP +For the \fIYY\fP component, values in the range [69,99] shall refer +to years 1969 to 1999 inclusive, and values in the range +[00,68] shall refer to years 2000 to 2068 inclusive. +.TP 7 +\fBNote:\fP +.RS +It is expected that in a future version of IEEE\ Std\ 1003.1-2001 +the default century inferred from a 2-digit year will +change. (This would apply to all commands accepting a 2-digit year +as input.) +.RE +.sp +.LP +No changes (deltas) to the SCCS file that were created after the specified +\fIcutoff\fP date-time shall be included in the +output. Units omitted from the date-time default to their maximum +possible values; for example, \fB-c\ 7502\fP is equivalent +to \fB-c\ 750228235959\fP. +.TP 7 +\fB-a\fP +Request writing of information for both removed-that is, \fIdelta\fP +\fItype\fP= +\fIR\fP (see \fIrmdel\fP )- and existing-that is, \fIdelta\fP +\fItype\fP= \fID\fP,- deltas. If the \fB-a\fP option is not specified, +information for existing deltas only shall be +provided. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file or a directory. If \fIfile\fP +is a directory, the \fIprs\fP utility shall behave as +though each file in the directory were specified as a named file, +except that non-SCCS files (last component of the pathname does +not begin with \fBs.\fP) and unreadable files shall be silently ignored. +.LP +If exactly one \fIfile\fP operand appears, and it is \fB'-'\fP , the +standard input shall be read; each line of the standard +input shall be taken to be the name of an SCCS file to be processed. +Non-SCCS files and unreadable files shall be silently +ignored. +.sp +.SH STDIN +.LP +The standard input shall be a text file used only when the \fIfile\fP +operand is specified as \fB'-'\fP . Each line of the +text file shall be interpreted as an SCCS pathname. +.SH INPUT FILES +.LP +Any SCCS files displayed are files of an unspecified format. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIprs\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be a text file whose format is dependent +on the data keywords specified with the \fB-d\fP option. +.SS Data Keywords +.LP +Data keywords specify which parts of an SCCS file shall be retrieved +and output. All parts of an SCCS file have an associated +data keyword. A data keyword may appear in a \fIdataspec\fP multiple +times. +.LP +The information written by \fIprs\fP shall consist of: +.IP " 1." 4 +The user-supplied text +.LP +.IP " 2." 4 +Appropriate values (extracted from the SCCS file) substituted for +the recognized data keywords in the order of appearance in the +\fIdataspec\fP +.LP +.LP +The format of a data keyword value shall either be simple ( \fB'S'\fP +), in which keyword substitution is direct, or +multi-line ( \fB'M'\fP ). +.LP +User-supplied text shall be any text other than recognized data keywords. +A <tab> shall be specified by \fB'\\t'\fP and +<newline> by \fB'\\n'\fP . When the \fB-r\fP option is not specified, +the default \fIdataspec\fP shall be: +.sp +.RS +.nf + +\fB:PN::\\n\\n +\fP +.fi +.RE +.LP +and the following \fIdataspec\fP shall be used for each selected delta: +.sp +.RS +.nf + +\fB:Dt:\\t:DL:\\nMRs:\\n:MR:COMMENTS:\\n:C: +\fP +.fi +.RE +.TS C +center;c1 s1 s1 s1 s. +\fBSCCS File Data Keywords\fP +.T& +l l l l l. +\fBKeyword\fP \fBData Item\fP \fBFile Section\fP \fBValue\fP \fBFormat\fP +\fB:Dt:\fP Delta information Delta Table \fBSee below*\fP S +\fB:DL:\fP Delta line statistics " \fB:Li:/:Ld:/:Lu:\fP S +\fB:Li:\fP Lines inserted by Delta " \fB\fInnnnn\fP***\fP S +\fB:Ld:\fP Lines deleted by Delta " \fB\fInnnnn\fP***\fP S +\fB:Lu:\fP Lines unchanged by Delta " \fB\fInnnnn\fP***\fP S +\fB:DT:\fP Delta type " \fBD or R\fP S +\fB:I:\fP SCCS ID string (SID) " \fBSee below**\fP S +\fB:R:\fP Release number " \fB\fInnnn\fP\fP S +\fB:L:\fP Level number " \fB\fInnnn\fP\fP S +\fB:B:\fP Branch number " \fB\fInnnn\fP\fP S +\fB:S:\fP Sequence number " \fB\fInnnn\fP\fP S +\fB:D:\fP Date delta created " \fB:Dy:/:Dm:/:Dd:\fP S +\fB:Dy:\fP Year delta created " \fB\fInn\fP\fP S +\fB:Dm:\fP Month delta created " \fB\fInn\fP\fP S +\fB:Dd:\fP Day delta created " \fB\fInn\fP\fP S +\fB:T:\fP Time delta created " \fB:Th:::Tm:::Ts:\fP S +\fB:Th:\fP Hour delta created " \fB\fInn\fP\fP S +\fB:Tm:\fP Minutes delta created " \fB\fInn\fP\fP S +\fB:Ts:\fP Seconds delta created " \fB\fInn\fP\fP S +\fB:P:\fP Programmer who created Delta " \fB\fIlogname\fP\fP S +\fB:DS:\fP Delta sequence number " \fB\fInnnn\fP\fP S +\fB:DP:\fP Predecessor Delta sequence " \fB\fInnnn\fP\fP S +\fB\ \fP number \ \fB\ \fP \ +\fB:DI:\fP Sequence number of deltas " \fB:Dn:/:Dx:/:Dg:\fP S +\fB\ \fP included, excluded, or ignored \ \fB\ \fP \ +\fB:Dn:\fP Deltas included (sequence #) " \fB:DS: :DS: ...\fP S +\fB:Dx:\fP Deltas excluded (sequence #) " \fB:DS: :DS: ...\fP S +\fB:Dg:\fP Deltas ignored (sequence #) " \fB:DS: :DS: ...\fP S +\fB:MR:\fP MR numbers for delta " \fB\fItext\fP\fP M +\fB:C:\fP Comments for delta " \fB\fItext\fP\fP M +\fB:UN:\fP User names User Names \fB\fItext\fP\fP M +\fB:FL:\fP Flag list Flags \fB\fItext\fP\fP M +\fB:Y:\fP Module type flag " \fB\fItext\fP\fP S +\fB:MF:\fP MR validation flag " \fByes or no\fP S +\fB:MP:\fP MR validation program name " \fB\fItext\fP\fP S +\fB:KF:\fP Keyword error, warning flag " \fByes or no\fP S +\fB:KV:\fP Keyword validation string " \fB\fItext\fP\fP S +\fB:BF:\fP Branch flag " \fByes or no\fP S +\fB:J:\fP Joint edit flag " \fByes or no\fP S +\fB:LK:\fP Locked releases " \fB:R: ...\fP S +\fB:Q:\fP User-defined keyword " \fB\fItext\fP\fP S +\fB:M:\fP Module name " \fB\fItext\fP\fP S +\fB:FB:\fP Floor boundary " \fB:R:\fP S +\fB:CB:\fP Ceiling boundary " \fB:R:\fP S +\fB:Ds:\fP Default SID " \fB:I:\fP S +\fB:ND:\fP Null delta flag " \fByes or no\fP S +\fB:FD:\fP File descriptive text Comments \fB\fItext\fP\fP M +\fB:BD:\fP Body Body \fB\fItext\fP\fP M +\fB:GB:\fP Gotten body " \fB\fItext\fP\fP M +\fB:W:\fP A form of \fIwhat\fP string N/A \fB:Z::M:\\t:I:\fP S +\fB:A:\fP A form of \fIwhat\fP string N/A \fB:Z::Y: :M: :I::Z:\fP S +\fB:Z:\fP \fIwhat\fP string delimiter N/A \fB\fB@(#)\fP\fP S +\fB:F:\fP SCCS filename N/A \fB\fItext\fP\fP S +\fB:PN:\fP SCCS file pathname N/A \fB\fItext\fP\fP S +.TE +.TP 7 +* +\fB:Dt:\fP= \fB:DT: :I: :D: :T: :P: :DS: :DP:\fP +.TP 7 +** +\fB:R:.:L:.:B:.:S:\fP if the delta is a branch delta ( \fB:BF:\fP== +\fByes\fP) +.br +\fB:R:.:L:\fP if the delta is not a branch delta ( \fB:BF:\fP== \fBno\fP) +.TP 7 +*** +The line statistics are capped at 99999. For example, if 100000 lines +were unchanged in a certain revision, \fB:Lu:\fP shall +produce the value 99999. +.sp +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.IP " 1." 4 +The following example: +.sp +.RS +.nf + +\fBprs -d "User Names for :F: are:\\n:UN:" s.file +\fP +.fi +.RE +.LP +might write to standard output: +.sp +.RS +.nf + +\fBUser Names for s.file are: +xyz +131 +abc +\fP +.fi +.RE +.LP +.IP " 2." 4 +The following example: +.sp +.RS +.nf + +\fBprs -d "Delta for pgm :M:: :I: - :D: By :P:" -r s.file +\fP +.fi +.RE +.LP +might write to standard output: +.sp +.RS +.nf + +\fBDelta for pgm main.c: 3.7 - 77/12/01 By cas +\fP +.fi +.RE +.LP +.IP " 3." 4 +As a special case: +.sp +.RS +.nf + +\fBprs s.file +\fP +.fi +.RE +.LP +might write to standard output: +.sp +.RS +.nf + +\fBs.file: +<\fP\fIblank line\fP\fB> +D 1.1 77/12/01 00:00:00 cas 1 000000/00000/00000 +MRs: +bl78-12345 +bl79-54321 +COMMENTS: +this is the comment line for s.file initial delta +<\fP\fIblank line\fP\fB> +\fP +.fi +.RE +.LP +for each delta table entry of the \fBD\fP type. The only option allowed +to be used with this special case is the \fB-a\fP +option. +.LP +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIadmin\fP , \fIdelta\fP , \fIget\fP , \fIwhat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ps.1p b/man1p/ps.1p new file mode 100644 index 000000000..a550a4951 --- /dev/null +++ b/man1p/ps.1p @@ -0,0 +1,598 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ps +.SH NAME +ps \- report process status +.SH SYNOPSIS +.LP +\fBps\fP \fB[\fP\fB-aA\fP\fB][\fP\fB-defl\fP\fB][\fP\fB-G\fP +\fIgrouplist\fP\fB][\fP\fB-o\fP \fIformat\fP\fB]\fP\fB...\fP\fB[\fP\fB-p\fP +\fIproclist\fP\fB][\fP\fB-t\fP +\fItermlist\fP\fB] +.br +.sp +[\fP\fB-U\fP \fIuserlist\fP\fB][\fP\fB-g\fP \fIgrouplist\fP\fB][\fP\fB-n\fP +\fInamelist\fP\fB][\fP\fB-u\fP +\fIuserlist\fP\fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIps\fP utility shall write information about processes, subject +to having the appropriate privileges to obtain +information about those processes. +.LP +By default, \fIps\fP shall select all processes with the same effective +user ID as the current user and the same controlling +terminal as the invoker. +.SH OPTIONS +.LP +The \fIps\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Write information for all processes associated with terminals. Implementations +may omit session leaders from this list. +.TP 7 +\fB-A\fP +Write information for all processes. +.TP 7 +\fB-d\fP +Write information for all processes, except session leaders. +.TP 7 +\fB-e\fP +Write information for all processes. (Equivalent to +\fB-A\fP.) +.TP 7 +\fB-f\fP +Generate a \fBfull\fP listing. (See the STDOUT section for the contents +of a \fBfull\fP listing.) +.TP 7 +\fB-g\ \fP \fIgrouplist\fP +Write information for processes whose session leaders are given in +\fIgrouplist\fP. The application shall ensure that the +\fIgrouplist\fP is a single argument in the form of a <blank> or comma-separated +list. +.TP 7 +\fB-G\ \fP \fIgrouplist\fP +Write information for processes whose real group ID numbers are given +in \fIgrouplist\fP. The application shall ensure that +the \fIgrouplist\fP is a single argument in the form of a <blank> +or comma-separated list. +.TP 7 +\fB-l\fP +Generate a \fBlong\fP listing. (See STDOUT for the contents of a \fBlong\fP +listing.) +.TP 7 +\fB-n\ \fP \fInamelist\fP +Specify the name of an alternative system \fInamelist\fP file in place +of the default. The name of the default file and the format +of a \fInamelist\fP file are unspecified. +.TP 7 +\fB-o\ \fP \fIformat\fP +Write information according to the format specification given in \fIformat\fP. +This is fully described in the STDOUT section. +Multiple \fB-o\fP options can be specified; the format specification +shall be interpreted as the <space>-separated +concatenation of all the \fIformat\fP option-arguments. +.TP 7 +\fB-p\ \fP \fIproclist\fP +Write information for processes whose process ID numbers are given +in \fIproclist\fP. The application shall ensure that the +\fIproclist\fP is a single argument in the form of a <blank> or comma-separated +list. +.TP 7 +\fB-t\ \fP \fItermlist\fP +Write information for processes associated with terminals given in +\fItermlist\fP. The application shall ensure that the +\fItermlist\fP is a single argument in the form of a <blank> or comma-separated +list. Terminal identifiers shall be given in +an implementation-defined format. \ On XSI-conformant systems, they +shall be given in one of two forms: the device's filename +(for example, \fBtty04\fP) or, if the device's filename starts with +\fBtty\fP, just the identifier following the characters +\fBtty\fP (for example, \fB"04"\fP ). +.TP 7 +\fB-u\ \fP \fIuserlist\fP +Write information for processes whose user ID numbers or login names +are given in \fIuserlist\fP. The application shall ensure +that the \fIuserlist\fP is a single argument in the form of a <blank> +or comma-separated list. In the listing, the numerical +user ID shall be written unless the \fB-f\fP option is used, in which +case the login name shall be written. +.TP 7 +\fB-U\ \fP \fIuserlist\fP +Write information for processes whose real user ID numbers or login +names are given in \fIuserlist\fP. The application shall +ensure that the \fIuserlist\fP is a single argument in the form of +a <blank> or comma-separated list. +.sp +.LP +With the exception of \fB-o\fP \fIformat\fP, all of the options shown +are used to select processes. If any are specified, the +default list shall be ignored and \fIps\fP shall select the processes +represented by the inclusive OR of all the +selection-criteria options. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIps\fP: +.TP 7 +\fICOLUMNS\fP +Override the system-selected horizontal display line size, used to +determine the number of text columns to display. See the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables for valid values and results when it is unset or null. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fILC_TIME\fP +Determine the format and contents of the date and time strings displayed. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone used to calculate date and time strings displayed. +If \fITZ\fP is unset or null, an unspecified default +timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When the \fB-o\fP option is not specified, the standard output format +is unspecified. +.LP +On XSI-conformant systems, the output format shall be as follows. +The column headings and descriptions of the columns in a +\fIps\fP listing are given below. The precise meanings of these fields +are implementation-defined. The letters \fB'f'\fP and +\fB'l'\fP (below) indicate the option ( \fBfull\fP or \fBlong\fP) +that shall cause the corresponding heading to appear; +\fBall\fP means that the heading always appears. Note that these two +options determine only what information is provided for a +process; they do not determine which processes are listed. +.TS C +center; l l lw(40). +\fBF\fP (l) T{ +.na +Flags (octal and additive) associated with the process. +.ad +T} +\fBS\fP (l) T{ +.na +The state of the process. +.ad +T} +\fBUID\fP (f,l) T{ +.na +The user ID number of the process owner; the login name is printed under the \fB-f\fP option. +.ad +T} +\fBPID\fP (all) T{ +.na +The process ID of the process; it is possible to kill a process if this datum is known. +.ad +T} +\fBPPID\fP (f,l) T{ +.na +The process ID of the parent process. +.ad +T} +\fBC\fP (f,l) T{ +.na +Processor utilization for scheduling. +.ad +T} +\fBPRI\fP (l) T{ +.na +The priority of the process; higher numbers mean lower priority. +.ad +T} +\fBNI\fP (l) T{ +.na +Nice value; used in priority computation. +.ad +T} +\fBADDR\fP (l) T{ +.na +The address of the process. +.ad +T} +\fBSZ\fP (l) T{ +.na +The size in blocks of the core image of the process. +.ad +T} +\fBWCHAN\fP (l) T{ +.na +The event for which the process is waiting or sleeping; if blank, the process is running. +.ad +T} +\fBSTIME\fP (f) T{ +.na +Starting time of the process. +.ad +T} +\fBTTY\fP (all) T{ +.na +The controlling terminal for the process. +.ad +T} +\fBTIME\fP (all) T{ +.na +The cumulative execution time for the process. +.ad +T} +\fBCMD\fP (all) T{ +.na +The command name; the full command name and its arguments are written under the \fB-f\fP option. +.ad +T} +.TE +.LP +A process that has exited and has a parent, but has not yet been waited +for by the parent, shall be marked \fBdefunct\fP. +.LP +Under the option \fB-f\fP, \fIps\fP tries to determine the command +name and arguments given when the process was created by +examining memory or the swap area. Failing this, the command name, +as it would appear without the option \fB-f\fP, is written in +square brackets. +.LP +The \fB-o\fP option allows the output format to be specified under +user control. +.LP +The application shall ensure that the format specification is a list +of names presented as a single argument, <blank> or +comma-separated. Each variable has a default header. The default header +can be overridden by appending an equals sign and the new +text of the header. The rest of the characters in the argument shall +be used as the header text. The fields specified shall be +written in the order specified on the command line, and should be +arranged in columns in the output. The field widths shall be +selected by the system to be at least as wide as the header text (default +or overridden value). If the header text is null, such as +\fB-o\fP \fIuser\fP=, the field width shall be at least as wide as +the default header text. If all header text fields are null, +no header line shall be written. +.LP +The following names are recognized in the POSIX locale: +.TP 7 +\fBruser\fP +The real user ID of the process. This shall be the textual user ID, +if it can be obtained and the field width permits, or a +decimal representation otherwise. +.TP 7 +\fBuser\fP +The effective user ID of the process. This shall be the textual user +ID, if it can be obtained and the field width permits, or +a decimal representation otherwise. +.TP 7 +\fBrgroup\fP +The real group ID of the process. This shall be the textual group +ID, if it can be obtained and the field width permits, or a +decimal representation otherwise. +.TP 7 +\fBgroup\fP +The effective group ID of the process. This shall be the textual group +ID, if it can be obtained and the field width permits, +or a decimal representation otherwise. +.TP 7 +\fBpid\fP +The decimal value of the process ID. +.TP 7 +\fBppid\fP +The decimal value of the parent process ID. +.TP 7 +\fBpgid\fP +The decimal value of the process group ID. +.TP 7 +\fBpcpu\fP +The ratio of CPU time used recently to CPU time available in the same +period, expressed as a percentage. The meaning of +"recently" in this context is unspecified. The CPU time available +is determined in an unspecified manner. +.TP 7 +\fBvsz\fP +The size of the process in (virtual) memory in 1024 byte units as +a decimal integer. +.TP 7 +\fBnice\fP +The decimal value of the nice value of the process; see \fInice\fP() +\&. +.TP 7 +\fBetime\fP +In the POSIX locale, the elapsed time since the process was started, +in the form: +.sp +.RS +.nf + +\fB[[\fP\fIdd\fP\fB-\fP\fB]\fP\fIhh\fP\fB:\fP\fB]\fP\fImm\fP\fB:\fP\fIss\fP +.fi +.RE +.LP +where \fIdd\fP shall represent the number of days, \fIhh\fP the number +of hours, \fImm\fP the number of minutes, and +\fIss\fP the number of seconds. The \fIdd\fP field shall be a decimal +integer. The \fIhh\fP, \fImm\fP, and \fIss\fP fields +shall be two-digit decimal integers padded on the left with zeros. +.TP 7 +\fBtime\fP +In the POSIX locale, the cumulative CPU time of the process in the +form: +.sp +.RS +.nf + +\fB[\fP\fIdd\fP\fB-\fP\fB]\fP\fIhh\fP\fB:\fP\fImm\fP\fB:\fP\fIss\fP +.fi +.RE +.LP +The \fIdd\fP, \fIhh\fP, \fImm\fP, and \fIss\fP fields shall be as +described in the \fBetime\fP specifier. +.TP 7 +\fBtty\fP +The name of the controlling terminal of the process (if any) in the +same format used by the \fIwho\fP utility. +.TP 7 +\fBcomm\fP +The name of the command being executed ( \fIargv\fP[0] value) as a +string. +.TP 7 +\fBargs\fP +The command with all its arguments as a string. The implementation +may truncate this value to the field width; it is +implementation-defined whether any further truncation occurs. It is +unspecified whether the string represented is a version of the +argument list as it was passed to the command when it started, or +is a version of the arguments as they may have been modified by +the application. Applications cannot depend on being able to modify +their argument list and having that modification be reflected +in the output of \fIps\fP. +.sp +.LP +Any field need not be meaningful in all implementations. In such a +case a hyphen ( \fB'-'\fP ) should be output in place of +the field value. +.LP +Only \fBcomm\fP and \fBargs\fP shall be allowed to contain <blank>s; +all others shall not. Any implementation-defined +variables shall be specified in the system documentation along with +the default header and indicating whether the field may contain +<blank>s. +.LP +The following table specifies the default header to be used in the +POSIX locale corresponding to each format specifier. +.br +.sp +.ce 1 +\fBTable: Variable Names and Default Headers in \fIps\fP\fP +.TS C +center; l1 l1 l1 l. +\fBFormat Specifier\fP \fBDefault Header\fP \fBFormat Specifier\fP \fBDefault Header\fP +\fBargs\fP \fBCOMMAND\fP \fBppid\fP \fBPPID\fP +\fBcomm\fP \fBCOMMAND\fP \fBrgroup\fP \fBRGROUP\fP +\fBetime\fP \fBELAPSED\fP \fBruser\fP \fBRUSER\fP +\fBgroup\fP \fBGROUP\fP \fBtime\fP \fBTIME\fP +\fBnice\fP \fBNI\fP \fBtty\fP \fBTT\fP +\fBpcpu\fP \fB%CPU\fP \fBuser\fP \fBUSER\fP +\fBpgid\fP \fBPGID\fP \fBvsz\fP \fBVSZ\fP +\fBpid\fP \fBPID\fP \fB\ \fP \fB\ \fP +.TE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Things can change while \fIps\fP is running; the snapshot it gives +is only true for an instant, and might not be accurate by +the time it is displayed. +.LP +The \fBargs\fP format specifier is allowed to produce a truncated +version of the command arguments. In some implementations, +this information is no longer available when the \fIps\fP utility +is executed. +.LP +If the field width is too narrow to display a textual ID, the system +may use a numeric version. Normally, the system would be +expected to choose large enough field widths, but if a large number +of fields were selected to write, it might squeeze fields to +their minimum sizes to fit on one line. One way to ensure adequate +width for the textual IDs is to override the default header for +a field to make it larger than most or all user or group names. +.LP +There is no special quoting mechanism for header text. The header +text is the rest of the argument. If multiple header changes +are needed, multiple \fB-o\fP options can be used, such as: +.sp +.RS +.nf + +\fBps -o "user=User Name" -o pid=Process\\ ID +\fP +.fi +.RE +.LP +On some implementations, especially multi-level secure systems, \fIps\fP +may be severely restricted and produce information +only about child processes owned by the user. +.SH EXAMPLES +.LP +The command: +.sp +.RS +.nf + +\fBps -o user,pid,ppid=MOM -o args +\fP +.fi +.RE +.LP +writes at least the following in the POSIX locale: +.sp +.RS +.nf + +\fB USER PID MOM COMMAND +helene 34 12 ps -o uid,pid,ppid=MOM -o args +\fP +.fi +.RE +.LP +The contents of the \fBCOMMAND\fP field need not be the same in all +implementations, due to possible truncation. +.SH RATIONALE +.LP +There is very little commonality between BSD and System V implementations +of \fIps\fP. Many options conflict or have subtly +different usages. The standard developers attempted to select a set +of options for the base standard that were useful on a wide +range of systems and selected options that either can be implemented +on both BSD and System V-based systems without breaking the +current implementations or where the options are sufficiently similar +that any changes would not be unduly problematic for users or +implementors. +.LP +It is recognized that on some implementations, especially multi-level +secure systems, \fIps\fP may be nearly useless. The +default output has therefore been chosen such that it does not break +historical implementations and also is likely to provide at +least some useful information on most systems. +.LP +The major change is the addition of the format specification capability. +The motivation for this invention is to provide a +mechanism for users to access a wider range of system information, +if the system permits it, in a portable manner. The fields +chosen to appear in this volume of IEEE\ Std\ 1003.1-2001 were arrived +at after considering what concepts were likely to be +both reasonably useful to the "average" user and had a reasonable +chance of being implemented on a wide range of systems. Again +it is recognized that not all systems are able to provide all the +information and, conversely, some may wish to provide more. It is +hoped that the approach adopted will be sufficiently flexible and +extensible to accommodate most systems. Implementations may be +expected to introduce new format specifiers. +.LP +The default output should consist of a short listing containing the +process ID, terminal name, cumulative execution time, and +command name of each process. +.LP +The preference of the standard developers would have been to make +the format specification an operand of the \fIps\fP command. +Unfortunately, BSD usage precluded this. +.LP +At one time a format was included to display the environment array +of the process. This was deleted because there is no portable +way to display it. +.LP +The \fB-A\fP option is equivalent to the BSD \fB-g\fP and the SVID +\fB-e\fP. Because the two systems differed, a mnemonic +compromise was selected. +.LP +The \fB-a\fP option is described with some optional behavior because +the SVID omits session leaders, but BSD does not. +.LP +In an early proposal, format specifiers appeared for priority and +start time. The former was not defined adequately in this +volume of IEEE\ Std\ 1003.1-2001 and was removed in deference to the +defined nice value; the latter because elapsed time +was considered to be more useful. +.LP +In a new BSD version of \fIps\fP, a \fB-O\fP option can be used to +write all of the default information, followed by +additional format specifiers. This was not adopted because the default +output is implementation-defined. Nevertheless, this is a +useful option that should be reserved for that purpose. In the \fB-o\fP +option for the POSIX Shell and Utilities \fIps\fP, the +format is the concatenation of each \fB-o\fP. Therefore, the user +can have an alias or function that defines the beginning of +their desired format and add more fields to the end of the output +in certain cases where that would be useful. +.LP +The format of the terminal name is unspecified, but the descriptions +of \fIps\fP, \fItalk\fP, \fIwho\fP, and \fIwrite\fP require that they +all use the same format. +.LP +The \fBpcpu\fP field indicates that the CPU time available is determined +in an unspecified manner. This is because it is +difficult to express an algorithm that is useful across all possible +machine architectures. Historical counterparts to this value +have attempted to show percentage of use in the recent past, such +as the preceding minute. Frequently, these values for all +processes did not add up to 100%. Implementations are encouraged to +provide data in this field to users that will help them +identify processes currently affecting the performance of the system. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIkill\fP() , \fInice\fP() , \fIrenice\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/pwd.1p b/man1p/pwd.1p new file mode 100644 index 000000000..eedbfd162 --- /dev/null +++ b/man1p/pwd.1p @@ -0,0 +1,156 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "PWD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" pwd +.SH NAME +pwd \- return working directory name +.SH SYNOPSIS +.LP +\fBpwd\fP \fB[\fP\fB-L | -P\fP \fB]\fP +.SH DESCRIPTION +.LP +The \fIpwd\fP utility shall write to standard output an absolute pathname +of the current working directory, which does not +contain the filenames dot or dot-dot. +.SH OPTIONS +.LP +The \fIpwd\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-L\fP +If the \fIPWD\fP environment variable contains an absolute pathname +of the current directory that does not contain the +filenames dot or dot-dot, \fIpwd\fP shall write this pathname to standard +output. Otherwise, the \fB-L\fP option shall behave as +the \fB-P\fP option. +.TP 7 +\fB-P\fP +The absolute pathname written shall not contain filenames that, in +the context of the pathname, refer to files of type symbolic +link. +.sp +.LP +If both \fB-L\fP and \fB-P\fP are specified, the last one shall apply. +If neither \fB-L\fP nor \fB-P\fP is specified, the +\fIpwd\fP utility shall behave as if \fB-L\fP had been specified. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIpwd\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPWD\fP +If the \fB-P\fP option is in effect, this variable shall be set to +an absolute pathname of the current working directory that +does not contain any components that specify symbolic links, does +not contain any components that are dot, and does not contain any +components that are dot-dot. If an application sets or unsets the +value of \fIPWD ,\fP the behavior of \fIpwd\fP is +unspecified. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIpwd\fP utility output is an absolute pathname of the current +working directory: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIdirectory pathname\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If an error is detected, output shall not be written to standard output, +a diagnostic message shall be written to standard +error, and the exit status is not zero. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Some implementations have historically provided \fIpwd\fP as a shell +special built-in command. +.LP +In most utilities, if an error occurs, partial output may be written +to standard output. This does not happen in historical +implementations of \fIpwd\fP. Because \fIpwd\fP is frequently used +in historical shell scripts without checking the exit status, +it is important that the historical behavior is required here; therefore, +the CONSEQUENCES OF ERRORS section specifically disallows +any partial output being written to standard output. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcd\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIgetcwd\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qalter.1p b/man1p/qalter.1p new file mode 100644 index 000000000..7c0049841 --- /dev/null +++ b/man1p/qalter.1p @@ -0,0 +1,790 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QALTER" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qalter +.SH NAME +qalter \- alter batch job +.SH SYNOPSIS +.LP +\fBqalter\fP \fB[\fP\fB-a\fP \fIdate_time\fP\fB][\fP\fB-A\fP +\fIaccount_string\fP\fB][\fP\fB-c\fP \fIinterval\fP\fB][\fP\fB-e\fP +\fIpath_name\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-h\fP \fIhold_list\fP\fB][\fP\fB-j\fP +\fIjoin_list\fP\fB][\fP\fB-k\fP \fIkeep_list\fP\fB][\fP\fB-l\fP \fIresource_list\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-m\fP \fImail_options\fP\fB][\fP\fB-M\fP +\fImail_list\fP\fB][\fP\fB-N\fP \fIname\fP\fB][\fP\fB-o\fP \fIpath_name\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-p\fP \fIpriority\fP\fB][\fP\fB-r\fP +\fIy\fP\fB|\fP\fIn\fP\fB][\fP\fB-S\fP \fIpath_name_list\fP\fB][\fP\fB-u\fP +\fIuser_list\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB\fP\fIjob_identifier\fP \fB... \fP +.SH DESCRIPTION +.LP +The attributes of a batch job are altered by a request to the batch +server that manages the batch job. The \fIqalter\fP utility +is a user-accessible batch client that requests the alteration of +the attributes of one or more batch jobs. +.LP +The \fIqalter\fP utility shall alter the attributes of those batch +jobs, and only those batch jobs, for which a batch +\fIjob_identifier\fP is presented to the utility. +.LP +The \fIqalter\fP utility shall alter the attributes of batch jobs +in the order in which the batch \fIjob_identifier\fPs are +presented to the utility. +.LP +If the \fIqalter\fP utility fails to process a batch \fIjob_identifier\fP +successfully, the utility shall proceed to process +the remaining batch \fIjob_identifier\fPs, if any. +.LP +For each batch \fIjob_identifier\fP for which the \fIqalter\fP utility +succeeds, each attribute of the identified batch job +shall be altered as indicated by all the options presented to the +utility. +.LP +For each identified batch job for which the \fIqalter\fP utility fails, +the utility shall not alter any attribute of the batch +job. +.LP +For each batch job that the \fIqalter\fP utility processes, the utility +shall not modify any attribute other than those +required by the options and option-arguments presented to the utility. +.LP +The \fIqalter\fP utility shall alter batch jobs by sending a \fIModify +Job Request\fP to the batch server that manages each +batch job. At the time the \fIqalter\fP utility exits, it shall have +modified the batch job corresponding to each successfully +processed batch \fIjob_identifier\fP. An attempt to alter the attributes +of a batch job in the RUNNING state is +implementation-defined. +.SH OPTIONS +.LP +The \fIqalter\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-a\ \fP \fIdate_time\fP +Redefine the time at which the batch job becomes eligible for execution. +.LP +The \fIdate_time\fP argument shall be in the same form and represent +the same time as for the \fItouch\fP utility. The time so represented +shall be set into the \fIExecution_Time\fP attribute +of the batch job. If the time specified is earlier than the current +time, the \fB-a\fP option shall have no effect. +.TP 7 +\fB-A\ \fP \fIaccount_string\fP +.sp +Redefine the account to which the resource consumption of the batch +job should be charged. +.LP +The syntax of the \fIaccount_string\fP option-argument is unspecified. +.LP +The \fIqalter\fP utility shall set the \fIAccount_Name\fP attribute +of the batch job to the value of the \fIaccount_string\fP +option-argument. +.TP 7 +\fB-c\ \fP \fIinterval\fP +Redefine whether the batch job should be checkpointed, and if so, +how often. +.LP +The \fIqalter\fP utility shall accept a value for the interval option-argument +that is one of the following: +.TP 7 +\fBn\fP +.RS +No checkpointing is to be performed on the batch job (NO_CHECKPOINT). +.RE +.TP 7 +\fBs\fP +.RS +Checkpointing is to be performed only when the batch server is shut +down (CHECKPOINT_AT_SHUTDOWN). +.RE +.TP 7 +\fBc\fP +.RS +Automatic periodic checkpointing is to be performed at the \fIMinimum_Cpu_Interval\fP +attribute of the batch queue, in units +of CPU minutes (CHECKPOINT_AT_MIN_CPU_INTERVAL). +.RE +.TP 7 +\fBc\fP=\fIminutes\fP +.RS +Automatic periodic checkpointing is to be performed every \fIminutes\fP +of CPU time, or every \fIMinimum_Cpu_Interval\fP +minutes, whichever is greater. The \fIminutes\fP argument shall conform +to the syntax for unsigned integers and shall be greater +than zero. +.RE +.sp +.LP +An implementation may define other checkpoint intervals. The conformance +document for an implementation shall describe any +alternative checkpoint intervals, how they are specified, their internal +behavior, and how they affect the behavior of the +utility. +.LP +The \fIqalter\fP utility shall set the \fICheckpoint\fP attribute +of the batch job to the value of the \fIinterval\fP +option-argument. +.TP 7 +\fB-e\ \fP \fIpath_name\fP +Redefine the path to be used for the standard error stream of the +batch job. +.LP +The \fIqalter\fP utility shall accept a \fIpath_name\fP option-argument +that conforms to the syntax of the \fIpath_name\fP +element defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +which can be preceded by a host name element of +the form \fIhostname\fP:. +.LP +If the \fIpath_name\fP option-argument constitutes an absolute pathname, +the \fIqalter\fP utility shall set the +\fIError_Path\fP attribute of the batch job to the value of the \fIpath_name\fP +option-argument, including the host name element, +if present. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and no host name element is specified, the \fIqalter\fP +utility shall set the \fIError_Path\fP attribute of the batch job +to the value of the absolute pathname derived by expanding the +\fIpath_name\fP option-argument relative to the current directory +of the process that executes the \fIqalter\fP utility. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and a host name element is specified, the \fIqalter\fP +utility shall set the \fIError_Path\fP attribute of the batch job +to the value of the option-argument without expansion. +.LP +If the \fIpath_name\fP option-argument does not include a host name +element, the \fIqalter\fP utility shall prefix the +pathname in the \fIError_Path\fP attribute with \fIhostname\fP:, where +\fIhostname\fP is the name of the host upon which the +\fIqalter\fP utility is being executed. +.TP 7 +\fB-h\ \fP \fIhold_list\fP +Redefine the types of holds, if any, on the batch job. The \fIqalter\fP +\fB-h\fP option shall accept a value for the +\fIhold_list\fP option-argument that is a string of alphanumeric characters +in the portable character set. +.LP +The \fIqalter\fP utility shall accept a value for the \fIhold_list\fP +option-argument that is a string of one or more of the +characters \fB'u'\fP , \fB's'\fP , or \fB'o'\fP , or the single character +\fB'n'\fP . For each unique character in the +\fIhold_list\fP option-argument, the \fIqalter\fP utility shall add +a value to the \fIHold_Types\fP attribute of the batch job +as follows, each representing a different hold type: +.TP 7 +\fBu\fP +.RS +USER +.RE +.TP 7 +\fBs\fP +.RS +SYSTEM +.RE +.TP 7 +\fBo\fP +.RS +OPERATOR +.RE +.sp +.LP +If any of these characters are duplicated in the \fIhold_list\fP option-argument, +the duplicates shall be ignored. An existing +\fIHold_Types\fP attribute can be cleared by the hold type: +.TP 7 +\fBn\fP +.RS +NO_HOLD +.RE +.sp +.LP +The \fIqalter\fP utility shall consider it an error if any hold type +other than \fB'n'\fP is combined with hold type +\fB'n'\fP . Strictly conforming applications shall not repeat any +of the characters \fB'u'\fP , \fB's'\fP , \fB'o'\fP , +or \fB'n'\fP within the \fIhold_list\fP option-argument. The \fIqalter\fP +utility shall permit the repetition of characters, +but shall not assign additional meaning to the repeated characters. +An implementation may define other hold types. The conformance +document for an implementation shall describe any additional hold +types, how they are specified, their internal behavior, and how +they affect the behavior of the utility. +.TP 7 +\fB-j\ \fP \fIjoin_list\fP +Redefine which streams of the batch job are to be merged. The \fIqalter\fP +\fB-j\fP option shall accept a value for the +\fIjoin_list\fP option-argument that is a string of alphanumeric characters +in the portable character set. +.LP +The \fIqalter\fP utility shall accept a \fIjoin_list\fP option-argument +that consists of one or more of the characters +\fB'e'\fP and \fB'o'\fP , or the single character \fB'n'\fP . +.LP +All of the other batch job output streams specified shall be merged +into the output stream represented by the character listed +first in the \fIjoin_list\fP option-argument. +.LP +For each unique character in the \fIjoin_list\fP option-argument, +the \fIqalter\fP utility shall add a value to the +\fIJoin_Path\fP attribute of the batch job as follows, each representing +a different batch job stream to join: +.TP 7 +\fBe\fP +.RS +The standard error of the batch job (JOIN_STD_ERROR). +.RE +.TP 7 +\fBo\fP +.RS +The standard output of the batch job (JOIN_STD_OUTPUT). +.RE +.sp +.LP +An existing \fIJoin_Path\fP attribute can be cleared by the join type: +.TP 7 +\fBn\fP +.RS +NO_JOIN +.RE +.sp +.LP +If \fB'n'\fP is specified, then no files are joined. The \fIqalter\fP +utility shall consider it an error if any join type +other than \fB'n'\fP is combined with join type \fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'e'\fP , \fB'o'\fP , or \fB'n'\fP within the +\fIjoin_list\fP option-argument. The \fIqalter\fP utility shall permit +the repetition of characters, but shall not assign +additional meaning to the repeated characters. +.LP +An implementation may define other join types. The conformance document +for an implementation shall describe any additional +batch job streams, how they are specified, their internal behavior, +and how they affect the behavior of the utility. +.TP 7 +\fB-k\ \fP \fIkeep_list\fP +Redefine which output of the batch job to retain on the execution +host. +.LP +The \fIqalter\fP \fB-k\fP option shall accept a value for the \fIkeep_list\fP +option-argument that is a string of +alphanumeric characters in the portable character set. +.LP +The \fIqalter\fP utility shall accept a \fIkeep_list\fP option-argument +that consists of one or more of the characters +\fB'e'\fP and \fB'o'\fP , or the single character \fB'n'\fP . +.LP +For each unique character in the \fIkeep_list\fP option-argument, +the \fIqalter\fP utility shall add a value to the +\fIKeep_Files\fP attribute of the batch job as follows, each representing +a different batch job stream to keep: +.TP 7 +\fBe\fP +.RS +The standard error of the batch job (KEEP_STD_ERROR). +.RE +.TP 7 +\fBo\fP +.RS +The standard output of the batch job (KEEP_STD_OUTPUT). +.RE +.sp +.LP +If both \fB'e'\fP and \fB'o'\fP are specified, then both files are +retained. An existing \fIKeep_Files\fP attribute can +be cleared by the keep type: +.TP 7 +\fBn\fP +.RS +NO_KEEP +.RE +.sp +.LP +If \fB'n'\fP is specified, then no files are retained. The \fIqalter\fP +utility shall consider it an error if any keep type +other than \fB'n'\fP is combined with keep type \fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'e'\fP , \fB'o'\fP , or \fB'n'\fP within the +\fIkeep_list\fP option-argument. The \fIqalter\fP utility shall permit +the repetition of characters, but shall not assign +additional meaning to the repeated characters. An implementation may +define other keep types. The conformance document for an +implementation shall describe any additional keep types, how they +are specified, their internal behavior, and how they affect the +behavior of the utility. +.TP 7 +\fB-l\ \fP \fIresource_list\fP +.sp +Redefine the resources that are allowed or required by the batch job. +.LP +The \fIqalter\fP utility shall accept a \fIresource_list\fP option-argument +that conforms to the following syntax: +.sp +.RS +.nf + +\fBresource=value[,,resource=value,,...] +\fP +.fi +.RE +.LP +The \fIqalter\fP utility shall set one entry in the value of the \fIResource_List\fP +attribute of the batch job for each +resource listed in the \fIresource_list\fP option-argument. +.LP +Because the list of supported resource names might vary by batch server, +the \fIqalter\fP utility shall rely on the batch +server to validate the resource names and associated values. See \fIMultiple +Keyword-Value +Pairs\fP for a means of removing \fIkeyword\fP= \fIvalue\fP (and \fIvalue\fP@ +\fIkeyword\fP) pairs and other general rules +for list-oriented batch job attributes. +.TP 7 +\fB-m\ \fP \fImail_options\fP +.sp +Redefine the points in the execution of the batch job at which the +batch server is to send mail about a change in the state of the +batch job. +.LP +The \fIqalter\fP \fB-m\fP option shall accept a value for the \fImail_options\fP +option-argument that is a string of +alphanumeric characters in the portable character set. +.LP +The \fIqalter\fP utility shall accept a value for the \fImail_options\fP +option-argument that is a string of one or more of +the characters \fB'e'\fP , \fB'b'\fP , and \fB'a'\fP , or the single +character \fB'n'\fP . For each unique character in +the \fImail_options\fP option-argument, the \fIqalter\fP utility shall +add a value to the \fIMail_Users\fP attribute of the +batch job as follows, each representing a different time during the +life of a batch job at which to send mail: +.TP 7 +\fBe\fP +.RS +MAIL_AT_EXIT +.RE +.TP 7 +\fBb\fP +.RS +MAIL_AT_BEGINNING +.RE +.TP 7 +\fBa\fP +.RS +MAIL_AT_ABORT +.RE +.sp +.LP +If any of these characters are duplicated in the \fImail_options\fP +option-argument, the duplicates shall be ignored. +.LP +An existing \fIMail_Points\fP attribute can be cleared by the mail +type: +.TP 7 +\fBn\fP +.RS +NO_MAIL +.RE +.sp +.LP +If \fB'n'\fP is specified, then mail is not sent. The \fIqalter\fP +utility shall consider it an error if any mail type other +than \fB'n'\fP is combined with mail type \fB'n'\fP . Strictly conforming +applications shall not repeat any of the characters +\fB'e'\fP , \fB'b'\fP , \fB'a'\fP , or \fB'n'\fP within the \fImail_options\fP +option-argument. The \fIqalter\fP +utility shall permit the repetition of characters but shall not assign +additional meaning to the repeated characters. +.LP +An implementation may define other mail types. The conformance document +for an implementation shall describe any additional mail +types, how they are specified, their internal behavior, and how they +affect the behavior of the utility. +.TP 7 +\fB-M\ \fP \fImail_list\fP +Redefine the list of users to which the batch server that executes +the batch job is to send mail, if the batch server sends +mail about the batch job. +.LP +The syntax of the \fImail_list\fP option-argument is unspecified. +If the implementation of the \fIqalter\fP utility uses a +name service to locate users, the utility shall accept the syntax +used by the name service. +.LP +If the implementation of the \fIqalter\fP utility does not use a name +service to locate users, the implementation shall accept +the following syntax for user names: +.sp +.RS +.nf + +\fBmail_address[,,mail_address,,...] +\fP +.fi +.RE +.LP +The interpretation of \fImail_address\fP is implementation-defined. +.LP +The \fIqalter\fP utility shall set the \fIMail_Users\fP attribute +of the batch job to the value of the \fImail_list\fP +option-argument. +.TP 7 +\fB-N\ \fP \fIname\fP +Redefine the name of the batch job. +.LP +The \fIqalter\fP \fB-N\fP option shall accept a value for the \fIname\fP +option-argument that is a string of up to 15 +alphanumeric characters in the portable character set where the first +character is alphabetic. +.LP +The syntax of the \fIname\fP option-argument is unspecified. +.LP +The \fIqalter\fP utility shall set the \fIJob_Name\fP attribute of +the batch job to the value of the \fIname\fP +option-argument. +.TP 7 +\fB-o\ \fP \fIpath_name\fP +Redefine the path for the standard output of the batch job. +.LP +The \fIqalter\fP utility shall accept a \fIpath_name\fP option-argument +that conforms to the syntax of the \fIpath_name\fP +element defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +which can be preceded by a host name element of +the form \fIhostname\fP:. +.LP +If the \fIpath_name\fP option-argument constitutes an absolute pathname, +the \fIqalter\fP utility shall set the +\fIOutput_Path\fP attribute of the batch job to the value of the \fIpath_name\fP +option-argument. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and no host name element is specified, the \fIqalter\fP +utility shall set the \fIOutput_Path\fP attribute of the batch job +to the absolute pathname derived by expanding the +\fIpath_name\fP option-argument relative to the current directory +of the process that executes the \fIqalter\fP utility. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and a host name element is specified, the \fIqalter\fP +utility shall set the \fIOutput_Path\fP attribute of the batch job +to the value of the \fIpath_name\fP option-argument without +any expansion of the pathname. +.LP +If the \fIpath_name\fP option-argument does not include a host name +element, the \fIqalter\fP utility shall prefix the +pathname in the \fIOutput_Path\fP attribute with \fIhostname\fP:, +where \fIhostname\fP is the name of the host upon which the +\fIqalter\fP utility is being executed. +.TP 7 +\fB-p\ \fP \fIpriority\fP +Redefine the priority of the batch job. +.LP +The \fIqalter\fP utility shall accept a value for the priority option-argument +that conforms to the syntax for signed decimal +integers, and which is not less than -1024 and not greater than 1023. +.LP +The \fIqalter\fP utility shall set the \fIPriority\fP attribute of +the batch job to the value of the \fIpriority\fP +option-argument. +.TP 7 +\fB-r\ \fP \fBy\fP|\fBn\fP +Redefine whether the batch job is rerunnable. +.LP +If the value of the option-argument is \fB'y'\fP , the \fIqalter\fP +utility shall set the \fIRerunable\fP attribute of the +batch job to TRUE. +.LP +If the value of the option-argument is \fB'n'\fP , the \fIqalter\fP +utility shall set the \fIRerunable\fP attribute of the +batch job to FALSE. +.LP +The \fIqalter\fP utility shall consider it an error if any character +other than \fB'y'\fP or \fB'n'\fP is specified in +the option-argument. +.TP 7 +\fB-S\ \fP \fIpath_name_list\fP +.sp +Redefine the shell that interprets the script at the destination system. +.LP +The \fIqalter\fP utility shall accept a \fIpath_name_list\fP option-argument +that conforms to the following syntax: +.sp +.RS +.nf + +\fBpathname[@host][,pathname[@host],...] +\fP +.fi +.RE +.LP +The \fIqalter\fP utility shall accept only one pathname that is missing +a corresponding host name. The \fIqalter\fP utility +shall allow only one pathname per named host. +.LP +The \fIqalter\fP utility shall add a value to the \fIShell_Path_List\fP +attribute of the batch job for each entry in the +\fIpath_name_list\fP option-argument. See \fIMultiple Keyword-Value +Pairs\fP for a +means of removing \fIkeyword\fP= \fIvalue\fP (and \fIvalue\fP@ \fIkeyword\fP) +pairs and other general rules for list-oriented +batch job attributes. +.TP 7 +\fB-u\ \fP \fIuser_list\fP +Redefine the user name under which the batch job is to run at the +destination system. +.LP +The \fIqalter\fP utility shall accept a \fIuser_list\fP option-argument +that conforms to the following syntax: +.sp +.RS +.nf + +\fBusername[@host][,,username[@host],,...] +\fP +.fi +.RE +.LP +The \fIqalter\fP utility shall accept only one user name that is missing +a corresponding host name. The \fIqalter\fP utility +shall accept only one user name per named host. +.LP +The \fIqalter\fP utility shall add a value to the \fIUser_List\fP +attribute of the batch job for each entry in the +\fIuser_list\fP option-argument. See \fIMultiple Keyword-Value Pairs\fP +for a means of +removing \fIkeyword\fP= \fIvalue\fP (and \fIvalue\fP@ \fIkeyword\fP) +pairs and other general rules for list-oriented batch job +attributes. +.sp +.SH OPERANDS +.LP +The \fIqalter\fP utility shall accept one or more operands that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqalter\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.TP 7 +\fITZ\fP +Determine the timezone used to interpret the \fIdate-time\fP option-argument. +If \fITZ\fP is unset or null, an unspecified +default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqalter\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqalter\fP utility attempts to locate +the batch job on other batch servers is +implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqalter\fP utility allows users to change the attributes of +a batch job. +.LP +As a means of altering a queued job, the \fIqalter\fP utility is superior +to deleting and requeuing the batch job insofar as an +altered job retains its place in the queue with some traditional selection +algorithms. In addition, the \fIqalter\fP utility is +both shorter and simpler than a sequence of \fIqdel\fP and \fIqsub\fP +utilities. +.LP +The result of an attempt on the part of a user to alter a batch job +in a RUNNING state is implementation-defined because a batch +job in the RUNNING state will already have opened its output files +and otherwise performed any actions indicated by the options in +effect at the time the batch job began execution. +.LP +The options processed by the \fIqalter\fP utility are identical to +those of the \fIqsub\fP utility, with a few exceptions: \fB-V\fP, +\fB-v\fP, and \fB-q\fP. The \fB-V\fP and +\fB-v\fP are inappropriate for the \fIqalter\fP utility, since they +capture potentially transient environment information from +the submitting process. The \fB-q\fP option would specify a new queue, +which would largely negate the previously stated advantage +of using \fIqalter\fP; furthermore, the \fIqmove\fP utility provides +a superior means of +moving jobs. +.LP +Each of the following paragraphs provides the rationale for a \fIqalter\fP +option. +.LP +Additional rationale concerning these options can be found in the +rationale for the \fIqsub\fP utility. +.LP +The \fB-a\fP option allows users to alter the date and time at which +a batch job becomes eligible to run. +.LP +The \fB-A\fP option allows users to change the account that will be +charged for the resources consumed by the batch job. +Support for the \fB-A\fP option is mandatory for conforming implementations +of \fIqalter\fP, even though support of accounting is +optional for servers. Whether or not to support accounting is left +to the implementor of the server, but mandatory support of the +\fB-A\fP option assures users of a consistent interface and allows +them to control accounting on servers that support +accounting. +.LP +The \fB-c\fP option allows users to alter the checkpointing interval +of a batch job. A checkpointing system, which is not +defined by IEEE\ Std\ 1003.1-2001, allows recovery of a batch job +at the most recent checkpoint in the event of a crash. +Checkpointing is typically used for jobs that consume expensive computing +time or must meet a critical schedule. Users should be +allowed to make the tradeoff between the overhead of checkpointing +and the risk to the timely completion of the batch job; +therefore, this volume of IEEE\ Std\ 1003.1-2001 provides the checkpointing +interval option. Support for checkpointing is +optional for servers. +.LP +The \fB-e\fP option allows users to alter the name and location of +the standard error stream written by a batch job. However, +the path of the standard error stream is meaningless if the value +of the \fIJoin_Path\fP attribute of the batch job is TRUE. +.LP +The \fB-h\fP option allows users to set the hold type in the \fIHold_Types\fP +attribute of a batch job. The \fIqhold\fP and \fIqrls\fP utilities +add or remove hold types +to the \fIHold_Types\fP attribute, respectively. The \fB-h\fP option +has been modified to allow for implementation-defined hold +types. +.LP +The \fB-j\fP option allows users to alter the decision to join (merge) +the standard error stream of the batch job with the +standard output stream of the batch job. +.LP +The \fB-l\fP option allows users to change the resource limits imposed +on a batch job. +.LP +The \fB-m\fP option allows users to modify the list of points in the +life of a batch job at which the designated users will +receive mail notification. +.LP +The \fB-M\fP option allows users to alter the list of users who will +receive notification about events in the life of a batch +job. +.LP +The \fB-N\fP option allows users to change the name of a batch job. +.LP +The \fB-o\fP option allows users to alter the name and path to which +the standard output stream of the batch job will be +written. +.LP +The \fB-P\fP option allows users to modify the priority of a batch +job. Support for priority is optional for batch servers. +.LP +The \fB-r\fP option allows users to alter the rerunability status +of a batch job. +.LP +The \fB-S\fP option allows users to change the name and location of +the shell image that will be invoked to interpret the +script of the batch job. This option has been modified to allow a +list of shell name and locations associated with different +hosts. +.LP +The \fB-u\fP option allows users to change the user identifier under +which the batch job will execute. +.LP +The \fIjob_identifier\fP operand syntax is provided so that the user +can differentiate between the originating and destination +(or executing) batch server. These may or may not be the same. The +\&. \fIserver_name\fP portion identifies the originating batch +server, while the @ \fIserver\fP portion identifies the destination +batch server. +.LP +Historically, the \fIqalter\fP utility has been a component of the +Network Queuing System (NQS), the existing practice from +which this utility has been derived. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIqdel\fP , \fIqhold\fP , \fIqmove\fP +, \fIqrls\fP , \fIqsub\fP , \fItouch\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qdel.1p b/man1p/qdel.1p new file mode 100644 index 000000000..7f8ae5b13 --- /dev/null +++ b/man1p/qdel.1p @@ -0,0 +1,175 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QDEL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qdel +.SH NAME +qdel \- delete batch jobs +.SH SYNOPSIS +.LP +\fBqdel\fP \fIjob_identifier\fP \fB... \fP +.SH DESCRIPTION +.LP +A batch job is deleted by sending a request to the batch server that +manages the batch job. A batch job that has been deleted is +no longer subject to management by batch services. +.LP +The \fIqdel\fP utility is a user-accessible client of batch services +that requests the deletion of one or more batch jobs. +.LP +The \fIqdel\fP utility shall request a batch server to delete those +batch jobs for which a batch \fIjob_identifier\fP is +presented to the utility. +.LP +The \fIqdel\fP utility shall delete batch jobs in the order in which +their batch \fIjob_identifier\fPs are presented to the +utility. +.LP +If the \fIqdel\fP utility fails to process any batch \fIjob_identifier\fP +successfully, the utility shall proceed to process +the remaining batch \fIjob_identifier\fPs, if any. +.LP +The \fIqdel\fP utility shall delete each batch job by sending a \fIDelete +Job Request\fP to the batch server that manages the +batch job. +.LP +The \fIqdel\fP utility shall not exit until the batch job corresponding +to each successfully processed batch +\fIjob_identifier\fP has been deleted. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The \fIqdel\fP utility shall accept one or more operands that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqdel\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +An implementation of the \fIqdel\fP utility may write informative +messages to standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqdel\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqdel\fP utility waits to output the +diagnostic message while attempting to locate the job on other +servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqdel\fP utility allows users and administrators to delete jobs. +.LP +The \fIqdel\fP utility provides functionality that is not otherwise +available. For example, the \fIkill\fP utility of the operating system +does not suffice. First, to use the \fIkill\fP utility, the user might +have to log in on a remote node, because the \fIkill\fP utility does +not operate across the network. Second, unlike \fIqdel\fP, \fIkill\fP +cannot remove jobs from queues. Lastly, the arguments of the \fIqdel\fP +utility are job +identifiers rather than process identifiers, and so this utility can +be passed the output of the \fIqselect\fP utility, thus providing +users with a means of deleting a list of jobs. +.LP +Because a set of jobs can be selected using the \fIqselect\fP utility, +the \fIqdel\fP +utility has not been complicated with options that provide for selection +of jobs. Instead, the batch jobs to be deleted are +identified individually by their job identifiers. +.LP +Historically, the \fIqdel\fP utility has been a component of NQS, +the existing practice on which it is based. However, the +\fIqdel\fP utility defined in this volume of IEEE\ Std\ 1003.1-2001 +does not provide an option for specifying a signal +number to send to the batch job prior to the killing of the process; +that capability has been subsumed by the \fIqsig\fP utility. +.LP +A discussion was held about the delays of networking and the possibility +that the batch server may never respond, due to a down +router, down batch server, or other network mishap. The DESCRIPTION +records this under the words "fails to process any job +identifier". In the broad sense, the network problem is also an error, +which causes the failure to process the batch job +identifier. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIkill\fP() , \fIqselect\fP , +\fIqsig\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qhold.1p b/man1p/qhold.1p new file mode 100644 index 000000000..c2e1a68d6 --- /dev/null +++ b/man1p/qhold.1p @@ -0,0 +1,230 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QHOLD" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qhold +.SH NAME +qhold \- hold batch jobs +.SH SYNOPSIS +.LP +\fBqhold\fP \fB[\fP\fB-h\fP \fIhold_list\fP\fB]\fP \fIjob_identifier\fP +\fB\&... \fP +.SH DESCRIPTION +.LP +A hold is placed on a batch job by a request to the batch server that +manages the batch job. A batch job that has one or more +holds is not eligible for execution. The \fIqhold\fP utility is a +user-accessible client of batch services that requests one or +more types of hold to be placed on one or more batch jobs. +.LP +The \fIqhold\fP utility shall place holds on those batch jobs for +which a batch \fIjob_identifier\fP is presented to the +utility. +.LP +The \fIqhold\fP utility shall place holds on batch jobs in the order +in which their batch \fIjob_identifier\fPs are presented +to the utility. If the \fIqhold\fP utility fails to process any batch +\fIjob_identifier\fP successfully, the utility shall +proceed to process the remaining batch \fIjob_identifier\fPs, if any. +.LP +The \fIqhold\fP utility shall place holds on each batch job by sending +a \fIHold Job Request\fP to the batch server that +manages the batch job. +.LP +The \fIqhold\fP utility shall not exit until holds have been placed +on the batch job corresponding to each successfully +processed batch \fIjob_identifier\fP. +.SH OPTIONS +.LP +The \fIqhold\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported by the implementation: +.TP 7 +\fB-h\ \fP \fIhold_list\fP +Define the types of holds to be placed on the batch job. +.LP +The \fIqhold\fP \fB-h\fP option shall accept a value for the \fIhold_list\fP +option-argument that is a string of alphanumeric +characters in the portable character set (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character +Set). +.LP +The \fIqhold\fP utility shall accept a value for the \fIhold_list\fP +option-argument that is a string of one or more of the +characters \fB'u'\fP , \fB's'\fP , or \fB'o'\fP , or the single character +\fB'n'\fP . +.LP +For each unique character in the \fIhold_list\fP option-argument, +the \fIqhold\fP utility shall add a value to the +\fIHold_Types\fP attribute of the batch job as follows, each representing +a different hold type: +.TP 7 +\fBu\fP +.RS +USER +.RE +.TP 7 +\fBs\fP +.RS +SYSTEM +.RE +.TP 7 +\fBo\fP +.RS +OPERATOR +.RE +.sp +.LP +If any of these characters are duplicated in the \fIhold_list\fP option-argument, +the duplicates shall be ignored. +.LP +An existing \fIHold_Types\fP attribute can be cleared by the following +hold type: +.TP 7 +\fBn\fP +.RS +NO_HOLD +.RE +.sp +.LP +The \fIqhold\fP utility shall consider it an error if any hold type +other than \fB'n'\fP is combined with hold type +\fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'u'\fP , \fB's'\fP , \fB'o'\fP , or +\fB'n'\fP within the \fIhold_list\fP option-argument. The \fIqhold\fP +utility shall permit the repetition of characters, but +shall not assign additional meaning to the repeated characters. +.LP +An implementation may define other hold types. The conformance document +for an implementation shall describe any additional hold +types, how they are specified, their internal behavior, and how they +affect the behavior of the utility. +.LP +If the \fB-h\fP option is not presented to the \fIqhold\fP utility, +the implementation shall set the \fIHold_Types\fP +attribute to USER. +.sp +.SH OPERANDS +.LP +The \fIqhold\fP utility shall accept one or more operands that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqhold\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqhold\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqhold\fP utility waits to output the +diagnostic message while attempting to locate the job on other +servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqhold\fP utility allows users to place a hold on one or more +jobs. A hold makes a batch job ineligible for +execution. +.LP +The \fIqhold\fP utility has options that allow the user to specify +the type of hold. Should the user wish to place a hold on a +set of jobs that meet a selection criteria, such a list of jobs can +be acquired using the \fIqselect\fP utility. +.LP +The \fB-h\fP option allows the user to specify the type of hold that +is to be placed on the job. This option allows for USER, +SYSTEM, OPERATOR, and implementation-defined hold types. The USER +and OPERATOR holds are distinct. The batch server that manages +the batch job will verify that the user is authorized to set the specified +hold for the batch job. +.LP +Mail is not required on hold because the administrator has the tools +and libraries to build this option if he or she wishes. +.LP +Historically, the \fIqhold\fP utility has been a part of some existing +batch systems, although it has not traditionally been a +part of the NQS. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIqselect\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qmove.1p b/man1p/qmove.1p new file mode 100644 index 000000000..557ff9b6f --- /dev/null +++ b/man1p/qmove.1p @@ -0,0 +1,154 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QMOVE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qmove +.SH NAME +qmove \- move batch jobs +.SH SYNOPSIS +.LP +\fBqmove\fP \fIdestination job_identifier\fP \fB... \fP +.SH DESCRIPTION +.LP +To move a batch job is to remove the batch job from the batch queue +in which it resides and instantiate the batch job in another +batch queue. A batch job is moved by a request to the batch server +that manages the batch job. The \fIqmove\fP utility is a +user-accessible batch client that requests the movement of one or +more batch jobs. +.LP +The \fIqmove\fP utility shall move those batch jobs, and only those +batch jobs, for which a batch \fIjob_identifier\fP is +presented to the utility. +.LP +The \fIqmove\fP utility shall move batch jobs in the order in which +the corresponding batch \fIjob_identifier\fPs are +presented to the utility. +.LP +If the \fIqmove\fP utility fails to process a batch \fIjob_identifier\fP +successfully, the utility shall proceed to process +the remaining batch \fIjob_identifier\fPs, if any. +.LP +The \fIqmove\fP utility shall move batch jobs by sending a \fIMove +Job Request\fP to the batch server that manages each batch +job. The \fIqmove\fP utility shall not exit before the batch jobs +corresponding to all successfully processed batch +\fIjob_identifier\fPs have been moved. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The \fIqmove\fP utility shall accept one operand that conforms to +the syntax for a destination (see \fIDestination\fP ). +.LP +The \fIqmove\fP utility shall accept one or more operands that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqmove\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqmove\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqmove\fP utility waits to output the +diagnostic message while attempting to locate the job on other +servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqmove\fP utility allows users to move jobs between queues. +.LP +The alternative to using the \fIqmove\fP utility-deleting the batch +job and requeuing it-entails considerably more typing. +.LP +Since the means of selecting jobs based on attributes has been encapsulated +in the \fIqselect\fP utility, the only option of the \fIqmove\fP utility +concerns authorization. The +\fB-u\fP option provides the user with the convenience of changing +the user identifier under which the batch job will execute. +Minimalism and consistency have taken precedence over convenience; +the \fB-u\fP option has been deleted because the equivalent +capability exists with the \fB-u\fP option of the \fIqalter\fP utility. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIqalter\fP , \fIqselect\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qmsg.1p b/man1p/qmsg.1p new file mode 100644 index 000000000..f0e6b2a48 --- /dev/null +++ b/man1p/qmsg.1p @@ -0,0 +1,214 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QMSG" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qmsg +.SH NAME +qmsg \- send message to batch jobs +.SH SYNOPSIS +.LP +\fBqmsg\fP \fB[\fP\fB-E\fP\fB][\fP\fB-O\fP\fB]\fP \fImessage_string +job_identifier\fP \fB... +\fP +.SH DESCRIPTION +.LP +To send a message to a batch job is to request that a server write +a message string into one or more output files of the batch +job. A message is sent to a batch job by a request to the batch server +that manages the batch job. The \fIqmsg\fP utility is a +user-accessible batch client that requests the sending of messages +to one or more batch jobs. +.LP +The \fIqmsg\fP utility shall write messages into the files of batch +jobs by sending a \fIJob Message Request\fP to the batch +server that manages the batch job. The \fIqmsg\fP utility shall not +directly write the message into the files of the batch +job. +.LP +The \fIqmsg\fP utility shall send a \fIJob Message Request\fP for +those batch jobs, and only those batch jobs, for which a +batch \fIjob_identifier\fP is presented to the utility. +.LP +The \fIqmsg\fP utility shall send \fIJob Message Request\fPs for batch +jobs in the order in which their batch +\fIjob_identifier\fPs are presented to the utility. +.LP +If the \fIqmsg\fP utility fails to process any batch \fIjob_identifier\fP +successfully, the utility shall proceed to process +the remaining batch \fIjob_identifier\fPs, if any. +.LP +The \fIqmsg\fP utility shall not exit before a \fIJob Message Request\fP +has been sent to the server that manages the batch +job that corresponds to each successfully processed batch \fIjob_identifier\fP. +.SH OPTIONS +.LP +The \fIqmsg\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-E\fP +Specify that the message is written to the standard error of each +batch job. +.LP +The \fIqmsg\fP utility shall write the message into the standard error +of the batch job. +.TP 7 +\fB-O\fP +Specify that the message is written to the standard output of each +batch job. +.LP +The \fIqmsg\fP utility shall write the message into the standard output +of the batch job. +.sp +.LP +If neither the \fB-O\fP nor the \fB-E\fP option is presented to the +\fIqmsg\fP utility, the utility shall write the message +into an implementation-defined file. The conformance document for +the implementation shall describe the name and location of the +implementation-defined file. If both the \fB-O\fP and the \fB-E\fP +options are presented to the \fIqmsg\fP utility, then the +utility shall write the messages to both standard output and standard +error. +.SH OPERANDS +.LP +The \fIqmsg\fP utility shall accept a minimum of two operands, \fImessage_string\fP +and one or more batch +\fIjob_identifier\fPs. +.LP +The \fImessage_string\fP operand shall be the string to be written +to one or more output files of the batch job followed by a +<newline>. If the string contains <blank>s, then the application shall +ensure that the string is quoted. The +\fImessage_string\fP shall be encoded in the portable character set +(see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character Set). +.LP +All remaining operands are batch \fIjob_identifier\fPs that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqmsg\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqmsg\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqmsg\fP utility waits to output the +diagnostic message while attempting to locate the job on other +servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqmsg\fP utility allows users to write messages into the output +files of running jobs. Users, including operators and +administrators, have a number of occasions when they want to place +messages in the output files of a batch job. For example, if a +disk that is being used by a batch job is showing errors, the operator +might note this in the standard error stream of the batch +job. +.LP +The options of the \fIqmsg\fP utility provide users with the means +of placing the message in the output stream of their choice. +The default output stream for the message-if the user does not designate +an output stream-is implementation-defined, since many +implementations will provide, as an extension to this volume of IEEE\ Std\ 1003.1-2001, +a log file that shows the history +of utility execution. +.LP +If users wish to send a message to a set of jobs that meet a selection +criteria, the \fIqselect\fP utility can be used to acquire the appropriate +list of job identifiers. +.LP +The \fB-E\fP option allows users to place the message in the standard +error stream of the batch job. +.LP +The \fB-O\fP option allows users to place the message in the standard +output stream of the batch job. +.LP +Historically, the \fIqmsg\fP utility is an existing practice in the +offerings of one or more implementors of an NQS-derived +batch system. The utility has been found to be useful enough that +it deserves to be included in this volume of +IEEE\ Std\ 1003.1-2001. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIqselect\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qrerun.1p b/man1p/qrerun.1p new file mode 100644 index 000000000..68ca6e697 --- /dev/null +++ b/man1p/qrerun.1p @@ -0,0 +1,146 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QRERUN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qrerun +.SH NAME +qrerun \- rerun batch jobs +.SH SYNOPSIS +.LP +\fBqrerun\fP \fIjob_identifier\fP \fB... \fP +.SH DESCRIPTION +.LP +To rerun a batch job is to terminate the session leader of the batch +job, delete any associated checkpoint files, and return the +batch job to the batch queued state. A batch job is rerun by a request +to the batch server that manages the batch job. The +\fIqrerun\fP utility is a user-accessible batch client that requests +the rerunning of one or more batch jobs. +.LP +The \fIqrerun\fP utility shall rerun those batch jobs for which a +batch \fIjob_identifier\fP is presented to the utility. +.LP +The \fIqrerun\fP utility shall rerun batch jobs in the order in which +their batch \fIjob_identifier\fPs are presented to the +utility. +.LP +If the \fIqrerun\fP utility fails to process any batch \fIjob_identifier\fP +successfully, the utility shall proceed to process +the remaining batch \fIjob_identifier\fPs, if any. +.LP +The \fIqrerun\fP utility shall rerun batch jobs by sending a \fIRerun +Job Request\fP to the batch server that manages each +batch job. +.LP +For each successfully processed batch \fIjob_identifier\fP, the \fIqrerun\fP +utility shall have rerun the corresponding batch +job at the time the utility exits. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The \fIqrerun\fP utility shall accept one or more operands that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqrerun\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqrerun\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqrerun\fP utility waits to output the +diagnostic message while attempting to locate the job on other +servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqrerun\fP utility allows users to cause jobs in the running +state to exit and rerun. +.LP +The \fIqrerun\fP utility is a new utility, \fIvis-a-vis\fP existing +practice, that has been defined in this volume of +IEEE\ Std\ 1003.1-2001 to correct user-perceived deficiencies in the +existing practice. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qrls.1p b/man1p/qrls.1p new file mode 100644 index 000000000..615356104 --- /dev/null +++ b/man1p/qrls.1p @@ -0,0 +1,236 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QRLS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qrls +.SH NAME +qrls \- release batch jobs +.SH SYNOPSIS +.LP +\fBqrls\fP \fB[\fP\fB-h\fP \fIhold_list\fP\fB]\fP \fIjob_identifier\fP +\fB\&... \fP +.SH DESCRIPTION +.LP +A batch job might have one or more holds, which prevent the batch +job from executing. A batch job from which all the holds have +been removed becomes eligible for execution and is said to have been +released. A batch job hold is removed by sending a request to +the batch server that manages the batch job. The \fIqrls\fP utility +is a user-accessible client of batch services that requests +holds be removed from one or more batch jobs. +.LP +The \fIqrls\fP utility shall remove one or more holds from those batch +jobs for which a batch \fIjob_identifier\fP is +presented to the utility. +.LP +The \fIqrls\fP utility shall remove holds from batch jobs in the order +in which their batch \fIjob_identifier\fPs are +presented to the utility. +.LP +If the \fIqrls\fP utility fails to process a batch \fIjob_identifier\fP +successfully, the utility shall proceed to process the +remaining batch \fIjob_identifier\fPs, if any. +.LP +The \fIqrls\fP utility shall remove holds on each batch job by sending +a \fIRelease Job Request\fP to the batch server that +manages the batch job. +.LP +The \fIqrls\fP utility shall not exit until the holds have been removed +from the batch job corresponding to each successfully +processed batch \fIjob_identifier\fP. +.SH OPTIONS +.LP +The \fIqrls\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported by the implementation: +.TP 7 +\fB-h\ \fP \fIhold_list\fP +Define the types of holds to be removed from the batch job. +.LP +The \fIqrls\fP \fB-h\fP option shall accept a value for the \fIhold_list\fP +option-argument that is a string of alphanumeric +characters in the portable character set (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character +Set). +.LP +The \fIqrls\fP utility shall accept a value for the \fIhold_list\fP +option-argument that is a string of one or more of the +characters \fB'u'\fP , \fB's'\fP , or \fB'o'\fP , or the single character +\fB'n'\fP . +.LP +For each unique character in the \fIhold_list\fP option-argument, +the \fIqrls\fP utility shall add a value to the +\fIHold_Types\fP attribute of the batch job as follows, each representing +a different hold type: +.TP 7 +\fBu\fP +.RS +USER +.RE +.TP 7 +\fBs\fP +.RS +SYSTEM +.RE +.TP 7 +\fBo\fP +.RS +OPERATOR +.RE +.sp +.LP +If any of these characters are duplicated in the \fIhold_list\fP option-argument, +the duplicates shall be ignored. +.LP +An existing \fIHold_Types\fP attribute can be cleared by the following +hold type: +.TP 7 +\fBn\fP +.RS +NO_HOLD +.RE +.sp +.LP +The \fIqrls\fP utility shall consider it an error if any hold type +other than \fB'n'\fP is combined with hold type +\fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'u'\fP , \fB's'\fP , \fB'o'\fP , or +\fB'n'\fP within the \fIhold_list\fP option-argument. The \fIqrls\fP +utility shall permit the repetition of characters, but +shall not assign additional meaning to the repeated characters. +.LP +An implementation may define other hold types. The conformance document +for an implementation shall describe any additional hold +types, how they are specified, their internal behavior, and how they +affect the behavior of the utility. +.LP +If the \fB-h\fP option is not presented to the \fIqrls\fP utility, +the implementation shall remove the USER hold in the +\fIHold_Types\fP attribute. +.sp +.SH OPERANDS +.LP +The \fIqrls\fP utility shall accept one or more operands that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqrls\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqrls\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqrls\fP utility waits to output the +diagnostic message while attempting to locate the job on other +servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqrls\fP utility allows users, operators, and administrators +to remove holds from jobs. +.LP +The \fIqrls\fP utility does not support any job selection options +or wildcard arguments. Users may acquire a list of jobs +selected by attributes using the \fIqselect\fP utility. For example, +a user could select +all of their held jobs. +.LP +The \fB-h\fP option allows the user to specify the type of hold that +is to be removed. This option allows for USER, SYSTEM, +OPERATOR, and implementation-defined hold types. The batch server +that manages the batch job will verify whether the user is +authorized to remove the specified hold for the batch job. If more +than one type of hold has been placed on the batch job, a user +may wish to remove only some of them. +.LP +Mail is not required on release because the administrator has the +tools and libraries to build this option if required. +.LP +The \fIqrls\fP utility is a new utility \fIvis-a-vis\fP existing practice; +it has been defined in this volume of +IEEE\ Std\ 1003.1-2001 as the natural complement to the \fIqhold\fP +utility. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIqhold\fP , \fIqselect\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qselect.1p b/man1p/qselect.1p new file mode 100644 index 000000000..673cdf744 --- /dev/null +++ b/man1p/qselect.1p @@ -0,0 +1,763 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QSELECT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qselect +.SH NAME +qselect \- select batch jobs +.SH SYNOPSIS +.LP +\fBqselect\fP \fB[\fP\fB-a\fP \fB[\fP\fIop\fP\fB]\fP\fIdate_time\fP\fB][\fP\fB-A\fP +\fIaccount_string\fP\fB][\fP\fB-c\fP \fB[\fP\fIop\fP\fB]\fP\fIinterval\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-h\fP \fIhold_list\fP\fB][\fP\fB-l\fP +\fIresource_list\fP\fB][\fP\fB-N\fP \fIname\fP\fB][\fP\fB-p\fP \fB[\fP\fIop\fP\fB]\fP\fIpriority\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-q\fP \fIdestination\fP\fB][\fP\fB-r\fP +\fIy\fP\fB|\fP\fIn\fP\fB][\fP\fB-s\fP \fIstates\fP\fB][\fP\fB-u\fP +\fIuser_list\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +To select a set of batch jobs is to return the batch \fIjob_identifier\fPs +for each batch job that meets a list of selection +criteria. A set of batch jobs is selected by a request to a batch +server. The \fIqselect\fP utility is a user-accessible batch +client that requests the selection of batch jobs. +.LP +Upon successful completion, the \fIqselect\fP utility shall have returned +a list of zero or more batch \fIjob_identifier\fPs +that meet the criteria specified by the options and option-arguments +presented to the utility. +.LP +The \fIqselect\fP utility shall select batch jobs by sending a \fISelect +Jobs Request\fP to a batch server. The \fIqselect\fP +utility shall not exit until the server replies to each request generated. +.LP +For each option presented to the \fIqselect\fP utility, the utility +shall restrict the set of selected batch jobs as described +in the OPTIONS section. +.LP +The \fIqselect\fP utility shall not restrict selection of batch jobs +except by authorization and as required by the options +presented to the utility. +.LP +When an option is specified with a mandatory or optional \fIop\fP +component to the option-argument, then \fIop\fP shall +specify a relation between the value of a certain batch job attribute +and the \fIvalue\fP component of the option-argument. If an +\fIop\fP is allowable on an option, then the description of the option +letter indicates the \fIop\fP as either mandatory or +optional. Acceptable strings for the \fIop\fP component, and the relation +the string indicates, are shown in the following +list: +.TP 7 +\fB\&.eq.\fP +The value represented by the attribute of the batch job is equal to +the value represented by the option-argument. +.TP 7 +\fB\&.ge.\fP +The value represented by the attribute of the batch job is greater +than or equal to the value represented by the +option-argument. +.TP 7 +\fB\&.gt.\fP +The value represented by the attribute of the batch job is greater +than the value represented by the option-argument. +.TP 7 +\fB\&.lt.\fP +The value represented by the attribute of the batch job is less than +the value represented by the option-argument. +.TP 7 +\fB\&.le.\fP +The value represented by the attribute of the batch job is less than +or equal to the value represented by the +option-argument. +.TP 7 +\fB\&.ne.\fP +The value represented by the attribute of the batch job is not equal +to the value represented by the option-argument. +.sp +.SH OPTIONS +.LP +The \fIqselect\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-a\ [\fP\fIop\fP\fB]\fP\fIdate_time\fP +.sp +Restrict selection to a specific time, or a range of times. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +value of the \fIExecution_Time\fP attribute is related to +the Epoch equivalent of the local time expressed by the value of the +\fIdate_time\fP component of the option-argument in the +manner indicated by the value of the \fIop\fP component of the option-argument. +.LP +The \fIqselect\fP utility shall accept a \fIdate_time\fP component +of the option-argument that conforms to the syntax of the +\fItime\fP operand of the \fItouch\fP utility. +.LP +If the \fIop\fP component of the option-argument is not presented +to the \fIqselect\fP utility, the utility shall select batch +jobs for which the \fIExecution_Time\fP attribute is equal to the +\fIdate_time\fP component of the option-argument. +.LP +When comparing times, the \fIqselect\fP utility shall use the following +definitions for the \fIop\fP component of the +option-argument: +.TP 7 +\fB\&.eq.\fP +.RS +The time represented by value of the \fIExecution_Time\fP attribute +of the batch job is equal to the time represented by the +\fIdate_time\fP component of the option-argument. +.RE +.TP 7 +\fB\&.ge.\fP +.RS +The time represented by value of the \fIExecution_Time\fP attribute +of the batch job is after or equal to the time represented +by the \fIdate_time\fP component of the option-argument. +.RE +.TP 7 +\fB\&.gt.\fP +.RS +The time represented by value of the \fIExecution_Time\fP attribute +of the batch job is after the time represented by the +\fIdate_time\fP component of the option-argument. +.RE +.TP 7 +\fB\&.lt.\fP +.RS +The time represented by value of the \fIExecution_Time\fP attribute +of the batch job is before the time represented by the +\fIdate_time\fP component of the option-argument. +.RE +.TP 7 +\fB\&.le.\fP +.RS +The time represented by value of the \fIExecution_Time\fP attribute +of the batch job is before or equal to the time +represented by the \fIdate_time\fP component of the option-argument. +.RE +.TP 7 +\fB\&.ne.\fP +.RS +The time represented by value of the \fIExecution_Time\fP attribute +of the batch job is not equal to the time represented by +the \fIdate_time\fP component of the option-argument. +.RE +.sp +.LP +The \fIqselect\fP utility shall accept the defined character strings +for the \fIop\fP component of the option-argument. +.TP 7 +\fB-A\ \fP \fIaccount_string\fP +.sp +Restrict selection to the batch jobs charging a specified account. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +value of the \fIAccount_Name\fP attribute of the batch +job matchs the value of the \fIaccount_string\fP option-argument. +.LP +The syntax of the \fIaccount_string\fP option-argument is unspecified. +.TP 7 +\fB-c\ [\fP\fIop\fP\fB]\fP\fIinterval\fP +.sp +Restrict selection to batch jobs within a range of checkpoint intervals. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +value of the \fICheckpoint\fP attribute relates to the +value of the \fIinterval\fP component of the option-argument in the +manner indicated by the value of the \fIop\fP component of +the option-argument. +.LP +If the \fIop\fP component of the option-argument is omitted, the \fIqselect\fP +utility shall select batch jobs for which the +value of the \fICheckpoint\fP attribute is equal to the value of the +\fIinterval\fP component of the option-argument. +.LP +When comparing checkpoint intervals, the \fIqselect\fP utility shall +use the following definitions for the \fIop\fP component +of the option-argument: +.TP 7 +\fB\&.eq.\fP +.RS +The value of the \fICheckpoint\fP attribute of the batch job equals +the value of the \fIinterval\fP component of the +option-argument. +.RE +.TP 7 +\fB\&.ge.\fP +.RS +The value of the \fICheckpoint\fP attribute of the batch job is greater +than or equal to the value of the \fIinterval\fP +component option-argument. +.RE +.TP 7 +\fB\&.gt.\fP +.RS +The value of the \fICheckpoint\fP attribute of the batch job is greater +than the value of the \fIinterval\fP component +option-argument. +.RE +.TP 7 +\fB\&.lt.\fP +.RS +The value of the \fICheckpoint\fP attribute of the batch job is less +than the value of the \fIinterval\fP component +option-argument. +.RE +.TP 7 +\fB\&.le.\fP +.RS +The value of the \fICheckpoint\fP attribute of the batch job is less +than or equal to the value of the \fIinterval\fP +component option-argument. +.RE +.TP 7 +\fB\&.ne.\fP +.RS +The value of the \fICheckpoint\fP attribute of the batch job does +not equal the value of the \fIinterval\fP component +option-argument. +.RE +.sp +.LP +The \fIqselect\fP utility shall accept the defined character strings +for the \fIop\fP component of the option-argument. +.LP +The ordering relationship for the values of the interval option-argument +is defined to be: +.sp +.RS +.nf + +\fB`n' .gt. `s' .gt. `c=\fP\fIminutes\fP\fB' .ge. `c' +\fP +.fi +.RE +When comparing \fICheckpoint\fP attributes with an interval having +the value of the single character \fB'u'\fP , only equality +or inequality are valid comparisons. +.TP 7 +\fB-h\ \fP \fIhold_list\fP +Restrict selection to batch jobs that have a specific type of hold. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +value of the \fIHold_Types\fP attribute matches the value +of the \fIhold_list\fP option-argument. +.LP +The \fIqselect\fP \fB-h\fP option shall accept a value for the \fIhold_list\fP +option-argument that is a string of +alphanumeric characters in the portable character set (see the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable +Character Set). +.LP +The \fIqselect\fP utility shall accept a value for the \fIhold_list\fP +option-argument that is a string of one or more of the +characters \fB'u'\fP , \fB's'\fP , or \fB'o'\fP , or the single character +\fB'n'\fP . +.LP +Each unique character in the \fIhold_list\fP option-argument of the +\fIqselect\fP utility is defined as follows, each +representing a different hold type: +.TP 7 +\fBu\fP +.RS +USER +.RE +.TP 7 +\fBs\fP +.RS +SYSTEM +.RE +.TP 7 +\fBo\fP +.RS +OPERATOR +.RE +.sp +.LP +If any of these characters are duplicated in the \fIhold_list\fP option-argument, +the duplicates shall be ignored. +.LP +The \fIqselect\fP utility shall consider it an error if any hold type +other than \fB'n'\fP is combined with hold type +\fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'u'\fP , \fB's'\fP , \fB'o'\fP , or +\fB'n'\fP within the \fIhold_list\fP option-argument. The \fIqselect\fP +utility shall permit the repetition of characters, but +shall not assign additional meaning to the repeated characters. +.LP +An implementation may define other hold types. The conformance document +for an implementation shall describe any additional hold +types, how they are specified, their internal behavior, and how they +affect the behavior of the utility. +.TP 7 +\fB-l\ \fP \fIresource_list\fP +.sp +Restrict selection to batch jobs with specified resource limits and +attributes. +.LP +The \fIqselect\fP utility shall accept a \fIresource_list\fP option-argument +with the following syntax: +.sp +.RS +.nf + +\fIresource_name op value\fP \fB[\fP\fB,,\fP\fIresource_name op value\fP\fB,, ...\fP\fB]\fP +.fi +.RE +.LP +When comparing resource values, the \fIqselect\fP utility shall use +the following definitions for the \fIop\fP component of +the option-argument: +.TP 7 +\fB\&.eq.\fP +.RS +The value of the resource of the same name in the \fIResource_List\fP +attribute of the batch job equals the value of the value +component of the option-argument. +.RE +.TP 7 +\fB\&.ge.\fP +.RS +The value of the resource of the same name in the \fIResource_List\fP +attribute of the batch job is greater than or equal to +the value of the \fIvalue\fP component of the option-argument. +.RE +.TP 7 +\fB\&.gt.\fP +.RS +The value of the resource of the same name in the \fIResource_List\fP +attribute of the batch job is greater than the value of +the value component of the option-argument. +.RE +.TP 7 +\fB\&.lt.\fP +.RS +The value of the resource of the same name in the \fIResource_List\fP +attribute of the batch job is less than the value of the +value component of the option-argument. +.RE +.TP 7 +\fB\&.ne.\fP +.RS +The value of the resource of the same name in the \fIResource_List\fP +attribute of the batch job does not equal the value of +the value component of the option-argument. +.RE +.TP 7 +\fB\&.le.\fP +.RS +The value of the resource of the same name in the \fIResource_List\fP +attribute of the batch job is less than or equal to the +value of the \fIvalue\fP component of the option-argument. +.RE +.sp +.LP +When comparing the limit of a \fIResource_List\fP attribute with the +\fIvalue\fP component of the option-argument, if the +limit, the value, or both are non-numeric, only equality or inequality +are valid comparisons. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +values of the \fIresource_name\fPs listed in the +\fIresource_list\fP option-argument match the corresponding limits +of the \fIResource_List\fP attribute of the batch job. +.LP +Limits of \fIresource_name\fPs present in the \fIResource_List\fP +attribute of the batch job that have no corresponding values +in the \fIresource_list\fP option-argument shall not be considered +when selecting batch jobs. +.TP 7 +\fB-N\ \fP \fIname\fP +Restrict selection to batch jobs with a specified name. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +value of the \fIJob_Name\fP attribute matches the value +of the \fIname\fP option-argument. The string specified in the \fIname\fP +option-argument shall be passed, uninterpreted, to the +server. This allows an implementation to match "wildcard" patterns +against batch job names. +.LP +An implementation shall describe in the conformance document the format +it supports for matching against the \fIJob_Name\fP +attribute. +.TP 7 +\fB-p\ [\fP\fIop\fP\fB]\fP\fIpriority\fP +.sp +Restrict selection to batch jobs of the specified priority or range +of priorities. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +value of the \fIPriority\fP attribute of the batch job +relates to the value of the \fIpriority\fP component of the option-argument +in the manner indicated by the value of the \fIop\fP +component of the option-argument. +.LP +If the \fIop\fP component of the option-argument is omitted, the \fIqselect\fP +utility shall select batch jobs for which the +value of the \fIPriority\fP attribute of the batch job is equal to +the value of the \fIpriority\fP component of the +option-argument. +.LP +When comparing priority values, the \fIqselect\fP utility shall use +the following definitions for the \fIop\fP component of +the option-argument: +.TP 7 +\fB\&.eq.\fP +.RS +The value of the \fIPriority\fP attribute of the batch job equals +the value of the \fIpriority\fP component of the +option-argument. +.RE +.TP 7 +\fB\&.ge.\fP +.RS +The value of the \fIPriority\fP attribute of the batch job is greater +than or equal to the value of the \fIpriority\fP +component option-argument. +.RE +.TP 7 +\fB\&.gt.\fP +.RS +The value of the \fIPriority\fP attribute of the batch job is greater +than the value of the \fIpriority\fP component +option-argument. +.RE +.TP 7 +\fB\&.lt.\fP +.RS +The value of the \fIPriority\fP attribute of the batch job is less +than the value of the \fIpriority\fP component +option-argument. +.RE +.TP 7 +\fB\&.lt.\fP +.RS +The value of the \fIPriority\fP attribute of the batch job is less +than or equal to the value of the \fIpriority\fP component +option-argument. +.RE +.TP 7 +\fB\&.ne.\fP +.RS +The value of the \fIPriority\fP attribute of the batch job does not +equal the value of the \fIpriority\fP component +option-argument. +.RE +.sp +.TP 7 +\fB-q\ \fP \fIdestination\fP +.sp +Restrict selection to the specified batch queue or server, or both. +.LP +The \fIqselect\fP utility shall select only batch jobs that are located +at the destination indicated by the value of the +\fIdestination\fP option-argument. +.LP +The destination defines a batch queue, a server, or a batch queue +at a server. +.LP +The \fIqselect\fP utility shall accept an option-argument for the +\fB-q\fP option that conforms to the syntax for a +destination. If the \fB-q\fP option is not presented to the \fIqselect\fP +utility, the utility shall select batch jobs from all +batch queues at the default batch server. +.LP +If the option-argument describes only a batch queue, the \fIqselect\fP +utility shall select only batch jobs from the batch +queue of the specified name at the default batch server. The means +by which \fIqselect\fP determines the default server is +implementation-defined. +.LP +If the option-argument describes only a batch server, the \fIqselect\fP +utility shall select batch jobs from all the batch +queues at that batch server. +.LP +If the option-argument describes both a batch queue and a batch server, +the \fIqselect\fP utility shall select only batch jobs +from the specified batch queue at the specified server. +.TP 7 +\fB-r\ \fP \fBy\fP|\fBn\fP +Restrict selection to batch jobs with the specified rerunability status. +.LP +The \fIqselect\fP utility shall select only batch jobs for which the +value of the \fIRerunable\fP attribute of the batch job +matches the value of the option-argument. +.LP +The \fIqselect\fP utility shall accept a value for the option-argument +that consists of either the single character +\fB'y'\fP or the single character \fB'n'\fP . The character \fB'y'\fP +represents the value TRUE, and the character +\fB'n'\fP represents the value FALSE. +.TP 7 +\fB-s\ \fP \fIstates\fP +Restrict selection to batch jobs in the specified states. +.LP +The \fIqselect\fP utility shall accept an option-argument that consists +of any combination of the characters \fB'e'\fP , +\fB'q'\fP , \fB'r'\fP , \fB'w'\fP , \fB'h'\fP , and \fB't'\fP . +.LP +Conforming applications shall not repeat any character in the option-argument. +The \fIqselect\fP utility shall permit the +repetition of characters in the option-argument, but shall not assign +additional meaning to repeated characters. +.LP +The \fIqselect\fP utility shall interpret the characters in the \fIstates\fP +option-argument as follows: +.TP 7 +\fBe\fP +.RS +Represents the EXITING state. +.RE +.TP 7 +\fBq\fP +.RS +Represents the QUEUED state. +.RE +.TP 7 +\fBr\fP +.RS +Represents the RUNNING state. +.RE +.TP 7 +\fBt\fP +.RS +Represents the TRANSITING state. +.RE +.TP 7 +\fBh\fP +.RS +Represents the HELD state. +.RE +.TP 7 +\fBw\fP +.RS +Represents the WAITING state. +.RE +.sp +.LP +For each character in the \fIstates\fP option-argument, the \fIqselect\fP +utility shall select batch jobs in the corresponding +state. +.TP 7 +\fB-u\ \fP \fIuser_list\fP +Restrict selection to batch jobs owned by the specified user names. +.LP +The \fIqselect\fP utility shall select only the batch jobs of those +users specified in the \fIuser_list\fP +option-argument. +.LP +The \fIqselect\fP utility shall accept a \fIuser_list\fP option-argument +that conforms to the following syntax: +.sp +.RS +.nf + +\fIusername\fP\fB[\fP\fB@\fP\fIhost\fP\fB][\fP\fB,,\fP\fIusername\fP\fB[\fP\fB@\fP\fIhost\fP\fB]\fP\fB,, ...\fP\fB]\fP +.fi +.RE +.LP +The \fIqselect\fP utility shall accept only one user name that is +missing a corresponding host name. The \fIqselect\fP utility +shall accept only one user name per named host. +.sp +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqselect\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.TP 7 +\fITZ\fP +Determine the timezone used to interpret the \fIdate-time\fP option-argument. +If \fITZ\fP is unset or null, an unspecified +default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIqselect\fP utility shall write zero or more batch \fIjob_identifier\fPs +to standard output. +.LP +The \fIqselect\fP utility shall separate the batch \fIjob_identifier\fPs +written to standard output by white space. +.LP +The \fIqselect\fP utility shall write batch \fIjob_identifier\fPs +in the following format: +.sp +.RS +.nf + +\fIsequence_number.server_name\fP\fB@\fP\fIserver\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +The following example shows how a user might use the \fIqselect\fP +utility in conjunction with the \fIqdel\fP utility to delete all of +his or her jobs in the queued state without affecting any jobs +that are already running: +.sp +.RS +.nf + +\fBqdel $(qselect -s q) +\fP +.fi +.RE +.LP +or: +.sp +.RS +.nf + +\fBqselect -s q || xargs qdel +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fIqselect\fP utility allows users to acquire a list of job identifiers +that match user-specified selection criteria. The +list of identifiers returned by the \fIqselect\fP utility conforms +to the syntax of the batch job identifier list processed by a +utility such as \fIqmove\fP, \fIqdel\fP, and \fIqrls\fP. The \fIqselect\fP +utility is thus a powerful tool for causing another batch system +utility to act upon a set of jobs that match a list of selection criteria. +.LP +The options of the \fIqselect\fP utility let the user apply a number +of useful filters for selecting jobs. Each option further +restricts the selection of jobs. Many of the selection options allow +the specification of a relational operator. The FORTRAN-like +syntax of the operator-that is, \fB".lt."\fP - was chosen rather than +the C-like \fB"<="\fP meta-characters. +.LP +The \fB-a\fP option allows users to restrict the selected jobs to +those that have been submitted (or altered) to wait until a +particular time. The time period is determined by the argument of +this option, which includes both a time and an operator-it is +thus possible to select jobs waiting until a specific time, jobs waiting +until after a certain time, or those waiting for a time +before the specified time. +.LP +The \fB-A\fP option allows users to restrict the selected jobs to +those that have been submitted (or altered) to charge a +particular account. +.LP +The \fB-c\fP option allows users to restrict the selected jobs to +those whose checkpointing interval falls within the specified +range. +.LP +The \fB-l\fP option allows users to select those jobs whose resource +limits fall within the range indicated by the value of the +option. For example, a user could select those jobs for which the +CPU time limit is greater than two hours. +.LP +The \fB-N\fP option allows users to select jobs by job name. For instance, +all the parts of a task that have been divided in +parallel jobs might be given the same name, and thus manipulated as +a group by means of this option. +.LP +The \fB-q\fP option allows users to select jobs in a specified queue. +.LP +The \fB-r\fP option allows users to select only those jobs with a +specified rerun criteria. For instance, a user might select +only those jobs that can be rerun for use with the \fIqrerun\fP utility. +.LP +The \fB-s\fP option allows users to select only those jobs that are +in a certain state. +.LP +The \fB-u\fP option allows users to select jobs that have been submitted +to execute under a particular account. +.LP +The selection criteria provided by the options of the \fIqselect\fP +utility allow users to select jobs based on all the +appropriate attributes that can be assigned to jobs by the \fIqsub\fP +utility. +.LP +Historically, the \fIqselect\fP utility has not been a part of existing +practice; it is an improvement that has been introduced +in this volume of IEEE\ Std\ 1003.1-2001. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIqdel\fP , \fIqrerun\fP , \fIqrls\fP , qselect , \fIqsub\fP , \fItouch\fP +, \fIBatch Environment Services\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qsig.1p b/man1p/qsig.1p new file mode 100644 index 000000000..fa156fbac --- /dev/null +++ b/man1p/qsig.1p @@ -0,0 +1,190 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QSIG" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qsig +.SH NAME +qsig \- signal batch jobs +.SH SYNOPSIS +.LP +\fBqsig\fP \fB[\fP\fB-s\fP \fIsignal\fP\fB]\fP \fIjob_identifier\fP +\fB\&... \fP +.SH DESCRIPTION +.LP +To signal a batch job is to send a signal to the session leader of +the batch job. A batch job is signaled by sending a request +to the batch server that manages the batch job. The \fIqsig\fP utility +is a user-accessible batch client that requests the +signaling of a batch job. +.LP +The \fIqsig\fP utility shall signal those batch jobs for which a batch +\fIjob_identifier\fP is presented to the utility. The +\fIqsig\fP utility shall not signal any batch jobs whose batch \fIjob_identifier\fPs +are not presented to the utility. +.LP +The \fIqsig\fP utility shall signal batch jobs in the order in which +the corresponding batch \fIjob_identifier\fPs are +presented to the utility. If the \fIqsig\fP utility fails to process +a batch \fIjob_identifier\fP successfully, the utility shall +proceed to process the remaining batch \fIjob_identifier\fPs, if any. +.LP +The \fIqsig\fP utility shall signal batch jobs by sending a \fISignal +Job Request\fP to the batch server that manages the +batch job. +.LP +For each successfully processed batch \fIjob_identifier\fP, the \fIqsig\fP +utility shall have received a completion reply to +each \fISignal Job Request\fP sent to a batch server at the time the +utility exits. +.SH OPTIONS +.LP +The \fIqsig\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported by the implementation: +.TP 7 +\fB-s\ \fP \fIsignal\fP +Define the signal to be sent to the batch job. +.LP +The \fIqsig\fP utility shall accept a \fIsignal\fP option-argument +that is either a symbolic signal name or an unsigned +integer signal number (see the POSIX.1-1990 standard, Section 3.3.1.1). +The \fIqsig\fP utility shall accept signal names for which +the SIG prefix has been omitted. +.LP +If the \fIsignal\fP option-argument is a signal name, the \fIqsig\fP +utility shall send that name. +.LP +If the \fIsignal\fP option-argument is a number, the \fIqsig\fP utility +shall send the signal value represented by the +number. +.LP +If the \fB-s\fP option is not presented to the \fIqsig\fP utility, +the utility shall send the signal SIGTERM to each signaled +batch job. +.sp +.SH OPERANDS +.LP +The \fIqsig\fP utility shall accept one or more operands that conform +to the syntax for a batch \fIjob_identifier\fP (see \fIBatch Job Identifier\fP +). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqsig\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +An implementation of the \fIqsig\fP utility may write informative +messages to standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqsig\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqsig\fP utility waits to output the +diagnostic message while attempting to locate the batch job on +other servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqsig\fP utility allows users to signal batch jobs. +.LP +A user may be unable to signal a batch job with the \fIkill\fP utility +of the operating +system for a number of reasons. First, the process ID of the batch +job may be unknown to the user. Second, the processes of the +batch job may be on a remote node. However, by virtue of communication +between batch nodes, the \fIqsig\fP utility can arrange for +the signaling of a process. +.LP +Because a batch job that is not running cannot be signaled, and because +the signal may not terminate the batch job, the +\fIqsig\fP utility is not a substitute for the \fIqdel\fP utility. +.LP +The options of the \fIqsig\fP utility allow the user to specify the +signal that is to be sent to the batch job. +.LP +The \fB-s\fP option allows users to specify a signal by name or by +number, and thus override the default signal. The +POSIX.1-1990 standard defines signals by both name and number. +.LP +The \fIqsig\fP utility is a new utility, \fIvis-a-vis\fP existing +practice; it has been defined in this volume of +IEEE\ Std\ 1003.1-2001 in response to user-perceived shortcomings +in existing practice. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIkill\fP() , \fIqdel\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qstat.1p b/man1p/qstat.1p new file mode 100644 index 000000000..d2ea4d5e9 --- /dev/null +++ b/man1p/qstat.1p @@ -0,0 +1,368 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QSTAT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qstat +.SH NAME +qstat \- show status of batch jobs +.SH SYNOPSIS +.LP +\fBqstat\fP \fB[\fP\fB-f\fP\fB]\fP \fIjob_identifier\fP \fB... +.br +.sp +qstat -Q\fP \fB[\fP\fB-f\fP\fB]\fP \fIdestination\fP \fB... +.br +.sp +qstat -B\fP \fB[\fP\fB-f\fP\fB]\fP \fIserver_name\fP \fB... \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The status of a batch job, batch queue, or batch server is obtained +by a request to the server. The \fIqstat\fP utility is a +user-accessible batch client that requests the status of one or more +batch jobs, batch queues, or servers, and writes the status +information to standard output. +.LP +For each successfully processed batch \fIjob_identifier\fP, the \fIqstat\fP +utility shall display information about the +corresponding batch job. +.LP +For each successfully processed destination, the \fIqstat\fP utility +shall display information about the corresponding batch +queue. +.LP +For each successfully processed server name, the \fIqstat\fP utility +shall display information about the corresponding +server. +.LP +The \fIqstat\fP utility shall acquire batch job status information +by sending a \fIJob Status Request\fP to a batch server. +The \fIqstat\fP utility shall acquire batch queue status information +by sending a \fIQueue Status Request\fP to a batch server. +The \fIqstat\fP utility shall acquire server status information by +sending a \fIServer Status Request\fP to a batch server. +.SH OPTIONS +.LP +The \fIqstat\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-f\fP +Specify that a full display is produced. +.LP +The minimum contents of a full display are specified in the STDOUT +section. +.LP +Additional contents and format of a full display are implementation-defined. +.TP 7 +\fB-Q\fP +Specify that the operand is a destination. +.LP +The \fIqstat\fP utility shall display information about each batch +queue at each destination identified as an operand. +.TP 7 +\fB-B\fP +Specify that the operand is a server name. +.LP +The \fIqstat\fP utility shall display information about each server +identified as an operand. +.sp +.SH OPERANDS +.LP +If the \fB-Q\fP option is presented to the \fIqstat\fP utility, the +utility shall accept one or more operands that conform to +the syntax for a destination (see \fIDestination\fP ). +.LP +If the \fB-B\fP option is presented to the \fIqstat\fP utility, the +utility shall accept one or more \fIserver_name\fP +operands. +.LP +If neither the \fB-B\fP nor the \fB-Q\fP option is presented to the +\fIqstat\fP utility, the utility shall accept one or more +operands that conform to the syntax for a batch \fIjob_identifier\fP +(see \fIBatch Job +Identifier\fP ). +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqstat\fP: +.TP 7 +\fIHOME\fP +Determine the pathname of the user's home directory. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_NUMERIC\fP +.sp +Determine the locale for selecting the radix character used when writing +floating-point formatted output. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If an operand presented to the \fIqstat\fP utility is a batch \fIjob_identifier\fP +and the \fB-f\fP option is not specified, +the \fIqstat\fP utility shall display the following items on a single +line, in the stated order, with white space between each +item, for each successfully processed operand: +.IP " *" 3 +The batch \fIjob_identifier\fP +.LP +.IP " *" 3 +The batch job name +.LP +.IP " *" 3 +The \fIJob_Owner\fP attribute +.LP +.IP " *" 3 +The CPU time used by the batch job +.LP +.IP " *" 3 +The batch job state +.LP +.IP " *" 3 +The batch job location +.LP +.LP +If an operand presented to the \fIqstat\fP utility is a batch \fIjob_identifier\fP +and the \fB-f\fP option is specified, the +\fIqstat\fP utility shall display the following items for each success +fully processed operand: +.IP " *" 3 +The batch \fIjob_identifier\fP +.LP +.IP " *" 3 +The batch job name +.LP +.IP " *" 3 +The \fIJob_Owner\fP attribute +.LP +.IP " *" 3 +The execution user ID +.LP +.IP " *" 3 +The CPU time used by the batch job +.LP +.IP " *" 3 +The batch job state +.LP +.IP " *" 3 +The batch job location +.LP +.IP " *" 3 +Additional implementation-defined information, if any, about the batch +job or batch queue +.LP +.LP +If an operand presented to the \fIqstat\fP utility is a destination, +the \fB-Q\fP option is specified, and the \fB-f\fP +option is not specified, the \fIqstat\fP utility shall display the +following items on a single line, in the stated order, with +white space between each item, for each successfully processed operand: +.IP " *" 3 +The batch queue name +.LP +.IP " *" 3 +The maximum number of batch jobs that shall be run in the batch queue +concurrently +.LP +.IP " *" 3 +The total number of batch jobs in the batch queue +.LP +.IP " *" 3 +The status of the batch queue +.LP +.IP " *" 3 +For each state, the number of batch jobs in that state in the batch +queue and the name of the state +.LP +.IP " *" 3 +The type of batch queue (execution or routing) +.LP +.LP +If the operands presented to the \fIqstat\fP utility are destinations, +the \fB-Q\fP option is specified, and the \fB-f\fP +option is specified, the \fIqstat\fP utility shall display the following +items for each successfully processed operand: +.IP " *" 3 +The batch queue name +.LP +.IP " *" 3 +The maximum number of batch jobs that shall be run in the batch queue +concurrently +.LP +.IP " *" 3 +The total number of batch jobs in the batch queue +.LP +.IP " *" 3 +The status of the batch queue +.LP +.IP " *" 3 +For each state, the number of batch jobs in that state in the batch +queue and the name of the state +.LP +.IP " *" 3 +The type of batch queue (execution or routing) +.LP +.IP " *" 3 +Additional implementation-defined information, if any, about the batch +queue +.LP +.LP +If the operands presented to the \fIqstat\fP utility are batch server +names, the \fB-B\fP option is specified, and the +\fB-f\fP option is not specified, the \fIqstat\fP utility shall display +the following items on a single line, in the stated +order, with white space between each item, for each successfully processed +operand: +.IP " *" 3 +The batch server name +.LP +.IP " *" 3 +The maximum number of batch jobs that shall be run in the batch queue +concurrently +.LP +.IP " *" 3 +The total number of batch jobs managed by the batch server +.LP +.IP " *" 3 +The status of the batch server +.LP +.IP " *" 3 +For each state, the number of batch jobs in that state and the name +of the state +.LP +.LP +If the operands presented to the \fIqstat\fP utility are server names, +the \fB-B\fP option is specified, and the \fB-f\fP +option is specified, the \fIqstat\fP utility shall display the following +items for each successfully processed operand: +.IP " *" 3 +The server name +.LP +.IP " *" 3 +The maximum number of batch jobs that shall be run in the batch queue +concurrently +.LP +.IP " *" 3 +The total number of batch jobs managed by the server +.LP +.IP " *" 3 +The status of the server +.LP +.IP " *" 3 +For each state, the number of batch jobs in that state and the name +of the state +.LP +.IP " *" 3 +Additional implementation-defined information, if any, about the server +.LP +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +In addition to the default behavior, the \fIqstat\fP utility shall +not be required to write a diagnostic message to standard +error when the error reply received from a batch server indicates +that the batch \fIjob_identifier\fP does not exist on the +server. Whether or not the \fIqstat\fP utility waits to output the +diagnostic message while attempting to locate the batch job on +other servers is implementation-defined. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqstat\fP utility allows users to display the status of jobs +and list the batch jobs in queues. +.LP +The operands of the \fIqstat\fP utility may be either job identifiers, +queues (specified as destination identifiers), or batch +server names. The \fB-Q\fP and \fB-B\fP options, or absence thereof, +indicate the nature of the operands. +.LP +The other options of the \fIqstat\fP utility allow the user to control +the amount of information displayed and the format in +which it is displayed. Should a user wish to display the status of +a set of jobs that match a selection criteria, the \fIqselect\fP utility +may be used to acquire such a list. +.LP +The \fB-f\fP option allows users to request a "full" display in an +implementation-defined format. +.LP +Historically, the \fIqstat\fP utility has been a part of the NQS and +its derivatives, the existing practice on which it is +based. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIqselect\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/qsub.1p b/man1p/qsub.1p new file mode 100644 index 000000000..dd50d9e04 --- /dev/null +++ b/man1p/qsub.1p @@ -0,0 +1,1024 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "QSUB" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" qsub +.SH NAME +qsub \- submit a script +.SH SYNOPSIS +.LP +\fBqsub\fP \fB[\fP\fB-a\fP \fIdate_time\fP\fB][\fP\fB-A\fP +\fIaccount_string\fP\fB][\fP\fB-c\fP \fIinterval\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-C\fP \fIdirective_prefix\fP\fB][\fP\fB-e\fP +\fIpath_name\fP\fB][\fP\fB-h\fP\fB][\fP\fB-j\fP \fIjoin_list\fP\fB][\fP\fB-k\fP +\fIkeep_list\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-m\fP \fImail_options\fP\fB][\fP\fB-M\fP +\fImail_list\fP\fB][\fP\fB-N\fP \fIname\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-o\fP \fIpath_name\fP\fB][\fP\fB-p\fP +\fIpriority\fP\fB][\fP\fB-q\fP \fIdestination\fP\fB][\fP\fB-r\fP \fIy\fP\fB|\fP\fIn\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-S\fP \fIpath_name_list\fP\fB][\fP\fB-u\fP +\fIuser_list\fP\fB][\fP\fB-v\fP \fIvariable_list\fP\fB][\fP\fB-V\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-z\fP\fB][\fP\fIscript\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +To submit a script is to create a batch job that executes the script. +A script is submitted by a request to a batch server. The +\fIqsub\fP utility is a user-accessible batch client that submits +a script. +.LP +Upon successful completion, the \fIqsub\fP utility shall have created +a batch job that will execute the submitted script. +.LP +The \fIqsub\fP utility shall submit a script by sending a \fIQueue +Job Request\fP to a batch server. +.LP +The \fIqsub\fP utility shall place the value of the following environment +variables in the \fIVariable_List\fP attribute of +the batch job: \fIHOME ,\fP \fILANG ,\fP \fILOGNAME ,\fP \fIPATH ,\fP +\fIMAIL ,\fP \fISHELL ,\fP and \fITZ .\fP The name of +the environment variable shall be the current name prefixed with the +string PBS_O_. +.TP 7 +\fBNote:\fP +If the current value of the \fIHOME\fP variable in the environment +space of the \fIqsub\fP utility is \fB/aa/bb/cc\fP, then +\fIqsub\fP shall place \fIPBS_O_HOME =\fP \fB/aa/bb/cc\fP in the \fIVariable_List\fP +attribute of the batch job. +.sp +.LP +In addition to the variables described above, the \fIqsub\fP utility +shall add the following variables with the indicated +values to the variable list: +.TP 7 +\fIPBS_O_WORKDIR\fP +The absolute path of the current working directory of the \fIqsub\fP +utility process. +.TP 7 +\fIPBS_O_HOST\fP +The name of the host on which the \fIqsub\fP utility is running. +.sp +.SH OPTIONS +.LP +The \fIqsub\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported by the implementation: +.TP 7 +\fB-a\ \fP \fIdate_time\fP +Define the time at which a batch job becomes eligible for execution. +.LP +The \fIqsub\fP utility shall accept an option-argument that conforms +to the syntax of the \fItime\fP operand of the \fItouch\fP utility. +.br +.sp +.ce 1 +\fBTable: Environment Variable Values (Utilities)\fP +.TS C +center; l l. +\fBVariable Name\fP \fBValue at qsub Time\fP +\fIPBS_O_HOME\fP \fIHOME\fP +\fIPBS_O_HOST\fP \fIClient host name\fP +\fIPBS_O_LANG\fP \fILANG\fP +\fIPBS_O_LOGNAME\fP \fILOGNAME\fP +\fIPBS_O_PATH\fP \fIPATH\fP +\fIPBS_O_MAIL\fP \fIMAIL\fP +\fIPBS_O_SHELL\fP \fISHELL\fP +\fIPBS_O_TZ\fP \fITZ\fP +\fIPBS_O_WORKDIR\fP \fICurrent working directory\fP +.TE +.TP 7 +\fBNote:\fP +.RS +The server that initiates execution of the batch job will add other +variables to the batch job's environment; see \fIBatch Job Execution\fP +\&. +.RE +.sp +.LP +The \fIqsub\fP utility shall set the \fIExecution_Time\fP attribute +of the batch job to the number of seconds since the Epoch +that is equivalent to the local time expressed by the value of the +\fIdate_time\fP option-argument. The Epoch is defined in the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 3.149, +Epoch. +.LP +If the \fB-a\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIExecution_Time\fP attribute +of the batch job to a time (number of seconds since the Epoch) that +is earlier than the time at which the utility exits. +.TP 7 +\fB-A\ \fP \fIaccount_string\fP +.sp +Define the account to which the resource consumption of the batch +job should be charged. +.LP +The syntax of the \fIaccount_string\fP option-argument is unspecified. +.LP +The \fIqsub\fP utility shall set the \fIAccount_Name\fP attribute +of the batch job to the value of the \fIaccount_string\fP +option-argument. +.LP +If the \fB-A\fP option is not presented to the \fIqsub\fP utility, +the utility shall omit the \fIAccount_Name\fP attribute +from the attributes of the batch job. +.TP 7 +\fB-c\ \fP \fIinterval\fP +Define whether the batch job should be checkpointed, and if so, how +often. +.LP +The \fIqsub\fP utility shall accept a value for the interval option-argument +that is one of the following: +.TP 7 +\fBn\fP +.RS +No checkpointing shall be performed on the batch job (NO_CHECKPOINT). +.RE +.TP 7 +\fBs\fP +.RS +Checkpointing shall be performed only when the batch server is shut +down (CHECKPOINT_AT_SHUTDOWN). +.RE +.TP 7 +\fBc\fP +.RS +Automatic periodic checkpointing shall be performed at the \fIMinimum_Cpu_Interval\fP +attribute of the batch queue, in units +of CPU minutes (CHECKPOINT_AT_MIN_CPU_INTERVAL). +.RE +.TP 7 +\fBc\fP=\fIminutes\fP +.RS +Automatic periodic checkpointing shall be performed every \fIminutes\fP +of CPU time, or every \fIMinimum_Cpu_Interval\fP +minutes, whichever is greater. The \fIminutes\fP argument shall conform +to the syntax for unsigned integers and shall be greater +than zero. +.RE +.sp +.LP +The \fIqsub\fP utility shall set the \fICheckpoint\fP attribute of +the batch job to the value of the \fIinterval\fP +option-argument. +.LP +If the \fB-c\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fICheckpoint\fP attribute of +the batch job to the single character \fB'u'\fP (CHECKPOINT_UNSPECIFIED). +.TP 7 +\fB-C\ \fP \fIdirective_prefix\fP +.sp +Define the prefix that declares a directive to the \fIqsub\fP utility +within the script. +.LP +The \fIdirective_prefix\fP is not a batch job attribute; it affects +the behavior of the \fIqsub\fP utility. +.LP +If the \fB-C\fP option is presented to the \fIqsub\fP utility, and +the value of the \fIdirective_prefix\fP option-argument is +the null string, the utility shall not scan the script file for directives. +If the \fB-C\fP option is not presented to the +\fIqsub\fP utility, then the value of the \fIPBS_DPREFIX\fP environment +variable is used. If the environment variable is not +defined, then #PBS encoded in the portable character set is the default. +.TP 7 +\fB-e\ \fP \fIpath_name\fP +Define the path to be used for the standard error stream of the batch +job. +.LP +The \fIqsub\fP utility shall accept a \fIpath_name\fP option-argument +which can be preceded by a host name element of the form +\fIhostname\fP:. +.LP +If the \fIpath_name\fP option-argument constitutes an absolute pathname, +the \fIqsub\fP utility shall set the +\fIError_Path\fP attribute of the batch job to the value of the \fIpath_name\fP +option-argument. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and no host name element is specified, the \fIqsub\fP +utility shall set the \fIError_Path\fP attribute of the batch job +to the value of the absolute pathname derived by expanding the +\fIpath_name\fP option-argument relative to the current directory +of the process executing \fIqsub\fP. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and a host name element is specified, the \fIqsub\fP +utility shall set the \fIError_Path\fP attribute of the batch job +to the value of the \fIpath_name\fP option-argument without +expansion. The host name element shall be included. +.LP +If the \fIpath_name\fP option-argument does not include a host name +element, the \fIqsub\fP utility shall prefix the pathname +with \fIhostname\fP:, where \fIhostname\fP is the name of the host +upon which the \fIqsub\fP utility is being executed. +.LP +If the \fB-e\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIError_Path\fP attribute of +the batch job to the host name and path of the current directory of +the submitting process and the default filename. +.LP +The default filename for standard error has the following format: +.sp +.RS +.nf + +\fIjob_name\fP\fB.e\fP\fIsequence_number\fP +.fi +.RE +.TP 7 +\fB-h\fP +Specify that a USER hold is applied to the batch job. +.LP +The \fIqsub\fP utility shall set the value of the \fIHold_Types\fP +attribute of the batch job to the value USER. +.LP +If the \fB-h\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIHold_Types\fP attribute of +the batch job to the value NO_HOLD. +.TP 7 +\fB-j\ \fP \fIjoin_list\fP +Define which streams of the batch job are to be merged. The \fIqsub\fP +\fB-j\fP option shall accept a value for the +\fIjoin_list\fP option-argument that is a string of alphanumeric characters +in the portable character set (see the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable +Character Set). +.LP +The \fIqsub\fP utility shall accept a \fIjoin_list\fP option-argument +that consists of one or more of the characters +\fB'e'\fP and \fB'o'\fP , or the single character \fB'n'\fP . +.LP +All of the other batch job output streams specified will be merged +into the output stream represented by the character listed +first in the \fIjoin_list\fP option-argument. +.LP +For each unique character in the \fIjoin_list\fP option-argument, +the \fIqsub\fP utility shall add a value to the +\fIJoin_Path\fP attribute of the batch job as follows, each representing +a different batch job stream to join: +.TP 7 +\fBe\fP +.RS +The standard error of the batch job (JOIN_STD_ERROR). +.RE +.TP 7 +\fBo\fP +.RS +The standard output of the batch job (JOIN_STD_OUTPUT). +.RE +.sp +.LP +An existing \fIJoin_Path\fP attribute can be cleared by the following +join type: +.TP 7 +\fBn\fP +.RS +NO_JOIN +.RE +.sp +.LP +If \fB'n'\fP is specified, then no files are joined. The \fIqsub\fP +utility shall consider it an error if any join type +other than \fB'n'\fP is combined with join type \fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'e'\fP , \fB'o'\fP , or \fB'n'\fP within the +\fIjoin_list\fP option-argument. The \fIqsub\fP utility shall permit +the repetition of characters, but shall not assign +additional meaning to the repeated characters. +.LP +An implementation may define other join types. The conformance document +for an implementation shall describe any additional +batch job streams, how they are specified, their internal behavior, +and how they affect the behavior of the utility. +.LP +If the \fB-j\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the value of the \fIJoin_Path\fP +attribute of the batch job to NO_JOIN. +.TP 7 +\fB-k\ \fP \fIkeep_list\fP +Define which output of the batch job to retain on the execution host. +.LP +The \fIqsub\fP \fB-k\fP option shall accept a value for the \fIkeep_list\fP +option-argument that is a string of alphanumeric +characters in the portable character set (see the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable Character +Set). +.LP +The \fIqsub\fP utility shall accept a \fIkeep_list\fP option-argument +that consists of one or more of the characters +\fB'e'\fP and \fB'o'\fP , or the single character \fB'n'\fP . +.LP +For each unique character in the \fIkeep_list\fP option-argument, +the \fIqsub\fP utility shall add a value to the +\fIKeep_Files\fP attribute of the batch job as follows, each representing +a different batch job stream to keep: +.TP 7 +\fBe\fP +.RS +The standard error of the batch job (KEEP_STD_ERROR). +.RE +.TP 7 +\fBo\fP +.RS +The standard output of the batch job (KEEP_STD_OUTPUT). +.RE +.sp +.LP +If both \fB'e'\fP and \fB'o'\fP are specified, then both files are +retained. An existing \fIKeep_Files\fP attribute can +be cleared by the following keep type: +.TP 7 +\fBn\fP +.RS +NO_KEEP +.RE +.sp +.LP +If \fB'n'\fP is specified, then no files are retained. The \fIqsub\fP +utility shall consider it an error if any keep type +other than \fB'n'\fP is combined with keep type \fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'e'\fP , \fB'o'\fP , or \fB'n'\fP within the +\fIkeep_list\fP option-argument. The \fIqsub\fP utility shall permit +the repetition of characters, but shall not assign +additional meaning to the repeated characters. +.LP +An implementation may define other keep types. The conformance document +for an implementation shall describe any additional keep +types, how they are specified, their internal behavior, and how they +affect the behavior of the utility. If the \fB-k\fP option is +not presented to the \fIqsub\fP utility, the utility shall set the +\fIKeep_Files\fP attribute of the batch job to the value +NO_KEEP. +.TP 7 +\fB-m\ \fP \fImail_options\fP +.sp +Define the points in the execution of the batch job at which the batch +server that manages the batch job shall send mail about a +change in the state of the batch job. +.LP +The \fIqsub\fP \fB-m\fP option shall accept a value for the \fImail_options\fP +option-argument that is a string of +alphanumeric characters in the portable character set (see the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable +Character Set). +.LP +The \fIqsub\fP utility shall accept a value for the \fImail_options\fP +option-argument that is a string of one or more of the +characters \fB'e'\fP , \fB'b'\fP , and \fB'a'\fP , or the single character +\fB'n'\fP . +.LP +For each unique character in the \fImail_options\fP option-argument, +the \fIqsub\fP utility shall add a value to the +\fIMail_Users\fP attribute of the batch job as follows, each representing +a different time during the life of a batch job at which +to send mail: +.TP 7 +\fBe\fP +.RS +MAIL_AT_EXIT +.RE +.TP 7 +\fBb\fP +.RS +MAIL_AT_BEGINNING +.RE +.TP 7 +\fBa\fP +.RS +MAIL_AT_ABORT +.RE +.sp +.LP +If any of these characters are duplicated in the \fImail_options\fP +option-argument, the duplicates shall be ignored. +.LP +An existing \fIMail_Points\fP attribute can be cleared by the following +mail type: +.TP 7 +\fBn\fP +.RS +NO_MAIL +.RE +.sp +.LP +If \fB'n'\fP is specified, then mail is not sent. The \fIqsub\fP utility +shall consider it an error if any mail type other +than \fB'n'\fP is combined with mail type \fB'n'\fP . +.LP +Strictly conforming applications shall not repeat any of the characters +\fB'e'\fP , \fB'b'\fP , \fB'a'\fP , or +\fB'n'\fP within the \fImail_options\fP option-argument. +.LP +The \fIqsub\fP utility shall permit the repetition of characters, +but shall not assign additional meaning to the repeated +characters. An implementation may define other mail types. The conformance +document for an implementation shall describe any +additional mail types, how they are specified, their internal behavior, +and how they affect the behavior of the utility. +.LP +If the \fB-m\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIMail_Points\fP attribute to +the value MAIL_AT_ABORT. +.TP 7 +\fB-M\ \fP \fImail_list\fP +Define the list of users to which a batch server that executes the +batch job shall send mail, if the server sends mail about +the batch job. +.LP +The syntax of the \fImail_list\fP option-argument is unspecified. +.LP +If the implementation of the \fIqsub\fP utility uses a name service +to locate users, the utility should accept the syntax used +by the name service. +.LP +If the implementation of the \fIqsub\fP utility does not use a name +service to locate users, the implementation should accept +the following syntax for user names: +.sp +.RS +.nf + +\fImail_address\fP\fB[\fP\fB,,\fP\fImail_address\fP\fB,, ...\fP\fB]\fP +.fi +.RE +.LP +The interpretation of \fImail_address\fP is implementation-defined. +.LP +The \fIqsub\fP utility shall set the \fIMail_Users\fP attribute of +the batch job to the value of the \fImail_list\fP +option-argument. +.LP +If the \fB-M\fP option is not presented to the \fIqsub\fP utility, +the utility shall place only the user name and host name +for the current process in the \fIMail_Users\fP attribute of the batch +job. +.TP 7 +\fB-N\ \fP \fIname\fP +Define the name of the batch job. +.LP +The \fIqsub\fP \fB-N\fP option shall accept a value for the \fIname\fP +option-argument that is a string of up to 15 +alphanumeric characters in the portable character set (see the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 6.1, Portable +Character Set) where the first character is alphabetic. +.LP +The \fIqsub\fP utility shall set the value of the \fIJob_Name\fP attribute +of the batch job to the value of the \fIname\fP +option-argument. +.LP +If the \fB-N\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIJob_Name\fP attribute of the +batch job to the name of the \fIscript\fP argument from which the +directory specification if any, has been removed. +.LP +If the \fB-N\fP option is not presented to the \fIqsub\fP utility, +and the script is read from standard input, the utility +shall set the \fIJob_Name\fP attribute of the batch job to the value +STDIN. +.TP 7 +\fB-o\ \fP \fIpath_name\fP +Define the path for the standard output of the batch job. +.LP +The \fIqsub\fP utility shall accept a \fIpath_name\fP option-argument +that conforms to the syntax of the \fIpath_name\fP +element defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +which can be preceded by a host name element of +the form \fIhostname\fP:. +.LP +If the \fIpath_name\fP option-argument constitutes an absolute pathname, +the \fIqsub\fP utility shall set the +\fIOutput_Path\fP attribute of the batch job to the value of the \fIpath_name\fP +option-argument without expansion. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and no host name element is specified, the \fIqsub\fP +utility shall set the \fIOutput_Path\fP attribute of the batch job +to the pathname derived by expanding the value of the +\fIpath_name\fP option-argument relative to the current directory +of the process executing the \fIqsub\fP. +.LP +If the \fIpath_name\fP option-argument constitutes a relative pathname +and a host name element is specified, the \fIqsub\fP +utility shall set the \fIOutput_Path\fP attribute of the batch job +to the value of the \fIpath_name\fP option-argument without +expansion. +.LP +If the \fIpath_name\fP option-argument does not specify a host name +element, the \fIqsub\fP utility shall prefix the pathname +with \fIhostname\fP:, where \fIhostname\fP is the name of the host +upon which the \fIqsub\fP utility is executing. +.LP +If the \fB-o\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIOutput_Path\fP attribute of +the batch job to the host name and path of the current directory of +the submitting process and the default filename. +.LP +The default filename for standard output has the following format: +.sp +.RS +.nf + +\fIjob_name\fP\fB.o\fP\fIsequence_number\fP +.fi +.RE +.TP 7 +\fB-p\ \fP \fIpriority\fP +Define the priority the batch job should have relative to other batch +jobs owned by the batch server. +.LP +The \fIqsub\fP utility shall set the \fIPriority\fP attribute of the +batch job to the value of the \fIpriority\fP +option-argument. +.LP +If the \fB-p\fP option is not presented to the \fIqsub\fP utility, +the value of the \fIPriority\fP attribute is +implementation-defined. +.LP +The \fIqsub\fP utility shall accept a value for the \fIpriority\fP +option-argument that conforms to the syntax for signed +decimal integers, and which is not less than -1024 and not greater +than 1023. +.TP 7 +\fB-q\ \fP \fIdestination\fP +.sp +Define the destination of the batch job. +.LP +The destination is not a batch job attribute; it determines the batch +server, and possibly the batch queue, to which the +\fIqsub\fP utility batch queues the batch job. +.LP +The \fIqsub\fP utility shall submit the script to the batch server +named by the \fIdestination\fP option-argument or the +server that owns the batch queue named in the \fIdestination\fP option-argument. +.LP +The \fIqsub\fP utility shall accept an option-argument for the \fB-q\fP +option that conforms to the syntax for a destination +(see \fIDestination\fP ). +.LP +If the \fB-q\fP option is not presented to the \fIqsub\fP utility, +the \fIqsub\fP utility shall submit the batch job to the +default destination. The mechanism for determining the default destination +is implementation-defined. +.TP 7 +\fB-r\ \fP \fIy\fP|\fIn\fP +Define whether the batch job is rerunnable. +.LP +If the value of the option-argument is \fIy\fP, the \fIqsub\fP utility +shall set the \fIRerunable\fP attribute of the batch +job to TRUE. +.LP +If the value of the option-argument is \fIn\fP, the \fIqsub\fP utility +shall set the \fIRerunable\fP attribute of the batch +job to FALSE. +.LP +If the \fB-r\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIRerunable\fP attribute of the +batch job to TRUE. +.TP 7 +\fB-S\ \fP \fIpath_name_list\fP +.sp +Define the pathname to the shell under which the batch job is to execute. +.LP +The \fIqsub\fP utility shall accept a \fIpath_name_list\fP option-argument +that conforms to the following syntax: +.sp +.RS +.nf + +\fIpathname\fP\fB[\fP\fB@\fP\fIhost\fP\fB][\fP\fB,,\fP\fIpathname\fP\fB[\fP\fB@\fP\fIhost\fP\fB]\fP\fB,, ...\fP\fB]\fP +.fi +.RE +.LP +The \fIqsub\fP utility shall allow only one pathname for a given host +name. The \fIqsub\fP utility shall allow only one +pathname that is missing a corresponding host name. +.LP +The \fIqsub\fP utility shall add a value to the \fIShell_Path_List\fP +attribute of the batch job for each entry in the +\fIpath_name_list\fP option-argument. +.LP +If the \fB-S\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIShell_Path_List\fP attribute +of the batch job to the null string. +.LP +The conformance document for an implementation shall describe the +mechanism used to set the default shell and determine the +current value of the default shell. An implementation shall provide +a means for the installation to set the default shell to the +login shell of the user under which the batch job is to execute. See +\fIMultiple +Keyword-Value Pairs\fP for a means of removing \fIkeyword\fP= \fIvalue\fP +(and \fIvalue\fP@ \fIkeyword\fP) pairs and other +general rules for list-oriented batch job attributes. +.TP 7 +\fB-u\ \fP \fIuser_list\fP +Define the user name under which the batch job is to execute. +.LP +The \fIqsub\fP utility shall accept a \fIuser_list\fP option-argument +that conforms to the following syntax: +.sp +.RS +.nf + +\fIusername\fP\fB[\fP\fB@\fP\fIhost\fP\fB][\fP\fB,,\fP\fIusername\fP\fB[\fP\fB@\fP\fIhost\fP\fB]\fP\fB,, ...\fP\fB]\fP +.fi +.RE +.LP +The \fIqsub\fP utility shall accept only one user name that is missing +a corresponding host name. The \fIqsub\fP utility shall +accept only one user name per named host. +.LP +The \fIqsub\fP utility shall add a value to the \fIUser_List\fP attribute +of the batch job for each entry in the +\fIuser_list\fP option-argument. +.LP +If the \fB-u\fP option is not presented to the \fIqsub\fP utility, +the utility shall set the \fIUser_List\fP attribute of the +batch job to the user name from which the utility is executing. See +\fIMultiple +Keyword-Value Pairs\fP for a means of removing \fIkeyword\fP= \fIvalue\fP +(and \fIvalue\fP@ \fIkeyword\fP) pairs and other +general rules for list-oriented batch job attributes. +.TP 7 +\fB-v\ \fP \fIvariable_list\fP +.sp +Add to the list of variables that are exported to the session leader +of the batch job. +.LP +A \fIvariable_list\fP is a set of strings of either the form < \fIvariable\fP> +or < \fIvariable\fP= +\fIvalue\fP>, delimited by commas. +.LP +If the \fB-v\fP option is presented to the \fIqsub\fP utility, the +utility shall also add, to the environment +\fIVariable_List\fP attribute of the batch job, every variable named +in the environment \fIvariable_list\fP option-argument and, +optionally, values of specified variables. +.LP +If a value is not provided on the command line, the \fIqsub\fP utility +shall set the value of each variable in the environment +\fIVariable_List\fP attribute of the batch job to the value of the +corresponding environment variable for the process in which the +utility is executing; see Environment Variable Values (Utilities) +\&. +.LP +A conforming application shall not repeat a variable in the environment +\fIvariable_list\fP option-argument. +.LP +The \fIqsub\fP utility shall not repeat a variable in the environment +\fIVariable_List\fP attribute of the batch job. See \fIMultiple Keyword-Value +Pairs\fP for a means of removing \fIkeyword\fP= \fIvalue\fP +(and \fIvalue\fP@ \fIkeyword\fP) pairs and other general rules for +list-oriented batch job attributes. +.TP 7 +\fB-V\fP +Specify that all of the environment variables of the process are exported +to the context of the batch job. +.LP +The \fIqsub\fP utility shall place every environment variable in the +process in which the utility is executing in the list and +shall set the value of each variable in the attribute to the value +of that variable in the process. +.TP 7 +\fB-z\fP +Specify that the utility does not write the batch \fIjob_identifier\fP +of the created batch job to standard output. +.LP +If the \fB-z\fP option is presented to the \fIqsub\fP utility, the +utility shall not write the batch \fIjob_identifier\fP of +the created batch job to standard output. +.LP +If the \fB-z\fP option is not presented to the \fIqsub\fP utility, +the utility shall write the identifier of the created batch +job to standard output. +.sp +.SH OPERANDS +.LP +The \fIqsub\fP utility shall accept a \fIscript\fP operand that indicates +the path to the script of the batch job. +.LP +If the \fIscript\fP operand is not presented to the \fIqsub\fP utility, +or if the operand is the single-character string +\fB'-'\fP , the utility shall read the script from standard input. +.LP +If the script represents a partial path, the \fIqsub\fP utility shall +expand the path relative to the current directory of the +process executing the utility. +.SH STDIN +.LP +The \fIqsub\fP utility reads the script of the batch job from standard +input if the script operand is omitted or is the single +character \fB'-'\fP . +.SH INPUT FILES +.LP +In addition to binding the file indicated by the \fIscript\fP operand +to the batch job, the \fIqsub\fP utility reads the +script file and acts on directives in the script. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIqsub\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILOGNAME\fP +Determine the login name of the user. +.TP 7 +\fIPBS_DPREFIX\fP +.sp +Determine the default prefix for directives within the script. +.TP 7 +\fISHELL\fP +Determine the pathname of the preferred command language interpreter +of the user. +.TP 7 +\fITZ\fP +Determine the timezone used to interpret the \fIdate-time\fP option-argument. +If \fITZ\fP is unset or null, an unspecified +default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Once created, a batch job exists until it exits, aborts, or is deleted. +.LP +After a batch job is created by the \fIqsub\fP utility, batch servers +might route, execute, modify, or delete the batch +job. +.SH STDOUT +.LP +The \fIqsub\fP utility writes the batch \fIjob_identifier\fP assigned +to the batch job to standard output, unless the +\fB-z\fP option is specified. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.SS Script Preservation +.LP +The \fIqsub\fP utility shall make the script available to the server +executing the batch job in such a way that the server +executes the script as it exists at the time of submission. +.LP +The \fIqsub\fP utility can send a copy of the script to the server +with the \fIQueue Job Request\fP or store a temporary copy +of the script in a location specified to the server. +.SS Option Specification +.LP +A script can contain directives to the \fIqsub\fP utility. +.LP +The \fIqsub\fP utility shall scan the lines of the script for directives, +skipping blank lines, until the first line that +begins with a string other than the directive string; if directives +occur on subsequent lines, the utility shall ignore those +directives. +.LP +Lines are separated by a <newline>. If the first line of the script +begins with \fB"#!"\fP or a colon ( \fB':'\fP ), +then it is skipped. The \fIqsub\fP utility shall process a line in +the script as a directive if and only if the string of +characters from the first non-white-space character on the line until +the first <space> or <tab> on the line match the +directive prefix. If a line in the script contains a directive and +the final characters of the line are backslash ( \fB'\\'\fP ) +and <newline>, then the next line shall be interpreted as a continuation +of that directive. +.LP +The \fIqsub\fP utility shall process the options and option-arguments +contained on the directive prefix line using the same +syntax as if the options were input on the \fIqsub\fP utility. +.LP +The \fIqsub\fP utility shall continue to process a directive prefix +line until after a <newline> is encountered. An +implementation may ignore lines which, according to the syntax of +the shell that will interpret the script, are comments. An +implementation shall describe in the conformance document the format +of any shell comments that it will recognize. +.LP +If an option is present in both a directive and the arguments to the +\fIqsub\fP utility, the utility shall ignore the option +and the corresponding option-argument, if any, in the directive. +.LP +If an option that is present in the directive is not present in the +arguments to the \fIqsub\fP utility, the utility shall +process the option and the option-argument, if any. +.LP +In order of preference, the \fIqsub\fP utility shall select the directive +prefix from one of the following sources: +.IP " *" 3 +If the \fB-C\fP option is presented to the utility, the value of the +\fIdirective_prefix\fP option-argument +.LP +.IP " *" 3 +If the environment variable \fIPBS_DPREFIX\fP is defined, the value +of that variable +.LP +.IP " *" 3 +The four-character string \fB"#PBS"\fP encoded in the portable character +set +.LP +.LP +If the \fB-C\fP option is present in the script file it shall be ignored. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIqsub\fP utility allows users to create a batch job that will +process the script specified as the operand of the +utility. +.LP +The options of the \fIqsub\fP utility allow users to control many +aspects of the queuing and execution of a batch job. +.LP +The \fB-a\fP option allows users to designate the time after which +the batch job will become eligible to run. By specifying an +execution time, users can take advantage of resources at off-peak +hours, synchronize jobs with chronologically predictable events, +and perhaps take advantage of off-peak pricing of computing time. +For these reasons and others, a timing option is existing +practice on the part of almost every batch system, including NQS. +.LP +The \fB-A\fP option allows users to specify the account that will +be charged for the batch job. Support for account is not +mandatory for conforming batch servers. +.LP +The \fB-C\fP option allows users to prescribe the prefix for directives +within the script file. The default prefix +\fB"#PBS"\fP may be inappropriate if the script will be interpreted +with an alternate shell, as specified by the \fB-S\fP +option. +.LP +The \fB-c\fP option allows users to establish the checkpointing interval +for their jobs. A checkpointing system, which is not +defined by this volume of IEEE\ Std\ 1003.1-2001, allows recovery +of a batch job at the most recent checkpoint in the event +of a crash. Checkpointing is typically used for jobs that consume +expensive computing time or must meet a critical schedule. Users +should be allowed to make the tradeoff between the overhead of checkpointing +and the risk to the timely completion of the batch +job; therefore, this volume of IEEE\ Std\ 1003.1-2001 provides the +checkpointing interval option. Support for checkpointing +is optional for batch servers. +.LP +The \fB-e\fP option allows users to redirect the standard error streams +of their jobs to a non-default path. For example, if +the submitted script generally produces a great deal of useless error +output, a user might redirect the standard error output to +the null device. Or, if the file system holding the default location +(the home directory of the user) has too little free space, +the user might redirect the standard error stream to a file in another +file system. +.LP +The \fB-h\fP option allows users to create a batch job that is held +until explicitly released. The ability to create a held job +is useful when some external event must complete before the batch +job can execute. For example, the user might submit a held job +and release it when the system load has dropped. +.LP +The \fB-j\fP option allows users to merge the standard error of a +batch job into its standard output stream, which has the +advantage of showing the sequential relationship between output and +error messages. +.LP +The \fB-m\fP option allows users to designate those points in the +execution of a batch job at which mail will be sent to the +submitting user, or to the account(s) indicated by the \fB-M\fP option. +By requesting mail notification at points of interest in +the life of a job, the submitting user, or other designated users, +can track the progress of a batch job. +.LP +The \fB-N\fP option allows users to associate a name with the batch +job. The job name in no way affects the processing of the +batch job, but rather serves as a mnemonic handle for users. For example, +the batch job name can help the user distinguish between +multiple jobs listed by the \fIqstat\fP utility. +.LP +The \fB-o\fP option allows users to redirect the standard output stream. +A user might, for example, wish to redirect to the +null device the standard output stream of a job that produces copious +yet superfluous output. +.LP +The \fB-P\fP option allows users to designate the relative priority +of a batch job for selection from a queue. +.LP +The \fB-q\fP option allows users to specify an initial queue for the +batch job. If the user specifies a routing queue, the +batch server routes the batch job to another queue for execution or +further routing. If the user specifies a non-routing queue, the +batch server of the queue eventually executes the batch job. +.LP +The \fB-r\fP option allows users to control whether the submitted +job will be rerun if the controlling batch node fails during +execution of the batch job. The \fB-r\fP option likewise allows users +to indicate whether or not the batch job is eligible to be +rerun by the \fIqrerun\fP utility. Some jobs cannot be correctly rerun +because of changes +they make in the state of databases or other aspects of their environment. +This volume of IEEE\ Std\ 1003.1-2001 specifies +that the default, if the \fB-r\fP option is not presented to the utility, +will be that the batch job cannot be rerun, since the +result of rerunning a non-rerunnable job might be catastrophic. +.LP +The \fB-S\fP option allows users to specify the program (usually a +shell) that will be invoked to process the script of the +batch job. This option has been modified to allow a list of shell +names and locations associated with different hosts. +.LP +The \fB-u\fP option is useful when the submitting user is authorized +to use more than one account on a given host, in which +case the \fB-u\fP option allows the user to select from among those +accounts. The option-argument is a list of user-host pairs, so +that the submitting user can provide different user identifiers for +different nodes in the event the batch job is routed. The +\fB-u\fP option provides a lot of flexibility to accommodate sites +with complex account structures. Users that have the same user +identifier on all the hosts they are authorized to use will not need +to use the \fB-u\fP option. +.LP +The \fB-V\fP option allows users to export all their current environment +variables, as of the time the batch job is submitted, +to the context of the processes of the batch job. +.LP +The \fB-v\fP option allows users to export specific environment variables +from their current process to the processes of the +batch job. +.LP +The \fB-z\fP option allows users to suppress the writing of the batch +job identifier to standard output. The \fB-z\fP option +is an existing NQS practice that has been standardized. +.LP +Historically, the \fIqsub\fP utility has served the batch job-submission +function in the NQS system, the existing practice on +which it is based. Some changes and additions have been made to the +\fIqsub\fP utility in this volume of +IEEE\ Std\ 1003.1-2001, \fIvis-a-vis\fP NQS, as a result of the growing +pool of experience with distributed batch +systems. +.LP +The set of features of the \fIqsub\fP utility as defined in this volume +of IEEE\ Std\ 1003.1-2001 appears to +incorporate all the common existing practice on potentially conforming +platforms. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIBatch Environment Services\fP , \fIqrerun\fP , \fIqstat\fP , \fItouch\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/read.1p b/man1p/read.1p new file mode 100644 index 000000000..daf4e3ad0 --- /dev/null +++ b/man1p/read.1p @@ -0,0 +1,214 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "READ" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" read +.SH NAME +read \- read a line from standard input +.SH SYNOPSIS +.LP +\fBread\fP \fB[\fP\fB-r\fP\fB]\fP \fIvar\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fIread\fP utility shall read a single line from standard input. +.LP +By default, unless the \fB-r\fP option is specified, backslash ( \fB'\\'\fP +) shall act as an escape character, as described +in \fIEscape Character (Backslash)\fP . If standard input is a terminal +device and the +invoking shell is interactive, \fIread\fP shall prompt for a continuation +line when: +.IP " *" 3 +The shell reads an input line ending with a backslash, unless the +\fB-r\fP option is specified. +.LP +.IP " *" 3 +A here-document is not terminated after a <newline> is entered. +.LP +.LP +The line shall be split into fields as in the shell (see \fIField +Splitting\fP ); +the first field shall be assigned to the first variable \fIvar\fP, +the second field to the second variable \fIvar\fP, and so on. +If there are fewer \fIvar\fP operands specified than there are fields, +the leftover fields and their intervening separators shall +be assigned to the last \fIvar\fP. If there are fewer fields than +\fIvar\fPs, the remaining \fIvar\fPs shall be set to empty +strings. +.LP +The setting of variables specified by the \fIvar\fP operands shall +affect the current shell execution environment; see \fIShell Execution +Environment\fP . If it is called in a subshell or separate utility +execution +environment, such as one of the following: +.sp +.RS +.nf + +\fB(read foo) +nohup read ... +find . -exec read ... \\; +\fP +.fi +.RE +.LP +it shall not affect the shell variables in the caller's environment. +.SH OPTIONS +.LP +The \fIread\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option is supported: +.TP 7 +\fB-r\fP +Do not treat a backslash character in any special way. Consider each +backslash to be part of the input line. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIvar\fP +The name of an existing or nonexisting shell variable. +.sp +.SH STDIN +.LP +The standard input shall be a text file. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIread\fP: +.TP 7 +\fIIFS\fP +Determine the internal field separators used to delimit fields; see +\fIShell +Variables\fP . +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPS2\fP +Provide the prompt string that an interactive shell shall write to +standard error when a line ending with a backslash is read +and the \fB-r\fP option was not specified, or if a here-document is +not terminated after a <newline> is entered. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used for diagnostic messages and prompts +for continued input. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +End-of-file was detected or an error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-r\fP option is included to enable \fIread\fP to subsume the +purpose of the \fIline\fP utility, which is not included +in IEEE\ Std\ 1003.1-2001. +.LP +The results are undefined if an end-of-file is detected following +a backslash at the end of a line when \fB-r\fP is not +specified. +.SH EXAMPLES +.LP +The following command: +.sp +.RS +.nf + +\fBwhile read -r xx yy +do + printf "%s %s\\n" "$yy" "$xx" +done <\fP \fIinput_file\fP +.fi +.RE +.LP +prints a file with the first field of each line moved to the end of +the line. +.SH RATIONALE +.LP +The \fIread\fP utility historically has been a shell built-in. It +was separated off into its own utility to take advantage of +the richer description of functionality introduced by this volume +of IEEE\ Std\ 1003.1-2001. +.LP +Since \fIread\fP affects the current shell execution environment, +it is generally provided as a shell regular built-in. If it +is called in a subshell or separate utility execution environment, +such as one of the following: +.sp +.RS +.nf + +\fB(read foo) +nohup read ... +find . -exec read ... \\; +\fP +.fi +.RE +.LP +it does not affect the shell variables in the environment of the caller. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/readonly.1p b/man1p/readonly.1p new file mode 100644 index 000000000..35e04085c --- /dev/null +++ b/man1p/readonly.1p @@ -0,0 +1,151 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "READONLY" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" readonly +.SH NAME +readonly \- set the readonly attribute for variables +.SH SYNOPSIS +.LP +\fBreadonly name\fP\fB[\fP\fB=\fP\fIword\fP\fB]\fP\fB... +.br +.sp +readonly -p +.br +\fP +.SH DESCRIPTION +.LP +The variables whose \fIname\fPs are specified shall be given the \fIreadonly\fP +attribute. The values of variables with the +\fIreadonly\fP attribute cannot be changed by subsequent assignment, +nor can those variables be unset by the \fIunset\fP utility. If the +name of a variable is followed by = \fIword\fP, then the value of +that +variable shall be set to \fIword\fP. +.LP +The \fIreadonly\fP special built-in shall support the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +When \fB-p\fP is specified, \fIreadonly\fP writes to the standard +output the names and values of all read-only variables, in +the following format: +.sp +.RS +.nf + +\fB"readonly %s=%s\\n", <\fP\fIname\fP\fB>, <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +if \fIname\fP is set, and +.sp +.RS +.nf + +\fB"readonly %s\\n", <\fP\fIname\fP\fB> +\fP +.fi +.RE +.LP +if \fIname\fP is unset. +.LP +The shell shall format the output, including the proper use of quoting, +so that it is suitable for reinput to the shell as +commands that achieve the same value and \fIreadonly\fP attribute-setting +results in a shell execution environment in which: +.IP " 1." 4 +Variables with values at the time they were output do not have the +\fIreadonly\fP attribute set. +.LP +.IP " 2." 4 +Variables that were unset at the time they were output do not have +a value at the time at which the saved output is reinput to +the shell. +.LP +.LP +When no arguments are given, the results are unspecified. +.SH OPTIONS +.LP +See the DESCRIPTION. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the DESCRIPTION. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +Zero. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fBreadonly HOME PWD +\fP +.fi +.RE +.SH RATIONALE +.LP +Some historical shells preserve the \fIreadonly\fP attribute across +separate invocations. This volume of +IEEE\ Std\ 1003.1-2001 allows this behavior, but does not require +it. +.LP +The \fB-p\fP option allows portable access to the values that can +be saved and then later restored using, for example, a \fIdot\fP script. +Also see the RATIONALE for \fIexport\fP +for a description of the no-argument and \fB-p\fP output cases and +a related example. +.LP +Read-only functions were considered, but they were omitted as not +being historical practice or particularly useful. Furthermore, +functions must not be read-only across invocations to preclude ``spoofing'' +(spoofing is the term for the practice of creating a +program that acts like a well-known utility with the intent of subverting +the real intent of the user) of administrative or +security-relevant (or security-conscious) shell scripts. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/renice.1p b/man1p/renice.1p new file mode 100644 index 000000000..8b92bbb5e --- /dev/null +++ b/man1p/renice.1p @@ -0,0 +1,251 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "RENICE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" renice +.SH NAME +renice \- set nice values of running processes +.SH SYNOPSIS +.LP +\fBrenice -n\fP \fIincrement\fP \fB[\fP\fB-g | -p | -u\fP\fB]\fP \fIID\fP +\fB\&... \fP +.SH DESCRIPTION +.LP +The \fIrenice\fP utility shall request that the nice values (see the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 3.239, Nice Value) of one or more running processes be changed. +By +default, the applicable processes are specified by their process IDs. +When a process group is specified (see \fB-g\fP), the +request shall apply to all processes in the process group. +.LP +The nice value shall be bounded in an implementation-defined manner. +If the requested \fIincrement\fP would raise or lower the +nice value of the executed utility beyond implementation-defined limits, +then the limit whose value was exceeded shall be used. +.LP +When a user is \fIrenice\fPd, the request applies to all processes +whose saved set-user-ID matches the user ID corresponding to +the user. +.LP +Regardless of which options are supplied or any other factor, \fIrenice\fP +shall not alter the nice values of any process +unless the user requesting such a change has appropriate privileges +to do so for the specified process. If the user lacks +appropriate privileges to perform the requested action, the utility +shall return an error status. +.LP +The saved set-user-ID of the user's process shall be checked instead +of its effective user ID when \fIrenice\fP attempts to +determine the user ID of the process in order to determine whether +the user has appropriate privileges. +.SH OPTIONS +.LP +The \fIrenice\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-g\fP +Interpret all operands as unsigned decimal integer process group IDs. +.TP 7 +\fB-n\ \fP \fIincrement\fP +Specify how the nice value of the specified process or processes is +to be adjusted. The \fIincrement\fP option-argument is a +positive or negative decimal integer that shall be used to modify +the nice value of the specified process or processes. +.LP +Positive \fIincrement\fP values shall cause a lower nice value. Negative +\fIincrement\fP values may require appropriate +privileges and shall cause a higher nice value. +.TP 7 +\fB-p\fP +Interpret all operands as unsigned decimal integer process IDs. The +\fB-p\fP option is the default if no options are +specified. +.TP 7 +\fB-u\fP +Interpret all operands as users. If a user exists with a user name +equal to the operand, then the user ID of that user is used +in further processing. Otherwise, if the operand represents an unsigned +decimal integer, it shall be used as the numeric user ID of +the user. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIID\fP +A process ID, process group ID, or user name/user ID, depending on +the option selected. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIrenice\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.IP " 1." 4 +Adjust the nice value so that process IDs 987 and 32 would have a +lower nice value: +.sp +.RS +.nf + +\fBrenice -n 5 -p 987 32 +\fP +.fi +.RE +.LP +.IP " 2." 4 +Adjust the nice value so that group IDs 324 and 76 would have a higher +nice value, if the user has the appropriate privileges to +do so: +.sp +.RS +.nf + +\fBrenice -n -4 -g 324 76 +\fP +.fi +.RE +.LP +.IP " 3." 4 +Adjust the nice value so that numeric user ID 8 and user \fBsas\fP +would have a lower nice value: +.sp +.RS +.nf + +\fBrenice -n 4 -u 8 sas +\fP +.fi +.RE +.LP +.LP +Useful nice value increments on historical systems include 19 or 20 +(the affected processes run only when nothing else in the +system attempts to run) and any negative number (to make processes +run faster). +.SH RATIONALE +.LP +The \fIgid\fP, \fIpid\fP, and \fIuser\fP specifications do not fit +either the definition of operand or option-argument. +However, for clarity, they have been included in the OPTIONS section, +rather than the OPERANDS section. +.LP +The definition of nice value is not intended to suggest that all processes +in a system have priorities that are comparable. +Scheduling policy extensions such as the realtime priorities in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001 make +the notion of a single underlying priority for all scheduling policies +problematic. Some implementations may implement the \fInice\fP-related +features to affect all processes on the system, others to affect just +the general +time-sharing activities implied by this volume of IEEE\ Std\ 1003.1-2001, +and others may have no effect at all. Because of +the use of "implementation-defined" in \fInice\fP and \fIrenice\fP, +a wide range of +implementation strategies are possible. +.LP +Originally, this utility was written in the historical manner, using +the term "nice value". This was always a point of concern +with users because it was never intuitively obvious what this meant. +With a newer version of \fIrenice\fP, which used the term +"system scheduling priority", it was hoped that novice users could +better understand what this utility was meant to do. Also, it +would be easier to document what the utility was meant to do. Unfortunately, +the addition of the POSIX realtime scheduling +capabilities introduced the concepts of process and thread scheduling +priorities that were totally unaffected by the \fInice\fP/ \fIrenice\fP +utilities or the \fInice\fP()/ \fIsetpriority\fP() functions. Continuing +to use the term "system scheduling priority'' +would have incorrectly suggested that these utilities and functions +were indeed affecting these realtime priorities. It was decided +to revert to the historical term "nice value" to reference this unrelated +process attribute. +.LP +Although this utility has use by system administrators (and in fact +appears in the system administration portion of the BSD +documentation), the standard developers considered that it was very +useful for individual end users to control their own +processes. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fInice\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/return.1p b/man1p/return.1p new file mode 100644 index 000000000..86bbc321e --- /dev/null +++ b/man1p/return.1p @@ -0,0 +1,94 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "RETURN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" return +.SH NAME +return \- return from a function +.SH SYNOPSIS +.LP +\fBreturn\fP \fB[\fP\fIn\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIreturn\fP utility shall cause the shell to stop executing the +current function or \fIdot\fP script. If the shell is not currently +executing a function or \fIdot\fP script, the results are unspecified. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The value of the special parameter \fB'?'\fP shall be set to \fIn\fP, +an unsigned decimal integer, or to the exit status of +the last command executed if \fIn\fP is not specified. If the value +of \fIn\fP is greater than 255, the results are undefined. +When \fIreturn\fP is executed in a \fItrap\fP action, the last command +is considered to be +the command that executed immediately preceding the \fItrap\fP action. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The behavior of \fIreturn\fP when not in a function or \fIdot\fP script +differs between +the System V shell and the KornShell. In the System V shell this is +an error, whereas in the KornShell, the effect is the same as +\fIexit\fP. +.LP +The results of returning a number greater than 255 are undefined because +of differing practices in the various historical +implementations. Some shells AND out all but the low-order 8 bits; +others allow larger values, but not of unlimited size. +.LP +See the discussion of appropriate exit status values under \fIexit\fP +\&. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/rm.1p b/man1p/rm.1p new file mode 100644 index 000000000..3b12db63e --- /dev/null +++ b/man1p/rm.1p @@ -0,0 +1,354 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "RM" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" rm +.SH NAME +rm \- remove directory entries +.SH SYNOPSIS +.LP +\fBrm\fP \fB[\fP\fB-fiRr\fP\fB]\fP \fIfile\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fIrm\fP utility shall remove the directory entry specified by +each \fIfile\fP argument. +.LP +If either of the files dot or dot-dot are specified as the basename +portion of an operand (that is, the final pathname +component), \fIrm\fP shall write a diagnostic message to standard +error and do nothing more with such operands. +.LP +For each \fIfile\fP the following steps shall be taken: +.IP " 1." 4 +If the \fIfile\fP does not exist: +.RS +.IP " a." 4 +If the \fB-f\fP option is not specified, \fIrm\fP shall write a diagnostic +message to standard error. +.LP +.IP " b." 4 +Go on to any remaining \fIfiles\fP. +.LP +.RE +.LP +.IP " 2." 4 +If \fIfile\fP is of type directory, the following steps shall be taken: +.RS +.IP " a." 4 +If neither the \fB-R\fP option nor the \fB-r\fP option is specified, +\fIrm\fP shall write a diagnostic message to standard +error, do nothing more with \fIfile\fP, and go on to any remaining +files. +.LP +.IP " b." 4 +If the \fB-f\fP option is not specified, and either the permissions +of \fIfile\fP do not permit writing and the standard input +is a terminal or the \fB-i\fP option is specified, \fIrm\fP shall +write a prompt to standard error and read a line from the +standard input. If the response is not affirmative, \fIrm\fP shall +do nothing more with the current file and go on to any +remaining files. +.LP +.IP " c." 4 +For each entry contained in \fIfile\fP, other than dot or dot-dot, +the four steps listed here (1 to 4) shall be taken with the +entry as if it were a \fIfile\fP operand. The \fIrm\fP utility shall +not traverse directories by following symbolic links into +other parts of the hierarchy, but shall remove the links themselves. +.LP +.IP " d." 4 +If the \fB-i\fP option is specified, \fIrm\fP shall write a prompt +to standard error and read a line from the standard input. +If the response is not affirmative, \fIrm\fP shall do nothing more +with the current file, and go on to any remaining files. +.LP +.RE +.LP +.IP " 3." 4 +If \fIfile\fP is not of type directory, the \fB-f\fP option is not +specified, and either the permissions of \fIfile\fP do not +permit writing and the standard input is a terminal or the \fB-i\fP +option is specified, \fIrm\fP shall write a prompt to the +standard error and read a line from the standard input. If the response +is not affirmative, \fIrm\fP shall do nothing more with +the current file and go on to any remaining files. +.LP +.IP " 4." 4 +If the current file is a directory, \fIrm\fP shall perform actions +equivalent to the \fIrmdir\fP() function defined in the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 +called with a pathname of the current file used as the \fIpath\fP +argument. If the current file is not a directory, \fIrm\fP +shall perform actions equivalent to the \fIunlink\fP() function defined +in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001 called with a pathname +of the current file used as the \fIpath\fP +argument. +.LP +If this fails for any reason, \fIrm\fP shall write a diagnostic message +to standard error, do nothing more with the current +file, and go on to any remaining files. +.LP +.LP +The \fIrm\fP utility shall be able to descend to arbitrary depths +in a file hierarchy, and shall not fail due to path length +limitations (unless an operand specified by the user exceeds system +limitations). +.SH OPTIONS +.LP +The \fIrm\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-f\fP +Do not prompt for confirmation. Do not write diagnostic messages or +modify the exit status in the case of nonexistent operands. +Any previous occurrences of the \fB-i\fP option shall be ignored. +.TP 7 +\fB-i\fP +Prompt for confirmation as described previously. Any previous occurrences +of the \fB-f\fP option shall be ignored. +.TP 7 +\fB-R\fP +Remove file hierarchies. See the DESCRIPTION. +.TP 7 +\fB-r\fP +Equivalent to \fB-R\fP. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a directory entry to be removed. +.sp +.SH STDIN +.LP +The standard input shall be used to read an input line in response +to each prompt specified in the STDOUT section. Otherwise, +the standard input shall not be used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIrm\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements used in the extended +regular expression defined for the \fByesexpr\fP locale keyword in +the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments) and the behavior of +character classes within regular expressions used in the +extended regular expression defined for the \fByesexpr\fP locale keyword +in the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale for the processing of affirmative responses that +should be used to affect the format and contents of +diagnostic messages written to standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +Prompts shall be written to standard error under the conditions specified +in the DESCRIPTION and OPTIONS sections. The prompts +shall contain the \fIfile\fP pathname, but their format is otherwise +unspecified. The standard error also shall be used for +diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All of the named directory entries for which \fIrm\fP performed actions +equivalent to the \fIrmdir\fP() or \fIunlink\fP() functions were removed. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIrm\fP utility is forbidden to remove the names dot and dot-dot +in order to avoid the consequences of inadvertently doing +something like: +.sp +.RS +.nf + +\fBrm -r .* +\fP +.fi +.RE +.LP +Some implementations do not permit the removal of the last link to +an executable binary file that is being executed; see the +[EBUSY] error in the \fIunlink\fP() function defined in the System +Interfaces volume of +IEEE\ Std\ 1003.1-2001. Thus, the \fIrm\fP utility can fail to remove +such files. +.LP +The \fB-i\fP option causes \fIrm\fP to prompt and read the standard +input even if the standard input is not a terminal, but in +the absence of \fB-i\fP the mode prompting is not done when the standard +input is not a terminal. +.SH EXAMPLES +.IP " 1." 4 +The following command: +.sp +.RS +.nf + +\fBrm a.out core +\fP +.fi +.RE +.LP +removes the directory entries: \fBa.out\fP and \fBcore\fP. +.LP +.IP " 2." 4 +The following command: +.sp +.RS +.nf + +\fBrm -Rf junk +\fP +.fi +.RE +.LP +removes the directory \fBjunk\fP and all its contents, without prompting. +.LP +.SH RATIONALE +.LP +For absolute clarity, paragraphs (2b) and (3) in the DESCRIPTION of +\fIrm\fP describing the behavior when prompting for +confirmation, should be interpreted in the following manner: +.sp +.RS +.nf + +\fBif ((NOT f_option) AND + ((not_writable AND input_is_terminal) OR i_option)) +\fP +.fi +.RE +.LP +The exact format of the interactive prompts is unspecified. Only the +general nature of the contents of prompts are specified +because implementations may desire more descriptive prompts than those +used on historical implementations. Therefore, an +application not using the \fB-f\fP option, or using the \fB-i\fP option, +relies on the system to provide the most suitable dialog +directly with the user, based on the behavior specified. +.LP +The \fB-r\fP option is historical practice on all known systems. The +synonym \fB-R\fP option is provided for consistency with +the other utilities in this volume of IEEE\ Std\ 1003.1-2001 that +provide options requesting recursive descent through the +file hierarchy. +.LP +The behavior of the \fB-f\fP option in historical versions of \fIrm\fP +is inconsistent. In general, along with "forcing" the +unlink without prompting for permission, it always causes diagnostic +messages to be suppressed and the exit status to be unmodified +for nonexistent operands and files that cannot be unlinked. In some +versions, however, the \fB-f\fP option suppresses usage +messages and system errors as well. Suppressing such messages is not +a service to either shell scripts or users. +.LP +It is less clear that error messages regarding files that cannot be +unlinked (removed) should be suppressed. Although this is +historical practice, this volume of IEEE\ Std\ 1003.1-2001 does not +permit the \fB-f\fP option to suppress such +messages. +.LP +When given the \fB-r\fP and \fB-i\fP options, historical versions +of \fIrm\fP prompt the user twice for each directory, once +before removing its contents and once before actually attempting to +delete the directory entry that names it. This allows the user +to "prune" the file hierarchy walk. Historical versions of \fIrm\fP +were inconsistent in that some did not do the former prompt +for directories named on the command line and others had obscure prompting +behavior when the \fB-i\fP option was specified and the +permissions of the file did not permit writing. The POSIX Shell and +Utilities \fIrm\fP differs little from historic practice, but +does require that prompts be consistent. Historical versions of \fIrm\fP +were also inconsistent in that prompts were done to both +standard output and standard error. This volume of IEEE\ Std\ 1003.1-2001 +requires that prompts be done to standard error, +for consistency with \fIcp\fP and \fImv\fP, and to allow +historical extensions to \fIrm\fP that provide an option to list deleted +files on standard output. +.LP +The \fIrm\fP utility is required to descend to arbitrary depths so +that any file hierarchy may be deleted. This means, for +example, that the \fIrm\fP utility cannot run out of file descriptors +during its descent (that is, if the number of file +descriptors is limited, \fIrm\fP cannot be implemented in the historical +fashion where one file descriptor is used per directory +level). Also, \fIrm\fP is not permitted to fail because of path length +restrictions, unless an operand specified by the user is +longer than {PATH_MAX}. +.LP +The \fIrm\fP utility removes symbolic links themselves, not the files +they refer to, as a consequence of the dependence on the +\fIunlink\fP() functionality, per the DESCRIPTION. When removing hierarchies +with \fB-r\fP +or \fB-R\fP, the prohibition on following symbolic links has to be +made explicit. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIrmdir\fP() , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIremove\fP(), \fIrmdir\fP(), \fIunlink\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/rmdel.1p b/man1p/rmdel.1p new file mode 100644 index 000000000..73c37c0b6 --- /dev/null +++ b/man1p/rmdel.1p @@ -0,0 +1,154 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "RMDEL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" rmdel +.SH NAME +rmdel \- remove a delta from an SCCS file (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBrmdel -r\fP \fISID file\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIrmdel\fP utility shall remove the delta specified by the SID +from each named SCCS file. The delta to be removed shall be +the most recent delta in its branch in the delta chain of each named +SCCS file. In addition, the application shall ensure that the +SID specified is not that of a version being edited for the purpose +of making a delta; that is, if a \fIp-file\fP (see \fIget\fP ) exists +for the named SCCS file, the SID specified shall not appear in any +entry of the +\fIp-file\fP. +.LP +Removal of a delta shall be restricted to: +.IP " 1." 4 +The user who made the delta +.LP +.IP " 2." 4 +The owner of the SCCS file +.LP +.IP " 3." 4 +The owner of the directory containing the SCCS file +.LP +.SH OPTIONS +.LP +The \fIrmdel\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-r\ \fP \fISID\fP +Specify the SCCS identification string ( \fISID\fP) of the delta to +be deleted. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file or a directory. If \fIfile\fP +is a directory, the \fIrmdel\fP utility shall behave as +though each file in the directory were specified as a named file, +except that non-SCCS files (last component of the pathname does +not begin with \fBs.\fP) and unreadable files shall be silently ignored. +.LP +If exactly one \fIfile\fP operand appears, and it is \fB'-'\fP , the +standard input shall be read; each line of the standard +input is taken to be the name of an SCCS file to be processed. Non-SCCS +files and unreadable files shall be silently ignored. +.sp +.SH STDIN +.LP +The standard input shall be a text file used only when the \fIfile\fP +operand is specified as \fB'-'\fP . Each line of the +text file shall be interpreted as an SCCS pathname. +.SH INPUT FILES +.LP +The SCCS files shall be files of unspecified format. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIrmdel\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The SCCS files shall be files of unspecified format. During processing +of a \fIfile\fP, a temporary \fIx-file\fP, as described +in \fIadmin\fP , may be created and deleted; a locking \fIz-file\fP, +as described in \fIget\fP , may be created and deleted. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIadmin\fP , \fIdelta\fP , \fIget\fP , \fIprs\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/rmdir.1p b/man1p/rmdir.1p new file mode 100644 index 000000000..1f1971c60 --- /dev/null +++ b/man1p/rmdir.1p @@ -0,0 +1,177 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "RMDIR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" rmdir +.SH NAME +rmdir \- remove directories +.SH SYNOPSIS +.LP +\fBrmdir\fP \fB[\fP\fB-p\fP\fB]\fP \fIdir\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fIrmdir\fP utility shall remove the directory entry specified +by each \fIdir\fP operand. +.LP +For each \fIdir\fP operand, the \fIrmdir\fP utility shall perform +actions equivalent to the \fIrmdir\fP() function called with the \fIdir\fP +operand as its only argument. +.LP +Directories shall be processed in the order specified. If a directory +and a subdirectory of that directory are specified in a +single invocation of the \fIrmdir\fP utility, the application shall +specify the subdirectory before the parent directory so that +the parent directory will be empty when the \fIrmdir\fP utility tries +to remove it. +.SH OPTIONS +.LP +The \fIrmdir\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-p\fP +Remove all directories in a pathname. For each \fIdir\fP operand: +.RS +.IP " 1." 4 +The directory entry it names shall be removed. +.LP +.IP " 2." 4 +If the \fIdir\fP operand includes more than one pathname component, +effects equivalent to the following command shall +occur: +.sp +.RS +.nf + +\fBrmdir -p $(dirname\fP \fIdir\fP\fB) +\fP +.fi +.RE +.LP +.RE +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIdir\fP +A pathname of an empty directory to be removed. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIrmdir\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Each directory entry specified by a \fIdir\fP operand was removed +successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The definition of an empty directory is one that contains, at most, +directory entries for dot and dot-dot. +.SH EXAMPLES +.LP +If a directory \fBa\fP in the current directory is empty except it +contains a directory \fBb\fP and \fBa/b\fP is empty except +it contains a directory \fBc\fP: +.sp +.RS +.nf + +\fBrmdir -p a/b/c +\fP +.fi +.RE +.LP +removes all three directories. +.SH RATIONALE +.LP +On historical System V systems, the \fB-p\fP option also caused a +message to be written to the standard output. The message +indicated whether the whole path was removed or whether part of the +path remained for some reason. The STDERR section requires this +diagnostic when the entire path specified by a \fIdir\fP operand is +not removed, but does not allow the status message reporting +success to be written as a diagnostic. +.LP +The \fIrmdir\fP utility on System V also included a \fB-s\fP option +that suppressed the informational message output by the +\fB-p\fP option. This option has been omitted because the informational +message is not specified by this volume of +IEEE\ Std\ 1003.1-2001. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIrm\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIremove\fP(), \fIrmdir\fP(), \fIunlink\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/sact.1p b/man1p/sact.1p new file mode 100644 index 000000000..54c56d876 --- /dev/null +++ b/man1p/sact.1p @@ -0,0 +1,174 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SACT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" sact +.SH NAME +sact \- print current SCCS file-editing activity (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBsact\fP \fIfile\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIsact\fP utility shall inform the user of any impending deltas +to a named SCCS file by writing a list to standard output. +This situation occurs when \fIget\fP \fB-e\fP has been executed previously +without a +subsequent execution of \fIdelta\fP, \fIunget\fP, or +\fIsccs\fP \fBunedit\fP. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file or a directory. If \fIfile\fP +is a directory, the \fIsact\fP utility shall behave as +though each file in the directory were specified as a named file, +except that non-SCCS files (last component of the pathname does +not begin with \fBs.\fP) and unreadable files shall be silently ignored. +.LP +If exactly one \fIfile\fP operand appears, and it is \fB'-'\fP , the +standard input shall be read; each line of the standard +input shall be taken to be the name of an SCCS file to be processed. +Non-SCCS files and unreadable files shall be silently +ignored. +.sp +.SH STDIN +.LP +The standard input shall be a text file used only when the \fIfile\fP +operand is specified as \fB'-'\fP . Each line of the +text file shall be interpreted as an SCCS pathname. +.SH INPUT FILES +.LP +Any SCCS files interrogated are files of an unspecified format. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIsact\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The output for each named file shall consist of a line in the following +format: +.sp +.RS +.nf + +\fB"%s %s %s %s %s\\n", <\fP\fISID\fP\fB>, <\fP\fInew SID\fP\fB>, <\fP\fIlogin\fP\fB>, <\fP\fIdate\fP\fB>, <\fP\fItime\fP\fB> +\fP +.fi +.RE +.TP 7 +<\fISID\fP> +Specifies the SID of a delta that currently exists in the SCCS file +to which changes are made to make the new delta. +.TP 7 +<\fInew\ SID\fP> +Specifies the SID for the new delta to be created. +.TP 7 +<\fIlogin\fP> +Contains the login name of the user who makes the delta (that is, +who executed a \fIget\fP +for editing). +.TP 7 +<\fIdate\fP> +Contains the date that \fIget\fP \fB-e\fP was executed, in the format +used by the \fIprs\fP \fB:D:\fP data keyword. +.TP 7 +<\fItime\fP> +Contains the time that \fIget\fP \fB-e\fP was executed, in the format +used by the \fIprs\fP \fB:T:\fP data keyword. +.sp +.LP +If there is more than one named file or if a directory or standard +input is named, each pathname shall be written before each of +the preceding lines: +.sp +.RS +.nf + +\fB"\\n%s:\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for optional informative messages +concerning SCCS files with no impending deltas, and for +diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIdelta\fP , \fIget\fP , \fIsccs\fP , \fIunget\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/sccs.1p b/man1p/sccs.1p new file mode 100644 index 000000000..1616e0b38 --- /dev/null +++ b/man1p/sccs.1p @@ -0,0 +1,411 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SCCS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" sccs +.SH NAME +sccs \- front end for the SCCS subsystem (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBsccs\fP \fB[\fP\fB-r\fP\fB][\fP\fB-d\fP \fIpath\fP\fB][\fP\fB-p\fP +\fIpath\fP\fB]\fP +\fIcommand\fP \fB[\fP\fIoptions\fP\fB...\fP\fB][\fP\fIoperands\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIsccs\fP utility is a front end to the SCCS programs. It also +includes the capability to run set-user-id to another user +to provide additional protection. +.LP +The \fIsccs\fP utility shall invoke the specified \fIcommand\fP with +the specified \fIoptions\fP and \fIoperands\fP. By +default, each of the \fIoperands\fP shall be modified by prefixing +it with the string \fB"SCCS/s."\fP . +.LP +The \fIcommand\fP can be the name of one of the SCCS utilities in +this volume of IEEE\ Std\ 1003.1-2001 ( \fIadmin\fP, \fIdelta\fP, +\fIget\fP, \fIprs\fP, \fIrmdel\fP, \fIsact\fP, \fIunget\fP, \fIval\fP, +or \fIwhat\fP) or one of the pseudo-utilities listed in the EXTENDED +DESCRIPTION section. +.SH OPTIONS +.LP +The \fIsccs\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that \fIoptions\fP operands are +actually options to be passed to the utility named by \fIcommand\fP. +When the portion of the command: +.sp +.RS +.nf + +\fIcommand\fP \fB[\fP\fIoptions\fP \fB...\fP \fB] [\fP\fIoperands\fP \fB...\fP \fB]\fP +.fi +.RE +.LP +is considered, all of the pseudo-utilities used as \fIcommand\fP shall +support the Utility Syntax Guidelines. Any of the other +SCCS utilities that can be invoked in this manner support the Guidelines +to the extent indicated by their individual OPTIONS +sections. +.LP +The following options shall be supported preceding the \fIcommand\fP +operand: +.TP 7 +\fB-d\ \fP \fIpath\fP +A pathname of a directory to be used as a root directory for the SCCS +files. The default shall be the current directory. The +\fB-d\fP option shall take precedence over the \fIPROJECTDIR\fP variable. +See \fB-p\fP. +.TP 7 +\fB-p\ \fP \fIpath\fP +A pathname of a directory in which the SCCS files are located. The +default shall be the \fBSCCS\fP directory. +.LP +The \fB-p\fP option differs from the \fB-d\fP option in that the \fB-d\fP +option-argument shall be prefixed to the entire +pathname and the \fB-p\fP option-argument shall be inserted before +the final component of the pathname. For example: +.sp +.RS +.nf + +\fBsccs -d /x -p y get a/b +\fP +.fi +.RE +.LP +converts to: +.sp +.RS +.nf + +\fBget /x/a/y/s.b +\fP +.fi +.RE +.LP +This allows the creation of aliases such as: +.sp +.RS +.nf + +\fBalias syssccs="sccs -d /usr/src" +\fP +.fi +.RE +.LP +which is used as: +.sp +.RS +.nf + +\fBsyssccs get cmd/who.c +\fP +.fi +.RE +.TP 7 +\fB-r\fP +Invoke \fIcommand\fP with the real user ID of the process, not any +effective user ID that the \fIsccs\fP utility is set to. +Certain commands ( \fIadmin\fP, \fBcheck\fP, \fBclean\fP, \fBdiffs\fP, +\fBinfo\fP, \fIrmdel\fP, and \fBtell\fP) cannot be run set-user-ID +by all users, since this would allow +anyone to change the authorizations. These commands are always run +as the real user. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIcommand\fP +An SCCS utility name or the name of one of the pseudo-utilities listed +in the EXTENDED DESCRIPTION section. +.TP 7 +\fIoptions\fP +An option or option-argument to be passed to \fIcommand\fP. +.TP 7 +\fIoperands\fP +An operand to be passed to \fIcommand\fP. +.sp +.SH STDIN +.LP +See the utility description for the specified \fIcommand\fP. +.SH INPUT FILES +.LP +See the utility description for the specified \fIcommand\fP. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIsccs\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPROJECTDIR\fP +.sp +Provide a default value for the \fB-d\fP \fIpath\fP option. If the +value of \fIPROJECTDIR\fP begins with a slash, it shall be +considered an absolute pathname; otherwise, the value of \fIPROJECTDIR\fP +is treated as a user name and that user's initial +working directory shall be examined for a subdirectory \fBsrc\fP or +\fBsource\fP. If such a directory is found, it shall be used. +Otherwise, the value shall be used as a relative pathname. +.sp +.LP +Additional environment variable effects may be found in the utility +description for the specified \fIcommand\fP. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the utility description for the specified \fIcommand\fP. +.SH STDERR +.LP +See the utility description for the specified \fIcommand\fP. +.SH OUTPUT FILES +.LP +See the utility description for the specified \fIcommand\fP. +.SH EXTENDED DESCRIPTION +.LP +The following pseudo-utilities shall be supported as \fIcommand\fP +operands. All options referred to in the following list are +values given in the \fIoptions\fP operands following \fIcommand\fP. +.TP 7 +\fBcheck\fP +Equivalent to \fBinfo\fP, except that nothing shall be printed if +nothing is being edited, and a non-zero exit status shall be +returned if anything is being edited. The intent is to have this included +in an "install" entry in a makefile to ensure that +everything is included into the SCCS file before a version is installed. +.TP 7 +\fBclean\fP +Remove everything from the current directory that can be recreated +from SCCS files, but do not remove any files being edited. +If the \fB-b\fP option is given, branches shall be ignored in the +determination of whether they are being edited; this is +dangerous if branches are kept in the same directory. +.TP 7 +\fBcreate\fP +Create an SCCS file, taking the initial contents from the file of +the same name. Any options to \fIadmin\fP are accepted. If the creation +is successful, the original files shall be renamed by +prefixing the basenames with a comma. These renamed files should be +removed after it has been verified that the SCCS files have +been created successfully. +.TP 7 +\fBdelget\fP +Perform a \fIdelta\fP on the named files and then \fIget\fP new versions. +The new versions shall have ID keywords expanded and shall not be +editable. +Any \fB-m\fP, \fB-p\fP, \fB-r\fP, \fB-s\fP, and \fB-y\fP options shall +be passed to \fIdelta\fP, and any \fB-b\fP, \fB-c\fP, \fB-e\fP, \fB-i\fP, +\fB-k\fP, \fB-l\fP, \fB-s\fP, +and \fB-x\fP options shall be passed to \fIget\fP. +.TP 7 +\fBdeledit\fP +Equivalent to \fBdelget\fP, except that the \fIget\fP phase shall +include the \fB-e\fP +option. This option is useful for making a checkpoint of the current +editing phase. The same options shall be passed to \fIdelta\fP as +described above, and all the options listed for \fIget\fP above except +\fB-e\fP shall be passed to \fBedit\fP. +.TP 7 +\fBdiffs\fP +Write a difference listing between the current version of the files +checked out for editing and the versions in SCCS format. +Any \fB-r\fP, \fB-c\fP, \fB-i\fP, \fB-x\fP, and \fB-t\fP options shall +be passed to \fIget\fP; any \fB-l\fP, \fB-s\fP, \fB-e\fP, \fB-f\fP, +\fB-h\fP, and \fB-b\fP options shall be +passed to \fIdiff\fP. A \fB-C\fP option shall be passed to \fIdiff\fP +as \fB-c\fP. +.TP 7 +\fBedit\fP +Equivalent to \fIget\fP \fB-e\fP. +.TP 7 +\fBfix\fP +Remove the named delta, but leave a copy of the delta with the changes +that were in it. It is useful for fixing small compiler +bugs, and so on. The application shall ensure that it is followed +by a \fB-r\fP \fISID\fP option. Since \fBfix\fP does not leave +audit trails, it should be used carefully. +.TP 7 +\fBinfo\fP +Write a listing of all files being edited. If the \fB-b\fP option +is given, branches (that is, SIDs with two or fewer +components) shall be ignored. If a \fB-u\fP \fIuser\fP option is given, +then only files being edited by the named user shall be +listed. A \fB-U\fP option shall be equivalent to \fB-u\fP< \fIcurrent\ user\fP>. +.TP 7 +\fBprint\fP +Write out verbose information about the named files, equivalent to +\fIsccs\fP \fIprs\fP. +.TP 7 +\fBtell\fP +Write a <newline>-separated list of the files being edited to standard +output. Takes the \fB-b\fP, \fB-u\fP, and +\fB-U\fP options like \fBinfo\fP and \fBcheck\fP. +.TP 7 +\fBunedit\fP +This is the opposite of an \fBedit\fP or a \fIget\fP \fB-e\fP. It +should be used with +caution, since any changes made since the \fIget\fP are lost. +.sp +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Many of the SCCS utilities take directory names as operands as well +as specific filenames. The pseudo-utilities supported by +\fIsccs\fP are not described as having this capability, but are not +prohibited from doing so. +.SH EXAMPLES +.IP " 1." 4 +To get a file for editing, edit it and produce a new delta: +.sp +.RS +.nf + +\fBsccs get -e file.c +ex file.c +sccs delta file.c +\fP +.fi +.RE +.LP +.IP " 2." 4 +To get a file from another directory: +.sp +.RS +.nf + +\fBsccs -p /usr/src/sccs/s. get cc.c +\fP +.fi +.RE +.LP +or: +.sp +.RS +.nf + +\fBsccs get /usr/src/sccs/s.cc.c +\fP +.fi +.RE +.LP +.IP " 3." 4 +To make a delta of a large number of files in the current directory: +.sp +.RS +.nf + +\fBsccs delta *.c +\fP +.fi +.RE +.LP +.IP " 4." 4 +To get a list of files being edited that are not on branches: +.sp +.RS +.nf + +\fBsccs info -b +\fP +.fi +.RE +.LP +.IP " 5." 4 +To delta everything being edited by the current user: +.sp +.RS +.nf + +\fBsccs delta $(sccs tell -U) +\fP +.fi +.RE +.LP +.IP " 6." 4 +In a makefile, to get source files from an SCCS file if it does not +already exist: +.sp +.RS +.nf + +\fBSRCS = <\fP\fIlist of source files\fP\fB> +$(SRCS): + sccs get $(REL) $@ +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +SCCS and its associated utilities are part of the XSI Development +Utilities option within the XSI extension. +.LP +SCCS is an abbreviation for Source Code Control System. It is a maintenance +and enhancement tracking tool. When a file is put +under SCCS, the source code control system maintains the file and, +when changes are made, identifies and stores them in the file +with the original source code and/or documentation. As other changes +are made, they too are identified and retained in the +file. +.LP +Retrieval of the original and any set of changes is possible. Any +version of the file as it develops can be reconstructed for +inspection or additional modification. History data can be stored +with each version, documenting why the changes were made, who +made them, and when they were made. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIadmin\fP , \fIdelta\fP , \fIget\fP , \fImake\fP , \fIprs\fP , \fIrmdel\fP +, \fIsact\fP , \fIunget\fP , \fIval\fP , \fIwhat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/sed.1p b/man1p/sed.1p new file mode 100644 index 000000000..d1ea019ae --- /dev/null +++ b/man1p/sed.1p @@ -0,0 +1,733 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SED" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" sed +.SH NAME +sed \- stream editor +.SH SYNOPSIS +.LP +\fBsed\fP \fB[\fP\fB-n\fP\fB]\fP \fIscript\fP\fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +.sp +sed\fP \fB[\fP\fB-n\fP\fB][\fP\fB-e\fP \fIscript\fP\fB]\fP\fB...\fP\fB[\fP\fB-f\fP +\fIscript_file\fP\fB]\fP\fB...\fP\fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIsed\fP utility is a stream editor that shall read one or more +text files, make editing changes according to a script of +editing commands, and write the results to standard output. The script +shall be obtained from either the \fIscript\fP operand +string or a combination of the option-arguments from the \fB-e\fP +\fIscript\fP and \fB-f\fP \fIscript_file\fP options. +.SH OPTIONS +.LP +The \fIsed\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the order of presentation of the +\fB-e\fP and \fB-f\fP options is significant. +.LP +The following options shall be supported: +.TP 7 +\fB-e\ \fP \fIscript\fP +Add the editing commands specified by the \fIscript\fP option-argument +to the end of the script of editing commands. The +\fIscript\fP option-argument shall have the same properties as the +\fIscript\fP operand, described in the OPERANDS section. +.TP 7 +\fB-f\ \fP \fIscript_file\fP +Add the editing commands in the file \fIscript_file\fP to the end +of the script. +.TP 7 +\fB-n\fP +Suppress the default output (in which each line, after it is examined +for editing, is written to standard output). Only lines +explicitly selected for output are written. +.sp +.LP +Multiple \fB-e\fP and \fB-f\fP options may be specified. All commands +shall be added to the script in the order specified, +regardless of their origin. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file whose contents are read and edited. If multiple +\fIfile\fP operands are specified, the named files shall +be read in the order specified and the concatenation shall be edited. +If no \fIfile\fP operands are specified, the standard input +shall be used. +.TP 7 +\fIscript\fP +A string to be used as the script of editing commands. The application +shall not present a \fIscript\fP that violates the +restrictions of a text file except that the final character need not +be a <newline>. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files. The \fIscript_file\fPs named +by the \fB-f\fP option shall consist of editing +commands. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIsed\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within regular +expressions. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), and +the behavior of character classes within regular +expressions. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The input files shall be written to standard output, with the editing +commands specified in the script applied. If the \fB-n\fP +option is specified, only those input lines selected by the script +shall be written to standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output files shall be text files whose formats are dependent on +the editing commands given. +.SH EXTENDED DESCRIPTION +.LP +The \fIscript\fP shall consist of editing commands of the following +form: +.sp +.RS +.nf + +\fB[\fP\fIaddress\fP\fB[\fP\fB,\fP\fIaddress\fP\fB]]\fP\fIfunction\fP +.fi +.RE +.LP +where \fIfunction\fP represents a single-character command verb from +the list in Editing Commands +in sed , followed by any applicable arguments. +.LP +The command can be preceded by <blank>s and/or semicolons. The function +can be preceded by <blank>s. These optional +characters shall have no effect. +.LP +In default operation, \fIsed\fP cyclically shall append a line of +input, less its terminating <newline>, into the pattern +space. Normally the pattern space will be empty, unless a \fBD\fP +command terminated the last cycle. The \fIsed\fP utility shall +then apply in sequence all commands whose addresses select that pattern +space, and at the end of the script copy the pattern space +to standard output (except when \fB-n\fP is specified) and delete +the pattern space. Whenever the pattern space is written to +standard output or a named file, \fIsed\fP shall immediately follow +it with a <newline>. +.LP +Some of the editing commands use a hold space to save all or part +of the pattern space for subsequent retrieval. The pattern and +hold spaces shall each be able to hold at least 8192 bytes. +.SS Addresses in sed +.LP +An address is either a decimal number that counts input lines cumulatively +across files, a \fB'$'\fP character that addresses +the last line of input, or a context address (which consists of a +BRE, as described in Regular +Expressions in sed , preceded and followed by a delimiter, usually +a slash). +.LP +An editing command with no addresses shall select every pattern space. +.LP +An editing command with one address shall select each pattern space +that matches the address. +.LP +An editing command with two addresses shall select the inclusive range +from the first pattern space that matches the first +address through the next pattern space that matches the second. (If +the second address is a number less than or equal to the line +number first selected, only one line shall be selected.) Starting +at the first line following the selected range, \fIsed\fP shall +look again for the first address. Thereafter, the process shall be +repeated. Omitting either or both of the address components in +the following form produces undefined results: +.sp +.RS +.nf + +\fB[\fP\fIaddress\fP\fB[\fP\fB,\fP\fIaddress\fP\fB]]\fP +.fi +.RE +.SS Regular Expressions in sed +.LP +The \fIsed\fP utility shall support the BREs described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 9.3, Basic Regular +Expressions, with the following additions: +.IP " *" 3 +In a context address, the construction \fB"\\cBREc"\fP , where \fIc\fP +is any character other than backslash or +<newline>, shall be identical to \fB"/BRE/"\fP . If the character +designated by \fIc\fP appears following a backslash, +then it shall be considered to be that literal character, which shall +not terminate the BRE. For example, in the context address +\fB"\\xabc\\xdefx"\fP , the second \fIx\fP stands for itself, so that +the BRE is \fB"abcxdef"\fP . +.LP +.IP " *" 3 +The escape sequence \fB'\\n'\fP shall match a <newline> embedded in +the pattern space. A literal <newline> shall +not be used in the BRE of a context address or in the substitute function. +.LP +.IP " *" 3 +If an RE is empty (that is, no pattern is specified) \fIsed\fP shall +behave as if the last RE used in the last command applied +(either as an address or as part of a substitute command) was specified. +.LP +.SS Editing Commands in sed +.LP +In the following list of editing commands, the maximum number of permissible +addresses for each function is indicated by [ +\fI0addr\fP], [ \fI1addr\fP], or [ \fI2addr\fP], representing zero, +one, or two addresses. +.LP +The argument \fItext\fP shall consist of one or more lines. Each embedded +<newline> in the text shall be preceded by a +backslash. Other backslashes in text shall be removed, and the following +character shall be treated literally. +.LP +The \fBr\fP and \fBw\fP command verbs, and the \fIw\fP flag to the +\fBs\fP command, take an optional \fIrfile\fP (or +\fIwfile\fP) parameter, separated from the command verb letter or +flag by one or more <blank>s; implementations may allow +zero separation as an extension. +.LP +The argument \fIrfile\fP or the argument \fIwfile\fP shall terminate +the editing command. Each \fIwfile\fP shall be created +before processing begins. Implementations shall support at least ten +\fIwfile\fP arguments in the script; the actual number +(greater than or equal to 10) that is supported by the implementation +is unspecified. The use of the \fIwfile\fP parameter shall +cause that file to be initially created, if it does not exist, or +shall replace the contents of an existing file. +.LP +The \fBb\fP, \fBr\fP, \fBs\fP, \fBt\fP, \fBw\fP, \fBy\fP, and \fB:\fP +command verbs shall accept additional arguments. +The following synopses indicate which arguments shall be separated +from the command verbs by a single <space>. +.LP +The \fBa\fP and \fBr\fP commands schedule text for later output. The +text specified for the \fBa\fP command, and the contents +of the file specified for the \fBr\fP command, shall be written to +standard output just before the next attempt to fetch a line of +input when executing the \fBN\fP or \fBn\fP commands, or when reaching +the end of the script. If written when reaching the end of +the script, and the \fB-n\fP option was not specified, the text shall +be written after copying the pattern space to standard +output. The contents of the file specified for the \fBr\fP command +shall be as of the time the output is written, not the time the +\fBr\fP command is applied. The text shall be output in the order +in which the \fBa\fP and \fBr\fP commands were applied to the +input. +.LP +Command verbs other than \fB{\fP, \fBa\fP, \fBb\fP, \fBc\fP, \fBi\fP, +\fBr\fP, \fBt\fP, \fBw\fP, \fB:\fP, and \fB#\fP +can be followed by a semicolon, optional <blank>s, and another command +verb. However, when the \fBs\fP command verb is used +with the \fIw\fP flag, following it with another command in this manner +produces undefined results. +.LP +A function can be preceded by one or more \fB'!'\fP characters, in +which case the function shall be applied if the addresses +do not select the pattern space. Zero or more <blank>s shall be accepted +before the first \fB'!'\fP character. It is +unspecified whether <blank>s can follow a \fB'!'\fP character, and +conforming applications shall not follow a \fB'!'\fP +character with <blank>s. +.TP 7 +\fB[\fP\fI2addr\fP\fB]\ {\fP\fIfunction\fP +.TP 7 +\fIfunction\fP +.TP 7 +\&... +.TP 7 +\fB}\fP +Execute a list of \fIsed\fP functions only when the pattern space +is selected. The list of \fIsed\fP functions shall be +surrounded by braces and separated by <newline>s, and conform to the +following rules. The braces can be preceded or followed +by <blank>s. The functions can be preceded by <blank>s, but shall +not be followed by <blank>s. The +<right-brace> shall be preceded by a <newline> and can be preceded +or followed by <blank>s. +.TP 7 +\fB[\fP\fI1addr\fP\fB]a\\\fP +.TP 7 +\fItext\fP +Write text to standard output as described previously. +.TP 7 +\fB[\fP\fI2addr\fP\fB]b\ [\fP\fIlabel\fP\fB]\fP +.sp +Branch to the \fB:\fP function bearing the \fIlabel\fP. If \fIlabel\fP +is not specified, branch to the end of the script. The +implementation shall support \fIlabel\fPs recognized as unique up +to at least 8 characters; the actual length (greater than or +equal to 8) that shall be supported by the implementation is unspecified. +It is unspecified whether exceeding a label length causes +an error or a silent truncation. +.TP 7 +\fB[\fP\fI2addr\fP\fB]c\\\fP +.TP 7 +\fItext\fP +Delete the pattern space. With a 0 or 1 address or at the end of a +2-address range, place \fItext\fP on the output and start +the next cycle. +.TP 7 +\fB[\fP\fI2addr\fP\fB]d\fP +Delete the pattern space and start the next cycle. +.TP 7 +\fB[\fP\fI2addr\fP\fB]D\fP +Delete the initial segment of the pattern space through the first +<newline> and start the next cycle. +.TP 7 +\fB[\fP\fI2addr\fP\fB]g\fP +Replace the contents of the pattern space by the contents of the hold +space. +.TP 7 +\fB[\fP\fI2addr\fP\fB]G\fP +Append to the pattern space a <newline> followed by the contents of +the hold space. +.TP 7 +\fB[\fP\fI2addr\fP\fB]h\fP +Replace the contents of the hold space with the contents of the pattern +space. +.TP 7 +\fB[\fP\fI2addr\fP\fB]H\fP +Append to the hold space a <newline> followed by the contents of the +pattern space. +.TP 7 +\fB[\fP\fI1addr\fP\fB]i\\\fP +.TP 7 +\fItext\fP +Write \fItext\fP to standard output. +.TP 7 +\fB[\fP\fI2addr\fP\fB]l\fP +(The letter ell.) Write the pattern space to standard output in a +visually unambiguous form. The characters listed in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Table 5-1, Escape Sequences +and Associated Actions ( \fB'\\\\'\fP , +\fB'\\a'\fP , \fB'\\b'\fP , \fB'\\f'\fP , \fB'\\r'\fP , \fB'\\t'\fP +, \fB'\\v'\fP ) shall be written as the +corresponding escape sequence; the \fB'\\n'\fP in that table is not +applicable. Non-printable characters not in that table shall +be written as one three-digit octal number (with a preceding backslash) +for each byte in the character (most significant byte +first). If the size of a byte on the system is greater than 9 bits, +the format used for non-printable characters is +implementation-defined. +.LP +Long lines shall be folded, with the point of folding indicated by +writing a backslash followed by a <newline>; the length +at which folding occurs is unspecified, but should be appropriate +for the output device. The end of each line shall be marked with +a \fB'$'\fP . +.TP 7 +\fB[\fP\fI2addr\fP\fB]n\fP +Write the pattern space to standard output if the default output has +not been suppressed, and replace the pattern space with +the next line of input, less its terminating <newline>. +.LP +If no next line of input is available, the \fBn\fP command verb shall +branch to the end of the script and quit without starting +a new cycle. +.TP 7 +\fB[\fP\fI2addr\fP\fB]N\fP +Append the next line of input, less its terminating <newline>, to +the pattern space, using an embedded <newline> to +separate the appended material from the original material. Note that +the current line number changes. +.LP +If no next line of input is available, the \fBN\fP command verb shall +branch to the end of the script and quit without starting +a new cycle or copying the pattern space to standard output. +.TP 7 +\fB[\fP\fI2addr\fP\fB]p\fP +Write the pattern space to standard output. +.TP 7 +\fB[\fP\fI2addr\fP\fB]P\fP +Write the pattern space, up to the first <newline>, to standard output. +.TP 7 +\fB[\fP\fI1addr\fP\fB]q\fP +Branch to the end of the script and quit without starting a new cycle. +.TP 7 +\fB[\fP\fI1addr\fP\fB]r\ \fP \fIrfile\fP +Copy the contents of \fIrfile\fP to standard output as described previously. +If \fIrfile\fP does not exist or cannot be read, +it shall be treated as if it were an empty file, causing no error +condition. +.TP 7 +\fB[\fP\fI2addr\fP\fB]s/\fP\fIBRE\fP\fB/\fP\fIreplacement\fP\fB/\fP\fIflags\fP +.sp +Substitute the replacement string for instances of the BRE in the +pattern space. Any character other than backslash or +<newline> can be used instead of a slash to delimit the BRE and the +replacement. Within the BRE and the replacement, the BRE +delimiter itself can be used as a literal character if it is preceded +by a backslash. +.LP +The replacement string shall be scanned from beginning to end. An +ampersand ( \fB'&'\fP ) appearing in the replacement +shall be replaced by the string matching the BRE. The special meaning +of \fB'&'\fP in this context can be suppressed by +preceding it by a backslash. The characters \fB"\\\fP\fIn"\fP, where +\fIn\fP is a digit, shall be replaced by the text matched +by the corresponding backreference expression. The special meaning +of \fB"\\\fP\fIn"\fP where \fIn\fP is a digit in this +context, can be suppressed by preceding it by a backslash. For each +other backslash ( \fB'\\'\fP ) encountered, the following +character shall lose its special meaning (if any). The meaning of +a \fB'\\'\fP immediately followed by any character other than +\fB'&'\fP , \fB'\\'\fP , a digit, or the delimiter character used +for this command, is unspecified. +.LP +A line can be split by substituting a <newline> into it. The application +shall escape the <newline> in the +replacement by preceding it by a backslash. A substitution shall be +considered to have been performed even if the replacement +string is identical to the string that it replaces. Any backslash +used to alter the default meaning of a subsequent character shall +be discarded from the BRE or the replacement before evaluating the +BRE or using the replacement. +.LP +The value of \fIflags\fP shall be zero or more of: +.TP 7 +\fIn\fP +.RS +Substitute for the \fIn\fPth occurrence only of the BRE found within +the pattern space. +.RE +.TP 7 +\fBg\fP +.RS +Globally substitute for all non-overlapping instances of the BRE rather +than just the first one. If both \fBg\fP and \fIn\fP +are specified, the results are unspecified. +.RE +.TP 7 +\fBp\fP +.RS +Write the pattern space to standard output if a replacement was made. +.RE +.TP 7 +\fBw\ \fP \fIwfile\fP +.RS +Write. Append the pattern space to \fIwfile\fP if a replacement was +made. A conforming application shall precede the +\fIwfile\fP argument with one or more <blank>s. If the \fBw\fP flag +is not the last flag value given in a concatenation of +multiple flag values, the results are undefined. +.RE +.sp +.TP 7 +\fB[\fP\fI2addr\fP\fB]t\ [\fP\fIlabel\fP\fB]\fP +.sp +Test. Branch to the \fB:\fP command verb bearing the \fIlabel\fP if +any substitutions have been made since the most recent +reading of an input line or execution of a \fBt\fP. If \fIlabel\fP +is not specified, branch to the end of the script. +.TP 7 +\fB[\fP\fI2addr\fP\fB]w\ \fP \fIwfile\fP +.sp +Append (write) the pattern space to \fIwfile\fP. +.TP 7 +\fB[\fP\fI2addr\fP\fB]x\fP +Exchange the contents of the pattern and hold spaces. +.TP 7 +\fB[\fP\fI2addr\fP\fB]y/\fP\fIstring1\fP\fB/\fP\fIstring2\fP\fB/\fP +.sp +Replace all occurrences of characters in \fIstring1\fP with the corresponding +characters in \fIstring2\fP. If a backslash +followed by an \fB'n'\fP appear in \fIstring1\fP or \fIstring2\fP, +the two characters shall be handled as a single +<newline>. If the number of characters in \fIstring1\fP and \fIstring2\fP +are not equal, or if any of the characters in +\fIstring1\fP appear more than once, the results are undefined. Any +character other than backslash or <newline> can be used +instead of slash to delimit the strings. If the delimiter is not \fIn\fP, +within \fIstring1\fP and \fIstring2\fP, the delimiter +itself can be used as a literal character if it is preceded by a backslash. +If a backslash character is immediately followed by a +backslash character in \fIstring1\fP or \fIstring2\fP, the two backslash +characters shall be counted as a single literal +backslash character. The meaning of a backslash followed by any character +that is not \fB'n'\fP , a backslash, or the delimiter +character is undefined. +.TP 7 +\fB[\fP\fI0addr\fP\fB]:\fP\fIlabel\fP +Do nothing. This command bears a \fIlabel\fP to which the \fBb\fP +and \fBt\fP commands branch. +.TP 7 +\fB[\fP\fI1addr\fP\fB]=\fP +Write the following to standard output: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fIcurrent line number\fP\fB> +\fP +.fi +.RE +.TP 7 +\fB[\fP\fI0addr\fP\fB]\fP +Ignore this empty command. +.TP 7 +\fB[\fP\fI0addr\fP\fB]#\fP +Ignore the \fB'#'\fP and the remainder of the line (treat them as +a comment), with the single exception that if the first +two characters in the script are \fB"#n"\fP , the default output shall +be suppressed; this shall be the equivalent of specifying +\fB-n\fP on the command line. +.sp +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Regular expressions match entire strings, not just individual lines, +but a <newline> is matched by \fB'\\n'\fP in a +\fIsed\fP RE; a <newline> is not allowed by the general definition +of regular expression in IEEE\ Std\ 1003.1-2001. +Also note that \fB'\\n'\fP cannot be used to match a <newline> at +the end of an arbitrary input line; <newline>s +appear in the pattern space as a result of the \fBN\fP editing command. +.SH EXAMPLES +.LP +This \fIsed\fP script simulates the BSD \fIcat\fP \fB-s\fP command, +squeezing excess +blank lines from standard input. +.sp +.RS +.nf + +\fBsed -n ' +# Write non-empty lines. +/./ { + p + d + } +# Write a single empty line, then look for more empty lines. +/^$/ p +# Get next line, discard the held <newline> (empty line), +# and look for more empty lines. +:Empty +/^$/ { + N + s/.// + b Empty + } +# Write the non-empty line before going back to search +# for the first in a set of empty lines. + p +' +\fP +.fi +.RE +.SH RATIONALE +.LP +This volume of IEEE\ Std\ 1003.1-2001 requires implementations to +support at least ten distinct \fIwfile\fPs, matching +historical practice on many implementations. Implementations are encouraged +to support more, but conforming applications should not +exceed this limit. +.LP +The exit status codes specified here are different from those in System +V. System V returns 2 for garbled \fIsed\fP commands, +but returns zero with its usage message or if the input file could +not be opened. The standard developers considered this to be a +bug. +.LP +The manner in which the \fBl\fP command writes non-printable characters +was changed to avoid the historical +backspace-overstrike method, and other requirements to achieve unambiguous +output were added. See the RATIONALE for \fIed\fP for details of the +format chosen, which is the same as that chosen for \fIsed\fP. +.LP +This volume of IEEE\ Std\ 1003.1-2001 requires implementations to +provide pattern and hold spaces of at least 8192 +bytes, larger than the 4000 bytes spaces used by some historical implementations, +but less than the 20480 bytes limit used in an +early proposal. Implementations are encouraged to allocate dynamically +larger pattern and hold spaces as needed. +.LP +The requirements for acceptance of <blank>s and <space>s in command +lines has been made more explicit than in early +proposals to describe clearly the historical practice and to remove +confusion about the phrase "protect initial blanks +[\fIsic\fP] and tabs from the stripping that is done on every script +line" that appears in much of the historical documentation +of the \fIsed\fP utility description of text. (Not all implementations +are known to have stripped <blank>s from text lines, +although they all have allowed leading <blank>s preceding the address +on a command line.) +.LP +The treatment of \fB'#'\fP comments differs from the SVID which only +allows a comment as the first line of the script, but +matches BSD-derived implementations. The comment character is treated +as a command, and it has the same properties in terms of +being accepted with leading <blank>s; the BSD implementation has historically +supported this. +.LP +Early proposals required that a \fIscript_file\fP have at least one +non-comment line. Some historical implementations have +behaved in unexpected ways if this were not the case. The standard +developers considered that this was incorrect behavior and that +application developers should not have to avoid this feature. A correct +implementation of this volume of +IEEE\ Std\ 1003.1-2001 shall permit \fIscript_file\fPs that consist +only of comment lines. +.LP +Early proposals indicated that if \fB-e\fP and \fB-f\fP options were +intermixed, all \fB-e\fP options were processed before +any \fB-f\fP options. This has been changed to process them in the +order presented because it matches historical practice and is +more intuitive. +.LP +The treatment of the \fBp\fP flag to the \fBs\fP command differs between +System V and BSD-based systems when the default +output is suppressed. In the two examples: +.sp +.RS +.nf + +\fBecho a | sed 's/a/A/p' +echo a | sed -n 's/a/A/p' +\fP +.fi +.RE +.LP +this volume of IEEE\ Std\ 1003.1-2001, BSD, System V documentation, +and the SVID indicate that the first example should +write two lines with \fBA\fP, whereas the second should write one. +Some System V systems write the \fBA\fP only once in both +examples because the \fBp\fP flag is ignored if the \fB-n\fP option +is not specified. +.LP +This is a case of a diametrical difference between systems that could +not be reconciled through the compromise of declaring the +behavior to be unspecified. The SVID/BSD/System V documentation behavior +was adopted for this volume of +IEEE\ Std\ 1003.1-2001 because: +.IP " *" 3 +No known documentation for any historic system describes the interaction +between the \fBp\fP flag and the \fB-n\fP option. +.LP +.IP " *" 3 +The selected behavior is more correct as there is no technical justification +for any interaction between the \fBp\fP flag and +the \fB-n\fP option. A relationship between \fB-n\fP and the \fBp\fP +flag might imply that they are only used together, but this +ignores valid scripts that interrupt the cyclical nature of the processing +through the use of the \fBD\fP, \fBd\fP, \fBq\fP, or +branching commands. Such scripts rely on the \fBp\fP suffix to write +the pattern space because they do not make use of the default +output at the "bottom" of the script. +.LP +.IP " *" 3 +Because the \fB-n\fP option makes the \fBp\fP flag unnecessary, any +interaction would only be useful if \fIsed\fP scripts +were written to run both with and without the \fB-n\fP option. This +is believed to be unlikely. It is even more unlikely that +programmers have coded the \fBp\fP flag expecting it to be unnecessary. +Because the interaction was not documented, the likelihood +of a programmer discovering the interaction and depending on it is +further decreased. +.LP +.IP " *" 3 +Finally, scripts that break under the specified behavior produce too +much output instead of too little, which is easier to +diagnose and correct. +.LP +.LP +The form of the substitute command that uses the \fBn\fP suffix was +limited to the first 512 matches in an early proposal. This +limit has been removed because there is no reason an editor processing +lines of {LINE_MAX} length should have this restriction. The +command \fBs/a/A/2047\fP should be able to substitute the 2047th occurrence +of \fBa\fP on a line. +.LP +The \fBb\fP, \fBt\fP, and \fB:\fP commands are documented to ignore +leading white space, but no mention is made of trailing +white space. Historical implementations of \fIsed\fP assigned different +locations to the labels \fB'x'\fP and +\fB"x\ "\fP . This is not useful, and leads to subtle programming +errors, but it is historical practice, and changing it +could theoretically break working scripts. Implementors are encouraged +to provide warning messages about labels that are never used +or jumps to labels that do not exist. +.LP +Historically, the \fIsed\fP \fB!\fP and \fB}\fP editing commands did +not permit multiple commands on a single line using a +semicolon as a command delimiter. Implementations are permitted, but +not required, to support this extension. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIawk\fP , \fIed\fP , \fIgrep\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/set.1p b/man1p/set.1p new file mode 100644 index 000000000..28c548d0a --- /dev/null +++ b/man1p/set.1p @@ -0,0 +1,592 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SET" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" set +.SH NAME +set \- set or unset options and positional parameters +.SH SYNOPSIS +.LP +\fBset\fP \fB[\fP\fB-abCefmnuvx\fP\fB][\fP\fB-h\fP\fB][\fP\fB-o\fP +\fIoption\fP\fB][\fP\fIargument\fP\fB...\fP\fB]\fP\fB +.br +.sp +set\fP \fB[\fP\fB+abCefmnuvx\fP\fB][\fP\fB+h\fP\fB][\fP\fB+o\fP +\fIoption\fP\fB][\fP\fIargument\fP\fB...]\fP\fB +.br +.sp +set --\fP \fB[\fP\fIargument\fP\fB...\fP\fB]\fP\fB +.br +.sp +set -o +.br +.sp +set +o +.br +\fP +.SH DESCRIPTION +.LP +If no \fIoption\fPs or \fIargument\fPs are specified, \fIset\fP shall +write the names and values of all shell variables in +the collation sequence of the current locale. Each \fIname\fP shall +start on a separate line, using the format: +.sp +.RS +.nf + +\fB"%s=%s\\n", <\fP\fIname\fP\fB>, <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +The \fIvalue\fP string shall be written with appropriate quoting; +see the description of shell quoting in \fIQuoting\fP . The output +shall be suitable for reinput to the shell, setting or resetting, +as +far as possible, the variables that are currently set; read-only variables +cannot be reset. +.LP +When options are specified, they shall set or unset attributes of +the shell, as described below. When \fIargument\fPs are +specified, they cause positional parameters to be set or unset, as +described below. Setting or unsetting attributes and positional +parameters are not necessarily related actions, but they can be combined +in a single invocation of \fIset\fP. +.LP +The \fIset\fP special built-in shall support the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines +except that options can be specified with +either a leading hyphen (meaning enable the option) or plus sign (meaning +disable it) unless otherwise specified. +.LP +Implementations shall support the options in the following list in +both their hyphen and plus-sign forms. These options can also +be specified as options to \fIsh\fP. +.TP 7 +\fB-a\fP +When this option is on, the \fIexport\fP attribute shall be set for +each variable to which an assignment is performed; see the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 4.21, Variable +Assignment. If the assignment precedes a utility name in a command, +the \fIexport\fP attribute shall not persist in the +current execution environment after the utility completes, with the +exception that preceding one of the special built-in utilities +causes the \fIexport\fP attribute to persist after the built-in has +completed. If the assignment does not precede a utility name +in the command, or if the assignment is a result of the operation +of the \fIgetopts\fP or +\fIread\fP utilities, the \fIexport\fP attribute shall persist until +the variable is +unset. +.TP 7 +\fB-b\fP +This option shall be supported if the implementation supports the +User Portability Utilities option. It shall cause the shell +to notify the user asynchronously of background job completions. The +following message is written to standard error: +.sp +.RS +.nf + +\fB"[%d]%c %s%s\\n", <\fP\fIjob-number\fP\fB>, <\fP\fIcurrent\fP\fB>, <status>, <job-name> +\fP +.fi +.RE +.LP +where the fields shall be as follows: +.TP 7 +<\fIcurrent\fP> +.RS +The character \fB'+'\fP identifies the job that would be used as a +default for the \fIfg\fP or \fIbg\fP utilities; this job can also +be specified +using the \fIjob_id\fP \fB"%+"\fP or \fB"%%"\fP . The character \fB'-'\fP +identifies the job that would become the +default if the current default job were to exit; this job can also +be specified using the \fIjob_id\fP \fB"%-"\fP . For other +jobs, this field is a <space>. At most one job can be identified with +\fB'+'\fP and at most one job can be identified with +\fB'-'\fP . If there is any suspended job, then the current job shall +be a suspended job. If there are at least two suspended +jobs, then the previous job also shall be a suspended job. +.RE +.TP 7 +<\fIjob-number\fP> +.RS +A number that can be used to identify the process group to the \fIwait\fP, +\fIfg\fP, \fIbg\fP, and \fIkill\fP utilities. Using these utilities, +the job can be identified by prefixing the job number +with \fB'%'\fP . +.RE +.TP 7 +<\fIstatus\fP> +.RS +Unspecified. +.RE +.TP 7 +<\fIjob-name\fP> +.RS +Unspecified. +.RE +.sp +.LP +When the shell notifies the user a job has been completed, it may +remove the job's process ID from the list of those known in +the current shell execution environment; see \fIAsynchronous Lists\fP +\&. Asynchronous +notification shall not be enabled by default. +.TP 7 +\fB-C\fP +(Uppercase C.) Prevent existing files from being overwritten by the +shell's \fB'>'\fP redirection operator (see \fIRedirecting Output\fP +); the \fB">|"\fP redirection operator shall override this +\fInoclobber\fP option for an individual file. +.TP 7 +\fB-e\fP +When this option is on, if a simple command fails for any of the reasons +listed in \fIConsequences of Shell Errors\fP or returns an exit status +value >0, and is not part of +the compound list following a \fBwhile\fP, \fBuntil\fP, or \fBif\fP +keyword, and is not a part of an AND or OR list, and is not +a pipeline preceded by the \fB!\fP reserved word, then the shell shall +immediately exit. +.TP 7 +\fB-f\fP +The shell shall disable pathname expansion. +.TP 7 +\fB-h\fP +Locate and remember utilities invoked by functions as those functions +are defined (the utilities are normally located when the +function is executed). +.TP 7 +\fB-m\fP +This option shall be supported if the implementation supports the +User Portability Utilities option. All jobs shall be run in +their own process groups. Immediately before the shell issues a prompt +after completion of the background job, a message reporting +the exit status of the background job shall be written to standard +error. If a foreground job stops, the shell shall write a +message to standard error to that effect, formatted as described by +the \fIjobs\fP utility. +In addition, if a job changes status other than exiting (for example, +if it stops for input or output or is stopped by a SIGSTOP +signal), the shell shall write a similar message immediately prior +to writing the next prompt. This option is enabled by default +for interactive shells. +.TP 7 +\fB-n\fP +The shell shall read commands but does not execute them; this can +be used to check for shell script syntax errors. An +interactive shell may ignore this option. +.TP 7 +\fB-o\fP +Write the current settings of the options to standard output in an +unspecified format. +.TP 7 +\fB+o\fP +Write the current option settings to standard output in a format that +is suitable for reinput to the shell as commands that +achieve the same options settings. +.TP 7 +\fB-o\ \fP \fIoption\fP +.sp +This option is supported if the system supports the User Portability +Utilities option. It shall set various options, many of which +shall be equivalent to the single option letters. The following values +of \fIoption\fP shall be supported: +.TP 7 +\fIallexport\fP +.RS +Equivalent to \fB-a\fP. +.RE +.TP 7 +\fIerrexit\fP +.RS +Equivalent to \fB-e\fP. +.RE +.TP 7 +\fIignoreeof\fP +.RS +Prevent an interactive shell from exiting on end-of-file. This setting +prevents accidental logouts when <control>-D is +entered. A user shall explicitly \fIexit\fP to leave the interactive +shell. +.RE +.TP 7 +\fImonitor\fP +.RS +Equivalent to \fB-m\fP. This option is supported if the system supports +the User Portability Utilities option. +.RE +.TP 7 +\fInoclobber\fP +.RS +Equivalent to \fB-C\fP (uppercase C). +.RE +.TP 7 +\fInoglob\fP +.RS +Equivalent to \fB-f\fP. +.RE +.TP 7 +\fInoexec\fP +.RS +Equivalent to \fB-n\fP. +.RE +.TP 7 +\fInolog\fP +.RS +Prevent the entry of function definitions into the command history; +see \fICommand History List\fP +\&. +.RE +.TP 7 +\fInotify\fP +.RS +Equivalent to \fB-b\fP. +.RE +.TP 7 +\fInounset\fP +.RS +Equivalent to \fB-u\fP. +.RE +.TP 7 +\fIverbose\fP +.RS +Equivalent to \fB-v\fP. +.RE +.TP 7 +\fIvi\fP +.RS +Allow shell command line editing using the built-in \fIvi\fP editor. +Enabling \fIvi\fP mode shall disable any other command line editing +mode provided as an implementation +extension. +.LP +It need not be possible to set \fIvi\fP mode on for certain block-mode +terminals. +.RE +.TP 7 +\fIxtrace\fP +.RS +Equivalent to \fB-x\fP. +.RE +.sp +.TP 7 +\fB-u\fP +The shell shall write a message to standard error when it tries to +expand a variable that is not set and immediately exit. An +interactive shell shall not exit. +.TP 7 +\fB-v\fP +The shell shall write its input to standard error as it is read. +.TP 7 +\fB-x\fP +The shell shall write to standard error a trace for each command after +it expands the command and before it executes it. It is +unspecified whether the command that turns tracing off is traced. +.sp +.LP +The default for all these options shall be off (unset) unless stated +otherwise in the description of the option or unless the +shell was invoked with them on; see \fIsh\fP. +.LP +The remaining arguments shall be assigned in order to the positional +parameters. The special parameter \fB'#'\fP shall be set +to reflect the number of positional parameters. All positional parameters +shall be unset before any new values are assigned. +.LP +The special argument \fB"--"\fP immediately following the \fIset\fP +command name can be used to delimit the arguments if the +first argument begins with \fB'+'\fP or \fB'-'\fP , or to prevent +inadvertent listing of all shell variables when there are +no arguments. The command \fIset\fP \fB--\fP without \fIargument\fP +shall unset all positional parameters and set the special +parameter \fB'#'\fP to zero. +.SH OPTIONS +.LP +See the DESCRIPTION. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the DESCRIPTION. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +Zero. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +Write out all variables and their values: +.sp +.RS +.nf + +\fBset +\fP +.fi +.RE +.LP +Set $1, $2, and $3 and set \fB"$#"\fP to 3: +.sp +.RS +.nf + +\fBset c a b +\fP +.fi +.RE +.LP +Turn on the \fB-x\fP and \fB-v\fP options: +.sp +.RS +.nf + +\fBset -xv +\fP +.fi +.RE +.LP +Unset all positional parameters: +.sp +.RS +.nf + +\fBset -- +\fP +.fi +.RE +.LP +Set $1 to the value of \fIx\fP, even if it begins with \fB'-'\fP or +\fB'+'\fP : +.sp +.RS +.nf + +\fBset -- "$x" +\fP +.fi +.RE +.LP +Set the positional parameters to the expansion of \fIx\fP, even if +\fIx\fP expands with a leading \fB'-'\fP or \fB'+'\fP +: +.sp +.RS +.nf + +\fBset -- $x +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fIset\fP -- form is listed specifically in the SYNOPSIS even +though this usage is implied by the Utility Syntax +Guidelines. The explanation of this feature removes any ambiguity +about whether the \fIset\fP -- form might be misinterpreted as +being equivalent to \fIset\fP without any options or arguments. The +functionality of this form has been adopted from the +KornShell. In System V, \fIset\fP -- only unsets parameters if there +is at least one argument; the only way to unset all +parameters is to use \fIshift\fP. Using the KornShell version should +not affect System V +scripts because there should be no reason to issue it without arguments +deliberately; if it were issued as, for example: +.sp +.RS +.nf + +\fBset -- "$@" +\fP +.fi +.RE +.LP +and there were in fact no arguments resulting from \fB"$@"\fP , unsetting +the parameters would have no result. +.LP +The \fIset\fP + form in early proposals was omitted as being an unnecessary +duplication of \fIset\fP alone and not widespread +historical practice. +.LP +The \fInoclobber\fP option was changed to allow \fIset\fP \fB-C\fP +as well as the \fIset\fP \fB-o\fP \fInoclobber\fP +option. The single-letter version was added so that the historical +\fB"$-"\fP paradigm would not be broken; see \fISpecial Parameters\fP +\&. +.LP +The \fB-h\fP flag is related to command name hashing and is only required +on XSI-conformant systems. +.LP +The following \fIset\fP flags were omitted intentionally with the +following rationale: +.TP 7 +\fB-k\fP +The \fB-k\fP flag was originally added by the author of the Bourne +shell to make it easier for users of pre-release versions +of the shell. In early versions of the Bourne shell the construct +\fIset\fP \fIname\fP= \fIvalue\fP had to be used to assign +values to shell variables. The problem with \fB-k\fP is that the behavior +affects parsing, virtually precluding writing any +compilers. To explain the behavior of \fB-k\fP, it is necessary to +describe the parsing algorithm, which is +implementation-defined. For example: +.sp +.RS +.nf + +\fBset -k; echo\fP \fIname\fP\fB=\fP\fIvalue\fP +.fi +.RE +.LP +and: +.sp +.RS +.nf + +\fBset -k +echo\fP \fIname\fP\fB=\fP\fIvalue\fP +.fi +.RE +.LP +behave differently. The interaction with functions is even more complex. +What is more, the \fB-k\fP flag is never needed, since +the command line could have been reordered. +.TP 7 +\fB-t\fP +The \fB-t\fP flag is hard to specify and almost never used. The only +known use could be done with here-documents. Moreover, +the behavior with \fIksh\fP and \fIsh\fP differs. The +reference page says that it exits after reading and executing one +command. What is one command? If the input is \fIdate\fP; +\fIdate\fP, \fIsh\fP executes both \fIdate\fP commands +while \fIksh\fP does only the first. +.sp +.LP +Consideration was given to rewriting \fIset\fP to simplify its confusing +syntax. A specific suggestion was that the \fIunset\fP utility should +be used to unset options instead of using the non- \fIgetopt\fP() +-able + \fIoption\fP syntax. However, the conclusion was reached that +the +historical practice of using + \fIoption\fP was satisfactory and that +there was no compelling reason to modify such widespread +historical practice. +.LP +The \fB-o\fP option was adopted from the KornShell to address user +needs. In addition to its generally friendly interface, +\fB-o\fP is needed to provide the \fIvi\fP command line editing mode, +for which historical +practice yields no single-letter option name. (Although it might have +been possible to invent such a letter, it was recognized that +other editing modes would be developed and \fB-o\fP provides ample +name space for describing such extensions.) +.LP +Historical implementations are inconsistent in the format used for +\fB-o\fP option status reporting. The \fB+o\fP format +without an option-argument was added to allow portable access to the +options that can be saved and then later restored using, for +instance, a dot script. +.LP +Historically, \fIsh\fP did trace the command \fIset\fP \fB+x\fP, but +\fIksh\fP did not. +.LP +The \fIignoreeof\fP setting prevents accidental logouts when the end-of-file +character (typically <control>-D) is +entered. A user shall explicitly \fIexit\fP to leave the interactive +shell. +.LP +The \fIset\fP \fB-m\fP option was added to apply only to the UPE because +it applies primarily to interactive use, not shell +script applications. +.LP +The ability to do asynchronous notification became available in the +1988 version of the KornShell. To have it occur, the user +had to issue the command: +.sp +.RS +.nf + +\fBtrap "jobs -n" CLD +\fP +.fi +.RE +.LP +The C shell provides two different levels of an asynchronous notification +capability. The environment variable \fInotify\fP is +analogous to what is done in \fIset\fP \fB-b\fP or \fIset\fP \fB-o\fP +\fInotify\fP. When set, it notifies the user immediately +of background job completions. When unset, this capability is turned +off. +.LP +The other notification ability comes through the built-in utility +\fInotify\fP. The +syntax is: +.sp +.RS +.nf + +\fBnotify\fP \fB[\fP\fB%job ...\fP \fB]\fP +.fi +.RE +.LP +By issuing \fInotify\fP with no operands, it causes the C shell to +notify the user +asynchronously when the state of the current job changes. If given +operands, \fInotify\fP +asynchronously informs the user of changes in the states of the specified +jobs. +.LP +To add asynchronous notification to the POSIX shell, neither the KornShell +extensions to \fItrap\fP, nor the C shell \fInotify\fP environment +variable +seemed appropriate ( \fInotify\fP is not a proper POSIX environment +variable name). +.LP +The \fIset\fP \fB-b\fP option was selected as a compromise. +.LP +The \fInotify\fP built-in was considered to have more functionality +than was required +for simple asynchronous notification. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/sh.1p b/man1p/sh.1p new file mode 100644 index 000000000..9cb7c7383 --- /dev/null +++ b/man1p/sh.1p @@ -0,0 +1,1358 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" sh +.SH NAME +sh \- shell, the standard command language interpreter +.SH SYNOPSIS +.LP +\fBsh\fP \fB[\fP\fB-abCefhimnuvx\fP\fB][\fP\fB-o\fP \fIoption\fP\fB][\fP\fB+abCefhimnuvx\fP\fB][\fP\fB+o\fP +\fIoption\fP\fB] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fIcommand_file\fP \fB[\fP\fIargument\fP\fB...\fP\fB]]\fP\fB +.br +.sp +sh -c\fP\fB[\fP\fB-abCefhimnuvx\fP\fB][\fP\fB-o\fP \fIoption\fP\fB][\fP\fB+abCefhimnuvx\fP\fB][\fP\fB+o\fP +\fIoption\fP\fB]\fP\fIcommand_string +.br +\fP \fB\ \ \ \ \ \ \fP \fI\fP\fB[\fP\fIcommand_name\fP +\fB[\fP\fIargument\fP\fB...\fP\fB]]\fP\fB +.br +.sp +sh -s\fP\fB[\fP\fB-abCefhimnuvx\fP\fB][\fP\fB-o\fP \fIoption\fP\fB][\fP\fB+abCefhimnuvx\fP\fB][\fP\fB+o\fP +\fIoption\fP\fB][\fP\fIargument\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIsh\fP utility is a command language interpreter that shall +execute commands read from a command line string, the +standard input, or a specified file. The application shall ensure +that the commands to be executed are expressed in the language +described in \fIShell Command Language\fP . +.LP +Pathname expansion shall not fail due to the size of a file. +.LP +Shell input and output redirections have an implementation-defined +offset maximum that is established in the open file +description. +.SH OPTIONS +.LP +The \fIsh\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +with an extension for support of a leading +plus sign ( \fB'+'\fP ) as noted below. +.LP +The \fB-a\fP, \fB-b\fP, \fB-C\fP, \fB-e\fP, \fB-f\fP, \fB-m\fP, \fB-n\fP, +\fB-o\fP \fIoption\fP, \fB-u\fP, \fB-v\fP, +and \fB-x\fP options are described as part of the \fIset\fP utility +in \fISpecial Built-In Utilities\fP . The option letters derived from +the \fIset\fP special built-in shall also be accepted with a leading +plus sign ( \fB'+'\fP ) +instead of a leading hyphen (meaning the reverse case of the option +as described in this volume of +IEEE\ Std\ 1003.1-2001). +.LP +The following additional options shall be supported: +.TP 7 +\fB-c\fP +Read commands from the \fIcommand_string\fP operand. Set the value +of special parameter 0 (see \fISpecial Parameters\fP ) from the value +of the \fIcommand_name\fP operand and the positional +parameters ($1, $2, and so on) in sequence from the remaining \fIargument\fP +operands. No commands shall be read from the standard +input. +.TP 7 +\fB-i\fP +Specify that the shell is \fIinteractive\fP; see below. An implementation +may treat specifying the \fB-i\fP option as an +error if the real user ID of the calling process does not equal the +effective user ID or if the real group ID does not equal the +effective group ID. +.TP 7 +\fB-s\fP +Read commands from the standard input. +.sp +.LP +If there are no operands and the \fB-c\fP option is not specified, +the \fB-s\fP option shall be assumed. +.LP +If the \fB-i\fP option is present, or if there are no operands and +the shell's standard input and standard error are attached +to a terminal, the shell is considered to be \fIinteractive\fP. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fB-\fP +A single hyphen shall be treated as the first operand and then ignored. +If both \fB'-'\fP and \fB"--"\fP are given as +arguments, or if other operands precede the single hyphen, the results +are undefined. +.TP 7 +\fIargument\fP +The positional parameters ($1, $2, and so on) shall be set to \fIarguments\fP, +if any. +.TP 7 +\fIcommand_file\fP +The pathname of a file containing commands. If the pathname contains +one or more slash characters, the implementation attempts +to read that file; the file need not be executable. If the pathname +does not contain a slash character: +.RS +.IP " *" 3 +The implementation shall attempt to read that file from the current +working directory; the file need not be executable. +.LP +.IP " *" 3 +If the file is not in the current working directory, the implementation +may perform a search for an executable file using the +value of \fIPATH ,\fP as described in \fICommand Search and Execution\fP +\&. +.LP +.RE +.LP +Special parameter 0 (see \fISpecial Parameters\fP ) shall be set to +the value of +\fIcommand_file\fP. If \fIsh\fP is called using a synopsis form that +omits \fIcommand_file\fP, special parameter 0 shall be set +to the value of the first argument passed to \fIsh\fP from its parent +(for example, \fIargv\fP[0] for a C program), which is +normally a pathname used to execute the \fIsh\fP utility. +.TP 7 +\fIcommand_name\fP +.sp +A string assigned to special parameter 0 when executing the commands +in \fIcommand_string\fP. If \fIcommand_name\fP is not +specified, special parameter 0 shall be set to the value of the first +argument passed to \fIsh\fP from its parent (for example, +\fIargv\fP[0] for a C program), which is normally a pathname used +to execute the \fIsh\fP utility. +.TP 7 +\fIcommand_string\fP +.sp +A string that shall be interpreted by the shell as one or more commands, +as if the string were the argument to the \fIsystem\fP() function +defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001. +If the \fIcommand_string\fP operand is an empty string, \fIsh\fP shall +exit with a zero exit status. +.sp +.SH STDIN +.LP +The standard input shall be used only if one of the following is true: +.IP " *" 3 +The \fB-s\fP option is specified. +.LP +.IP " *" 3 +The \fB-c\fP option is not specified and no operands are specified. +.LP +.IP " *" 3 +The script executes one or more commands that require input from standard +input (such as a \fIread\fP command that does not redirect its input). +.LP +.LP +See the INPUT FILES section. +.LP +When the shell is using standard input and it invokes a command that +also uses standard input, the shell shall ensure that the +standard input file pointer points directly after the command it has +read when the command begins execution. It shall not read +ahead in such a manner that any characters intended to be read by +the invoked command are consumed by the shell (whether +interpreted by the shell or not) or that characters that are not read +by the invoked command are not seen by the shell. When the +command expecting to read standard input is started asynchronously +by an interactive shell, it is unspecified whether characters +are read by the command or interpreted by the shell. +.LP +If the standard input to \fIsh\fP is a FIFO or terminal device and +is set to non-blocking reads, then \fIsh\fP shall enable +blocking reads on standard input. This shall remain in effect when +the command completes. +.SH INPUT FILES +.LP +The input file shall be a text file, except that line lengths shall +be unlimited. If the input file is empty or consists solely +of blank lines or comments, or both, \fIsh\fP shall exit with a zero +exit status. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIsh\fP: +.TP 7 +\fIENV\fP +This variable, when and only when an interactive shell is invoked, +shall be subjected to parameter expansion (see \fIParameter Expansion\fP +) by the shell, and the resulting value shall be used as a pathname +of a file containing shell commands to execute in the current environment. +The file need not be executable. If the expanded value +of \fIENV\fP is not an absolute pathname, the results are unspecified. +\fIENV\fP shall be ignored if the real and effective user +IDs or real and effective group IDs of the process are different. +.TP 7 +\fIFCEDIT\fP +This variable, when expanded by the shell, shall determine the default +value for the \fB-e\fP \fIeditor\fP option's +\fIeditor\fP option-argument. If \fIFCEDIT\fP is null or unset, \fIed\fP +shall be used as the +editor. This volume of IEEE\ Std\ 1003.1-2001 specifies the effects +of this variable only for systems supporting the User +Portability Utilities option. +.TP 7 +\fIHISTFILE\fP +Determine a pathname naming a command history file. If the \fIHISTFILE\fP +variable is not set, the shell may attempt to access +or create a file \fB.sh_history\fP in the directory referred to by +the \fIHOME\fP environment variable. If the shell cannot +obtain both read and write access to, or create, the history file, +it shall use an unspecified mechanism that allows the history to +operate properly. (References to history "file" in this section shall +be understood to mean this unspecified mechanism in such +cases.) An implementation may choose to access this variable only +when initializing the history file; this initialization shall +occur when \fIfc\fP or \fIsh\fP first attempt to retrieve entries +from, or add entries to, the +file, as the result of commands issued by the user, the file named +by the \fIENV\fP variable, or implementation-defined system +start-up files. Implementations may choose to disable the history +list mechanism for users with appropriate privileges who do not +set \fIHISTFILE ;\fP the specific circumstances under which this occurs +are implementation-defined. If more than one instance of +the shell is using the same history file, it is unspecified how updates +to the history file from those shells interact. As entries +are deleted from the history file, they shall be deleted oldest first. +It is unspecified when history file entries are physically +removed from the history file. This volume of IEEE\ Std\ 1003.1-2001 +specifies the effects of this variable only for +systems supporting the User Portability Utilities option. +.TP 7 +\fIHISTSIZE\fP +Determine a decimal number representing the limit to the number of +previous commands that are accessible. If this variable is +unset, an unspecified default greater than or equal to 128 shall be +used. The maximum number of commands in the history list is +unspecified, but shall be at least 128. An implementation may choose +to access this variable only when initializing the history +file, as described under \fIHISTFILE .\fP Therefore, it is unspecified +whether changes made to \fIHISTSIZE\fP after the history +file has been initialized are effective. +.TP 7 +\fIHOME\fP +Determine the pathname of the user's home directory. The contents +of \fIHOME\fP are used in tilde expansion as described in \fITilde +Expansion\fP . This volume of IEEE\ Std\ 1003.1-2001 specifies the +effects of this variable only for systems supporting the User Portability +Utilities option. +.TP 7 +\fIIFS\fP +(Input Field Separators.) A string treated as a list of characters +that shall be used for field splitting and to split lines +into words with the \fIread\fP command. See \fIField +Splitting\fP . If \fIIFS\fP is not set, the shell shall behave as +if the value of \fIIFS\fP were <space>, <tab>, +and <newline>. Implementations may ignore the value of \fIIFS\fP in +the environment at the time \fIsh\fP is invoked, +treating \fIIFS\fP as if it were not set. +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the behavior of range expressions, equivalence classes, +and multi-character collating elements within pattern +matching. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), which +characters are defined as letters (character class +\fBalpha\fP), and the behavior of character classes within pattern +matching. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fIMAIL\fP +Determine a pathname of the user's mailbox file for purposes of incoming +mail notification. If this variable is set, the shell +shall inform the user if the file named by the variable is created +or if its modification time has changed. Informing the user +shall be accomplished by writing a string of unspecified format to +standard error prior to the writing of the next primary prompt +string. Such check shall be performed only after the completion of +the interval defined by the \fIMAILCHECK\fP variable after the +last such check. The user shall be informed only if \fIMAIL\fP is +set and \fIMAILPATH\fP is not set. This volume of +IEEE\ Std\ 1003.1-2001 specifies the effects of this variable only +for systems supporting the User Portability Utilities +option. +.TP 7 +\fIMAILCHECK\fP +.sp +Establish a decimal integer value that specifies how often (in seconds) +the shell shall check for the arrival of mail in the files +specified by the \fIMAILPATH\fP or \fIMAIL\fP variables. The default +value shall be 600 seconds. If set to zero, the shell shall +check before issuing each primary prompt. This volume of IEEE\ Std\ 1003.1-2001 +specifies the effects of this variable only +for systems supporting the User Portability Utilities option. +.TP 7 +\fIMAILPATH\fP +Provide a list of pathnames and optional messages separated by colons. +If this variable is set, the shell shall inform the user +if any of the files named by the variable are created or if any of +their modification times change. (See the preceding entry for +\fIMAIL\fP for descriptions of mail arrival and user informing.) Each +pathname can be followed by \fB'%'\fP and a string that +shall be subjected to parameter expansion and written to standard +error when the modification time changes. If a \fB'%'\fP +character in the pathname is preceded by a backslash, it shall be +treated as a literal \fB'%'\fP in the pathname. The default +message is unspecified. +.LP +The \fIMAILPATH\fP environment variable takes precedence over the +\fIMAIL\fP variable. This volume of +IEEE\ Std\ 1003.1-2001 specifies the effects of this variable only +for systems supporting the User Portability Utilities +option. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Establish a string formatted as described in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables, +used to effect command interpretation; see \fICommand Search and Execution\fP +\&. +.TP 7 +\fIPWD\fP +This variable shall represent an absolute pathname of the current +working directory. Assignments to this variable may be +ignored unless the value is an absolute pathname of the current working +directory and there are no filename components of dot or +dot-dot. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the STDERR section. +.SH STDERR +.LP +Except as otherwise stated (by the descriptions of any invoked utilities +or in interactive mode), standard error shall be used +only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +See \fIShell Command Language\fP . The following additional capabilities +are supported on +systems supporting the User Portability Utilities option. +.SS Command History List +.LP +When the \fIsh\fP utility is being used interactively, it shall maintain +a list of commands previously entered from the +terminal in the file named by the \fIHISTFILE\fP environment variable. +The type, size, and internal format of this file are +unspecified. Multiple \fIsh\fP processes can share access to the file +for a user, if file access permissions allow this; see the +description of the \fIHISTFILE\fP environment variable. +.SS Command Line Editing +.LP +When \fIsh\fP is being used interactively from a terminal, the current +command and the command history (see \fIfc\fP ) can be edited using +\fIvi\fP-mode command line editing. This mode +uses commands, described below, similar to a subset of those described +in the \fIvi\fP utility. +Implementations may offer other command line editing modes corresponding +to other editing utilities. +.LP +The command \fIset\fP \fB-o\fP \fIvi\fP +shall enable \fIvi\fP-mode editing and place \fIsh\fP into \fIvi\fP +insert mode (see Command Line Editing (vi-mode) ). This +command also shall disable any other editing mode that the implementation +may provide. The command \fIset\fP \fB+o\fP \fIvi\fP disables \fIvi\fP-mode +editing. +.LP +Certain block-mode terminals may be unable to support shell command +line editing. If a terminal is unable to provide either edit +mode, it need not be possible to \fIset\fP \fB-o\fP \fIvi\fP when +using the shell on this terminal. +.LP +In the following sections, the characters \fIerase\fP, \fIinterrupt\fP, +\fIkill\fP, and \fIend-of-file\fP are those set by +the \fIstty\fP utility. +.SS Command Line Editing (vi-mode) +.LP +In \fIvi\fP editing mode, there shall be a distinguished line, the +edit line. All the +editing operations which modify a line affect the edit line. The edit +line is always the newest line in the command history +buffer. +.LP +With \fIvi\fP-mode enabled, \fIsh\fP can be switched between insert +mode and command +mode. +.LP +When in insert mode, an entered character shall be inserted into the +command line, except as noted in vi Line Editing Insert Mode . Upon +entering \fIsh\fP and after termination of the previous command, +\fIsh\fP shall be in insert mode. +.LP +Typing an escape character shall switch \fIsh\fP into command mode +(see vi Line Editing Command +Mode ). In command mode, an entered character shall either invoke +a defined operation, be used as part of a multi-character +operation, or be treated as an error. A character that is not recognized +as part of an editing command shall terminate any specific +editing command and shall alert the terminal. Typing the \fIinterrupt\fP +character in command mode shall cause \fIsh\fP to +terminate command line editing on the current command line, reissue +the prompt on the next line of the terminal, and reset the +command history (see \fIfc\fP ) so that the most recently executed +command is the previous command (that is, +the command that was being edited when it was interrupted is not reentered +into the history). +.LP +In the following sections, the phrase "move the cursor to the beginning +of the word" shall mean "move the cursor to the first +character of the current word" and the phrase "move the cursor to +the end of the word" shall mean "move the cursor to the last +character of the current word". The phrase "beginning of the command +line" indicates the point between the end of the prompt +string issued by the shell (or the beginning of the terminal line, +if there is no prompt string) and the first character of the +command text. +.SS vi Line Editing Insert Mode +.LP +While in insert mode, any character typed shall be inserted in the +current command line, unless it is from the following +set. +.TP 7 +<newline> +Execute the current command line. If the current command line is not +empty, this line shall be entered into the command history +(see \fIfc\fP ). +.TP 7 +\fIerase\fP +Delete the character previous to the current cursor position and move +the current cursor position back one character. In insert +mode, characters shall be erased from both the screen and the buffer +when backspacing. +.TP 7 +\fIinterrupt\fP +Terminate command line editing with the same effects as described +for interrupting command mode; see Command Line Editing (vi-mode) +\&. +.TP 7 +\fIkill\fP +Clear all the characters from the input line. +.TP 7 +<control>-V +Insert the next character input, even if the character is otherwise +a special insert mode character. +.TP 7 +<control>-W +Delete the characters from the one preceding the cursor to the preceding +word boundary. The word boundary in this case is the +closer to the cursor of either the beginning of the line or a character +that is in neither the \fBblank\fP nor \fBpunct\fP +character classification of the current locale. +.TP 7 +\fIend-of-file\fP +Interpreted as the end of input in \fIsh\fP. This interpretation shall +occur only at the beginning of an input line. If +\fIend-of-file\fP is entered other than at the beginning of the line, +the results are unspecified. +.TP 7 +<ESC> +Place \fIsh\fP into command mode. +.sp +.SS vi Line Editing Command Mode +.LP +In command mode for the command line editing feature, decimal digits +not beginning with 0 that precede a command letter shall be +remembered. Some commands use these decimal digits as a count number +that affects the operation. +.LP +The term \fImotion command\fP represents one of the commands: +.sp +.RS +.nf + +\fB<space> 0 b F l W ^ $ ; E f T w | , B e h t +\fP +.fi +.RE +.LP +If the current line is not the edit line, any command that modifies +the current line shall cause the content of the current line +to replace the content of the edit line, and the current line shall +become the edit line. This replacement cannot be undone (see +the \fBu\fP and \fBU\fP commands below). The modification requested +shall then be performed to the edit line. When the current +line is the edit line, the modification shall be done directly to +the edit line. +.LP +Any command that is preceded by \fIcount\fP shall take a count (the +numeric value of any preceding decimal digits). Unless +otherwise noted, this count shall cause the specified operation to +repeat by the number of times specified by the count. Also +unless otherwise noted, a \fIcount\fP that is out of range is considered +an error condition and shall alert the terminal, but +neither the cursor position, nor the command line, shall change. +.LP +The terms \fIword\fP and \fIbigword\fP are used as defined in the +\fIvi\fP description. +The term \fIsave buffer\fP corresponds to the term \fIunnamed buffer\fP +in \fIvi\fP. +.LP +The following commands shall be recognized in command mode: +.TP 7 +<newline> +Execute the current command line. If the current command line is not +empty, this line shall be entered into the command history +(see \fIfc\fP ). +.TP 7 +<control>-L +Redraw the current command line. Position the cursor at the same location +on the redrawn line. +.TP 7 +\fB#\fP +Insert the character \fB'#'\fP at the beginning of the current command +line and treat the resulting edit line as a comment. +This line shall be entered into the command history; see \fIfc\fP +\&. +.TP 7 +\fB=\fP +Display the possible shell word expansions (see \fIWord Expansions\fP +) of the bigword +at the current command line position. +.TP 7 +\fBNote:\fP +.RS +This does not modify the content of the current line, and therefore +does not cause the current line to become the edit +line. +.RE +.sp +.LP +These expansions shall be displayed on subsequent terminal lines. +If the bigword contains none of the characters \fB'?'\fP , +\fB'*'\fP , or \fB'['\fP , an asterisk ( \fB'*'\fP ) shall be implicitly +assumed at the end. If any directories are +matched, these expansions shall have a \fB'/'\fP character appended. +After the expansion, the line shall be redrawn, the cursor +repositioned at the current cursor position, and \fIsh\fP shall be +placed in command mode. +.TP 7 +\fB\\\fP +Perform pathname expansion (see \fIPathname Expansion\fP ) on the +current bigword, +up to the largest set of characters that can be matched uniquely. +If the bigword contains none of the characters \fB'?'\fP , +\fB'*'\fP , or \fB'['\fP , an asterisk ( \fB'*'\fP ) shall be implicitly +assumed at the end. This maximal expansion then +shall replace the original bigword in the command line, and the cursor +shall be placed after this expansion. If the resulting +bigword completely and uniquely matches a directory, a \fB'/'\fP character +shall be inserted directly after the bigword. If some +other file is completely matched, a single <space> shall be inserted +after the bigword. After this operation, \fIsh\fP shall +be placed in insert mode. +.TP 7 +\fB*\fP +Perform pathname expansion on the current bigword and insert all expansions +into the command to replace the current bigword, +with each expansion separated by a single <space>. If at the end of +the line, the current cursor position shall be moved to +the first column position following the expansions and \fIsh\fP shall +be placed in insert mode. Otherwise, the current cursor +position shall be the last column position of the first character +after the expansions and \fIsh\fP shall be placed in insert +mode. If the current bigword contains none of the characters \fB'?'\fP +, \fB'*'\fP , or \fB'['\fP , before the operation, +an asterisk shall be implicitly assumed at the end. +.TP 7 +\fB@\fP\fIletter\fP +Insert the value of the alias named \fI_letter\fP. The symbol \fIletter\fP +represents a single alphabetic character from the +portable character set; implementations may support additional characters +as an extension. If the alias \fI_letter\fP contains +other editing commands, these commands shall be performed as part +of the insertion. If no alias \fI_letter\fP is enabled, this +command shall have no effect. +.TP 7 +\fB[\fP\fIcount\fP\fB]~\fP +Convert, if the current character is a lowercase letter, to the equivalent +uppercase letter and \fIvice versa\fP, as +prescribed by the current locale. The current cursor position then +shall be advanced by one character. If the cursor was positioned +on the last character of the line, the case conversion shall occur, +but the cursor shall not advance. If the \fB'~'\fP +command is preceded by a \fIcount\fP, that number of characters shall +be converted, and the cursor shall be advanced to the +character position after the last character converted. If the \fIcount\fP +is larger than the number of characters after the +cursor, this shall not be considered an error; the cursor shall advance +to the last character on the line. +.TP 7 +\fB[\fP\fIcount\fP\fB].\fP +Repeat the most recent non-motion command, even if it was executed +on an earlier command line. If the previous command was +preceded by a \fIcount\fP, and no count is given on the \fB'.'\fP +command, the count from the previous command shall be +included as part of the repeated command. If the \fB'.'\fP command +is preceded by a \fIcount\fP, this shall override any +\fIcount\fP argument to the previous command. The \fIcount\fP specified +in the \fB'.'\fP command shall become the count for +subsequent \fB'.'\fP commands issued without a count. +.TP 7 +\fB[\fP\fInumber\fP\fB]v\fP +Invoke the \fIvi\fP editor to edit the current command line in a temporary +file. When the +editor exits, the commands in the temporary file shall be executed +and placed in the command history. If a \fInumber\fP is +included, it specifies the command number in the command history to +be edited, rather than the current command line. +.TP 7 +\fB[\fP\fIcount\fP\fB]l\fP\ \ \ (ell) +.TP 7 +\fB[\fP\fIcount\fP\fB]\fP<space> +.sp +Move the current cursor position to the next character position. If +the cursor was positioned on the last character of the line, +the terminal shall be alerted and the cursor shall not be advanced. +If the \fIcount\fP is larger than the number of characters +after the cursor, this shall not be considered an error; the cursor +shall advance to the last character on the line. +.TP 7 +\fB[\fP\fIcount\fP\fB]h\fP +Move the current cursor position to the \fIcount\fPth (default 1) +previous character position. If the cursor was positioned on +the first character of the line, the terminal shall be alerted and +the cursor shall not be moved. If the count is larger than the +number of characters before the cursor, this shall not be considered +an error; the cursor shall move to the first character on the +line. +.TP 7 +\fB[\fP\fIcount\fP\fB]w\fP +Move to the start of the next word. If the cursor was positioned on +the last character of the line, the terminal shall be +alerted and the cursor shall not be advanced. If the \fIcount\fP is +larger than the number of words after the cursor, this shall +not be considered an error; the cursor shall advance to the last character +on the line. +.TP 7 +\fB[\fP\fIcount\fP\fB]W\fP +Move to the start of the next bigword. If the cursor was positioned +on the last character of the line, the terminal shall be +alerted and the cursor shall not be advanced. If the \fIcount\fP is +larger than the number of bigwords after the cursor, this +shall not be considered an error; the cursor shall advance to the +last character on the line. +.TP 7 +\fB[\fP\fIcount\fP\fB]e\fP +Move to the end of the current word. If at the end of a word, move +to the end of the next word. If the cursor was positioned on +the last character of the line, the terminal shall be alerted and +the cursor shall not be advanced. If the \fIcount\fP is larger +than the number of words after the cursor, this shall not be considered +an error; the cursor shall advance to the last character on +the line. +.TP 7 +\fB[\fP\fIcount\fP\fB]E\fP +Move to the end of the current bigword. If at the end of a bigword, +move to the end of the next bigword. If the cursor was +positioned on the last character of the line, the terminal shall be +alerted and the cursor shall not be advanced. If the +\fIcount\fP is larger than the number of bigwords after the cursor, +this shall not be considered an error; the cursor shall +advance to the last character on the line. +.TP 7 +\fB[\fP\fIcount\fP\fB]b\fP +Move to the beginning of the current word. If at the beginning of +a word, move to the beginning of the previous word. If the +cursor was positioned on the first character of the line, the terminal +shall be alerted and the cursor shall not be moved. If the +\fIcount\fP is larger than the number of words preceding the cursor, +this shall not be considered an error; the cursor shall +return to the first character on the line. +.TP 7 +\fB[\fP\fIcount\fP\fB]B\fP +Move to the beginning of the current bigword. If at the beginning +of a bigword, move to the beginning of the previous bigword. +If the cursor was positioned on the first character of the line, the +terminal shall be alerted and the cursor shall not be moved. +If the \fIcount\fP is larger than the number of bigwords preceding +the cursor, this shall not be considered an error; the cursor +shall return to the first character on the line. +.TP 7 +\fB^\fP +Move the current cursor position to the first character on the input +line that is not a <blank>. +.TP 7 +\fB$\fP +Move to the last character position on the current command line. +.TP 7 +\fB0\fP +(Zero.) Move to the first character position on the current command +line. +.TP 7 +\fB[\fP\fIcount\fP\fB]|\fP +Move to the \fIcount\fPth character position on the current command +line. If no number is specified, move to the first +position. The first character position shall be numbered 1. If the +count is larger than the number of characters on the line, this +shall not be considered an error; the cursor shall be placed on the +last character on the line. +.TP 7 +\fB[\fP\fIcount\fP\fB]f\fP\fIc\fP +Move to the first occurrence of the character \fB'c'\fP that occurs +after the current cursor position. If the cursor was +positioned on the last character of the line, the terminal shall be +alerted and the cursor shall not be advanced. If the character +\fB'c'\fP does not occur in the line after the current cursor position, +the terminal shall be alerted and the cursor shall not +be moved. +.TP 7 +\fB[\fP\fIcount\fP\fB]F\fP\fIc\fP +Move to the first occurrence of the character \fB'c'\fP that occurs +before the current cursor position. If the cursor was +positioned on the first character of the line, the terminal shall +be alerted and the cursor shall not be moved. If the character +\fB'c'\fP does not occur in the line before the current cursor position, +the terminal shall be alerted and the cursor shall not +be moved. +.TP 7 +\fB[\fP\fIcount\fP\fB]t\fP\fIc\fP +Move to the character before the first occurrence of the character +\fB'c'\fP that occurs after the current cursor position. +If the cursor was positioned on the last character of the line, the +terminal shall be alerted and the cursor shall not be advanced. +If the character \fB'c'\fP does not occur in the line after the current +cursor position, the terminal shall be alerted and the +cursor shall not be moved. +.TP 7 +\fB[\fP\fIcount\fP\fB]T\fP\fIc\fP +Move to the character after the first occurrence of the character +\fB'c'\fP that occurs before the current cursor position. +If the cursor was positioned on the first character of the line, the +terminal shall be alerted and the cursor shall not be moved. +If the character \fB'c'\fP does not occur in the line before the current +cursor position, the terminal shall be alerted and the +cursor shall not be moved. +.TP 7 +\fB[\fP\fIcount\fP\fB];\fP +Repeat the most recent \fBf\fP, \fBF\fP, \fBt\fP, or \fBT\fP command. +Any number argument on that previous command shall be +ignored. Errors are those described for the repeated command. +.TP 7 +\fB[\fP\fIcount\fP\fB],\fP +Repeat the most recent \fBf\fP, \fBF\fP, \fBt\fP, or \fBT\fP command. +Any number argument on that previous command shall be +ignored. However, reverse the direction of that command. +.TP 7 +\fBa\fP +Enter insert mode after the current cursor position. Characters that +are entered shall be inserted before the next +character. +.TP 7 +\fBA\fP +Enter insert mode after the end of the current command line. +.TP 7 +\fBi\fP +Enter insert mode at the current cursor position. Characters that +are entered shall be inserted before the current +character. +.TP 7 +\fBI\fP +Enter insert mode at the beginning of the current command line. +.TP 7 +\fBR\fP +Enter insert mode, replacing characters from the command line beginning +at the current cursor position. +.TP 7 +\fB[\fP\fIcount\fP\fB]c\fP\fImotion\fP +.sp +Delete the characters between the current cursor position and the +cursor position that would result from the specified motion +command. Then enter insert mode before the first character following +any deleted characters. If \fIcount\fP is specified, it shall +be applied to the motion command. A \fIcount\fP shall be ignored for +the following motion commands: +.sp +.RS +.nf + +\fB0 ^ $ c +\fP +.fi +.RE +.LP +If the motion command is the character \fB'c'\fP , the current command +line shall be cleared and insert mode shall be +entered. If the motion command would move the current cursor position +toward the beginning of the command line, the character under +the current cursor position shall not be deleted. If the motion command +would move the current cursor position toward the end of +the command line, the character under the current cursor position +shall be deleted. If the \fIcount\fP is larger than the number +of characters between the current cursor position and the end of the +command line toward which the motion command would move the +cursor, this shall not be considered an error; all of the remaining +characters in the aforementioned range shall be deleted and +insert mode shall be entered. If the motion command is invalid, the +terminal shall be alerted, the cursor shall not be moved, and +no text shall be deleted. +.TP 7 +\fBC\fP +Delete from the current character to the end of the line and enter +insert mode at the new end-of-line. +.TP 7 +\fBS\fP +Clear the entire edit line and enter insert mode. +.TP 7 +\fB[\fP\fIcount\fP\fB]r\fP\fIc\fP +Replace the current character with the character \fB'c'\fP . With +a number \fIcount\fP, replace the current and the +following \fIcount\fP-1 characters. After this command, the current +cursor position shall be on the last character that was +changed. If the \fIcount\fP is larger than the number of characters +after the cursor, this shall not be considered an error; all +of the remaining characters shall be changed. +.TP 7 +\fB[\fP\fIcount\fP\fB]_\fP +Append a <space> after the current character position and then append +the last bigword in the previous input line after +the <space>. Then enter insert mode after the last character just +appended. With a number \fIcount\fP, append the +\fIcount\fPth bigword in the previous line. +.TP 7 +\fB[\fP\fIcount\fP\fB]x\fP +Delete the character at the current cursor position and place the +deleted characters in the save buffer. If the cursor was +positioned on the last character of the line, the character shall +be deleted and the cursor position shall be moved to the previous +character (the new last character). If the \fIcount\fP is larger than +the number of characters after the cursor, this shall not be +considered an error; all the characters from the cursor to the end +of the line shall be deleted. +.TP 7 +\fB[\fP\fIcount\fP\fB]X\fP +Delete the character before the current cursor position and place +the deleted characters in the save buffer. The character +under the current cursor position shall not change. If the cursor +was positioned on the first character of the line, the terminal +shall be alerted, and the \fBX\fP command shall have no effect. If +the line contained a single character, the \fBX\fP command +shall have no effect. If the line contained no characters, the terminal +shall be alerted and the cursor shall not be moved. If the +\fIcount\fP is larger than the number of characters before the cursor, +this shall not be considered an error; all the characters +from before the cursor to the beginning of the line shall be deleted. +.TP 7 +\fB[\fP\fIcount\fP\fB]d\fP\fImotion\fP +.sp +Delete the characters between the current cursor position and the +character position that would result from the motion command. A +number \fIcount\fP repeats the motion command \fIcount\fP times. If +the motion command would move toward the beginning of the +command line, the character under the current cursor position shall +not be deleted. If the motion command is \fBd\fP, the entire +current command line shall be cleared. If the \fIcount\fP is larger +than the number of characters between the current cursor +position and the end of the command line toward which the motion command +would move the cursor, this shall not be considered an +error; all of the remaining characters in the aforementioned range +shall be deleted. The deleted characters shall be placed in the +save buffer. +.TP 7 +\fBD\fP +Delete all characters from the current cursor position to the end +of the line. The deleted characters shall be placed in the +save buffer. +.TP 7 +\fB[\fP\fIcount\fP\fB]y\fP\fImotion\fP +.sp +Yank (that is, copy) the characters from the current cursor position +to the position resulting from the motion command into the +save buffer. A number \fIcount\fP shall be applied to the motion command. +If the motion command would move toward the beginning of +the command line, the character under the current cursor position +shall not be included in the set of yanked characters. If the +motion command is \fBy\fP, the entire current command line shall be +yanked into the save buffer. The current cursor position shall +be unchanged. If the \fIcount\fP is larger than the number of characters +between the current cursor position and the end of the +command line toward which the motion command would move the cursor, +this shall not be considered an error; all of the remaining +characters in the aforementioned range shall be yanked. +.TP 7 +\fBY\fP +Yank the characters from the current cursor position to the end of +the line into the save buffer. The current character +position shall be unchanged. +.TP 7 +\fB[\fP\fIcount\fP\fB]p\fP +Put a copy of the current contents of the save buffer after the current +cursor position. The current cursor position shall be +advanced to the last character put from the save buffer. A \fIcount\fP +shall indicate how many copies of the save buffer shall be +put. +.TP 7 +\fB[\fP\fIcount\fP\fB]P\fP +Put a copy of the current contents of the save buffer before the current +cursor position. The current cursor position shall be +moved to the last character put from the save buffer. A \fIcount\fP +shall indicate how many copies of the save buffer shall be +put. +.TP 7 +\fBu\fP +Undo the last command that changed the edit line. This operation shall +not undo the copy of any command line to the edit +line. +.TP 7 +\fBU\fP +Undo all changes made to the edit line. This operation shall not undo +the copy of any command line to the edit line. +.TP 7 +\fB[\fP\fIcount\fP\fB]k\fP +.TP 7 +\fB[\fP\fIcount\fP\fB]-\fP +Set the current command line to be the \fIcount\fPth previous command +line in the shell command history. If \fIcount\fP is +not specified, it shall default to 1. The cursor shall be positioned +on the first character of the new command. If a \fBk\fP or +\fB-\fP command would retreat past the maximum number of commands +in effect for this shell (affected by the \fIHISTSIZE\fP +environment variable), the terminal shall be alerted, and the command +shall have no effect. +.TP 7 +\fB[\fP\fIcount\fP\fB]j\fP +.TP 7 +\fB[\fP\fIcount\fP\fB]+\fP +Set the current command line to be the \fIcount\fPth next command +line in the shell command history. If \fIcount\fP is not +specified, it shall default to 1. The cursor shall be positioned on +the first character of the new command. If a \fBj\fP or +\fB+\fP command advances past the edit line, the current command line +shall be restored to the edit line and the terminal shall be +alerted. +.TP 7 +\fB[\fP\fInumber\fP\fB]G\fP +Set the current command line to be the oldest command line stored +in the shell command history. With a number \fInumber\fP, +set the current command line to be the command line \fInumber\fP in +the history. If command line \fInumber\fP does not exist, the +terminal shall be alerted and the command line shall not be changed. +.TP 7 +\fB/\fP\fIpattern\fP<newline> +.sp +Move backwards through the command history, searching for the specified +pattern, beginning with the previous command line. Patterns +use the pattern matching notation described in \fIPattern Matching +Notation\fP , except +that the \fB'^'\fP character shall have special meaning when it appears +as the first character of \fIpattern\fP. In this case, +the \fB'^'\fP is discarded and the characters after the \fB'^'\fP +shall be matched only at the beginning of a line. Commands +in the command history shall be treated as strings, not as filenames. +If the pattern is not found, the current command line shall +be unchanged and the terminal is alerted. If it is found in a previous +line, the current command line shall be set to that line and +the cursor shall be set to the first character of the new command +line. +.LP +If \fIpattern\fP is empty, the last non-empty pattern provided to +\fB/\fP or \fB?\fP shall be used. If there is no previous +non-empty pattern, the terminal shall be alerted and the current command +line shall remain unchanged. +.TP 7 +\fB?\fP\fIpattern\fP<newline> +.sp +Move forwards through the command history, searching for the specified +pattern, beginning with the next command line. Patterns use +the pattern matching notation described in \fIPattern Matching Notation\fP +, except that +the \fB'^'\fP character shall have special meaning when it appears +as the first character of \fIpattern\fP. In this case, the +\fB'^'\fP is discarded and the characters after the \fB'^'\fP shall +be matched only at the beginning of a line. Commands in +the command history shall be treated as strings, not as filenames. +If the pattern is not found, the current command line shall be +unchanged and the terminal alerted. If it is found in a following +line, the current command line shall be set to that line and the +cursor shall be set to the fist character of the new command line. +.LP +If \fIpattern\fP is empty, the last non-empty pattern provided to +\fB/\fP or \fB?\fP shall be used. If there is no previous +non-empty pattern, the terminal shall be alerted and the current command +line shall remain unchanged. +.TP 7 +\fBn\fP +Repeat the most recent \fB/\fP or \fB?\fP command. If there is no +previous \fB/\fP or \fB?\fP, the terminal shall be +alerted and the current command line shall remain unchanged. +.TP 7 +\fBN\fP +Repeat the most recent \fB/\fP or \fB?\fP command, reversing the direction +of the search. If there is no previous \fB/\fP or +\fB?\fP, the terminal shall be alerted and the current command line +shall remain unchanged. +.sp +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ \ \ \ 0 +The script to be executed consisted solely of zero or more blank lines +or comments, or both. +.TP 7 +1-125 +A non-interactive shell detected a syntax, redirection, or variable +assignment error. +.TP 7 +\ \ 127 +A specified \fIcommand_file\fP could not be found by a non-interactive +shell. +.sp +.LP +Otherwise, the shell shall return the exit status of the last command +it invoked or attempted to invoke (see also the \fIexit\fP utility +in \fISpecial Built-In +Utilities\fP ). +.SH CONSEQUENCES OF ERRORS +.LP +See \fIConsequences of Shell Errors\fP . +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Standard input and standard error are the files that determine whether +a shell is interactive when \fB-i\fP is not specified. +For example: +.sp +.RS +.nf + +\fBsh > file +\fP +.fi +.RE +.LP +and: +.sp +.RS +.nf + +\fBsh 2> file +\fP +.fi +.RE +.LP +create interactive and non-interactive shells, respectively. Although +both accept terminal input, the results of error +conditions are different, as described in \fIConsequences of Shell +Errors\fP ; in the +second example a redirection error encountered by a special built-in +utility aborts the shell. +.LP +A conforming application must protect its first operand, if it starts +with a plus sign, by preceding it with the \fB"--"\fP +argument that denotes the end of the options. +.LP +Applications should note that the standard \fIPATH\fP to the shell +cannot be assumed to be either \fB/bin/sh\fP or +\fB/usr/bin/sh\fP, and should be determined by interrogation of the +\fIPATH\fP returned by \fIgetconf\fP \fIPATH ,\fP ensuring that the +returned pathname is an absolute pathname and not a +shell built-in. +.LP +For example, to determine the location of the standard \fIsh\fP utility: +.sp +.RS +.nf + +\fBcommand -v sh +\fP +.fi +.RE +.LP +On some implementations this might return: +.sp +.RS +.nf + +\fB/usr/xpg4/bin/sh +\fP +.fi +.RE +.LP +Furthermore, on systems that support executable scripts (the \fB"#!"\fP +construct), it is recommended that applications using +executable scripts install them using \fIgetconf\fP \fB-v\fP to determine +the shell +pathname and update the \fB"#!"\fP script appropriately as it is being +installed (for example, with \fIsed\fP). For example: +.sp +.RS +.nf + +\fB# +# Installation time script to install correct POSIX shell pathname +# +# Get list of paths to check +# +Sifs=$IFS +IFS=: +set $(getconf PATH) +IFS=$Sifs +# +# Check each path for 'sh' +# +for i in $@ +do + if [ -f ${i}/sh ]; + then + Pshell=${i}/sh + fi +done +# +# This is the list of scripts to update. They should be of the +# form '${name}.source' and will be transformed to '${name}'. +# Each script should begin: +# +# !INSTALLSHELLPATH -p +# +scripts="a b c" +# +# Transform each script +# +for i in ${scripts} +do + sed -e "s|INSTALLSHELLPATH|${Pshell}|" < ${i}.source > ${i} +done +\fP +.fi +.RE +.SH EXAMPLES +.IP " 1." 4 +Execute a shell command from a string: +.sp +.RS +.nf + +\fBsh -c "cat myfile" +\fP +.fi +.RE +.LP +.IP " 2." 4 +Execute a shell script from a file in the current directory: +.sp +.RS +.nf + +\fBsh my_shell_cmds +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fIsh\fP utility and the \fIset\fP special built-in utility share +a common +set of options. +.LP +The KornShell ignores the contents of \fIIFS\fP upon entry to the +script. A conforming application cannot rely on importing +\fIIFS .\fP One justification for this, beyond security considerations, +is to assist possible future shell compilers. Allowing +\fIIFS\fP to be imported from the environment prevents many optimizations +that might otherwise be performed via dataflow analysis +of the script itself. +.LP +The text in the STDIN section about non-blocking reads concerns an +instance of \fIsh\fP that has been invoked, probably by a +C-language program, with standard input that has been opened using +the O_NONBLOCK flag; see \fIopen\fP() in the System Interfaces volume +of IEEE\ Std\ 1003.1-2001. If the shell did not +reset this flag, it would immediately terminate because no input data +would be available yet and that would be considered the same +as end-of-file. +.LP +The options associated with a \fIrestricted shell\fP (command name +\fIrsh\fP and the \fB-r\fP option) were excluded because +the standard developers considered that the implied level of security +could not be achieved and they did not want to raise false +expectations. +.LP +On systems that support set-user-ID scripts, a historical trapdoor +has been to link a script to the name \fB-i\fP. When it is +called by a sequence such as: +.sp +.RS +.nf + +\fBsh - +\fP +.fi +.RE +.LP +or by: +.sp +.RS +.nf + +\fB#! usr/bin/sh - +\fP +.fi +.RE +.LP +the historical systems have assumed that no option letters follow. +Thus, this volume of IEEE\ Std\ 1003.1-2001 allows +the single hyphen to mark the end of the options, in addition to the +use of the regular \fB"--"\fP argument, because it was +considered that the older practice was so pervasive. An alternative +approach is taken by the KornShell, where real and effective +user/group IDs must match for an interactive shell; this behavior +is specifically allowed by this volume of +IEEE\ Std\ 1003.1-2001. +.TP 7 +\fBNote:\fP +There are other problems with set-user-ID scripts that the two approaches +described here do not resolve. +.sp +.LP +The initialization process for the history file can be dependent on +the system start-up files, in that they may contain commands +that effectively preempt the user's settings of \fIHISTFILE\fP and +\fIHISTSIZE .\fP For example, function definition commands are +recorded in the history file, unless the \fIset\fP \fB-o\fP \fInolog\fP +option is +set. If the system administrator includes function definitions in +some system start-up file called before the \fIENV\fP file, the +history file is initialized before the user gets a chance to influence +its characteristics. In some historical shells, the history +file is initialized just after the \fIENV\fP file has been processed. +Therefore, it is implementation-defined whether changes made +to \fIHISTFILE\fP after the history file has been initialized are +effective. +.LP +The default messages for the various \fIMAIL -related\fP messages +are unspecified because they vary across implementations. +Typical messages are: +.sp +.RS +.nf + +\fB"you have mail\\n" +\fP +.fi +.RE +.LP +or: +.sp +.RS +.nf + +\fB"you have new mail\\n" +\fP +.fi +.RE +.LP +It is important that the descriptions of command line editing refer +to the same shell as that in IEEE\ Std\ 1003.1-2001 +so that interactive users can also be application programmers without +having to deal with programmatic differences in their two +environments. It is also essential that the utility name \fIsh\fP +be specified because this explicit utility name is too firmly +rooted in historical practice of application programs for it to change. +.LP +Consideration was given to mandating a diagnostic message when attempting +to set \fIvi\fP-mode on terminals that do not support command line +editing. However, it is not historical +practice for the shell to be cognizant of all terminal types and thus +be able to detect inappropriate terminals in all cases. +Implementations are encouraged to supply diagnostics in this case +whenever possible, rather than leaving the user in a state where +editing commands work incorrectly. +.LP +In early proposals, the KornShell-derived \fIemacs\fP mode of command +line editing was included, even though the \fIemacs\fP +editor itself was not. The community of \fIemacs\fP proponents was +adamant that the full \fIemacs\fP editor not be standardized +because they were concerned that an attempt to standardize this very +powerful environment would encourage vendors to ship strictly +conforming versions lacking the extensibility required by the community. +The author of the original \fIemacs\fP program also +expressed his desire to omit the program. Furthermore, there were +a number of historical systems that did not include \fIemacs\fP, +or included it without supporting it, but there were very few that +did not include and support \fIvi\fP. The shell \fIemacs\fP command +line editing mode was finally omitted because it became +apparent that the KornShell version and the editor being distributed +with the GNU system had diverged in some respects. The author +of \fIemacs\fP requested that the POSIX \fIemacs\fP mode either be +deleted or have a significant number of unspecified +conditions. Although the KornShell author agreed to consider changes +to bring the shell into alignment, the standard developers +decided to defer specification at that time. At the time, it was assumed +that convergence on an acceptable definition would occur +for a subsequent draft, but that has not happened, and there appears +to be no impetus to do so. In any case, implementations are +free to offer additional command line editing modes based on the exact +models of editors their users are most comfortable with. +.LP +Early proposals had the following list entry in vi Line Editing Insert +Mode : +.TP 7 +\fB\\\fP +If followed by the \fIerase\fP or \fIkill\fP character, that character +shall be inserted into the input line. Otherwise, the +backslash itself shall be inserted into the input line. +.sp +.LP +However, this is not actually a feature of \fIsh\fP command line editing +insert mode, but one of some historical terminal line +drivers. Some conforming implementations continue to do this when +the \fIstty\fP +\fBiexten\fP flag is set. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIcd\fP , \fIecho\fP , \fIexit\fP() +, \fIfc\fP , \fIpwd\fP , \fIread\fP() , \fIset\fP , \fIstty\fP , \fItest\fP +, \fIumask\fP() , \fIvi\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIdup\fP(), \fIexec\fP, \fIexit\fP(), \fIfork\fP(), \fIopen\fP(), +\fIpipe\fP(), \fIsignal\fP(), \fIsystem\fP(), \fIulimit\fP(), \fIumask\fP(), +\fIwait\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/shift.1p b/man1p/shift.1p new file mode 100644 index 000000000..b680847a9 --- /dev/null +++ b/man1p/shift.1p @@ -0,0 +1,93 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SHIFT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" shift +.SH NAME +shift \- shift positional parameters +.SH SYNOPSIS +.LP +\fBshift\fP \fB[\fP\fIn\fP\fB]\fP +.SH DESCRIPTION +.LP +The positional parameters shall be shifted. Positional parameter 1 +shall be assigned the value of parameter (1+\fIn\fP), +parameter 2 shall be assigned the value of parameter (2+\fIn\fP), +and so on. The parameters represented by the numbers +\fB"$#"\fP down to \fB"$#-n+1"\fP shall be unset, and the parameter +\fB'#'\fP is updated to reflect the new number of +positional parameters. +.LP +The value \fIn\fP shall be an unsigned decimal integer less than or +equal to the value of the special parameter \fB'#'\fP . +If \fIn\fP is not given, it shall be assumed to be 1. If \fIn\fP is +0, the positional and special parameters are not changed. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The exit status is >0 if \fIn\fP>$#; otherwise, it is zero. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fB$\fP \fBset a b c d e +\fP\fB$\fP \fBshift 2 +\fP\fB$\fP \fBecho $* +\fP\fBc d e\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/sleep.1p b/man1p/sleep.1p new file mode 100644 index 000000000..b729909c0 --- /dev/null +++ b/man1p/sleep.1p @@ -0,0 +1,173 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SLEEP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" sleep +.SH NAME +sleep \- suspend execution for an interval +.SH SYNOPSIS +.LP +\fBsleep\fP \fItime\fP +.SH DESCRIPTION +.LP +The \fIsleep\fP utility shall suspend execution for at least the integral +number of seconds specified by the \fItime\fP +operand. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fItime\fP +A non-negative decimal integer specifying the number of seconds for +which to suspend execution. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIsleep\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +If the \fIsleep\fP utility receives a SIGALRM signal, one of the following +actions shall be taken: +.IP " 1." 4 +Terminate normally with a zero exit status. +.LP +.IP " 2." 4 +Effectively ignore the signal. +.LP +.IP " 3." 4 +Provide the default behavior for signals described in the ASYNCHRONOUS +EVENTS section of \fIUtility Description Defaults\fP . This could +include terminating with a non-zero exit +status. +.LP +.LP +The \fIsleep\fP utility shall take the standard action for all other +signals. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The execution was successfully suspended for at least \fItime\fP seconds, +or a SIGALRM signal was received. See the +ASYNCHRONOUS EVENTS section. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +The \fIsleep\fP utility can be used to execute a command after a certain +amount of time, as in: +.sp +.RS +.nf + +\fB(sleep 105;\fP \fIcommand\fP\fB) & +\fP +.fi +.RE +.LP +or to execute a command every so often, as in: +.sp +.RS +.nf + +\fBwhile true +do + \fP \fIcommand\fP \fB sleep 37 +done +\fP +.fi +.RE +.SH RATIONALE +.LP +The exit status is allowed to be zero when \fIsleep\fP is interrupted +by the SIGALRM signal because most implementations of +this utility rely on the arrival of that signal to notify them that +the requested finishing time has been successfully attained. +Such implementations thus do not distinguish this situation from the +successful completion case. Other implementations are allowed +to catch the signal and go back to sleep until the requested time +expires or to provide the normal signal termination +procedures. +.LP +As with all other utilities that take integral operands and do not +specify subranges of allowed values, \fIsleep\fP is required +by this volume of IEEE\ Std\ 1003.1-2001 to deal with \fItime\fP requests +of up to 2147483647 seconds. This may mean that +some implementations have to make multiple calls to the delay mechanism +of the underlying operating system if its argument range is +less than this. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIwait\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIalarm\fP(), \fIsleep\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/sort.1p b/man1p/sort.1p new file mode 100644 index 000000000..3714cceaf --- /dev/null +++ b/man1p/sort.1p @@ -0,0 +1,512 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SORT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" sort +.SH NAME +sort \- sort, merge, or sequence check text files +.SH SYNOPSIS +.LP +\fBsort\fP \fB[\fP\fB-m\fP\fB][\fP\fB-o\fP \fIoutput\fP\fB][\fP\fB-bdfinru\fP\fB][\fP\fB-t\fP +\fIchar\fP\fB][\fP\fB-k\fP \fIkeydef\fP\fB]\fP\fB...\fP \fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB +.br +.sp +sort -c\fP \fB[\fP\fB-bdfinru\fP\fB][\fP\fB-t\fP \fIchar\fP\fB][\fP\fB-k\fP +\fIkeydef\fP\fB][\fP\fIfile\fP\fB]\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIsort\fP utility shall perform one of the following functions: +.IP " 1." 4 +Sort lines of all the named files together and write the result to +the specified output. +.LP +.IP " 2." 4 +Merge lines of all the named (presorted) files together and write +the result to the specified output. +.LP +.IP " 3." 4 +Check that a single input file is correctly presorted. +.LP +.LP +Comparisons shall be based on one or more sort keys extracted from +each line of input (or, if no sort keys are specified, the +entire line up to, but not including, the terminating <newline>), +and shall be performed using the collating sequence of the +current locale. +.SH OPTIONS +.LP +The \fIsort\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +and the \fB-k\fP \fIkeydef\fP option should +follow the \fB-b\fP, \fB-d\fP, \fB-f\fP, \fB-i\fP, \fB-n\fP, and \fB-r\fP +options. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Check that the single input file is ordered as specified by the arguments +and the collating sequence of the current locale. No +output shall be produced; only the exit code shall be affected. +.TP 7 +\fB-m\fP +Merge only; the input file shall be assumed to be already sorted. +.TP 7 +\fB-o\ \fP \fIoutput\fP +Specify the name of an output file to be used instead of the standard +output. This file can be the same as one of the input +\fIfile\fPs. +.TP 7 +\fB-u\fP +Unique: suppress all but one in each set of lines having equal keys. +If used with the \fB-c\fP option, check that there are no +lines with duplicate keys, in addition to checking that the input +file is sorted. +.sp +.LP +The following options shall override the default ordering rules. When +ordering options appear independent of any key field +specifications, the requested field ordering rules shall be applied +globally to all sort keys. When attached to a specific key (see +\fB-k\fP), the specified ordering options shall override all global +ordering options for that key. +.TP 7 +\fB-d\fP +Specify that only <blank>s and alphanumeric characters, according +to the current setting of \fILC_CTYPE ,\fP shall be +significant in comparisons. The behavior is undefined for a sort key +to which \fB-i\fP or \fB-n\fP also applies. +.TP 7 +\fB-f\fP +Consider all lowercase characters that have uppercase equivalents, +according to the current setting of \fILC_CTYPE ,\fP to be +the uppercase equivalent for the purposes of comparison. +.TP 7 +\fB-i\fP +Ignore all characters that are non-printable, according to the current +setting of \fILC_CTYPE .\fP +.TP 7 +\fB-n\fP +Restrict the sort key to an initial numeric string, consisting of +optional <blank>s, optional minus sign, and zero or +more digits with an optional radix character and thousands separators +(as defined in the current locale), which shall be sorted by +arithmetic value. An empty digit string shall be treated as zero. +Leading zeros and signs on zeros shall not affect ordering. +.TP 7 +\fB-r\fP +Reverse the sense of comparisons. +.sp +.LP +The treatment of field separators can be altered using the options: +.TP 7 +\fB-b\fP +Ignore leading <blank>s when determining the starting and ending positions +of a restricted sort key. If the \fB-b\fP +option is specified before the first \fB-k\fP option, it shall be +applied to all \fB-k\fP options. Otherwise, the \fB-b\fP +option can be attached independently to each \fB-k\fP \fIfield_start\fP +or \fIfield_end\fP option-argument (see below). +.TP 7 +\fB-t\ \fP \fIchar\fP +Use \fIchar\fP as the field separator character; \fIchar\fP shall +not be considered to be part of a field (although it can be +included in a sort key). Each occurrence of \fIchar\fP shall be significant +(for example, <\fIchar\fP><\fIchar\fP> +delimits an empty field). If \fB-t\fP is not specified, <blank>s shall +be used as default field separators; each maximal +non-empty sequence of <blank>s that follows a non- <blank> shall be +a field separator. +.sp +.LP +Sort keys can be specified using the options: +.TP 7 +\fB-k\ \fP \fIkeydef\fP +The \fIkeydef\fP argument is a restricted sort key field definition. +The format of this definition is: +.sp +.RS +.nf + +\fIfield_start\fP\fB[\fP\fItype\fP\fB][\fP\fB,\fP\fIfield_end\fP\fB[\fP\fItype\fP\fB]]\fP +.fi +.RE +.LP +where \fIfield_start\fP and \fIfield_end\fP define a key field restricted +to a portion of the line (see the EXTENDED +DESCRIPTION section), and \fItype\fP is a modifier from the list of +characters \fB'b'\fP , \fB'd'\fP , \fB'f'\fP , +\fB'i'\fP , \fB'n'\fP , \fB'r'\fP . The \fB'b'\fP modifier shall behave +like the \fB-b\fP option, but shall apply only +to the \fIfield_start\fP or \fIfield_end\fP to which it is attached. +The other modifiers shall behave like the corresponding +options, but shall apply only to the key field to which they are attached; +they shall have this effect if specified with +\fIfield_start\fP, \fIfield_end\fP, or both. If any modifier is attached +to a \fIfield_start\fP or to a \fIfield_end\fP, no +option shall apply to either. Implementations shall support at least +nine occurrences of the \fB-k\fP option, which shall be +significant in command line order. If no \fB-k\fP option is specified, +a default sort key of the entire line shall be used. +.LP +When there are multiple key fields, later keys shall be compared only +after all earlier keys compare equal. Except when the +\fB-u\fP option is specified, lines that otherwise compare equal shall +be ordered as if none of the options \fB-d\fP, \fB-f\fP, +\fB-i\fP, \fB-n\fP, or \fB-k\fP were present (but with \fB-r\fP still +in effect, if it was specified) and with all bytes in the +lines significant to the comparison. The order in which lines that +still compare equal are written is unspecified. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to be sorted, merged, or checked. If no \fIfile\fP +operands are specified, or if a \fIfile\fP operand is +\fB'-'\fP , the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP . +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files, except that the \fIsort\fP utility +shall add a <newline> to the end of a file ending +with an incomplete last line. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIsort\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for ordering rules. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classification for the \fB-b\fP, +\fB-d\fP, \fB-f\fP, \fB-i\fP, and \fB-n\fP options. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_NUMERIC\fP +.sp +Determine the locale for the definition of the radix character and +thousands separator for the \fB-n\fP option. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Unless the \fB-o\fP or \fB-c\fP options are in effect, the standard +output shall contain the sorted input. +.SH STDERR +.LP +The standard error shall be used for diagnostic messages. A warning +message about correcting an incomplete last line of an input +file may be generated, but need not affect the final exit status. +.SH OUTPUT FILES +.LP +If the \fB-o\fP option is in effect, the sorted input shall be written +to the file \fIoutput\fP. +.SH EXTENDED DESCRIPTION +.LP +The notation: +.sp +.RS +.nf + +\fB-k\fP \fIfield_start\fP\fB[\fP\fItype\fP\fB][\fP\fB,\fP\fIfield_end\fP\fB[\fP\fItype\fP\fB]]\fP +.fi +.RE +.LP +shall define a key field that begins at \fIfield_start\fP and ends +at \fIfield_end\fP inclusive, unless \fIfield_start\fP +falls beyond the end of the line or after \fIfield_end\fP, in which +case the key field is empty. A missing \fIfield_end\fP shall +mean the last character of the line. +.LP +A field comprises a maximal sequence of non-separating characters +and, in the absence of option \fB-t\fP, any preceding field +separator. +.LP +The \fIfield_start\fP portion of the \fIkeydef\fP option-argument +shall have the form: +.sp +.RS +.nf + +\fIfield_number\fP\fB[\fP\fB.\fP\fIfirst_character\fP\fB]\fP +.fi +.RE +.LP +Fields and characters within fields shall be numbered starting with +1. The \fIfield_number\fP and \fIfirst_character\fP +pieces, interpreted as positive decimal integers, shall specify the +first character to be used as part of a sort key. If +\fI\&.first_character\fP is omitted, it shall refer to the first character +of the field. +.LP +The \fIfield_end\fP portion of the \fIkeydef\fP option-argument shall +have the form: +.sp +.RS +.nf + +\fIfield_number\fP\fB[\fP\fB.\fP\fIlast_character\fP\fB]\fP +.fi +.RE +.LP +The \fIfield_number\fP shall be as described above for \fIfield_start.\fP +The \fIlast_character\fP piece, interpreted as a +non-negative decimal integer, shall specify the last character to +be used as part of the sort key. If \fIlast_character\fP +evaluates to zero or \fI.last_character\fP is omitted, it shall refer +to the last character of the field specified by +\fIfield_number\fP. +.LP +If the \fB-b\fP option or \fBb\fP type modifier is in effect, characters +within a field shall be counted from the first non- +<blank> in the field. (This shall apply separately to \fIfirst_character\fP +and \fIlast_character\fP.) +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input files were output successfully, or \fB-c\fP was specified +and the input file was correctly sorted. +.TP 7 +\ 1 +Under the \fB-c\fP option, the file was not ordered as specified, +or if the \fB-c\fP and \fB-u\fP options were both +specified, two input lines were found with equal keys. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The default value for \fB-t\fP, <blank>, has different properties +from, for example, \fB-t\fP "<space>". If a line +contains: +.sp +.RS +.nf + +\fB<space><space>foo +\fP +.fi +.RE +.LP +the following treatment would occur with default separation as opposed +to specifically selecting a <space>: +.TS C +center; l l l. +\fBField\fP \fBDefault\fP \fB-t "<space>"\fP +1 <space><space>foo \fIempty\fP +2 \fIempty\fP \fIempty\fP +3 \fIempty\fP foo +.TE +.LP +The leading field separator itself is included in a field when \fB-t\fP +is not used. For example, this command returns an exit +status of zero, meaning the input was already sorted: +.sp +.RS +.nf + +\fBsort -c -k 2 <<eof +y<tab>b +x<space>a +eof +\fP +.fi +.RE +.LP +(assuming that a <tab> precedes the <space> in the current collating +sequence). The field separator is not included +in a field when it is explicitly set via \fB-t\fP. This is historical +practice and allows usage such as: +.sp +.RS +.nf + +\fBsort -t "|" -k 2n <<eof +Atlanta|425022|Georgia +Birmingham|284413|Alabama +Columbia|100385|South Carolina +eof +\fP +.fi +.RE +.LP +where the second field can be correctly sorted numerically without +regard to the non-numeric field separator. +.LP +The wording in the OPTIONS section clarifies that the \fB-b\fP, \fB-d\fP, +\fB-f\fP, \fB-i\fP, \fB-n\fP, and \fB-r\fP +options have to come before the first sort key specified if they are +intended to apply to all specified keys. The way it is +described in this volume of IEEE\ Std\ 1003.1-2001 matches historical +practice, not historical documentation. The results +are unspecified if these options are specified after a \fB-k\fP option. +.LP +The \fB-f\fP option might not work as expected in locales where there +is not a one-to-one mapping between an uppercase and a +lowercase letter. +.SH EXAMPLES +.IP " 1." 4 +The following command sorts the contents of \fBinfile\fP with the +second field as the sort key: +.sp +.RS +.nf + +\fBsort -k 2,2 infile +\fP +.fi +.RE +.LP +.IP " 2." 4 +The following command sorts, in reverse order, the contents of \fBinfile1\fP +and \fBinfile2\fP, placing the output in +\fBoutfile\fP and using the second character of the second field as +the sort key (assuming that the first character of the second +field is the field separator): +.sp +.RS +.nf + +\fBsort -r -o outfile -k 2.2,2.2 infile1 infile2 +\fP +.fi +.RE +.LP +.IP " 3." 4 +The following command sorts the contents of \fBinfile1\fP and \fBinfile2\fP +using the second non- <blank> of the second +field as the sort key: +.sp +.RS +.nf + +\fBsort -k 2.2b,2.2b infile1 infile2 +\fP +.fi +.RE +.LP +.IP " 4." 4 +The following command prints the System\ V password file (user database) +sorted by the numeric user ID (the third +colon-separated field): +.sp +.RS +.nf + +\fBsort -t : -k 3,3n /etc/passwd +\fP +.fi +.RE +.LP +.IP " 5." 4 +The following command prints the lines of the already sorted file +\fBinfile\fP, suppressing all but one occurrence of lines +having the same third field: +.sp +.RS +.nf + +\fBsort -um -k 3.1,3.0 infile +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +Examples in some historical documentation state that options \fB-um\fP +with one input file keep the first in each set of lines +with equal keys. This behavior was deemed to be an implementation +artifact and was not standardized. +.LP +The \fB-z\fP option was omitted; it is not standard practice on most +systems and is inconsistent with using \fIsort\fP to sort +several files individually and then merge them together. The text +concerning \fB-z\fP in historical documentation appeared to +require implementations to determine the proper buffer length during +the sort phase of operation, but not during the merge. +.LP +The \fB-y\fP option was omitted because of non-portability. The \fB-M\fP +option, present in System V, was omitted because of +non-portability in international usage. +.LP +An undocumented \fB-T\fP option exists in some implementations. It +is used to specify a directory for intermediate files. +Implementations are encouraged to support the use of the \fITMPDIR\fP +environment variable instead of adding an option to support +this functionality. +.LP +The \fB-k\fP option was added to satisfy two objections. First, the +zero-based counting used by \fIsort\fP is not consistent +with other utility conventions. Second, it did not meet syntax guideline +requirements. +.LP +Historical documentation indicates that "setting \fB-n\fP implies +\fB-b\fP". The description of \fB-n\fP already states +that optional leading <blank>s are tolerated in doing the comparison. +If \fB-b\fP is enabled, rather than implied, by +\fB-n\fP, this has unusual side effects. When a character offset is +used in a column of numbers (for example, to sort modulo 100), +that offset is measured relative to the most significant digit, not +to the column. Based upon a recommendation from the author of +the original \fIsort\fP utility, the \fB-b\fP implication has been +omitted from this volume of IEEE\ Std\ 1003.1-2001, +and an application wishing to achieve the previously mentioned side +effects has to code the \fB-b\fP flag explicitly. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcomm\fP , \fIjoin\fP , \fIuniq\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fItoupper\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/split.1p b/man1p/split.1p new file mode 100644 index 000000000..ac9fe5538 --- /dev/null +++ b/man1p/split.1p @@ -0,0 +1,258 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "SPLIT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" split +.SH NAME +split \- split files into pieces +.SH SYNOPSIS +.LP +\fBsplit\fP \fB[\fP\fB-l\fP \fIline_count\fP\fB][\fP\fB-a\fP +\fIsuffix_length\fP\fB][\fP\fIfile\fP\fB[\fP\fIname\fP\fB]]\fP\fB +.br +.sp +split -b\fP \fIn\fP\fB[\fP\fBk|m\fP\fB][\fP\fB-a\fP +\fIsuffix_length\fP\fB][\fP\fIfile\fP\fB[\fP\fIname\fP\fB]]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIsplit\fP utility shall read an input file and write one or +more output files. The default size of each output file shall +be 1000 lines. The size of the output files can be modified by specification +of the \fB-b\fP or \fB-l\fP options. Each output +file shall be created with a unique suffix. The suffix shall consist +of exactly \fIsuffix_length\fP lowercase letters from the +POSIX locale. The letters of the suffix shall be used as if they were +a base-26 digit system, with the first suffix to be created +consisting of all \fB'a'\fP characters, the second with a \fB'b'\fP +replacing the last \fB'a'\fP , and so on, until a name +of all \fB'z'\fP characters is created. By default, the names of the +output files shall be \fB'x'\fP , followed by a +two-character suffix from the character set as described above, starting +with \fB"aa"\fP , \fB"ab"\fP , \fB"ac"\fP , and +so on, and continuing until the suffix \fB"zz"\fP , for a maximum +of 676 files. +.LP +If the number of files required exceeds the maximum allowed by the +suffix length provided, such that the last allowable file +would be larger than the requested size, the \fIsplit\fP utility shall +fail after creating the last file with a valid suffix; +\fIsplit\fP shall not delete the files it created with valid suffixes. +If the file limit is not exceeded, the last file created +shall contain the remainder of the input file, and may be smaller +than the requested size. +.SH OPTIONS +.LP +The \fIsplit\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\ \fP \fIsuffix_length\fP +.sp +Use \fIsuffix_length\fP letters to form the suffix portion of the +filenames of the split file. If \fB-a\fP is not specified, the +default suffix length shall be two. If the sum of the \fIname\fP operand +and the \fIsuffix_length\fP option-argument would create +a filename exceeding {NAME_MAX} bytes, an error shall result; \fIsplit\fP +shall exit with a diagnostic message and no files shall +be created. +.TP 7 +\fB-b\ \fP \fIn\fP +Split a file into pieces \fIn\fP bytes in size. +.TP 7 +\fB-b\ \fP \fIn\fP\fBk\fP +Split a file into pieces \fIn\fP*1024 bytes in size. +.TP 7 +\fB-b\ \fP \fIn\fP\fBm\fP +Split a file into pieces \fIn\fP*1048576 bytes in size. +.TP 7 +\fB-l\ \fP \fIline_count\fP +Specify the number of lines in each resulting file piece. The \fIline_count\fP +argument is an unsigned decimal integer. The +default is 1000. If the input does not end with a <newline>, the partial +line shall be included in the last output file. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +The pathname of the ordinary file to be split. If no input file is +given or \fIfile\fP is \fB'-'\fP , the standard input +shall be used. +.TP 7 +\fIname\fP +The prefix to be used for each of the files resulting from the split +operation. If no \fIname\fP argument is given, +\fB'x'\fP shall be used as the prefix of the output files. The combined +length of the basename of \fIprefix\fP and +\fIsuffix_length\fP cannot exceed {NAME_MAX} bytes. See the OPTIONS +section. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +Any file can be used as input. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIsplit\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output files contain portions of the original input file; otherwise, +unchanged. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +In the following examples \fBfoo\fP is a text file that contains 5000 +lines. +.IP " 1." 4 +Create five files, \fBxaa\fP, \fBxab\fP, \fBxac\fP, \fBxad\fP, and +\fBxae\fP: +.sp +.RS +.nf + +\fBsplit foo +\fP +.fi +.RE +.LP +.IP " 2." 4 +Create five files, but the suffixed portion of the created files consists +of three letters, \fBxaaa\fP, \fBxaab\fP, +\fBxaac\fP, \fBxaad\fP, and \fBxaae\fP: +.sp +.RS +.nf + +\fBsplit -a 3 foo +\fP +.fi +.RE +.LP +.IP " 3." 4 +Create three files with four-letter suffixes and a supplied prefix, +\fBbar_aaaa\fP, \fBbar_aaab\fP, and \fBbar_aaac\fP: +.sp +.RS +.nf + +\fBsplit -a 4 -l 2000 foo bar_ +\fP +.fi +.RE +.LP +.IP " 4." 4 +Create as many files as are necessary to contain at most 20*1024 bytes, +each with the default prefix of \fBx\fP and a +five-letter suffix: +.sp +.RS +.nf + +\fBsplit -a 5 -b 20k foo +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fB-b\fP option was added to provide a mechanism for splitting +files other than by lines. While most uses of the \fB-b\fP +option are for transmitting files over networks, some believed it +would have additional uses. +.LP +The \fB-a\fP option was added to overcome the limitation of being +able to create only 676 files. +.LP +Consideration was given to deleting this utility, using the rationale +that the functionality provided by this utility is +available via the \fIcsplit\fP utility (see \fIcsplit\fP ). Upon +reconsideration of the purpose of the User Portability Extension, +it was decided to retain both this utility and the \fIcsplit\fP utility +because users use both utilities and have historical expectations +of their +behavior. Furthermore, the splitting on byte boundaries in \fIsplit\fP +cannot be duplicated with the historical \fIcsplit\fP. +.LP +The text " \fIsplit\fP shall not delete the files it created with +valid suffixes" would normally be assumed, but since the +related utility, \fIcsplit\fP, does delete files under some circumstances, +the historical +behavior of \fIsplit\fP is made explicit to avoid misinterpretation. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcsplit\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/strings.1p b/man1p/strings.1p new file mode 100644 index 000000000..9a93a1e18 --- /dev/null +++ b/man1p/strings.1p @@ -0,0 +1,222 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "STRINGS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" strings +.SH NAME +strings \- find printable strings in files +.SH SYNOPSIS +.LP +\fBstrings\fP \fB[\fP\fB-a\fP\fB][\fP\fB-t\fP \fIformat\fP\fB][\fP\fB-n\fP +\fInumber\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIstrings\fP utility shall look for printable strings in regular +files and shall write those strings to standard output. A +printable string is any sequence of four (by default) or more printable +characters terminated by a <newline> or NUL +character. Additional implementation-defined strings may be written; +see \fIlocaledef\fP. +.SH OPTIONS +.LP +The \fIstrings\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Scan files in their entirety. If \fB-a\fP is not specified, it is +implementation-defined what portion of each file is scanned +for strings. +.TP 7 +\fB-n\ \fP \fInumber\fP +Specify the minimum string length, where the \fInumber\fP argument +is a positive decimal integer. The default shall be 4. +.TP 7 +\fB-t\ \fP \fIformat\fP +Write each string preceded by its byte offset from the start of the +file. The format shall be dependent on the single character +used as the \fIformat\fP option-argument: +.TP 7 +\fBd\fP +.RS +The offset shall be written in decimal. +.RE +.TP 7 +\fBo\fP +.RS +The offset shall be written in octal. +.RE +.TP 7 +\fBx\fP +.RS +The offset shall be written in hexadecimal. +.RE +.sp +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a regular file to be used as input. If no \fIfile\fP +operand is specified, the \fIstrings\fP utility shall read +from the standard input. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files named by the utility arguments or the standard input +shall be regular files of any format. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIstrings\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +to identify printable strings. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Strings found shall be written to the standard output, one per line. +.LP +When the \fB-t\fP option is not specified, the format of the output +shall be: +.sp +.RS +.nf + +\fB"%s", <\fP\fIstring\fP\fB> +\fP +.fi +.RE +.LP +With the \fB-t\ o\fP option, the format of the output shall be: +.sp +.RS +.nf + +\fB"%o %s", <\fP\fIbyte offset\fP\fB>, <\fP\fIstring\fP\fB> +\fP +.fi +.RE +.LP +With the \fB-t\ x\fP option, the format of the output shall be: +.sp +.RS +.nf + +\fB"%x %s", <\fP\fIbyte offset\fP\fB>, <\fP\fIstring\fP\fB> +\fP +.fi +.RE +.LP +With the \fB-t\ d\fP option, the format of the output shall be: +.sp +.RS +.nf + +\fB"%d %s", <\fP\fIbyte offset\fP\fB>, <\fP\fIstring\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +By default the data area (as opposed to the text, "bss", or header +areas) of a binary executable file is scanned. +Implementations document which areas are scanned. +.LP +Some historical implementations do not require NUL or <newline> terminators +for strings to permit those languages that do +not use NUL as a string terminator to have their strings written. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Apart from rationalizing the option syntax and slight difficulties +with object and executable binary files, \fIstrings\fP is +specified to match historical practice closely. The \fB-a\fP and \fB-n\fP +options were introduced to replace the non-conforming +\fB-\fP and \fB-\fP \fInumber\fP options. +.LP +The \fB-o\fP option historically means different things on different +implementations. Some use it to mean " \fIoffset\fP in +decimal", while others use it as " \fIoffset\fP in octal". Instead +of trying to decide which way would be least objectionable, +the \fB-t\fP option was added. It was originally named \fB-O\fP to +mean "offset", but was changed to \fB-t\fP to be consistent +with \fIod\fP. +.LP +The ISO\ C standard function \fIisprint\fP() is restricted to a domain +of +\fBunsigned char\fP. This volume of IEEE\ Std\ 1003.1-2001 requires +implementations to write strings as defined by the +current locale. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIlocaledef\fP , \fInm\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/strip.1p b/man1p/strip.1p new file mode 100644 index 000000000..afef7bd8f --- /dev/null +++ b/man1p/strip.1p @@ -0,0 +1,128 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "STRIP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" strip +.SH NAME +strip \- remove unnecessary information from executable files (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBstrip\fP \fIfile\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIstrip\fP utility shall remove from executable files named by +the \fIfile\fP operands any information the implementor +deems unnecessary for execution of those files. The nature of that +information is unspecified. The effect of \fIstrip\fP shall be +similar to the use of the \fB-s\fP option to \fIc99\fP or \fIfort77\fP. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname referring to an executable file. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The input files shall be in the form of executable files successfully +produced by any compiler defined by this volume of +IEEE\ Std\ 1003.1-2001. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIstrip\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The \fIstrip\fP utility shall produce executable files of unspecified +format. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Historically, this utility has been used to remove the symbol table +from an executable file. It was included since it is known +that the amount of symbolic information can amount to several megabytes; +the ability to remove it in a portable manner was deemed +important, especially for smaller systems. +.LP +The behavior of \fIstrip\fP is said to be the same as the \fB-s\fP +option to a compiler. While the end result is essentially +the same, it is not required to be identical. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIar\fP , \fIc99\fP , \fIfort77\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/stty.1p b/man1p/stty.1p new file mode 100644 index 000000000..8493c8934 --- /dev/null +++ b/man1p/stty.1p @@ -0,0 +1,697 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "STTY" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" stty +.SH NAME +stty \- set the options for a terminal +.SH SYNOPSIS +.LP +\fBstty\fP \fB[\fP \fB-a| -g\fP\fB]\fP\fB +.br +.sp +stty\fP \fIoperands\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIstty\fP utility shall set or report on terminal I/O characteristics +for the device that is its standard input. Without +options or operands specified, it shall report the settings of certain +characteristics, usually those that differ from +implementation-defined defaults. Otherwise, it shall modify the terminal +state according to the specified operands. Detailed +information about the modes listed in the first five groups below +are described in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. Operands +in the Combination Modes group (see Combination Modes ) are implemented +using operands in the +previous groups. Some combinations of operands are mutually-exclusive +on some terminal types; the results of using such +combinations are unspecified. +.LP +Typical implementations of this utility require a communications line +configured to use the \fBtermios\fP interface defined in +the System Interfaces volume of IEEE\ Std\ 1003.1-2001. On systems +where none of these lines are available, and on lines +not currently configured to support the \fBtermios\fP interface, some +of the operands need not affect terminal +characteristics. +.SH OPTIONS +.LP +The \fIstty\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Write to standard output all the current settings for the terminal. +.TP 7 +\fB-g\fP +Write to standard output all the current settings in an unspecified +form that can be used as arguments to another invocation of +the \fIstty\fP utility on the same system. The form used shall not +contain any characters that would require quoting to avoid word +expansion by the shell; see \fIWord Expansions\fP . +.sp +.SH OPERANDS +.LP +The following operands shall be supported to set the terminal characteristics. +.SS Control Modes +.TP 7 +\fBparenb\ \fP (\fB-parenb\fP) +Enable (disable) parity generation and detection. This shall have +the effect of setting (not setting) PARENB in the +\fBtermios\fP \fIc_cflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBparodd\ \fP (\fB-parodd\fP) +.sp +Select odd (even) parity. This shall have the effect of setting (not +setting) PARODD in the \fBtermios\fP \fIc_cflag\fP field, as +defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, +General Terminal Interface. +.TP 7 +\fBcs5\ cs6\ cs7\ cs8\fP +Select character size, if possible. This shall have the effect of +setting CS5, CS6, CS7, and CS8, respectively, in the +\fBtermios\fP \fIc_cflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fInumber\fP +Set terminal baud rate to the number given, if possible. If the baud +rate is set to zero, the modem control lines shall no +longer be asserted. This shall have the effect of setting the input +and output \fBtermios\fP baud rate values as defined in the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General +Terminal Interface. +.TP 7 +\fBispeed\ \fP \fInumber\fP +Set terminal input baud rate to the number given, if possible. If +the input baud rate is set to zero, the input baud rate shall +be specified by the value of the output baud rate. This shall have +the effect of setting the input \fBtermios\fP baud rate values +as defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter +11, General Terminal Interface. +.TP 7 +\fBospeed\ \fP \fInumber\fP +Set terminal output baud rate to the number given, if possible. If +the output baud rate is set to zero, the modem control lines +shall no longer be asserted. This shall have the effect of setting +the output \fBtermios\fP baud rate values as defined in the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General +Terminal Interface. +.TP 7 +\fBhupcl\ \fP (\fB-hupcl\fP) +Stop asserting modem control lines (do not stop asserting modem control +lines) on last close. This shall have the effect of +setting (not setting) HUPCL in the \fBtermios\fP \fIc_cflag\fP field, +as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBhup\ \fP (\fB-hup\fP) +Equivalent to \fBhupcl\fP( \fB-hupcl\fP). +.TP 7 +\fBcstopb\ \fP (\fB-cstopb\fP) +Use two (one) stop bits per character. This shall have the effect +of setting (not setting) CSTOPB in the \fBtermios\fP +\fIc_cflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBcread\ \fP (\fB-cread\fP) +Enable (disable) the receiver. This shall have the effect of setting +(not setting) CREAD in the \fBtermios\fP \fIc_cflag\fP +field, as defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, General Terminal Interface. +.TP 7 +\fBclocal\ \fP (\fB-clocal\fP) +Assume a line without (with) modem control. This shall have the effect +of setting (not setting) CLOCAL in the \fBtermios\fP +\fIc_cflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.sp +.LP +It is unspecified whether \fIstty\fP shall report an error if an attempt +to set a Control Mode fails. +.SS Input Modes +.TP 7 +\fBignbrk\ \fP (\fB-ignbrk\fP) +Ignore (do not ignore) break on input. This shall have the effect +of setting (not setting) IGNBRK in the \fBtermios\fP +\fIc_iflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBbrkint\ \fP (\fB-brkint\fP) +Signal (do not signal) INTR on break. This shall have the effect of +setting (not setting) BRKINT in the \fBtermios\fP +\fIc_iflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBignpar\ \fP (\fB-ignpar\fP) +Ignore (do not ignore) bytes with parity errors. This shall have the +effect of setting (not setting) IGNPAR in the +\fBtermios\fP \fIc_iflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBparmrk\ \fP (\fB-parmrk\fP) +.sp +Mark (do not mark) parity errors. This shall have the effect of setting +(not setting) PARMRK in the \fBtermios\fP \fIc_iflag\fP +field, as defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, General Terminal Interface. +.TP 7 +\fBinpck\ \fP (\fB-inpck\fP) +Enable (disable) input parity checking. This shall have the effect +of setting (not setting) INPCK in the \fBtermios\fP +\fIc_iflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBistrip\ \fP (\fB-istrip\fP) +Strip (do not strip) input characters to seven bits. This shall have +the effect of setting (not setting) ISTRIP in the +\fBtermios\fP \fIc_iflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBinlcr\ \fP (\fB-inlcr\fP) +Map (do not map) NL to CR on input. This shall have the effect of +setting (not setting) INLCR in the \fBtermios\fP +\fIc_iflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBigncr\ (-igncr)\fP +Ignore (do not ignore) CR on input. This shall have the effect of +setting (not setting) IGNCR in the \fBtermios\fP +\fIc_iflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBicrnl\ \fP (\fB-icrnl\fP) +Map (do not map) CR to NL on input. This shall have the effect of +setting (not setting) ICRNL in the \fBtermios\fP +\fIc_iflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBixon\ \fP (\fB-ixon\fP) +Enable (disable) START/STOP output control. Output from the system +is stopped when the system receives STOP and started when +the system receives START. This shall have the effect of setting (not +setting) IXON in the \fBtermios\fP \fIc_iflag\fP field, as +defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, +General Terminal Interface. +.TP 7 +\fBixany\ \fP (\fB-ixany\fP) +Allow any character to restart output. This shall have the effect +of setting (not setting) IXANY in the \fBtermios\fP +\fIc_iflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBixoff\ \fP (\fB-ixoff\fP) +Request that the system send (not send) STOP characters when the input +queue is nearly full and START characters to resume data +transmission. This shall have the effect of setting (not setting) +IXOFF in the \fBtermios\fP \fIc_iflag\fP field, as defined in +the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 11, +General +Terminal Interface. +.sp +.SS Output Modes +.TP 7 +\fBopost\ \fP (\fB-opost\fP) +Post-process output (do not post-process output; ignore all other +output modes). This shall have the effect of setting (not +setting) OPOST in the \fBtermios\fP \fIc_oflag\fP field, as defined +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBocrnl\ \fP (\fB-ocrnl\fP) +Map (do not map) CR to NL on output This shall have the effect of +setting (not setting) OCRNL in the \fBtermios\fP \fIc_oflag\fP +field, as defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, General Terminal Interface. +.TP 7 +\fBonocr\ \fP (\fB-onocr\fP) +Do not (do) output CR at column zero. This shall have the effect of +setting (not setting) ONOCR in the \fBtermios\fP +\fIc_oflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBonlret\ \fP (\fB-onlret\fP) +The terminal newline key performs (does not perform) the CR function. +This shall have the effect of setting (not setting) +ONLRET in the \fBtermios\fP \fIc_oflag\fP field, as defined in the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General +Terminal Interface. +.TP 7 +\fBofill\ \fP (\fB-ofill\fP) +Use fill characters (use timing) for delays. This shall have the effect +of setting (not setting) OFILL in the \fBtermios\fP +\fIc_oflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBofdel\ \fP (\fB-ofdel\fP) +Fill characters are DELs (NULs). This shall have the effect of setting +(not setting) OFDEL in the \fBtermios\fP \fIc_oflag\fP +field, as defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, General Terminal Interface. +.TP 7 +\fBcr0\ cr1\ cr2\ cr3\fP +Select the style of delay for CRs. This shall have the effect of setting +CRDLY to CR0, CR1, CR2, or CR3, respectively, in the +\fBtermios\fP \fIc_oflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBnl0\ nl1\fP +Select the style of delay for NL. This shall have the effect of setting +NLDLY to NL0 or NL1, respectively, in the +\fBtermios\fP \fIc_oflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBtab0\ tab1\ tab2\ tab3\fP +.sp +Select the style of delay for horizontal tabs. This shall have the +effect of setting TABDLY to TAB0, TAB1, TAB2, or TAB3, +respectively, in the \fBtermios\fP \fIc_oflag\fP field, as defined +in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. Note +that +TAB3 has the effect of expanding <tab>s to <space>s. +.TP 7 +\fBtabs\ \fP (\fB-tabs\fP) +Synonym for \fBtab0\fP ( \fBtab3\fP). +.TP 7 +\fBbs0\ bs1\fP +Select the style of delay for backspaces. This shall have the effect +of setting BSDLY to BS0 or BS1, respectively, in the +\fBtermios\fP \fIc_oflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBff0\ ff1\fP +Select the style of delay for form-feeds. This shall have the effect +of setting FFDLY to FF0 or FF1, respectively, in the +\fBtermios\fP \fIc_oflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBvt0\ vt1\fP +Select the style of delay for vertical-tabs. This shall have the effect +of setting VTDLY to VT0 or VT1, respectively, in the +\fBtermios\fP \fIc_oflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.sp +.SS Local Modes +.TP 7 +\fBisig\ \fP (\fB-isig\fP) +Enable (disable) the checking of characters against the special control +characters INTR, QUIT, and SUSP. This shall have the +effect of setting (not setting) ISIG in the \fBtermios\fP \fIc_lflag\fP +field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBicanon\ \fP (\fB-icanon\fP) +Enable (disable) canonical input (ERASE and KILL processing). This +shall have the effect of setting (not setting) ICANON in the +\fBtermios\fP \fIc_lflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBiexten\ \fP (\fB-iexten\fP) +Enable (disable) any implementation-defined special control characters +not currently controlled by \fBicanon\fP, \fBisig\fP, +\fBixon\fP, or \fBixoff\fP. This shall have the effect of setting +(not setting) IEXTEN in the \fBtermios\fP \fIc_lflag\fP +field, as defined in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, General Terminal Interface. +.TP 7 +\fBecho\ \fP (\fB-echo\fP) +Echo back (do not echo back) every character typed. This shall have +the effect of setting (not setting) ECHO in the +\fBtermios\fP \fIc_lflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBechoe\ \fP (\fB-echoe\fP) +The ERASE character visually erases (does not erase) the last character +in the current line from the display, if possible. This +shall have the effect of setting (not setting) ECHOE in the \fBtermios\fP +\fIc_lflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal +Interface. +.TP 7 +\fBechok\ \fP (\fB-echok\fP) +Echo (do not echo) NL after KILL character. This shall have the effect +of setting (not setting) ECHOK in the \fBtermios\fP +\fIc_lflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBechonl\ \fP (\fB-echonl\fP) +Echo (do not echo) NL, even if \fBecho\fP is disabled. This shall +have the effect of setting (not setting) ECHONL in the +\fBtermios\fP \fIc_lflag\fP field, as defined in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBnoflsh\ \fP (\fB-noflsh\fP) +Disable (enable) flush after INTR, QUIT, SUSP. This shall have the +effect of setting (not setting) NOFLSH in the \fBtermios\fP +\fIc_lflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.TP 7 +\fBtostop\ \fP (\fB-tostop\fP) +Send SIGTTOU for background output. This shall have the effect of +setting (not setting) TOSTOP in the \fBtermios\fP +\fIc_lflag\fP field, as defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface. +.sp +.SS Special Control Character Assignments +.TP 7 +<\fIcontrol\fP>-\fIcharacter\ string\fP +.sp +Set <\fIcontrol\fP>-\fIcharacter\fP to \fIstring\fP. If <\fIcontrol\fP>-\fIcharacter\fP +is one of the character +sequences in the first column of the following table, the corresponding +Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Chapter 11, General Terminal Interface control character from the +second column +shall be recognized. This has the effect of setting the corresponding +element of the \fBtermios\fP \fIc_cc\fP array (see the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 13, Headers, +\fI<termios.h>\fP). +.br +.sp +.ce 1 +\fBTable: Control Character Names in \fIstty\fP\fP +.TS C +center; l2 l2 l. +\fBControl Character\fP \fBc_cc Subscript\fP \fBDescription\fP +\fBeof\fP VEOF EOF character +\fBeol\fP VEOL EOL character +\fBerase\fP VERASE ERASE character +\fBintr\fP VINTR INTR character +\fBkill\fP VKILL KILL character +\fBquit\fP VQUIT QUIT character +\fBsusp\fP VSUSP SUSP character +\fBstart\fP VSTART START character +\fBstop\fP VSTOP STOP character +.TE +.LP +If \fIstring\fP is a single character, the control character shall +be set to that character. If \fIstring\fP is the +two-character sequence \fB"^-"\fP or the string \fIundef\fP, the control +character shall be set to _POSIX_VDISABLE , if it is +in effect for the device; if _POSIX_VDISABLE is not in effect for +the device, it shall be treated as an error. In the POSIX locale, +if \fIstring\fP is a two-character sequence beginning with circumflex +( \fB'^'\fP ), and the second character is one of those +listed in the \fB"^c"\fP column of the following table, the control +character shall be set to the corresponding character value +in the Value column of the table. +.sp +.ce 1 +\fBTable: Circumflex Control Characters in \fIstty\fP\fP +.TS C +center; l l l l l l. +\fB^c\fP \fBValue\fP \fB^c\fP \fBValue\fP \fB^c\fP \fBValue\fP +a, A <SOH> l, L <FF> w, W <ETB> +b, B <STX> m, M <CR> x, X <CAN> +c, C <ETX> n, N <SO> y, Y <EM> +d, D <EOT> o, O <SI> z, Z <SUB> +e, E <ENQ> p, P <DLE> [ <ESC> +f, F <ACK> q, Q <DC1> \\ <FS> +g, G <BEL> r, R <DC2> ] <GS> +h, H <BS> s, S <DC3> ^ <RS> +i, I <HT> t, T <DC4> _ <US> +j, J <LF> u, U <NAK> ? <DEL> +k, K <VT> v, V <SYN> +.TE +.TP 7 +\fBmin\ \fP \fInumber\fP +.sp +Set the value of MIN to \fInumber\fP. MIN is used in non-canonical +mode input processing ( \fBicanon\fP). +.TP 7 +\fBtime\ \fP \fInumber\fP +.sp +Set the value of TIME to \fInumber\fP. TIME is used in non-canonical +mode input processing ( \fBicanon\fP). +.sp +.SS Combination Modes +.TP 7 +\fIsaved\ settings\fP +.sp +Set the current terminal characteristics to the saved settings produced +by the \fB-g\fP option. +.TP 7 +\fBevenp\fP\ or\ \fBparity\fP +.sp +Enable \fBparenb\fP and \fBcs7\fP; disable \fBparodd\fP. +.TP 7 +\fBoddp\fP +.sp +Enable \fBparenb\fP, \fBcs7\fP, and \fBparodd\fP. +.TP 7 +\fB-parity\fP, \fB-evenp\fP, or \fB-oddp\fP +.sp +Disable \fBparenb\fP, and set \fBcs8\fP. +.TP 7 +\fBraw\ \fP (\fB-raw\fP\ or\ \fBcooked\fP) +.sp +Enable (disable) raw input and output. Raw mode shall be equivalent +to setting: +.sp +.RS +.nf + +\fBstty cs8 erase ^- kill ^- intr ^- \\ + quit ^- eof ^- eol ^- -post -inpck +\fP +.fi +.RE +.TP 7 +\fBnl\ \fP (\fB-nl\fP) +.sp +Disable (enable) \fBicrnl\fP. In addition, \fB-nl\fP unsets \fBinlcr\fP +and \fBigncr\fP. +.TP 7 +\fBek\fP +Reset ERASE and KILL characters back to system defaults. +.TP 7 +\fBsane\fP +.sp +Reset all modes to some reasonable, unspecified, values. +.sp +.SH STDIN +.LP +Although no input is read from standard input, standard input shall +be used to get the current terminal I/O characteristics and +to set new terminal I/O characteristics. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIstty\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +This variable determines the locale for the interpretation of sequences +of bytes of text data as characters (for example, +single-byte as opposed to multi-byte characters in arguments) and +which characters are in the class \fBprint\fP. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If operands are specified, no output shall be produced. +.LP +If the \fB-g\fP option is specified, \fIstty\fP shall write to standard +output the current settings in a form that can be used +as arguments to another instance of \fIstty\fP on the same system. +.LP +If the \fB-a\fP option is specified, all of the information as described +in the OPERANDS section shall be written to standard +output. Unless otherwise specified, this information shall be written +as <space>-separated tokens in an unspecified format, +on one or more lines, with an unspecified number of tokens per line. +Additional information may be written. +.LP +If no options or operands are specified, an unspecified subset of +the information written for the \fB-a\fP option shall be +written. +.LP +If speed information is written as part of the default output, or +if the \fB-a\fP option is specified and if the terminal input +speed and output speed are the same, the speed information shall be +written as follows: +.sp +.RS +.nf + +\fB"speed %d baud;", <\fP\fIspeed\fP\fB> +\fP +.fi +.RE +.LP +Otherwise, speeds shall be written as: +.sp +.RS +.nf + +\fB"ispeed %d baud; ospeed %d baud;", <\fP\fIispeed\fP\fB>, <\fP\fIospeed\fP\fB> +\fP +.fi +.RE +.LP +In locales other than the POSIX locale, the word \fBbaud\fP may be +changed to something more appropriate in those locales. +.LP +If control characters are written as part of the default output, or +if the \fB-a\fP option is specified, control characters +shall be written as: +.sp +.RS +.nf + +\fB"%s = %s;", <\fP\fIcontrol-character name\fP\fB>, <\fP\fIvalue\fP\fB> +\fP +.fi +.RE +.LP +where <\fIvalue\fP> is either the character, or some visual representation +of the character if it is non-printable, or +the string \fIundef\fP if the character is disabled. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The terminal options were read or set successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-g\fP flag is designed to facilitate the saving and restoring +of terminal state from the shell level. For example, a +program may: +.sp +.RS +.nf + +\fBsaveterm="$(stty -g)" # save terminal state +stty\fP \fI(new settings)\fP \fB # set new state +\&... # ... +stty $saveterm # restore terminal state +\fP +.fi +.RE +.LP +Since the format is unspecified, the saved value is not portable across +systems. +.LP +Since the \fB-a\fP format is so loosely specified, scripts that save +and restore terminal settings should use the \fB-g\fP +option. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The original \fIstty\fP description was taken directly from System +V and reflected the System V terminal driver \fBtermio\fP. +It has been modified to correspond to the terminal driver \fBtermios\fP. +.LP +Output modes are specified only for XSI-conformant systems. All implementations +are expected to provide \fIstty\fP operands +corresponding to all of the output modes they support. +.LP +The \fIstty\fP utility is primarily used to tailor the user interface +of the terminal, such as selecting the preferred ERASE +and KILL characters. As an application programming utility, \fIstty\fP +can be used within shell scripts to alter the terminal +settings for the duration of the script. +.LP +The \fBtermios\fP section states that individual disabling of control +characters is possible through the option +_POSIX_VDISABLE. If enabled, two conventions currently exist for specifying +this: System V uses \fB"^-"\fP , and BSD uses +\fIundef\fP. Both are accepted by \fIstty\fP in this volume of IEEE\ Std\ 1003.1-2001. +The other BSD convention of using +the letter \fB'u'\fP was rejected because it conflicts with the actual +letter \fB'u'\fP , which is an acceptable value for a +control character. +.LP +Early proposals did not specify the mapping of \fB"^c"\fP to control +characters because the control characters were not +specified in the POSIX locale character set description file requirements. +The control character set is now specified in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 3, Definitions +so the +historical mapping is specified. Note that although the mapping corresponds +to control-character key assignments on many terminals +that use the ISO/IEC\ 646:1991 standard (or ASCII) character encodings, +the mapping specified here is to the control +characters, not their keyboard encodings. +.LP +Since \fBtermios\fP supports separate speeds for input and output, +two new options were added to specify each distinctly. +.LP +Some historical implementations use standard input to get and set +terminal characteristics; others use standard output. Since +input from a login TTY is usually restricted to the owner while output +to a TTY is frequently open to anyone, using standard input +provides fewer chances of accidentally (or maliciously) altering the +terminal settings of other users. Using standard input also +allows \fIstty\fP \fB-a\fP and \fIstty\fP \fB-g\fP output to be redirected +for later use. Therefore, usage of standard input is +required by this volume of IEEE\ Std\ 1003.1-2001. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface, \fI<termios.h>\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/tabs.1p b/man1p/tabs.1p new file mode 100644 index 000000000..a64978ca7 --- /dev/null +++ b/man1p/tabs.1p @@ -0,0 +1,263 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TABS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" tabs +.SH NAME +tabs \- set terminal tabs +.SH SYNOPSIS +.LP +\fBtabs\fP \fB[\fP \fB-\fP\fIn\fP\fB| -a| -a2| -c| -c2| -c3| -f| -p| +-s| +-u\fP\fB][\fP\fB+m\fP\fB[\fP\fIn\fP\fB]]\fP \fB\fP\fB[\fP\fB-T\fP +\fItype\fP\fB]\fP\fB +.br +.sp +tabs\fP \fB[\fP\fB-T\fP \fItype\fP\fB][\fP \fB+\fP\fB[\fP\fIn\fP\fB]]\fP +\fIn1\fP\fB[\fP\fB,\fP\fIn2\fP\fB,...\fP\fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fItabs\fP utility shall display a series of characters that first +clears the hardware terminal tab settings and then +initializes the tab stops at the specified positions \ and optionally +adjusts the margin. +.LP +The phrase "tab-stop position \fIN\fP" shall be taken to mean that, +from the start of a line of output, tabbing to position +\fIN\fP shall cause the next character output to be in the ( \fIN\fP+1)th +column position on that line. The maximum number of tab +stops allowed is terminal-dependent. +.LP +It need not be possible to implement \fItabs\fP on certain terminals. +If the terminal type obtained from the \fITERM\fP +environment variable or \fB-T\fP option represents such a terminal, +an appropriate diagnostic message shall be written to standard +error and \fItabs\fP shall exit with a status greater than zero. +.SH OPTIONS +.LP +The \fItabs\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +\ except for +various extensions: the options \fB-a2\fP, \fB-c2\fP, and \fB-c3\fP +are multi-character. +.LP +The following options shall be supported: +.TP 7 +\fB-\fP\fIn\fP +Specify repetitive tab stops separated by a uniform number of column +positions, \fIn\fP, where \fIn\fP is a single-digit +decimal number. The default usage of \fItabs\fP with no arguments +shall be equivalent to \fBtabs\fP-8. When \fB-0\fP is used, +the tab stops shall be cleared and no new ones set. +.TP 7 +\fB-a\fP +1,10,16,36,72 +.br +Assembler, applicable to some mainframes. +.TP 7 +\fB-a2\fP +1,10,16,40,72 +.br +Assembler, applicable to some mainframes. +.TP 7 +\fB-c\fP +1,8,12,16,20,55 +.br +COBOL, normal format. +.TP 7 +\fB-c2\fP +1,6,10,14,49 +.br +COBOL, compact format (columns 1 to 6 omitted). +.TP 7 +\fB-c3\fP +1,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,67 +.br +COBOL compact format (columns 1 to 6 omitted), with more tabs than +\fB-c2\fP. +.TP 7 +\fB-f\fP +1,7,11,15,19,23 +.br +FORTRAN +.TP 7 +\fB-p\fP +1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61 +.br +PL/1 +.TP 7 +\fB-s\fP +1,10,55 +.br +SNOBOL +.TP 7 +\fB-u\fP +1,12,20,44 +.br +Assembler, applicable to some mainframes. +.TP 7 +\fB-T\ \fP \fItype\fP +Indicate the type of terminal. If this option is not supplied and +the \fITERM\fP variable is unset or null, an unspecified +default terminal type shall be used. The setting of \fItype\fP shall +take precedence over the value in \fITERM .\fP +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIn1\fP\fB[\fP,\fIn2\fP,...\fB]\fP +A single command line argument that consists of tab-stop values separated +using either commas or <blank>s. The +application shall ensure that the tab-stop values are positive decimal +integers in strictly ascending order. If any number (except +the first one) is preceded by a plus sign, it is taken as an increment +to be added to the previous value. For example, the tab +lists 1,10,20,30 and 1,10,+10,+10 are considered to be identical. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItabs\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITERM\fP +Determine the terminal type. If this variable is unset or null, and +if the \fB-T\fP option is not specified, an unspecified +default terminal type shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If standard output is a terminal, the appropriate sequence to clear +and set the tab stops may be written to standard output in +an unspecified format. If standard output is not a terminal, undefined +results occur. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +This utility makes use of the terminal's hardware tabs and the \fIstty\fP +\fItabs\fP +option. +.LP +This utility is not recommended for application use. +.LP +Some integrated display units might not have escape sequences to set +tab stops, but may be set by internal system calls. On +these terminals, \fItabs\fP works if standard output is directed to +the terminal; if output is directed to another file, however, +\fItabs\fP fails. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Consideration was given to having the \fItput\fP utility handle all +of the functions +described in \fItabs\fP. However, the separate \fItabs\fP utility +was retained because it seems more intuitive to use a command +named \fItabs\fP than \fItput\fP with a new option. The \fItput\fP +utility does not support setting or clearing tabs, and no known historical +version of +\fItabs\fP supports the capability of setting arbitrary tab stops. +.LP +The System V \fItabs\fP interface is very complex; the version in +this volume of IEEE\ Std\ 1003.1-2001 has a reduced +feature list, but many of the features omitted were restored as XSI +extensions even though the supported languages and coding +styles are primarily historical. +.LP +There was considerable sentiment for specifying only a means of resetting +the tabs back to a known state-presumably the +"standard" of tabs every eight positions. The following features were +omitted: +.IP " *" 3 +Setting tab stops via the first line in a file, using -- \fIfile\fP. +Since even the SVID has no complete explanation of this +feature, it is doubtful that it is in widespread use. +.LP +.LP +In an early proposal, a \fB-t\fP \fItablist\fP option was added for +consistency with \fIexpand\fP; this was later removed when inconsistencies +with the historical list of tabs were +identified. +.LP +Consideration was given to adding a \fB-p\fP option that would output +the current tab settings so that they could be saved and +then later restored. This was not accepted because querying the tab +stops of the terminal is not a capability in historical +\fIterminfo\fP or \fItermcap\fP facilities and might not be supported +on a wide range of terminals. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIexpand\fP , \fIstty\fP , \fItput\fP , \fIunexpand\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/tail.1p b/man1p/tail.1p new file mode 100644 index 000000000..515d18ea9 --- /dev/null +++ b/man1p/tail.1p @@ -0,0 +1,249 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TAIL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" tail +.SH NAME +tail \- copy the last part of a file +.SH SYNOPSIS +.LP +\fBtail\fP \fB[\fP\fB-f\fP\fB][\fP \fB-c\fP \fInumber\fP\fB| -n\fP +\fInumber\fP\fB][\fP\fIfile\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fItail\fP utility shall copy its input file to the standard output +beginning at a designated place. +.LP +Copying shall begin at the point in the file indicated by the \fB-c\fP +\fInumber\fP or \fB-n\fP \fInumber\fP options. The +option-argument \fInumber\fP shall be counted in units of lines or +bytes, according to the options \fB-n\fP and \fB-c\fP. Both +line and byte counts start from 1. +.LP +Tails relative to the end of the file may be saved in an internal +buffer, and thus may be limited in length. Such a buffer, if +any, shall be no smaller than {LINE_MAX}*10 bytes. +.SH OPTIONS +.LP +The \fItail\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\ \fP \fInumber\fP +The application shall ensure that the \fInumber\fP option-argument +is a decimal integer whose sign affects the location in the +file, measured in bytes, to begin the copying: +.TS C +center; l l. +\fBSign\fP \fBCopying Starts\fP ++ Relative to the beginning of the file. +- Relative to the end of the file. +\fInone\fP Relative to the end of the file. +.TE +.LP +The origin for counting shall be 1; that is, \fB-c\fP +1 represents +the first byte of the file, \fB-c\fP -1 the last. +.TP 7 +\fB-f\fP +If the input file is a regular file or if the \fIfile\fP operand specifies +a FIFO, do not terminate after the last line of the +input file has been copied, but read and copy further bytes from the +input file when they become available. If no \fIfile\fP +operand is specified and standard input is a pipe, the \fB-f\fP option +shall be ignored. If the input file is not a FIFO, pipe, or +regular file, it is unspecified whether or not the \fB-f\fP option +shall be ignored. +.TP 7 +\fB-n\ \fP \fInumber\fP +This option shall be equivalent to \fB-c\fP \fInumber\fP, except the +starting location in the file shall be measured in lines +instead of bytes. The origin for counting shall be 1; that is, \fB-n\fP ++1 represents the first line of the file, \fB-n\fP -1 the +last. +.sp +.LP +If neither \fB-c\fP nor \fB-n\fP is specified, \fB-n\fP 10 shall be +assumed. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If no \fIfile\fP operands are specified, +the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +If the \fB-c\fP option is specified, the input file can contain arbitrary +data; otherwise, the input file shall be a text +file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItail\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The designated portion of the input file shall be written to standard +output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-c\fP option should be used with caution when the input is +a text file containing multi-byte characters; it may produce +output that does not start on a character boundary. +.LP +Although the input file to \fItail\fP can be any type, the results +might not be what would be expected on some character +special device files or on file types not described by the System +Interfaces volume of IEEE\ Std\ 1003.1-2001. Since this +volume of IEEE\ Std\ 1003.1-2001 does not specify the block size used +when doing input, \fItail\fP need not read all of +the data from devices that only perform block transfers. +.SH EXAMPLES +.LP +The \fB-f\fP option can be used to monitor the growth of a file that +is being written by some other process. For example, the +command: +.sp +.RS +.nf + +\fBtail -f fred +\fP +.fi +.RE +.LP +prints the last ten lines of the file \fBfred\fP, followed by any +lines that are appended to \fBfred\fP between the time +\fItail\fP is initiated and killed. As another example, the command: +.sp +.RS +.nf + +\fBtail -f -c 15 fred +\fP +.fi +.RE +.LP +prints the last 15 bytes of the file \fBfred\fP, followed by any bytes +that are appended to \fBfred\fP between the time +\fItail\fP is initiated and killed. +.SH RATIONALE +.LP +This version of \fItail\fP was created to allow conformance to the +Utility Syntax Guidelines. The historical \fB-b\fP option +was omitted because of the general non-portability of block-sized +units of text. The \fB-c\fP option historically meant +"characters", but this volume of IEEE\ Std\ 1003.1-2001 indicates +that it means "bytes". This was selected to allow +reasonable implementations when multi-byte characters are possible; +it was not named \fB-b\fP to avoid confusion with the +historical \fB-b\fP. +.LP +The origin of counting both lines and bytes is 1, matching all widespread +historical implementations. +.LP +The restriction on the internal buffer is a compromise between the +historical System V implementation of 4096 bytes and the BSD +32768 bytes. +.LP +The \fB-f\fP option has been implemented as a loop that sleeps for +1 second and copies any bytes that are available. This is +sufficient, but if more efficient methods of determining when new +data are available are developed, implementations are encouraged +to use them. +.LP +Historical documentation indicates that \fItail\fP ignores the \fB-f\fP +option if the input file is a pipe (pipe and FIFO on +systems that support FIFOs). On BSD-based systems, this has been true; +on System V-based systems, this was true when input was +taken from standard input, but it did not ignore the \fB-f\fP flag +if a FIFO was named as the \fIfile\fP operand. Since the +\fB-f\fP option is not useful on pipes and all historical implementations +ignore \fB-f\fP if no \fIfile\fP operand is specified +and standard input is a pipe, this volume of IEEE\ Std\ 1003.1-2001 +requires this behavior. However, since the \fB-f\fP +option is useful on a FIFO, this volume of IEEE\ Std\ 1003.1-2001 +also requires that if standard input is a FIFO or a FIFO +is named, the \fB-f\fP option shall not be ignored. Although historical +behavior does not ignore the \fB-f\fP option for other +file types, this is unspecified so that implementations are allowed +to ignore the \fB-f\fP option if it is known that the file +cannot be extended. +.LP +This was changed to the current form based on comments noting that +\fB-c\fP was almost never used without specifying a number +and that there was no need to specify \fB-l\fP if \fB-n\fP \fInumber\fP +was given. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIhead\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/talk.1p b/man1p/talk.1p new file mode 100644 index 000000000..b6a101a4d --- /dev/null +++ b/man1p/talk.1p @@ -0,0 +1,278 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TALK" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" talk +.SH NAME +talk \- talk to another user +.SH SYNOPSIS +.LP +\fBtalk\fP \fIaddress\fP \fB[\fP\fIterminal\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fItalk\fP utility is a two-way, screen-oriented communication +program. +.LP +When first invoked, \fItalk\fP shall send a message similar to: +.sp +.RS +.nf + +\fBMessage from <\fP\fIunspecified string\fP\fB> +talk: connection requested by\fP \fIyour_address\fP\fBtalk: respond with: talk\fP \fIyour_address\fP +.fi +.RE +.LP +to the specified \fIaddress\fP. At this point, the recipient of the +message can reply by typing: +.sp +.RS +.nf + +\fBtalk\fP \fIyour_address\fP +.fi +.RE +.LP +Once communication is established, the two parties can type simultaneously, +with their output displayed in separate regions of +the screen. Characters shall be processed as follows: +.IP " *" 3 +Typing the alert character shall alert the recipient's terminal. +.LP +.IP " *" 3 +Typing <control>-L shall cause the sender's screen regions to be refreshed. +.LP +.IP " *" 3 +Typing the erase and kill characters shall affect the sender's terminal +in the manner described by the \fBtermios\fP interface +in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter +11, General +Terminal Interface. +.LP +.IP " *" 3 +Typing the interrupt or end-of-file characters shall terminate the +local \fItalk\fP utility. Once the \fItalk\fP session has +been terminated on one side, the other side of the \fItalk\fP session +shall be notified that the \fItalk\fP session has been +terminated and shall be able to do nothing except exit. +.LP +.IP " *" 3 +Typing characters from \fILC_CTYPE\fP classifications \fBprint\fP +or \fBspace\fP shall cause those characters to be sent to +the recipient's terminal. +.LP +.IP " *" 3 +When and only when the \fIstty\fP \fBiexten\fP local mode is enabled, +the existence and +processing of additional special control characters and multi-byte +or single-byte functions shall be implementation-defined. +.LP +.IP " *" 3 +Typing other non-printable characters shall cause implementation-defined +sequences of printable characters to be sent to the +recipient's terminal. +.LP +.LP +Permission to be a recipient of a \fItalk\fP message can be denied +or granted by use of the \fImesg\fP utility. However, a user's privilege +may further constrain the domain of accessibility of +other users' terminals. The \fItalk\fP utility shall fail when the +user lacks the appropriate privileges to perform the requested +action. +.LP +Certain block-mode terminals do not have all the capabilities necessary +to support the simultaneous exchange of messages +required for \fItalk\fP. When this type of exchange cannot be supported +on such terminals, the implementation may support an +exchange with reduced levels of simultaneous interaction or it may +report an error describing the terminal-related deficiency. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIaddress\fP +The recipient of the \fItalk\fP session. One form of \fIaddress\fP +is the <\fIuser\ name\fP>, as returned by the +\fIwho\fP utility. Other address formats and how they are handled +are unspecified. +.TP 7 +\fIterminal\fP +If the recipient is logged in more than once, the \fIterminal\fP argument +can be used to indicate the appropriate terminal +name. If \fIterminal\fP is not specified, the \fItalk\fP message shall +be displayed on one or more accessible terminals in use by +the recipient. The format of \fIterminal\fP shall be the same as that +returned by the \fIwho\fP utility. +.sp +.SH STDIN +.LP +Characters read from standard input shall be copied to the recipient's +terminal in an unspecified manner. If standard input is +not a terminal, talk shall write a diagnostic message and exit with +a non-zero status. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItalk\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). If +the recipient's locale does not use an \fILC_CTYPE\fP +equivalent to the sender's, the results are undefined. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITERM\fP +Determine the name of the invoker's terminal type. If this variable +is unset or null, an unspecified default terminal type +shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +When the \fItalk\fP utility receives a SIGINT signal, the utility +shall terminate and exit with a zero status. It shall take +the standard action for all other signals. +.SH STDOUT +.LP +If standard output is a terminal, characters copied from the recipient's +standard input may be written to standard output. +Standard output also may be used for diagnostic messages. If standard +output is not a terminal, \fItalk\fP shall exit with a +non-zero status. +.SH STDERR +.LP +None. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred or \fItalk\fP was invoked on a terminal incapable +of supporting it. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Because the handling of non-printable, non- <space>s is tied to the +\fIstty\fP +description of \fBiexten\fP, implementation extensions within the +terminal driver can be accessed. For example, some +implementations provide line editing functions with certain control +character sequences. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIwrite\fP utility was included in this volume of IEEE\ Std\ 1003.1-2001 +since it can be implemented on all terminal types. The \fItalk\fP +utility, which cannot be implemented on certain terminals, was +considered to be a "better" communications interface. Both of these +programs are in widespread use on historical implementations. +Therefore, both utilities have been specified. +.LP +All references to networking abilities (\fItalk\fPing to a user on +another system) were removed as being outside the scope of +this volume of IEEE\ Std\ 1003.1-2001. +.LP +Historical BSD and System V versions of \fItalk\fP terminate both +of the conversations when either user breaks out of the +session. This can lead to adverse consequences if a user unwittingly +continues to enter text that is interpreted by the shell when +the other terminates the session. Therefore, the version of \fItalk\fP +specified by this volume of IEEE\ Std\ 1003.1-2001 +requires both users to terminate their end of the session explicitly. +.LP +Only messages sent to the terminal of the invoking user can be internationalized +in any way: +.IP " *" 3 +The original "Message from <\fIunspecified string\fP> ..." message +sent to the terminal of the recipient cannot be +internationalized because the environment of the recipient is as yet +inaccessible to the \fItalk\fP utility. The environment of +the invoking party is irrelevant. +.LP +.IP " *" 3 +Subsequent communication between the two parties cannot be internationalized +because the two parties may specify different +languages in their environment (and non-portable characters cannot +be mapped from one language to another). +.LP +.IP " *" 3 +Neither party can be required to communicate in a language other than +C and/or the one specified by their environment because +unavailable terminal hardware support (for example, fonts) may be +required. +.LP +.LP +The text in the STDOUT section reflects the usage of the verb "display" +in this section; some \fItalk\fP implementations +actually use standard output to write to the terminal, but this volume +of IEEE\ Std\ 1003.1-2001 does not require that to +be the case. +.LP +The format of the terminal name is unspecified, but the descriptions +of \fIps\fP, +\fItalk\fP, \fIwho\fP, and \fIwrite\fP require that +they all use or accept the same format. +.LP +The handling of non-printable characters is partially implementation-defined +because the details of mapping them to printable +sequences is not needed by the user. Historical implementations, for +security reasons, disallow the transmission of non-printable +characters that may send commands to the other terminal. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fImesg\fP , \fIstty\fP , \fIwho\fP , \fIwrite\fP , the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/tee.1p b/man1p/tee.1p new file mode 100644 index 000000000..c74d80a8e --- /dev/null +++ b/man1p/tee.1p @@ -0,0 +1,174 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TEE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" tee +.SH NAME +tee \- duplicate standard input +.SH SYNOPSIS +.LP +\fBtee\fP \fB[\fP\fB-ai\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fItee\fP utility shall copy standard input to standard output, +making a copy in zero or more files. The \fItee\fP utility +shall not buffer output. +.LP +If the \fB-a\fP option is not specified, output files shall be written +(see \fIFile +Read, Write, and Creation\fP . +.SH OPTIONS +.LP +The \fItee\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Append the output to the files. +.TP 7 +\fB-i\fP +Ignore the SIGINT signal. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of an output file. Processing of at least 13 \fIfile\fP +operands shall be supported. +.sp +.SH STDIN +.LP +The standard input can be of any type. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItee\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default, except that if the \fB-i\fP option was specified, SIGINT +shall be ignored. +.SH STDOUT +.LP +The standard output shall be a copy of the standard input. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +If any \fIfile\fP operands are specified, the standard input shall +be copied to each named file. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The standard input was successfully copied to all output files. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If a write to any successfully opened \fIfile\fP operand fails, writes +to other successfully opened \fIfile\fP operands and +standard output shall continue, but the exit status shall be non-zero. +Otherwise, the default actions specified in \fIUtility Description +Defaults\fP apply. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fItee\fP utility is usually used in a pipeline, to make a copy +of the output of some utility. +.LP +The \fIfile\fP operand is technically optional, but \fItee\fP is no +more useful than \fIcat\fP when none is specified. +.SH EXAMPLES +.LP +Save an unsorted intermediate form of the data in a pipeline: +.sp +.RS +.nf + +\fB\&... | tee unsorted | sort > sorted +\fP +.fi +.RE +.SH RATIONALE +.LP +The buffering requirement means that \fItee\fP is not allowed to use +ISO\ C standard fully buffered or line-buffered +writes. It does not mean that \fItee\fP has to do 1-byte reads followed +by 1-byte writes. +.LP +It should be noted that early versions of BSD ignore any invalid options +and accept a single \fB'-'\fP as an alternative to +\fB-i\fP. They also print a message if unable to open a file: +.sp +.RS +.nf + +\fB"tee: cannot access %s\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.LP +Historical implementations ignore write errors. This is explicitly +not permitted by this volume of +IEEE\ Std\ 1003.1-2001. +.LP +Some historical implementations use O_APPEND when providing append +mode; others use the \fIlseek\fP() function to seek to the end-of-file +after opening the file without O_APPEND. This +volume of IEEE\ Std\ 1003.1-2001 requires functionality equivalent +to using O_APPEND; see \fIFile Read, Write, and Creation\fP . +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIIntroduction\fP , \fIcat\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIlseek\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/test.1p b/man1p/test.1p new file mode 100644 index 000000000..78b92722a --- /dev/null +++ b/man1p/test.1p @@ -0,0 +1,757 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TEST" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" test +.SH NAME +test \- evaluate expression +.SH SYNOPSIS +.LP +\fBtest\fP \fB[\fP\fIexpression\fP\fB]\fP\fB +.br +.sp +[\fP \fB[\fP\fIexpression\fP\fB]\fP \fB] +.br +\fP +.SH DESCRIPTION +.LP +The \fItest\fP utility shall evaluate the \fIexpression\fP and indicate +the result of the evaluation by its exit status. An +exit status of zero indicates that the expression evaluated as true +and an exit status of 1 indicates that the expression evaluated +as false. +.LP +In the second form of the utility, which uses \fB"[]"\fP rather than +\fItest\fP, the application shall ensure that the +square brackets are separate arguments. +.SH OPTIONS +.LP +The \fItest\fP utility shall not recognize the \fB"--"\fP argument +in the manner specified by guideline 10 in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility +Syntax +Guidelines. +.LP +No options shall be supported. +.SH OPERANDS +.LP +The application shall ensure that all operators and elements of primaries +are presented as separate arguments to the \fItest\fP +utility. +.LP +The following primaries can be used to construct \fIexpression\fP: +.TP 7 +\fB-b\ \fP \fIfile\fP +True if \fIfile\fP exists and is a block special file. +.TP 7 +\fB-c\ \fP \fIfile\fP +True if \fIfile\fP exists and is a character special file. +.TP 7 +\fB-d\ \fP \fIfile\fP +True if \fIfile\fP exists and is a directory. +.TP 7 +\fB-e\ \fP \fIfile\fP +True if \fIfile\fP exists. +.TP 7 +\fB-f\ \fP \fIfile\fP +True if \fIfile\fP exists and is a regular file. +.TP 7 +\fB-g\ \fP \fIfile\fP +True if \fIfile\fP exists and its set-group-ID flag is set. +.TP 7 +\fB-h\ \fP \fIfile\fP +True if \fIfile\fP exists and is a symbolic link. +.TP 7 +\fB-L\ \fP \fIfile\fP +True if \fIfile\fP exists and is a symbolic link. +.TP 7 +\fB-n\ \fP \fIstring\fP +True if the length of \fIstring\fP is non-zero. +.TP 7 +\fB-p\ \fP \fIfile\fP +True if \fIfile\fP is a FIFO. +.TP 7 +\fB-r\ \fP \fIfile\fP +True if \fIfile\fP exists and is readable. True shall indicate that +permission to read from \fIfile\fP will be granted, as +defined in \fIFile Read, Write, and Creation\fP . +.TP 7 +\fB-S\ \fP \fIfile\fP +True if \fIfile\fP exists and is a socket. +.TP 7 +\fB-s\ \fP \fIfile\fP +True if \fIfile\fP exists and has a size greater than zero. +.TP 7 +\fB-t\ \fP \fIfile_descriptor\fP +.sp +True if the file whose file descriptor number is \fIfile_descriptor\fP +is open and is associated with a terminal. +.TP 7 +\fB-u\ \fP \fIfile\fP +True if \fIfile\fP exists and its set-user-ID flag is set. +.TP 7 +\fB-w\ \fP \fIfile\fP +True if \fIfile\fP exists and is writable. True shall indicate that +permission to write from \fIfile\fP will be granted, as +defined in \fIFile Read, Write, and Creation\fP . +.TP 7 +\fB-x\ \fP \fIfile\fP +True if \fIfile\fP exists and is executable. True shall indicate that +permission to execute \fIfile\fP will be granted, as +defined in \fIFile Read, Write, and Creation\fP . If \fIfile\fP is +a directory, +true shall indicate that permission to search \fIfile\fP will be granted. +.TP 7 +\fB-z\ \fP \fIstring\fP +True if the length of string \fIstring\fP is zero. +.TP 7 +\fIstring\fP +True if the string \fIstring\fP is not the null string. +.TP 7 +\fIs1\fP\fB\ =\ \fP \fIs2\fP +True if the strings \fIs1\fP and \fIs2\fP are identical. +.TP 7 +\fIs1\fP\fB\ !=\ \fP \fIs2\fP +True if the strings \fIs1\fP and \fIs2\fP are not identical. +.TP 7 +\fIn1\fP\fB\ -eq\ \fP \fIn2\fP +True if the integers \fIn1\fP and \fIn2\fP are algebraically equal. +.TP 7 +\fIn1\fP\fB\ -ne\ \fP \fIn2\fP +True if the integers \fIn1\fP and \fIn2\fP are not algebraically equal. +.TP 7 +\fIn1\fP\fB\ -gt\ \fP \fIn2\fP +True if the integer \fIn1\fP is algebraically greater than the integer +\fIn2\fP. +.TP 7 +\fIn1\fP\fB\ -ge\ \fP \fIn2\fP +True if the integer \fIn1\fP is algebraically greater than or equal +to the integer \fIn2\fP. +.TP 7 +\fIn1\fP\fB\ -lt\ \fP \fIn2\fP +True if the integer \fIn1\fP is algebraically less than the integer +\fIn2\fP. +.TP 7 +\fIn1\fP\fB\ -le\ \fP \fIn2\fP +True if the integer \fIn1\fP is algebraically less than or equal to +the integer \fIn2\fP. +.TP 7 +\fIexpression1\fP\fB\ -a\ \fP \fIexpression2\fP +.sp +True if both \fIexpression1\fP and \fIexpression2\fP are true. The +\fB-a\fP binary primary is left associative. It has a higher +precedence than \fB-o\fP. +.TP 7 +\fIexpression1\fP\fB\ -o\ \fP \fIexpression2\fP +.sp +True if either \fIexpression1\fP or \fIexpression2\fP is true. The +\fB-o\fP binary primary is left associative. +.sp +.LP +With the exception of the \fB-h\fP \fIfile\fP and \fB-L\fP \fIfile\fP +primaries, if a \fIfile\fP argument is a symbolic +link, \fItest\fP shall evaluate the expression by resolving the symbolic +link and using the file referenced by the link. +.LP +These primaries can be combined with the following operators: +.TP 7 +\fB!\ \fP \fIexpression\fP +True if \fIexpression\fP is false. +.TP 7 +\fB(\ \fP \fIexpression\ \fP \fB)\fP +True if \fIexpression\fP is true. The parentheses can be used to alter +the normal precedence and associativity. +.sp +.LP +The primaries with two elements of the form: +.sp +.RS +.nf + +\fB-\fP\fIprimary_operator primary_operand\fP +.fi +.RE +.LP +are known as \fIunary primaries\fP. The primaries with three elements +in either of the two forms: +.sp +.RS +.nf + +\fIprimary_operand\fP \fB-\fP\fIprimary_operator primary_operand +.sp + +primary_operand primary_operator primary_operand\fP +.fi +.RE +.LP +are known as \fIbinary primaries\fP. Additional implementation-defined +operators and \fIprimary_operator\fPs may be provided +by implementations. They shall be of the form - \fIoperator\fP where +the first character of \fIoperator\fP is not a digit. +.LP +The algorithm for determining the precedence of the operators and +the return value that shall be generated is based on the +number of arguments presented to \fItest\fP. (However, when using +the \fB"[...]"\fP form, the right-bracket final argument +shall not be counted in this algorithm.) +.LP +In the following list, $1, $2, $3, and $4 represent the arguments +presented to \fItest\fP: +.TP 7 +0\ arguments: +Exit false (1). +.TP 7 +1\ argument: +Exit true (0) if $1 is not null; otherwise, exit false. +.TP 7 +2\ arguments: +.RS +.IP " *" 3 +If $1 is \fB'!'\fP , exit true if $2 is null, false if $2 is not null. +.LP +.IP " *" 3 +If $1 is a unary primary, exit true if the unary test is true, false +if the unary test is false. +.LP +.IP " *" 3 +Otherwise, produce unspecified results. +.LP +.RE +.TP 7 +3\ arguments: +.RS +.IP " *" 3 +If $2 is a binary primary, perform the binary test of $1 and $3. +.LP +.IP " *" 3 +If $1 is \fB'!'\fP , negate the two-argument test of $2 and $3. +.LP +.IP " *" 3 +If $1 is \fB'('\fP and $3 is \fB')'\fP , perform the unary test of +$2. +.LP +.IP " *" 3 +Otherwise, produce unspecified results. +.LP +.RE +.TP 7 +4\ arguments: +.RS +.IP " *" 3 +If $1 is \fB'!'\fP , negate the three-argument test of $2, $3, and +$4. +.LP +.IP " *" 3 +If $1 is \fB'('\fP and $4 is \fB')'\fP , perform the two-argument +test of $2 and $3. +.LP +.IP " *" 3 +Otherwise, the results are unspecified. +.LP +.RE +.TP 7 +>4\ arguments: +The results are unspecified. +.LP +On XSI-conformant systems, combinations of primaries and operators +shall be evaluated using the precedence and associativity rules +described previously. In addition, the string comparison binary primaries +\fB'='\fP and \fB"!="\fP shall have a higher +precedence than any unary primary. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItest\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +\fIexpression\fP evaluated to true. +.TP 7 +\ 1 +\fIexpression\fP evaluated to false or \fIexpression\fP was missing. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Scripts should be careful when dealing with user-supplied input that +could be confused with primaries and operators. Unless the +application writer knows all the cases that produce input to the script, +invocations like: +.sp +.RS +.nf + +\fBtest "$1" -a "$2" +\fP +.fi +.RE +.LP +should be written as: +.sp +.RS +.nf + +\fBtest "$1" && test "$2" +\fP +.fi +.RE +.LP +to avoid problems if a user supplied values such as $1 set to \fB'!'\fP +and $2 set to the null string. That is, in cases +where maximal portability is of concern, replace: +.sp +.RS +.nf + +\fBtest expr1 -a expr2 +\fP +.fi +.RE +.LP +with: +.sp +.RS +.nf + +\fBtest expr1 && test expr2 +\fP +.fi +.RE +.LP +and replace: +.sp +.RS +.nf + +\fBtest expr1 -o expr2 +\fP +.fi +.RE +.LP +with: +.sp +.RS +.nf + +\fBtest expr1 || test expr2 +\fP +.fi +.RE +.LP +but note that, in \fItest\fP, \fB-a\fP has higher precedence than +\fB-o\fP while \fB"&&"\fP and \fB"||"\fP have +equal precedence in the shell. +.LP +Parentheses or braces can be used in the shell command language to +effect grouping. +.LP +Parentheses must be escaped when using \fIsh\fP; for example: +.sp +.RS +.nf + +\fBtest \\( expr1 -a expr2 \\) -o expr3 +\fP +.fi +.RE +.LP +This command is not always portable outside XSI-conformant systems. +The following form can be used instead: +.sp +.RS +.nf + +\fB( test expr1 && test expr2 ) || test expr3 +\fP +.fi +.RE +.LP +The two commands: +.sp +.RS +.nf + +\fBtest "$1" +test ! "$1" +\fP +.fi +.RE +.LP +could not be used reliably on some historical systems. Unexpected +results would occur if such a \fIstring\fP expression were +used and $1 expanded to \fB'!'\fP , \fB'('\fP , or a known unary primary. +Better constructs are: +.sp +.RS +.nf + +\fBtest -n "$1" +test -z "$1" +\fP +.fi +.RE +respectively. +.LP +Historical systems have also been unreliable given the common construct: +.sp +.RS +.nf + +\fBtest "$response" = "expected string" +\fP +.fi +.RE +.LP +One of the following is a more reliable form: +.sp +.RS +.nf + +\fBtest "X$response" = "Xexpected string" +test "expected string" = "$response" +\fP +.fi +.RE +.LP +Note that the second form assumes that \fIexpected string\fP could +not be confused with any unary primary. If \fIexpected +string\fP starts with \fB'-'\fP , \fB'('\fP , \fB'!'\fP , or even +\fB'='\fP , the first form should be used instead. +Using the preceding rules without the XSI marked extensions, any of +the three comparison forms is reliable, given any input. +(However, note that the strings are quoted in all cases.) +.LP +Because the string comparison binary primaries, \fB'='\fP and \fB"!="\fP +, have a higher precedence than any unary primary +in the greater than 4 argument case, unexpected results can occur +if arguments are not properly prepared. For example, in: +.sp +.RS +.nf + +\fBtest -d $1 -o -d $2 +\fP +.fi +.RE +.LP +If $1 evaluates to a possible directory name of \fB'='\fP , the first +three arguments are considered a string comparison, +which shall cause a syntax error when the second \fB-d\fP is encountered. +One of the following forms prevents this; the second is +preferred: +.sp +.RS +.nf + +\fBtest \\( -d "$1" \\) -o \\( -d "$2" \\) +test -d "$1" || test -d "$2" +\fP +.fi +.RE +.LP +Also in the greater than 4 argument case: +.sp +.RS +.nf + +\fBtest "$1" = "bat" -a "$2" = "ball" +\fP +.fi +.RE +.LP +syntax errors occur if $1 evaluates to \fB'('\fP or \fB'!'\fP . One +of the following forms prevents this; the third is +preferred: +.sp +.RS +.nf + +\fBtest "X$1" = "Xbat" -a "X$2" = "Xball" +test "$1" = "bat" && test "$2" = "ball" +test "X$1" = "Xbat" && test "X$2" = "Xball" +\fP +.fi +.RE +.SH EXAMPLES +.IP " 1." 4 +Exit if there are not two or three arguments (two variations): +.sp +.RS +.nf + +\fBif [ $# -ne 2 -a $# -ne 3 ]; then exit 1; fi +if [ $# -lt 2 -o $# -gt 3 ]; then exit 1; fi +\fP +.fi +.RE +.LP +.IP " 2." 4 +Perform a \fImkdir\fP if a directory does not exist: +.sp +.RS +.nf + +\fBtest ! -d tempdir && mkdir tempdir +\fP +.fi +.RE +.LP +.IP " 3." 4 +Wait for a file to become non-readable: +.sp +.RS +.nf + +\fBwhile test -r thefile +do + sleep 30 +done +echo '"thefile" is no longer readable' +\fP +.fi +.RE +.LP +.IP " 4." 4 +Perform a command if the argument is one of three strings (two variations): +.sp +.RS +.nf + +\fBif [ "$1" = "pear" ] || [ "$1" = "grape" ] || [ "$1" = "apple" ] +then + \fP \fIcommand\fP\fB +fi +.sp + +case "$1" in + pear|grape|apple)\fP \fIcommand\fP \fB;; +esac +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The KornShell-derived conditional command (double bracket \fB[[]]\fP) +was removed from the shell command language description +in an early proposal. Objections were raised that the real problem +is misuse of the \fItest\fP command ( \fB[\fP), and putting it +into the shell is the wrong way to fix the problem. Instead, proper +documentation and a new shell reserved word ( \fB!\fP) are +sufficient. +.LP +Tests that require multiple \fItest\fP operations can be done at the +shell level using individual invocations of the +\fItest\fP command and shell logicals, rather than using the error-prone +\fB-o\fP flag of \fItest\fP. +.LP +XSI-conformant systems support more than four arguments. +.LP +XSI-conformant systems support the combining of primaries with the +following constructs: +.TP 7 +\fIexpression1\fP \fB-a\fP \fIexpression2\fP +.sp +True if both \fIexpression1\fP and \fIexpression2\fP are true. +.TP 7 +\fIexpression1\fP \fB-o\fP \fIexpression2\fP +.sp +True if at least one of \fIexpression1\fP and \fIexpression2\fP are +true. +.TP 7 +\fB(\fP \fIexpression\fP \fB)\fP +.sp +True if \fIexpression\fP is true. +.sp +.LP +In evaluating these more complex combined expressions, the following +precedence rules are used: +.IP " *" 3 +The unary primaries have higher precedence than the algebraic binary +primaries. +.LP +.IP " *" 3 +The unary primaries have lower precedence than the string binary primaries. +.LP +.IP " *" 3 +The unary and binary primaries have higher precedence than the unary +\fIstring\fP primary. +.LP +.IP " *" 3 +The \fB!\fP operator has higher precedence than the \fB-a\fP operator, +and the \fB-a\fP operator has higher precedence than +the \fB-o\fP operator. +.LP +.IP " *" 3 +The \fB-a\fP and \fB-o\fP operators are left associative. +.LP +.IP " *" 3 +The parentheses can be used to alter the normal precedence and associativity. +.LP +.LP +The BSD and System V versions of \fB-f\fP are not the same. The BSD +definition was: +.TP 7 +\fB-f\ \fP \fIfile\fP +True if \fIfile\fP exists and is not a directory. +.sp +.LP +The SVID version (true if the file exists and is a regular file) was +chosen for this volume of IEEE\ Std\ 1003.1-2001 +because its use is consistent with the \fB-b\fP, \fB-c\fP, \fB-d\fP, +and \fB-p\fP operands ( \fIfile\fP exists and is a +specific file type). +.LP +The \fB-e\fP primary, possessing similar functionality to that provided +by the C shell, was added because it provides the only +way for a shell script to find out if a file exists without trying +to open the file. Since implementations are allowed to add +additional file types, a portable script cannot use: +.sp +.RS +.nf + +\fBtest -b foo -o -c foo -o -d foo -o -f foo -o -p foo +\fP +.fi +.RE +.LP +to find out if \fBfoo\fP is an existing file. On historical BSD systems, +the existence of a file could be determined by: +.sp +.RS +.nf + +\fBtest -f foo -o -d foo +\fP +.fi +.RE +.LP +but there was no easy way to determine that an existing file was a +regular file. An early proposal used the KornShell \fB-a\fP +primary (with the same meaning), but this was changed to \fB-e\fP +because there were concerns about the high probability of humans +confusing the \fB-a\fP primary with the \fB-a\fP binary operator. +.LP +The following options were not included in this volume of IEEE\ Std\ 1003.1-2001, +although they are provided by some +implementations. These operands should not be used by new implementations +for other purposes: +.TP 7 +\fB-k\ \fP \fIfile\fP +True if \fIfile\fP exists and its sticky bit is set. +.TP 7 +\fB-C\ \fP \fIfile\fP +True if \fIfile\fP is a contiguous file. +.TP 7 +\fB-V\ \fP \fIfile\fP +True if \fIfile\fP is a version file. +.sp +.LP +The following option was not included because it was undocumented +in most implementations, has been removed from some +implementations (including System V), and the functionality is provided +by the shell (see \fIParameter Expansion\fP . +.TP 7 +\fB-l\ \fP \fIstring\fP +The length of the string \fIstring\fP. +.sp +.LP +The \fB-b\fP, \fB-c\fP, \fB-g\fP, \fB-p\fP, \fB-u\fP, and \fB-x\fP +operands are derived from the SVID; historical BSD does +not provide them. The \fB-k\fP operand is derived from System V; historical +BSD does not provide it. +.LP +On historical BSD systems, \fItest\fP \fB-w\fP \fIdirectory\fP always +returned false because \fItest\fP tried to open the +directory for writing, which always fails. +.LP +Some additional primaries newly invented or from the KornShell appeared +in an early proposal as part of the conditional command +( \fB[[]]\fP): \fIs1\fP \fB>\fP \fIs2\fP, \fIs1\fP \fB<\fP \fIs2\fP, +\fIstr\fP \fB=\fP \fIpattern\fP, \fIstr\fP +\fB!=\fP \fIpattern\fP, \fIf1\fP \fB-nt\fP \fIf2\fP, \fIf1\fP \fB-ot\fP +\fIf2\fP, and \fIf1\fP \fB-ef\fP \fIf2\fP. They +were not carried forward into the \fItest\fP utility when the conditional +command was removed from the shell because they have not +been included in the \fItest\fP utility built into historical implementations +of the \fIsh\fP +utility. +.LP +The \fB-t\fP \fIfile_descriptor\fP primary is shown with a mandatory +argument because the grammar is ambiguous if it can be +omitted. Historical implementations have allowed it to be omitted, +providing a default of 1. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIFile Read, Write, and Creation\fP , \fIfind\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/time.1p b/man1p/time.1p new file mode 100644 index 000000000..4804461e5 --- /dev/null +++ b/man1p/time.1p @@ -0,0 +1,278 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TIME" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" time +.SH NAME +time \- time a simple command +.SH SYNOPSIS +.LP +\fBtime\fP \fB[\fP\fB-p\fP\fB]\fP \fIutility\fP +\fB[\fP\fIargument\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fItime\fP utility shall invoke the utility named by the \fIutility\fP +operand with arguments supplied as the +\fIargument\fP operands and write a message to standard error that +lists timing statistics for the utility. The message shall +include the following information: +.IP " *" 3 +The elapsed (real) time between invocation of \fIutility\fP and its +termination. +.LP +.IP " *" 3 +The User CPU time, equivalent to the sum of the \fItms_utime\fP and +\fItms_cutime\fP fields returned by the \fItimes\fP() function defined +in the System Interfaces volume of IEEE\ Std\ 1003.1-2001 for +the process in which \fIutility\fP is executed. +.LP +.IP " *" 3 +The System CPU time, equivalent to the sum of the \fItms_stime\fP +and \fItms_cstime\fP fields returned by the \fItimes\fP() function +for the process in which \fIutility\fP is executed. +.LP +.LP +The precision of the timing shall be no less than the granularity +defined for the size of the clock tick unit on the system, but +the results shall be reported in terms of standard time units (for +example, 0.02 seconds, 00:00:00.02, 1m33.75s, 365.21 seconds), +not numbers of clock ticks. +.LP +When \fItime\fP is used as part of a pipeline, the times reported +are unspecified, except when it is the sole command within a +grouping command (see \fIGrouping Commands\fP ) in that pipeline. +For example, the +commands on the left are unspecified; those on the right report on +utilities \fBa\fP and \fBc\fP, respectively: +.sp +.RS +.nf + +\fBtime a | b | c { time a } | b | c +a | b | time c a | b | (time c) +\fP +.fi +.RE +.SH OPTIONS +.LP +The \fItime\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-p\fP +Write the timing output to standard error in the format shown in the +STDERR section. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIutility\fP +The name of a utility that is to be invoked. If the \fIutility\fP +operand names any of the special built-in utilities in \fISpecial +Built-In Utilities\fP , the results are undefined. +.TP 7 +\fIargument\fP +Any string to be supplied as an argument when invoking the utility +named by the \fIutility\fP operand. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItime\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic and informative messages written to +standard error. +.TP 7 +\fILC_NUMERIC\fP +.sp +Determine the locale for numeric formatting. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the search path that shall be used to locate the utility +to be invoked; see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used to write the timing statistics. If +\fB-p\fP is specified, the following format shall be used +in the POSIX locale: +.sp +.RS +.nf + +\fB"real %f\\nuser %f\\nsys %f\\n", <\fP\fIreal seconds\fP\fB>, <\fP\fIuser seconds\fP\fB>, + <\fP\fIsystem seconds\fP\fB> +\fP +.fi +.RE +.LP +where each floating-point number shall be expressed in seconds. The +precision used may be less than the default six digits of +\fB%f\fP , but shall be sufficiently precise to accommodate the size +of the clock tick on the system (for example, if there were +60 clock ticks per second, at least two digits shall follow the radix +character). The number of digits following the radix +character shall be no less than one, even if this always results in +a trailing zero. The implementation may append white space and +additional information following the format shown here. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If the \fIutility\fP utility is invoked, the exit status of \fItime\fP +shall be the exit status of \fIutility\fP; otherwise, +the \fItime\fP utility shall exit with one of the following values: +.TP 7 +1-125 +An error occurred in the \fItime\fP utility. +.TP 7 +\ \ 126 +The utility specified by \fIutility\fP was found but could not be +invoked. +.TP 7 +\ \ 127 +The utility specified by \fIutility\fP could not be found. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIcommand\fP, \fIenv\fP, \fInice\fP, \fInohup\fP, \fItime\fP, +and \fIxargs\fP utilities have been specified to use exit code 127 +if an error occurs so that +applications can distinguish "failure to find a utility" from "invoked +utility exited with an error indication". The value 127 +was chosen because it is not commonly used for other meanings; most +utilities use small values for "normal error conditions" and +the values above 128 can be confused with termination due to receipt +of a signal. The value 126 was chosen in a similar manner to +indicate that the utility could be found, but not invoked. Some scripts +produce meaningful error messages differentiating the 126 +and 127 cases. The distinction between exit codes 126 and 127 is based +on KornShell practice that uses 127 when all attempts to +\fIexec\fP the utility fail with [ENOENT], and uses 126 when any attempt +to \fIexec\fP the utility fails for any other +reason. +.SH EXAMPLES +.LP +It is frequently desirable to apply \fItime\fP to pipelines or lists +of commands. This can be done by placing pipelines and +command lists in a single file; this file can then be invoked as a +utility, and the \fItime\fP applies to everything in the +file. +.LP +Alternatively, the following command can be used to apply \fItime\fP +to a complex command: +.sp +.RS +.nf + +\fBtime sh -c '\fP\fIcomplex-command-line\fP\fB' +\fP +.fi +.RE +.SH RATIONALE +.LP +When the \fItime\fP utility was originally proposed to be included +in the ISO\ POSIX-2:1993 standard, questions were raised +about its suitability for inclusion on the grounds that it was not +useful for conforming applications, specifically: +.IP " *" 3 +The underlying CPU definitions from the System Interfaces volume of +IEEE\ Std\ 1003.1-2001 are vague, so the numeric +output could not be compared accurately between systems or even between +invocations. +.LP +.IP " *" 3 +The creation of portable benchmark programs was outside the scope +this volume of IEEE\ Std\ 1003.1-2001. +.LP +.LP +However, \fItime\fP does fit in the scope of user portability. Human +judgement can be applied to the analysis of the output, +and it could be very useful in hands-on debugging of applications +or in providing subjective measures of system performance. Hence +it has been included in this volume of IEEE\ Std\ 1003.1-2001. +.LP +The default output format has been left unspecified because historical +implementations differ greatly in their style of +depicting this numeric output. The \fB-p\fP option was invented to +provide scripts with a common means of obtaining this +information. +.LP +In the KornShell, \fItime\fP is a shell reserved word that can be +used to time an entire pipeline, rather than just a simple +command. The POSIX definition has been worded to allow this implementation. +Consideration was given to invalidating this approach +because of the historical model from the C shell and System V shell. +However, since the System V \fItime\fP utility historically +has not produced accurate results in pipeline timing (because the +constituent processes are not all owned by the same parent +process, as allowed by POSIX), it did not seem worthwhile to break +historical KornShell usage. +.LP +The term \fIutility\fP is used, rather than \fIcommand\fP, to highlight +the fact that shell compound commands, pipelines, +special built-ins, and so on, cannot be used directly. However, \fIutility\fP +includes user application programs and shell +scripts, not just the standard utilities. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIsh\fP , the System Interfaces +volume of IEEE\ Std\ 1003.1-2001, \fItimes\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/times.1p b/man1p/times.1p new file mode 100644 index 000000000..f98ab7b55 --- /dev/null +++ b/man1p/times.1p @@ -0,0 +1,102 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TIMES" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" times +.SH NAME +times \- write process times +.SH SYNOPSIS +.LP +\fBtimes\fP +.SH DESCRIPTION +.LP +The \fItimes\fP utility shall write the accumulated user and system +times for the shell and for all of its child processes, in +the following POSIX locale format: +.sp +.RS +.nf + +\fB"%dm%fs %dm%fs\\n%dm%fs %dm%fs\\n", <\fP\fIshell user minutes\fP\fB>, + <\fP\fIshell user seconds\fP\fB>, <\fP\fIshell system minutes\fP\fB>, + <\fP\fIshell system seconds\fP\fB>, <\fP\fIchildren user minutes\fP\fB>, + <\fP\fIchildren user seconds\fP\fB>, <\fP\fIchildren system minutes\fP\fB>, + <\fP\fIchildren system seconds\fP\fB> +\fP +.fi +.RE +.LP +The four pairs of times shall correspond to the members of the \fI<sys/times.h>\fP +\fBtms\fP structure (defined in the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 13, Headers) as returned by \fItimes\fP(): +\fItms_utime\fP, \fItms_stime\fP, \fItms_cutime\fP, and \fItms_cstime\fP, +respectively. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the DESCRIPTION. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +Zero. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.sp +.RS +.nf + +\fB$\fP \fBtimes +\fP\fB0m0.43s 0m1.11s +8m44.18s 1m43.23s\fP +.fi +.RE +.SH RATIONALE +.LP +The \fItimes\fP special built-in from the Single UNIX Specification +is now required for all conforming shells. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/touch.1p b/man1p/touch.1p new file mode 100644 index 000000000..5c1c65a30 --- /dev/null +++ b/man1p/touch.1p @@ -0,0 +1,344 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TOUCH" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" touch +.SH NAME +touch \- change file access and modification times +.SH SYNOPSIS +.LP +\fBtouch\fP \fB[\fP\fB-acm\fP\fB][\fP \fB-r\fP \fIref_file\fP\fB| +-t\fP \fItime\fP\fB]\fP +\fIfile\fP\fB...\fP +.SH DESCRIPTION +.LP +The \fItouch\fP utility shall change the modification times, access +times, or both of files. The modification time shall be +equivalent to the value of the \fIst_mtime\fP member of the \fBstat\fP +structure for a file, as described in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001; the access time shall +be equivalent to the value of \fIst_atime\fP. +.LP +The time used can be specified by the \fB-t\fP \fItime\fP option-argument, +the corresponding time fields of the file +referenced by the \fB-r\fP \fIref_file\fP option-argument, or the +\fIdate_time\fP operand, as specified in the following +sections. If none of these are specified, \fItouch\fP shall use the +current time (the value returned by the equivalent of the \fItime\fP() +function defined in the System Interfaces volume of +IEEE\ Std\ 1003.1-2001). +.LP +For each \fIfile\fP operand, \fItouch\fP shall perform actions equivalent +to the following functions defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001: +.IP " 1." 4 +If \fIfile\fP does not exist, a \fIcreat\fP() function call is made +with the \fIfile\fP +operand used as the \fIpath\fP argument and the value of the bitwise-inclusive +OR of S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, +and S_IWOTH used as the \fImode\fP argument. +.LP +.IP " 2." 4 +The \fIutime\fP() function is called with the following arguments: +.RS +.IP " a." 4 +The \fIfile\fP operand is used as the \fIpath\fP argument. +.LP +.IP " b." 4 +The \fButimbuf\fP structure members \fIactime\fP and \fImodtime\fP +are determined as described in the OPTIONS section. +.LP +.RE +.LP +.SH OPTIONS +.LP +The \fItouch\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Change the access time of \fIfile\fP. Do not change the modification +time unless \fB-m\fP is also specified. +.TP 7 +\fB-c\fP +Do not create a specified \fIfile\fP if it does not exist. Do not +write any diagnostic messages concerning this +condition. +.TP 7 +\fB-m\fP +Change the modification time of \fIfile\fP. Do not change the access +time unless \fB-a\fP is also specified. +.TP 7 +\fB-r\ \fP \fIref_file\fP +Use the corresponding time of the file named by the pathname \fIref_file\fP +instead of the current time. +.TP 7 +\fB-t\ \fP \fItime\fP +Use the specified \fItime\fP instead of the current time. The option-argument +shall be a decimal number of the form: +.sp +.RS +.nf + +\fB[[\fP\fICC\fP\fB]\fP\fIYY\fP\fB]\fP\fIMMDDhhmm\fP\fB[\fP\fB.\fP\fISS\fP\fB]\fP +.fi +.RE +.LP +where each two digits represents the following: +.TP 7 +\fIMM\fP +.RS +The month of the year [01,12]. +.RE +.TP 7 +\fIDD\fP +.RS +The day of the month [01,31]. +.RE +.TP 7 +\fIhh\fP +.RS +The hour of the day [00,23]. +.RE +.TP 7 +\fImm\fP +.RS +The minute of the hour [00,59]. +.RE +.TP 7 +\fICC\fP +.RS +The first two digits of the year (the century). +.RE +.TP 7 +\fIYY\fP +.RS +The second two digits of the year. +.RE +.TP 7 +\fISS\fP +.RS +The second of the minute [00,60]. +.RE +.sp +.LP +Both \fICC\fP and \fIYY\fP shall be optional. If neither is given, +the current year shall be assumed. If \fIYY\fP is +specified, but \fICC\fP is not, \fICC\fP shall be derived as follows: +.TS C +center; l l. +\fBIf \fIYY\fP is:\fP \fB\fICC\fP becomes:\fP +[69,99] 19 +[00,68] 20 +.TE +.TP 7 +\fBNote:\fP +.RS +It is expected that in a future version of IEEE\ Std\ 1003.1-2001 +the default century inferred from a 2-digit year will +change. (This would apply to all commands accepting a 2-digit year +as input.) +.RE +.sp +.LP +The resulting time shall be affected by the value of the \fITZ\fP +environment variable. If the resulting time value precedes +the Epoch, \fItouch\fP shall exit immediately with an error status. +The range of valid times past the Epoch is +implementation-defined, but it shall extend to at least the time 0 +hours, 0 minutes, 0 seconds, January 1, 2038, Coordinated +Universal Time. Some implementations may not be able to represent +dates beyond January 18, 2038, because they use \fBsigned int\fP +as a time holder. +.LP +The range for \fISS\fP is [00,60] rather than [00,59] because of leap +seconds. If \fISS\fP is 60, and the resulting time, as +affected by the \fITZ\fP environment variable, does not refer to a +leap second, the resulting time shall be one second after a +time where \fISS\fP is 59. If \fISS\fP is not given a value, it is +assumed to be zero. +.sp +.LP +If neither the \fB-a\fP nor \fB-m\fP options were specified, \fItouch\fP +shall behave as if both the \fB-a\fP and \fB-m\fP +options were specified. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file whose times shall be modified. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItouch\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone to be used for interpreting the \fItime\fP +option-argument. If \fITZ\fP is unset or null, an +unspecified default timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The utility executed successfully and all requested changes were made. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The interpretation of time is taken to be \fIseconds since the Epoch\fP +(see the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 4.14, Seconds Since the Epoch). It +should be noted that implementations conforming to the System Interfaces +volume of IEEE\ Std\ 1003.1-2001 do not take leap +seconds into account when computing seconds since the Epoch. When +\fISS\fP=60 is used, the resulting time always refers to 1 plus +\fIseconds since the Epoch\fP for a time when \fISS\fP=59. +.LP +Although the \fB-t\fP \fItime\fP option-argument specifies values +in 1969, the access time and modification time fields are +defined in terms of seconds since the Epoch (00:00:00 on 1 January +1970 UTC). Therefore, depending on the value of \fITZ\fP when +\fItouch\fP is run, there is never more than a few valid hours in +1969 and there need not be any valid times in 1969. +.LP +One ambiguous situation occurs if \fB-t\fP \fItime\fP is not specified, +\fB-r\fP \fIref_file\fP is not specified, and the +first operand is an eight or ten-digit decimal number. A portable +script can avoid this problem by using: +.sp +.RS +.nf + +\fBtouch -- file +\fP +.fi +.RE +.LP +or: +.sp +.RS +.nf + +\fBtouch ./file +\fP +.fi +.RE +.LP +in this case. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The functionality of \fItouch\fP is described almost entirely through +references to functions in the System Interfaces volume +of IEEE\ Std\ 1003.1-2001. In this way, there is no duplication of +effort required for describing such side effects as the +relationship of user IDs to the user database, permissions, and so +on. +.LP +There are some significant differences between the \fItouch\fP utility +in this volume of IEEE\ Std\ 1003.1-2001 and +those in System V and BSD systems. They are upwards-compatible for +historical applications from both implementations: +.IP " 1." 4 +In System V, an ambiguity exists when a pathname that is a decimal +number leads the operands; it is treated as a time value. In +BSD, no \fItime\fP value is allowed; files may only be \fItouch\fPed +to the current time. The \fB-t\fP \fItime\fP construct +solves these problems for future conforming applications (note that +the \fB-t\fP option is not historical practice). +.LP +.IP " 2." 4 +The inclusion of the century digits, \fICC\fP, is also new. Note that +a ten-digit \fItime\fP value is treated as if \fIYY\fP, +and not \fICC\fP, were specified. The caveat about the range of dates +following the Epoch was included as recognition that some +implementations are not able to represent dates beyond 18 January +2038 because they use \fBsigned int\fP as a time holder. +.LP +.LP +The \fB-r\fP option was added because several comments requested this +capability. This option was named \fB-f\fP in an early +proposal, but was changed because the \fB-f\fP option is used in the +BSD version of \fItouch\fP with a different meaning. +.LP +At least one historical implementation of \fItouch\fP incremented +the exit code if \fB-c\fP was specified and the file did not +exist. This volume of IEEE\ Std\ 1003.1-2001 requires exit status +zero if no errors occur. +.SH FUTURE DIRECTIONS +.LP +Applications should use the \fB-r\fP or \fB-t\fP options. +.SH SEE ALSO +.LP +\fIdate\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001, +\fIcreat\fP(), \fItime\fP(), \fIutime\fP(), the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, \fI<sys/stat.h>\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/tput.1p b/man1p/tput.1p new file mode 100644 index 000000000..3a94b1e9f --- /dev/null +++ b/man1p/tput.1p @@ -0,0 +1,228 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TPUT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" tput +.SH NAME +tput \- change terminal characteristics +.SH SYNOPSIS +.LP +\fBtput\fP \fB[\fP\fB-T\fP \fItype\fP\fB]\fP \fIoperand\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fItput\fP utility shall display terminal-dependent information. +The manner in which this information is retrieved is +unspecified. The information displayed shall clear the terminal screen, +initialize the user's terminal, or reset the user's +terminal, depending on the operand given. The exact consequences of +displaying this information are unspecified. +.SH OPTIONS +.LP +The \fItput\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-T\ \fP \fItype\fP +Indicate the type of terminal. If this option is not supplied and +the \fITERM\fP variable is unset or null, an unspecified +default terminal type shall be used. The setting of \fItype\fP shall +take precedence over the value in \fITERM .\fP +.sp +.SH OPERANDS +.LP +The following strings shall be supported as operands by the implementation +in the POSIX locale: +.TP 7 +\fBclear\fP +Display the clear-screen sequence. +.TP 7 +\fBinit\fP +Display the sequence that initializes the user's terminal in an implementation-defined +manner. +.TP 7 +\fBreset\fP +Display the sequence that resets the user's terminal in an implementation-defined +manner. +.sp +.LP +If a terminal does not support any of the operations described by +these operands, this shall not be considered an error +condition. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItput\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITERM\fP +Determine the terminal type. If this variable is unset or null, and +if the \fB-T\fP option is not specified, an unspecified +default terminal type shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If standard output is a terminal device, it may be used for writing +the appropriate sequence to clear the screen or reset or +initialize the terminal. If standard output is not a terminal device, +undefined results occur. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The requested string was written successfully. +.TP 7 +\ 1 +Unspecified. +.TP 7 +\ 2 +Usage error. +.TP 7 +\ 3 +No information is available about the specified terminal type. +.TP 7 +\ 4 +The specified operand is invalid. +.TP 7 +>4 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If one of the operands is not available for the terminal, \fItput\fP +continues processing the remaining operands. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The difference between resetting and initializing a terminal is left +unspecified, as they vary greatly based on hardware types. +In general, resetting is a more severe action. +.LP +Some terminals use control characters to perform the stated functions, +and on such terminals it might make sense to use +\fItput\fP to store the initialization strings in a file or environment +variable for later use. However, because other terminals +might rely on system calls to do this work, the standard output cannot +be used in a portable manner, such as the following +non-portable constructs: +.sp +.RS +.nf + +\fBClearVar=`tput clear` +tput reset | mailx -s "Wake Up" ddg +\fP +.fi +.RE +.SH EXAMPLES +.IP " 1." 4 +Initialize the terminal according to the type of terminal in the environmental +variable \fITERM .\fP This command can be +included in a \fB.profile\fP file. +.sp +.RS +.nf + +\fBtput init +\fP +.fi +.RE +.LP +.IP " 2." 4 +Reset a 450 terminal. +.sp +.RS +.nf + +\fBtput -T 450 reset +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The list of operands was reduced to a minimum for the following reasons: +.IP " *" 3 +The only features chosen were those that were likely to be used by +human users interacting with a terminal. +.LP +.IP " *" 3 +Specifying the full \fIterminfo\fP set was not considered desirable, +but the standard developers did not want to select among +operands. +.LP +.IP " *" 3 +This volume of IEEE\ Std\ 1003.1-2001 does not attempt to provide +applications with sophisticated terminal handling +capabilities, as that falls outside of its assigned scope and intersects +with the responsibilities of other standards bodies. +.LP +.LP +The difference between resetting and initializing a terminal is left +unspecified as this varies greatly based on hardware types. +In general, resetting is a more severe action. +.LP +The exit status of 1 is historically reserved for finding out if a +Boolean operand is not set. Although the operands were +reduced to a minimum, the exit status of 1 should still be reserved +for the Boolean operands, for those sites that wish to support +them. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIstty\fP , \fItabs\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/tr.1p b/man1p/tr.1p new file mode 100644 index 000000000..9a8baabc4 --- /dev/null +++ b/man1p/tr.1p @@ -0,0 +1,538 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" tr +.SH NAME +tr \- translate characters +.SH SYNOPSIS +.LP +\fBtr\fP \fB[\fP\fB-c | -C\fP\fB][\fP\fB-s]\fP \fIstring1 string2\fP\fB +.br +.sp +tr -s\fP \fB[\fP\fB-c | -C\fP\fB]\fP \fIstring1\fP\fB +.br +.sp +tr -d\fP \fB[\fP\fB-c | -C\fP\fB]\fP \fIstring1\fP\fB +.br +.sp +tr -ds\fP \fB[\fP\fB-c | -C\fP\fB]\fP \fIstring1 string2\fP\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fItr\fP utility shall copy the standard input to the standard +output with substitution or deletion of selected characters. +The options specified and the \fIstring1\fP and \fIstring2\fP operands +shall control translations that occur while copying +characters and single-character collating elements. +.SH OPTIONS +.LP +The \fItr\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Complement the set of values specified by \fIstring1\fP. See the EXTENDED +DESCRIPTION section. +.TP 7 +\fB-C\fP +Complement the set of characters specified by \fIstring1\fP. See the +EXTENDED DESCRIPTION section. +.TP 7 +\fB-d\fP +Delete all occurrences of input characters that are specified by \fIstring1\fP. +.TP 7 +\fB-s\fP +Replace instances of repeated characters with a single character, +as described in the EXTENDED DESCRIPTION section. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIstring1\fP,\ \fIstring2\fP +.sp +Translation control strings. Each string shall represent a set of +characters to be converted into an array of characters used for +the translation. For a detailed description of how the strings are +interpreted, see the EXTENDED DESCRIPTION section. +.sp +.SH STDIN +.LP +The standard input can be any type of file. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItr\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of range expressions and equivalence +classes. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments) and the behavior of +character classes. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fItr\fP output shall be identical to the input, with the exception +of the specified transformations. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +The operands \fIstring1\fP and \fIstring2\fP (if specified) define +two arrays of characters. The constructs in the following +list can be used to specify characters or single-character collating +elements. If any of the constructs result in multi-character +collating elements, \fItr\fP shall exclude, without a diagnostic, +those multi-character elements from the resulting array. +.TP 7 +\fIcharacter\fP +Any character not described by one of the conventions below shall +represent itself. +.TP 7 +\\\fIoctal\fP +Octal sequences can be used to represent characters with specific +coded values. An octal sequence shall consist of a backslash +followed by the longest sequence of one, two, or three-octal-digit +characters (01234567). The sequence shall cause the value whose +encoding is represented by the one, two, or three-digit octal integer +to be placed into the array. If the size of a byte on the +system is greater than nine bits, the valid escape sequence used to +represent a byte is implementation-defined. Multi-byte +characters require multiple, concatenated escape sequences of this +type, including the leading \fB'\\'\fP for each byte. +.TP 7 +\\\fIcharacter\fP +The backslash-escape sequences in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Table 5-1, Escape Sequences +and Associated Actions ( \fB'\\\\'\fP , \fB'\\a'\fP , \fB'\\b'\fP +, \fB'\\f'\fP , \fB'\\n'\fP , \fB'\\r'\fP , +\fB'\\t'\fP , \fB'\\v'\fP ) shall be supported. The results of using +any other character, other than an octal digit, following +the backslash are unspecified. +.TP 7 +\fIc\fP-\fIc\fP +In the POSIX locale, this construct shall represent the range of collating +elements between the range endpoints (as long as +neither endpoint is an octal sequence of the form \\\fIoctal\fP), +inclusive, as defined by the collation sequence. The characters +or collating elements in the range shall be placed in the array in +ascending collation sequence. If the second endpoint precedes +the starting endpoint in the collation sequence, it is unspecified +whether the range of collating elements is empty, or this +construct is treated as invalid. In locales other than the POSIX locale, +this construct has unspecified behavior. +.LP +If either or both of the range endpoints are octal sequences of the +form \\\fIoctal\fP, this shall represent the range of +specific coded values between the two range endpoints, inclusive. +.TP 7 +.B :\fIclass\fP: +Represents all characters belonging to the defined character class, +as defined by the current setting of the \fILC_CTYPE\fP +locale category. The following character class names shall be accepted +when specified in \fIstring1\fP: +.TS C +center; l l l l l l. +\fBalnum\fP \fBblank\fP \fBdigit\fP \fBlower\fP \fBpunct\fP \fBupper\fP +\fBalpha\fP \fBcntrl\fP \fBgraph\fP \fBprint\fP \fBspace\fP \fBxdigit\fP +.TE +.LP +In addition, character class expressions of the form [: \fIname\fP:] +shall be recognized in those locales where the \fIname\fP +keyword has been given a \fBcharclass\fP definition in the \fILC_CTYPE\fP +category. +.LP +When both the \fB-d\fP and \fB-s\fP options are specified, any of +the character class names shall be accepted in +\fIstring2\fP. Otherwise, only character class names \fBlower\fP or +\fBupper\fP are valid in \fIstring2\fP and then only if the +corresponding character class ( \fBupper\fP and \fBlower\fP, respectively) +is specified in the same relative position in +\fIstring1\fP. Such a specification shall be interpreted as a request +for case conversion. When [: \fIlower\fP:] appears in +\fIstring1\fP and [: \fIupper\fP:] appears in \fIstring2\fP, the arrays +shall contain the characters from the \fBtoupper\fP +mapping in the \fILC_CTYPE\fP category of the current locale. When +[: \fIupper\fP:] appears in \fIstring1\fP and [: +\fIlower\fP:] appears in \fIstring2\fP, the arrays shall contain the +characters from the \fBtolower\fP mapping in the +\fILC_CTYPE\fP category of the current locale. The first character +from each mapping pair shall be in the array for \fIstring1\fP +and the second character from each mapping pair shall be in the array +for \fIstring2\fP in the same relative position. +.LP +Except for case conversion, the characters specified by a character +class expression shall be placed in the array in an +unspecified order. +.LP +If the name specified for \fIclass\fP does not define a valid character +class in the current locale, the behavior is +undefined. +.TP 7 +.B =\fIequiv\fP= +Represents all characters or collating elements belonging to the same +equivalence class as \fIequiv\fP, as defined by the +current setting of the \fILC_COLLATE\fP locale category. An equivalence +class expression shall be allowed only in \fIstring1\fP, +or in \fIstring2\fP when it is being used by the combined \fB-d\fP +and \fB-s\fP options. The characters belonging to the +equivalence class shall be placed in the array in an unspecified order. +.TP 7 +.B \fIx\fP*\fIn\fP +Represents \fIn\fP repeated occurrences of the character \fIx\fP. +Because this expression is used to map multiple characters +to one, it is only valid when it occurs in \fIstring2\fP. If \fIn\fP +is omitted or is zero, it shall be interpreted as large +enough to extend the \fIstring2\fP-based sequence to the length of +the \fIstring1\fP-based sequence. If \fIn\fP has a leading +zero, it shall be interpreted as an octal value. Otherwise, it shall +be interpreted as a decimal value. +.sp +.LP +When the \fB-d\fP option is not specified: +.IP " *" 3 +Each input character found in the array specified by \fIstring1\fP +shall be replaced by the character in the same relative +position in the array specified by \fIstring2\fP. When the array specified +by \fIstring2\fP is shorter that the one specified by +\fIstring1\fP, the results are unspecified. +.LP +.IP " *" 3 +If the \fB-C\fP option is specified, the complements of the characters +specified by \fIstring1\fP (the set of all characters +in the current character set, as defined by the current setting of +\fILC_CTYPE ,\fP except for those actually specified in the +\fIstring1\fP operand) shall be placed in the array in ascending collation +sequence, as defined by the current setting of +\fILC_COLLATE .\fP +.LP +.IP " *" 3 +If the \fB-c\fP option is specified, the complement of the values +specified by \fIstring1\fP shall be placed in the array in +ascending order by binary value. +.LP +.IP " *" 3 +Because the order in which characters specified by character class +expressions or equivalence class expressions is undefined, +such expressions should only be used if the intent is to map several +characters into one. An exception is case conversion, as +described previously. +.LP +.LP +When the \fB-d\fP option is specified: +.IP " *" 3 +Input characters found in the array specified by \fIstring1\fP shall +be deleted. +.LP +.IP " *" 3 +When the \fB-C\fP option is specified with \fB-d\fP, all characters +except those specified by \fIstring1\fP shall be deleted. +The contents of \fIstring2\fP are ignored, unless the \fB-s\fP option +is also specified. +.LP +.IP " *" 3 +When the \fB-c\fP option is specified with \fB-d\fP, all values except +those specified by \fIstring1\fP shall be deleted. The +contents of \fIstring2\fP shall be ignored, unless the \fB-s\fP option +is also specified. +.LP +.IP " *" 3 +The same string cannot be used for both the \fB-d\fP and the \fB-s\fP +option; when both options are specified, both +\fIstring1\fP (used for deletion) and \fIstring2\fP (used for squeezing) +shall be required. +.LP +.LP +When the \fB-s\fP option is specified, after any deletions or translations +have taken place, repeated sequences of the same +character shall be replaced by one occurrence of the same character, +if the character is found in the array specified by the last +operand. If the last operand contains a character class, such as the +following example: +.sp +.RS +.nf + +\fBtr -s '[:space:]' +\fP +.fi +.RE +.LP +the last operand's array shall contain all of the characters in that +character class. However, in a case conversion, as +described previously, such as: +.sp +.RS +.nf + +\fBtr -s '[:upper:]' '[:lower:]' +\fP +.fi +.RE +.LP +the last operand's array shall contain only those characters defined +as the second characters in each of the \fBtoupper\fP or +\fBtolower\fP character pairs, as appropriate. +.LP +An empty string used for \fIstring1\fP or \fIstring2\fP produces undefined +results. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +All input was processed successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +If necessary, \fIstring1\fP and \fIstring2\fP can be quoted to avoid +pattern matching by the shell. +.LP +If an ordinary digit (representing itself) is to follow an octal sequence, +the octal sequence must use the full three digits to +avoid ambiguity. +.LP +When \fIstring2\fP is shorter than \fIstring1\fP, a difference results +between historical System\ V and BSD systems. A BSD +system pads \fIstring2\fP with the last character found in \fIstring2\fP. +Thus, it is possible to do the following: +.sp +.RS +.nf + +\fBtr 0123456789 d +\fP +.fi +.RE +.LP +which would translate all digits to the letter \fB'd'\fP . Since this +area is specifically unspecified in this volume of +IEEE\ Std\ 1003.1-2001, both the BSD and System\ V behaviors are allowed, +but a conforming application cannot rely on +the BSD behavior. It would have to code the example in the following +way: +.sp +.RS +.nf + +\fBtr 0123456789 '[d*]' +\fP +.fi +.RE +.LP +It should be noted that, despite similarities in appearance, the string +operands used by \fItr\fP are not regular +expressions. +.LP +Unlike some historical implementations, this definition of the \fItr\fP +utility correctly processes NUL characters in its input +stream. NUL characters can be stripped by using: +.sp +.RS +.nf + +\fBtr -d '\\000' +\fP +.fi +.RE +.SH EXAMPLES +.IP " 1." 4 +The following example creates a list of all words in \fBfile1\fP one +per line in \fBfile2\fP, where a word is taken to be a +maximal string of letters. +.sp +.RS +.nf + +\fBtr -cs "[:alpha:]" "[\\n*]" <file1 >file2 +\fP +.fi +.RE +.LP +.IP " 2." 4 +The next example translates all lowercase characters in \fBfile1\fP +to uppercase and writes the results to standard output. +.sp +.RS +.nf + +\fBtr "[:lower:]" "[:upper:]" <file1 +\fP +.fi +.RE +.LP +.IP " 3." 4 +This example uses an equivalence class to identify accented variants +of the base character \fB'e'\fP in \fBfile1\fP, which +are stripped of diacritical marks and written to \fBfile2\fP. +.sp +.RS +.nf + +\fBtr "[=e=]" e <file1 >file2 +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +In some early proposals, an explicit option \fB-n\fP was added to +disable the historical behavior of stripping NUL characters +from the input. It was considered that automatically stripping NUL +characters from the input was not correct functionality. +However, the removal of \fB-n\fP in a later proposal does not remove +the requirement that \fItr\fP correctly process NUL +characters in its input stream. NUL characters can be stripped by +using \fItr\fP \fB-d\fP '\\000'. +.LP +Historical implementations of \fItr\fP differ widely in syntax and +behavior. For example, the BSD version has not needed the +bracket characters for the repetition sequence. The \fItr\fP utility +syntax is based more closely on the System V and XPG3 model +while attempting to accommodate historical BSD implementations. In +the case of the short \fIstring2\fP padding, the decision was +to unspecify the behavior and preserve System V and XPG3 scripts, +which might find difficulty with the BSD method. The assumption +was made that BSD users of \fItr\fP have to make accommodations to +meet the syntax defined here. Since it is possible to use the +repetition sequence to duplicate the desired behavior, whereas there +is no simple way to achieve the System V method, this was the +correct, if not desirable, approach. +.LP +The use of octal values to specify control characters, while having +historical precedents, is not portable. The introduction of +escape sequences for control characters should provide the necessary +portability. It is recognized that this may cause some +historical scripts to break. +.LP +An early proposal included support for multi-character collating elements. +It was pointed out that, while \fItr\fP does employ +some syntactical elements from REs, the aim of \fItr\fP is quite different; +ranges, for example, do not have a similar meaning +(``any of the chars in the range matches", \fIversus\fP "translate +each character in the range to the output counterpart"). As +a result, the previously included support for multi-character collating +elements has been removed. What remains are ranges in +current collation order (to support, for example, accented characters), +character classes, and equivalence classes. +.LP +In XPG3 the [: \fIclass\fP:] and [= \fIequiv\fP=] conventions are +shown with double brackets, as in RE syntax. However, +\fItr\fP does not implement RE principles; it just borrows part of +the syntax. Consequently, [: \fIclass\fP:] and [= +\fIequiv\fP=] should be regarded as syntactical elements on a par +with [ \fIx\fP* \fIn\fP], which is not an RE bracket +expression. +.LP +The standard developers will consider changes to \fItr\fP that allow +it to translate characters between different character +encodings, or they will consider providing a new utility to accomplish +this. +.LP +On historical System V systems, a range expression requires enclosing +square-brackets, such as: +.sp +.RS +.nf + +\fBtr '[a-z]' '[A-Z]' +\fP +.fi +.RE +.LP +However, BSD-based systems did not require the brackets, and this +convention is used here to avoid breaking large numbers of BSD +scripts: +.sp +.RS +.nf + +\fBtr a-z A-Z +\fP +.fi +.RE +.LP +The preceding System V script will continue to work because the brackets, +treated as regular characters, are translated to +themselves. However, any System V script that relied on \fB"a-z"\fP +representing the three characters \fB'a'\fP , +\fB'-'\fP , and \fB'z'\fP have to be rewritten as \fB"az-"\fP . +.LP +The ISO\ POSIX-2:1993 standard had a \fB-c\fP option that behaved +similarly to the \fB-C\fP option, but did not supply +functionality equivalent to the \fB-c\fP option specified in IEEE\ Std\ 1003.1-2001. +This meant that historical practice +of being able to specify \fItr\fP \fB-d\fP\\200-\\377 (which would +delete all bytes with the top bit set) would have no effect +because, in the C locale, bytes with the values octal 200 to octal +377 are not characters. +.LP +The earlier version also said that octal sequences referred to collating +elements and could be placed adjacent to each other to +specify multi-byte characters. However, it was noted that this caused +ambiguities because \fItr\fP would not be able to tell +whether adjacent octal sequences were intending to specify multi-byte +characters or multiple single byte characters. +IEEE\ Std\ 1003.1-2001 specifies that octal sequences always refer +to single byte binary values. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIsed\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/trap.1p b/man1p/trap.1p new file mode 100644 index 000000000..18bcefb93 --- /dev/null +++ b/man1p/trap.1p @@ -0,0 +1,240 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TRAP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" trap +.SH NAME +trap \- trap signals +.SH SYNOPSIS +.LP +\fBtrap\fP \fB[\fP\fIaction condition\fP \fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +If \fIaction\fP is \fB'-'\fP , the shell shall reset each \fIcondition\fP +to the default value. If \fIaction\fP is null ( +\fB""\fP ), the shell shall ignore each specified \fIcondition\fP +if it arises. Otherwise, the argument \fIaction\fP shall be +read and executed by the shell when one of the corresponding conditions +arises. The action of \fItrap\fP shall override a previous +action (either default action or one explicitly set). The value of +\fB"$?"\fP after the \fItrap\fP action completes shall be +the value it had before \fItrap\fP was invoked. +.LP +The condition can be EXIT, 0 (equivalent to EXIT), or a signal specified +using a symbolic name, without the SIG prefix, as +listed in the tables of signal names in the \fI<signal.h>\fP header +defined in the +Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 13, Headers; +for example, HUP, INT, QUIT, TERM. Implementations may permit names +with the SIG prefix or ignore case in signal names as an +extension. Setting a trap for SIGKILL or SIGSTOP produces undefined +results. +.LP +The environment in which the shell executes a \fItrap\fP on EXIT shall +be identical to the environment immediately after the +last command executed before the \fItrap\fP on EXIT was taken. +.LP +Each time \fItrap\fP is invoked, the \fIaction\fP argument shall be +processed in a manner equivalent to: +.sp +.RS +.nf + +\fBeval\fP \fIaction\fP +.fi +.RE +.LP +Signals that were ignored on entry to a non-interactive shell cannot +be trapped or reset, although no error need be reported +when attempting to do so. An interactive shell may reset or catch +signals ignored on entry. Traps shall remain in place for a given +shell until explicitly changed with another \fItrap\fP command. +.LP +When a subshell is entered, traps that are not being ignored are set +to the default actions. This does not imply that the +\fItrap\fP command cannot be used within the subshell to set new traps. +.LP +The \fItrap\fP command with no arguments shall write to standard output +a list of commands associated with each condition. The +format shall be: +.sp +.RS +.nf + +\fB"trap -- %s %s ...\\n", <\fP\fIaction\fP\fB>, <\fP\fIcondition\fP\fB> ... +\fP +.fi +.RE +.LP +The shell shall format the output, including the proper use of quoting, +so that it is suitable for reinput to the shell as +commands that achieve the same trapping results. For example: +.sp +.RS +.nf + +\fBsave_traps=$(trap) +\&... +eval "$save_traps" +\fP +.fi +.RE +.LP +XSI-conformant systems also allow numeric signal numbers for the conditions +corresponding to the following signal names: +.TS C +center; l l. +\fBSignal Number\fP \fBSignal Name\fP +1 SIGHUP +2 SIGINT +3 SIGQUIT +6 SIGABRT +9 SIGKILL +14 SIGALRM +15 SIGTERM +.TE +.LP +The \fItrap\fP special built-in shall conform to the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +See the DESCRIPTION. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If the trap name \ or number is invalid, a non-zero +exit status shall be returned; otherwise, zero shall be returned. +For both interactive and non-interactive shells, invalid signal +names \ or numbers shall not be considered a syntax error and do +not cause the shell to abort. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +Write out a list of all traps and actions: +.sp +.RS +.nf + +\fBtrap +\fP +.fi +.RE +.LP +Set a trap so the \fIlogout\fP utility in the directory referred to +by the \fIHOME\fP +environment variable executes when the shell terminates: +.sp +.RS +.nf + +\fBtrap '$HOME/logout' EXIT +\fP +.fi +.RE +.LP +or: +.sp +.RS +.nf + +\fBtrap '$HOME/logout' 0 +\fP +.fi +.RE +.LP +Unset traps on INT, QUIT, TERM, and EXIT: +.sp +.RS +.nf + +\fBtrap - INT QUIT TERM EXIT +\fP +.fi +.RE +.SH RATIONALE +.LP +Implementations may permit lowercase signal names as an extension. +Implementations may also accept the names with the SIG +prefix; no known historical shell does so. The \fItrap\fP and \fIkill\fP +utilities in this +volume of IEEE\ Std\ 1003.1-2001 are now consistent in their omission +of the SIG prefix for signal names. Some \fIkill\fP implementations +do not allow the prefix, and \fIkill\fP \fB-l\fP lists the signals +without prefixes. +.LP +Trapping SIGKILL or SIGSTOP is syntactically accepted by some historical +implementations, but it has no effect. Portable POSIX +applications cannot attempt to trap these signals. +.LP +The output format is not historical practice. Since the output of +historical \fItrap\fP commands is not portable (because +numeric signal values are not portable) and had to change to become +so, an opportunity was taken to format the output in a way that +a shell script could use to save and then later reuse a trap if it +wanted. +.LP +The KornShell uses an \fBERR\fP trap that is triggered whenever \fIset\fP +\fB-e\fP would +cause an exit. This is allowable as an extension, but was not mandated, +as other shells have not used it. +.LP +The text about the environment for the EXIT trap invalidates the behavior +of some historical versions of interactive shells +which, for example, close the standard input before executing a trap +on 0. For example, in some historical interactive shell +sessions the following trap on 0 would always print \fB"--"\fP : +.sp +.RS +.nf + +\fBtrap 'read foo; echo "-$foo-"' 0 +\fP +.fi +.RE +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/true.1p b/man1p/true.1p new file mode 100644 index 000000000..7372f0437 --- /dev/null +++ b/man1p/true.1p @@ -0,0 +1,91 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TRUE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" true +.SH NAME +true \- return true value +.SH SYNOPSIS +.LP +\fBtrue\fP +.SH DESCRIPTION +.LP +The \fItrue\fP utility shall return with exit code zero. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +Not used. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +Zero. +.SH CONSEQUENCES OF ERRORS +.LP +None. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +This utility is typically used in shell scripts, as shown in the EXAMPLES +section. The special built-in utility \fB:\fP is +sometimes more efficient than \fItrue\fP. +.SH EXAMPLES +.LP +This command is executed forever: +.sp +.RS +.nf + +\fBwhile true +do + command +done +\fP +.fi +.RE +.SH RATIONALE +.LP +The \fItrue\fP utility has been retained in this volume of IEEE\ Std\ 1003.1-2001, +even though the shell special +built-in \fB:\fP provides similar functionality, because \fItrue\fP +is widely used in historical scripts and is less cryptic to +novice script readers. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIfalse\fP , \fIShell Commands\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/tsort.1p b/man1p/tsort.1p new file mode 100644 index 000000000..ca4243356 --- /dev/null +++ b/man1p/tsort.1p @@ -0,0 +1,154 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TSORT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" tsort +.SH NAME +tsort \- topological sort +.SH SYNOPSIS +.LP +\fBtsort\fP \fB[\fP\fIfile\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fItsort\fP utility shall write to standard output a totally ordered +list of items consistent with a partial ordering of +items contained in the input. +.LP +The application shall ensure that the input consists of pairs of items +(non-empty strings) separated by <blank>s. Pairs of +different items indicate ordering. Pairs of identical items indicate +presence, but not ordering. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a text file to order. If no \fIfile\fP operand is given, +the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be a text file that is used if no \fIfile\fP +operand is given. +.SH INPUT FILES +.LP +The input file named by the \fIfile\fP operand is a text file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItsort\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be a text file consisting of the order list +produced from the partially ordered input. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fILC_COLLATE\fP variable need not affect the actions of \fItsort\fP. +The output ordering is not lexicographic, but +depends on the pairs of items given as input. +.SH EXAMPLES +.LP +The command: +.sp +.RS +.nf + +\fBtsort <<EOF +a b c c d e +g g +f g e f +h h +EOF +\fP +.fi +.RE +.LP +produces the output: +.sp +.RS +.nf + +\fBa +b +c +d +e +f +g +h\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +None. +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/tty.1p b/man1p/tty.1p new file mode 100644 index 000000000..569b066ff --- /dev/null +++ b/man1p/tty.1p @@ -0,0 +1,147 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TTY" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" tty +.SH NAME +tty \- return user's terminal name +.SH SYNOPSIS +.LP +\fBtty\fP +.SH DESCRIPTION +.LP +The \fItty\fP utility shall write to the standard output the name +of the terminal that is open as standard input. The name that +is used shall be equivalent to the string that would be returned by +the \fIttyname\fP() +function defined in the System Interfaces volume of IEEE\ Std\ 1003.1-2001. +.SH OPTIONS +.LP +The \fItty\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +While no input is read from standard input, standard input shall be +examined to determine whether or not it is a terminal, and, +if so, to determine the name of the terminal. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItty\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If standard input is a terminal device, a pathname of the terminal +as specified by the \fIttyname\fP() function defined in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001 +shall be written in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIterminal name\fP\fB> +\fP +.fi +.RE +.LP +Otherwise, a message shall be written indicating that standard input +is not connected to a terminal. In the POSIX locale, the +\fItty\fP utility shall use the format: +.sp +.RS +.nf + +\fB"not a tty\\n" +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Standard input is a terminal. +.TP 7 +\ 1 +Standard input is not a terminal. +.TP 7 +>1 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +This utility checks the status of the file open as standard input +against that of an implementation-defined set of files. It is +possible that no match can be found, or that the match found need +not be the same file as that which was opened for standard input +(although they are the same device). +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIisatty\fP(), +\fIttyname\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/type.1p b/man1p/type.1p new file mode 100644 index 000000000..01a6ea1d7 --- /dev/null +++ b/man1p/type.1p @@ -0,0 +1,137 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "TYPE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" type +.SH NAME +type \- write a description of command type +.SH SYNOPSIS +.LP +\fBtype\fP \fIname\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fItype\fP utility shall indicate how each argument would be interpreted +if used as a command name. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIname\fP +A name to be interpreted. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fItype\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the location of \fIname\fP, as described in the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment Variables. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output of \fItype\fP contains information about each +operand in an unspecified format. The information provided +typically identifies the operand as a shell built-in, function, alias, +or keyword, and where applicable, may display the operand's +pathname. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since \fItype\fP must be aware of the contents of the current shell +execution environment (such as the lists of commands, +functions, and built-ins processed by \fIhash\fP), it is always provided +as a shell regular +built-in. If it is called in a separate utility execution environment, +such as one of the following: +.sp +.RS +.nf + +\fBnohup type writer +find . -type f | xargs type +\fP +.fi +.RE +it might not produce accurate results. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcommand\fP , \fIhash\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/ulimit.1p b/man1p/ulimit.1p new file mode 100644 index 000000000..193fb8c75 --- /dev/null +++ b/man1p/ulimit.1p @@ -0,0 +1,173 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ULIMIT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" ulimit +.SH NAME +ulimit \- set or report file size limit +.SH SYNOPSIS +.LP +\fBulimit\fP \fB[\fP\fB-f\fP\fB][\fP\fIblocks\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIulimit\fP utility shall set or report the file-size writing +limit imposed on files written by the shell and its child +processes (files of any size may be read). Only a process with appropriate +privileges can increase the limit. +.SH OPTIONS +.LP +The \fIulimit\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-f\fP +Set (or report, if no \fIblocks\fP operand is present), the file size +limit in blocks. The \fB-f\fP option shall also be the +default case. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIblocks\fP +The number of 512-byte blocks to use as the new file size limit. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIulimit\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be used when no \fIblocks\fP operand is +present. If the current number of blocks is limited, the +number of blocks in the current limit shall be written in the following +format: +.sp +.RS +.nf + +\fB"%d\\n", <\fP\fInumber of 512-byte blocks\fP\fB> +\fP +.fi +.RE +.LP +If there is no current limit on the number of blocks, in the POSIX +locale the following format shall be used: +.sp +.RS +.nf + +\fB"unlimited\\n" +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +A request for a higher limit was rejected or an error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since \fIulimit\fP affects the current shell execution environment, +it is always provided as a shell regular built-in. If it is +called in a separate utility execution environment, such as one of +the following: +.sp +.RS +.nf + +\fBnohup ulimit -f 10000 +env ulimit 10000 +\fP +.fi +.RE +.LP +it does not affect the file size limit of the caller's environment. +.LP +Once a limit has been decreased by a process, it cannot be increased +(unless appropriate privileges are involved), even back to +the original system limit. +.SH EXAMPLES +.LP +Set the file size limit to 51200 bytes: +.sp +.RS +.nf + +\fBulimit -f 100 +\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIulimit\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/umask.1p b/man1p/umask.1p new file mode 100644 index 000000000..d471b1c9b --- /dev/null +++ b/man1p/umask.1p @@ -0,0 +1,310 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UMASK" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" umask +.SH NAME +umask \- get or set the file mode creation mask +.SH SYNOPSIS +.LP +\fBumask\fP \fB[\fP\fB-S\fP\fB][\fP\fImask\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIumask\fP utility shall set the file mode creation mask of the +current shell execution environment (see \fIShell Execution Environment\fP +) to the value specified by the \fImask\fP operand. This mask +shall affect the initial value of the file permission bits of subsequently +created files. If \fIumask\fP is called in a subshell +or separate utility execution environment, such as one of the following: +.sp +.RS +.nf + +\fB(umask 002) +nohup umask ... +find . -exec umask ... \\; +\fP +.fi +.RE +.LP +it shall not affect the file mode creation mask of the caller's environment. +.LP +If the \fImask\fP operand is not specified, the \fIumask\fP utility +shall write to standard output the value of the invoking +process' file mode creation mask. +.SH OPTIONS +.LP +The \fIumask\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-S\fP +Produce symbolic output. +.sp +.LP +The default output style is unspecified, but shall be recognized on +a subsequent invocation of \fIumask\fP on the same system +as a \fImask\fP operand to restore the previous file mode creation +mask. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fImask\fP +A string specifying the new file mode creation mask. The string is +treated in the same way as the \fImode\fP operand described +in the EXTENDED DESCRIPTION section for \fIchmod\fP. +.LP +For a \fIsymbolic_mode\fP value, the new value of the file mode creation +mask shall be the logical complement of the file +permission bits portion of the file mode specified by the \fIsymbolic_mode\fP +string. +.LP +In a \fIsymbolic_mode\fP value, the permissions \fIop\fP characters +\fB'+'\fP and \fB'-'\fP shall be interpreted +relative to the current file mode creation mask; \fB'+'\fP shall cause +the bits for the indicated permissions to be cleared in +the mask; \fB'-'\fP shall cause the bits for the indicated permissions +to be set in the mask. +.LP +The interpretation of \fImode\fP values that specify file mode bits +other than the file permission bits is unspecified. +.LP +In the octal integer form of \fImode\fP, the specified bits are set +in the file mode creation mask. +.LP +The file mode creation mask shall be set to the resulting numeric +value. +.LP +The default output of a prior invocation of \fIumask\fP on the same +system with no operand also shall be recognized as a +\fImask\fP operand. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIumask\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When the \fImask\fP operand is not specified, the \fIumask\fP utility +shall write a message to standard output that can later +be used as a \fIumask\fP \fImask\fP operand. +.LP +If \fB-S\fP is specified, the message shall be in the following format: +.sp +.RS +.nf + +\fB"u=%s,g=%s,o=%s\\n", <\fP\fIowner permissions\fP\fB>, <\fP\fIgroup permissions\fP\fB>, + <\fP\fIother permissions\fP\fB> +\fP +.fi +.RE +.LP +where the three values shall be combinations of letters from the set +{ \fIr\fP, \fIw\fP, \fIx\fP}; the presence of a letter +shall indicate that the corresponding bit is clear in the file mode +creation mask. +.LP +If a \fImask\fP operand is specified, there shall be no output written +to standard output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The file mode creation mask was successfully changed, or no \fImask\fP +operand was supplied. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since \fIumask\fP affects the current shell execution environment, +it is generally provided as a shell regular built-in. +.LP +In contrast to the negative permission logic provided by the file +mode creation mask and the octal number form of the +\fImask\fP argument, the symbolic form of the \fImask\fP argument +specifies those permissions that are left alone. +.SH EXAMPLES +.LP +Either of the commands: +.sp +.RS +.nf + +\fBumask a=rx,ug+w +.sp + +umask 002 +\fP +.fi +.RE +.LP +sets the mode mask so that subsequently created files have their S_IWOTH +bit cleared. +.LP +After setting the mode mask with either of the above commands, the +\fIumask\fP command can be used to write out the current +value of the mode mask: +.sp +.RS +.nf + +\fB$\fP \fBumask +\fP\fB0002\fP +.fi +.RE +.LP +(The output format is unspecified, but historical implementations +use the octal integer mode format.) +.sp +.RS +.nf + +\fB$\fP \fBumask -S +\fP\fBu=rwx,g=rwx,o=rx\fP +.fi +.RE +.LP +Either of these outputs can be used as the mask operand to a subsequent +invocation of the \fIumask\fP utility. +.LP +Assuming the mode mask is set as above, the command: +.sp +.RS +.nf + +\fBumask g-w +\fP +.fi +.RE +.LP +sets the mode mask so that subsequently created files have their S_IWGRP +and S_IWOTH bits cleared. +.LP +The command: +.sp +.RS +.nf + +\fBumask -- -w +\fP +.fi +.RE +.LP +sets the mode mask so that subsequently created files have all their +write bits cleared. Note that \fImask\fP operands +\fB-r\fP, \fB-w\fP, \fB-x\fP or anything beginning with a hyphen, +must be preceded by \fB"--"\fP to keep it from being +interpreted as an option. +.SH RATIONALE +.LP +Since \fIumask\fP affects the current shell execution environment, +it is generally provided as a shell regular built-in. If it +is called in a subshell or separate utility execution environment, +such as one of the following: +.sp +.RS +.nf + +\fB(umask 002) +nohup umask ... +find . -exec umask ... \\; +\fP +.fi +.RE +.LP +it does not affect the file mode creation mask of the environment +of the caller. +.LP +The description of the historical utility was modified to allow it +to use the symbolic modes of \fIchmod\fP. The \fB-s\fP option used +in early proposals was changed to \fB-S\fP because \fB-s\fP +could be confused with a \fIsymbolic_mode\fP form of mask referring +to the S_ISUID and S_ISGID bits. +.LP +The default output style is implementation-defined to permit implementors +to provide migration to the new symbolic style at the +time most appropriate to their users. A \fB-o\fP flag to force octal +mode output was omitted because the octal mode may not be +sufficient to specify all of the information that may be present in +the file mode creation mask when more secure file access +permission checks are implemented. +.LP +It has been suggested that trusted systems developers might appreciate +ameliorating the requirement that the mode mask +"affects" the file access permissions, since it seems access control +lists might replace the mode mask to some degree. The +wording has been changed to say that it affects the file permission +bits, and it leaves the details of the behavior of how they +affect the file access permissions to the description in the System +Interfaces volume of IEEE\ Std\ 1003.1-2001. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIchmod\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIumask\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/unalias.1p b/man1p/unalias.1p new file mode 100644 index 000000000..f4004cc1d --- /dev/null +++ b/man1p/unalias.1p @@ -0,0 +1,146 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNALIAS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" unalias +.SH NAME +unalias \- remove alias definitions +.SH SYNOPSIS +.LP +\fBunalias\fP \fIalias-name\fP\fB... +.br +.sp +unalias -a \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIunalias\fP utility shall remove the definition for each alias +name specified. See \fIAlias Substitution\fP . The aliases shall be +removed from the current shell execution +environment; see \fIShell Execution Environment\fP . +.SH OPTIONS +.LP +The \fIunalias\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-a\fP +Remove all alias definitions from the current shell execution environment. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIalias-name\fP +The name of an alias to be removed. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIunalias\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +One of the \fIalias-name\fP operands specified did not represent a +valid alias definition, or an error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since \fIunalias\fP affects the current shell execution environment, +it is generally provided as a shell regular built-in. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIunalias\fP description is based on that from historical KornShell +implementations. Known differences exist between that +and the C shell. The KornShell version was adopted to be consistent +with all the other KornShell features in this volume of +IEEE\ Std\ 1003.1-2001, such as command line editing. +.LP +The \fB-a\fP option is the equivalent of the \fIunalias\fP * form +of the C shell and is provided to address security concerns +about unknown aliases entering the environment of a user (or application) +through the allowable implementation-defined predefined +alias route or as a result of an \fIENV\fP file. (Although \fIunalias\fP +could be used to simplify the "secure" shell script +shown in the \fIcommand\fP rationale, it does not obviate the need +to quote all command +names. An initial call to \fIunalias\fP \fB-a\fP would have to be +quoted in case there was an alias for \fIunalias\fP.) +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIalias\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uname.1p b/man1p/uname.1p new file mode 100644 index 000000000..df18a2ef6 --- /dev/null +++ b/man1p/uname.1p @@ -0,0 +1,200 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNAME" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uname +.SH NAME +uname \- return system name +.SH SYNOPSIS +.LP +\fBuname\fP \fB[\fP\fB-snrvma\fP\fB]\fP +.SH DESCRIPTION +.LP +By default, the \fIuname\fP utility shall write the operating system +name to standard output. When options are specified, +symbols representing one or more system characteristics shall be written +to the standard output. The format and contents of the +symbols are implementation-defined. On systems conforming to the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, the +symbols written shall be those supported by the \fIuname\fP() function +as defined in the +System Interfaces volume of IEEE\ Std\ 1003.1-2001. +.SH OPTIONS +.LP +The \fIuname\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +Behave as though all of the options \fB-mnrsv\fP were specified. +.TP 7 +\fB-m\fP +Write the name of the hardware type on which the system is running +to standard output. +.TP 7 +\fB-n\fP +Write the name of this node within an implementation-defined communications +network. +.TP 7 +\fB-r\fP +Write the current release level of the operating system implementation. +.TP 7 +\fB-s\fP +Write the name of the implementation of the operating system. +.TP 7 +\fB-v\fP +Write the current version level of this release of the operating system +implementation. +.sp +.LP +If no options are specified, the \fIuname\fP utility shall write the +operating system name, as if the \fB-s\fP option had been +specified. +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuname\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +By default, the output shall be a single line of the following form: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIsysname\fP\fB> +\fP +.fi +.RE +.LP +If the \fB-a\fP option is specified, the output shall be a single +line of the following form: +.sp +.RS +.nf + +\fB"%s %s %s %s %s\\n", <\fP\fIsysname\fP\fB>, <\fP\fInodename\fP\fB>, <\fP\fIrelease\fP\fB>, + <\fP\fIversion\fP\fB>, <\fP\fImachine\fP\fB> +\fP +.fi +.RE +.LP +Additional implementation-defined symbols may be written; all such +symbols shall be written at the end of the line of output +before the <newline>. +.LP +If options are specified to select different combinations of the symbols, +only those symbols shall be written, in the order +shown above for the \fB-a\fP option. If a symbol is not selected for +writing, its corresponding trailing <blank>s also shall +not be written. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The requested information was successfully written. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Note that any of the symbols could include embedded <space>s, which +may affect parsing algorithms if multiple options are +selected for output. +.LP +The node name is typically a name that the system uses to identify +itself for inter-system communication addressing. +.SH EXAMPLES +.LP +The following command: +.sp +.RS +.nf + +\fBuname -sr +\fP +.fi +.RE +.LP +writes the operating system name and release level, separated by one +or more <blank>s. +.SH RATIONALE +.LP +It was suggested that this utility cannot be used portably since the +format of the symbols is implementation-defined. The +POSIX.1 working group could not achieve consensus on defining these +formats in the underlying \fIuname\fP() function, and there was no +expectation that this volume of +IEEE\ Std\ 1003.1-2001 would be any more successful. Some applications +may still find this historical utility of value. For +example, the symbols could be used for system log entries or for comparison +with operator or user input. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +The System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIuname\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uncompress.1p b/man1p/uncompress.1p new file mode 100644 index 000000000..5211168e3 --- /dev/null +++ b/man1p/uncompress.1p @@ -0,0 +1,163 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNCOMPRESS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uncompress +.SH NAME +uncompress \- expand compressed data +.SH SYNOPSIS +.LP +\fBuncompress\fP \fB[\fP\fB-cfv\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIuncompress\fP utility shall restore files to their original +state after they have been compressed using the \fIcompress\fP utility. +If no files are specified, the standard input shall be uncompressed +to +the standard output. If the invoking process has appropriate privileges, +the ownership, modes, access time, and modification time +of the original file shall be preserved. +.LP +This utility shall support the uncompressing of any files produced +by the \fIcompress\fP utility on the same implementation. For files +produced by \fIcompress\fP on other systems, \fIuncompress\fP supports +9 to 14-bit compression (see \fIcompress\fP , \fB-b\fP); it is implementation-defined +whether values of \fB-b\fP greater than 14 are +supported. +.SH OPTIONS +.LP +The \fIuncompress\fP utility shall conform to the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Write to standard output; no files are changed. +.TP 7 +\fB-f\fP +Do not prompt for overwriting files. Except when run in the background, +if \fB-f\fP is not given the user shall be prompted as +to whether an existing file should be overwritten. If the standard +input is not a terminal and \fB-f\fP is not given, +\fIuncompress\fP shall write a diagnostic message to standard error +and exit with a status greater than zero. +.TP 7 +\fB-v\fP +Write messages to standard error concerning the expansion of each +file. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file. If \fIfile\fP already has the \fB.Z\fP suffix +specified, it shall be used as the input file and the +output file shall be named \fBfile\fP with the \fB.Z\fP suffix removed. +Otherwise, \fIfile\fP shall be used as the name of the +output file and \fBfile\fP with the \fB.Z\fP suffix appended shall +be used as the input file. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP +\&. +.SH INPUT FILES +.LP +Input files shall be in the format produced by the \fIcompress\fP +utility. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuncompress\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +When there are no \fIfile\fP operands or the \fB-c\fP option is specified, +the uncompressed output is written to standard +output. +.SH STDERR +.LP +Prompts shall be written to the standard error output under the conditions +specified in the DESCRIPTION and OPTIONS sections. +The prompts shall contain the \fIfile\fP pathname, but their format +is otherwise unspecified. Otherwise, the standard error output +shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Output files are the same as the respective input files to \fIcompress\fP. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +The input file remains unmodified. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The limit of 14 on the \fIcompress\fP \fB-b\fP \fIbits\fP argument +is to achieve +portability to all systems (within the restrictions imposed by the +lack of an explicit published file format). Some implementations +based on 16-bit architectures cannot support 15 or 16-bit uncompression. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcompress\fP , \fIzcat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/unexpand.1p b/man1p/unexpand.1p new file mode 100644 index 000000000..0db58e401 --- /dev/null +++ b/man1p/unexpand.1p @@ -0,0 +1,182 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNEXPAND" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" unexpand +.SH NAME +unexpand \- convert spaces to tabs +.SH SYNOPSIS +.LP +\fBunexpand\fP \fB[\fP \fB-a| -t\fP \fItablist\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIunexpand\fP utility shall copy files or standard input to standard +output, converting <blank>s at the beginning of +each line into the maximum number of <tab>s followed by the minimum +number of <space>s needed to fill the same column +positions originally filled by the translated <blank>s. By default, +tabstops shall be set at every eighth column position. +Each <backspace> shall be copied to the output, and shall cause the +column position count for tab calculations to be +decremented; the count shall never be decremented to a value less +than one. +.SH OPTIONS +.LP +The \fIunexpand\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-a\fP +In addition to translating <blank>s at the beginning of each line, +translate all sequences of two or more <blank>s +immediately preceding a tab stop to the maximum number of <tab>s followed +by the minimum number of <space>s needed to +fill the same column positions originally filled by the translated +<blank>s. +.TP 7 +\fB-t\ \fP \fItablist\fP +Specify the tab stops. The application shall ensure that the \fItablist\fP +option-argument is a single argument consisting of +a single positive decimal integer or multiple positive decimal integers, +separated by <blank>s or commas, in ascending order. +If a single number is given, tabs shall be set \fItablist\fP column +positions apart instead of the default 8. If multiple numbers +are given, the tabs shall be set at those specific column positions. +.LP +The application shall ensure that each tab-stop position \fIN\fP is +an integer value greater than zero, and the list shall be +in strictly ascending order. This is taken to mean that, from the +start of a line of output, tabbing to position \fIN\fP shall +cause the next character output to be in the ( \fIN\fP+1)th column +position on that line. When the \fB-t\fP option is not +specified, the default shall be the equivalent of specifying \fB-t\ 8\fP +(except for the interaction with \fB-a\fP, described +below). +.LP +No <space>-to- <tab> conversions shall occur for characters at positions +beyond the last of those specified in a +multiple tab-stop list. +.LP +When \fB-t\fP is specified, the presence or absence of the \fB-a\fP +option shall be ignored; conversion shall not be limited +to the processing of leading <blank>s. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of a text file to be used as input. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be text files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIunexpand\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files), the +processing of <tab>s and <space>s, and for the +determination of the width in column positions each character would +occupy on an output device. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be equivalent to the input files with the +specified <space>-to- <tab> conversions. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +One non-intuitive aspect of \fIunexpand\fP is its restriction to leading +spaces when neither \fB-a\fP nor \fB-t\fP is +specified. Users who always want to convert all spaces in a file can +easily alias \fIunexpand\fP to use the \fB-a\fP or +\fB-t\ 8\fP option. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +On several occasions, consideration was given to adding a \fB-t\fP +option to the \fIunexpand\fP utility to complement the +\fB-t\fP in \fIexpand\fP (see \fIexpand\fP ). The historical +intent of \fIunexpand\fP was to translate multiple <blank>s into tab +stops, where tab stops were a multiple of eight column +positions on most UNIX systems. An early proposal omitted \fB-t\fP +because it seemed outside the scope of the User Portability +Utilities option; it was not described in any of the base documents. +However, hard-coding tab stops every eight columns was not +suitable for the international community and broke historical precedents +for some vendors in the FORTRAN community, so \fB-t\fP +was restored in conjunction with the list of valid extension categories +considered by the standard developers. Thus, +\fIunexpand\fP is now the logical converse of \fIexpand\fP. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIexpand\fP , \fItabs\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/unget.1p b/man1p/unget.1p new file mode 100644 index 000000000..fc8abc5fc --- /dev/null +++ b/man1p/unget.1p @@ -0,0 +1,174 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNGET" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" unget +.SH NAME +unget \- undo a previous get of an SCCS file (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBunget\fP \fB[\fP\fB-ns\fP\fB][\fP\fB-r\fP \fISID\fP\fB]\fP \fIfile\fP\fB... +\fP +.SH DESCRIPTION +.LP +The \fIunget\fP utility shall reverse the effect of a \fIget\fP \fB-e\fP +done prior to +creating the intended new delta. +.SH OPTIONS +.LP +The \fIunget\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-r\ \fP \fISID\fP +Uniquely identify which delta is no longer intended. (This would have +been specified by \fIget\fP as the new delta.) The use of this option +is necessary only if two or more outstanding \fIget\fP commands for +editing on the same SCCS file were done by the same person (login +name). +.TP 7 +\fB-s\fP +Suppress the writing to standard output of the intended delta's SID. +.TP 7 +\fB-n\fP +Retain the file that was obtained by \fIget\fP, which would normally +be removed from the +current directory. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file or a directory. If \fIfile\fP +is a directory, the \fIunget\fP utility shall behave as +though each file in the directory were specified as a named file, +except that non-SCCS files (last component of the pathname does +not begin with \fBs.\fP) and unreadable files shall be silently ignored. +.LP +If exactly one \fIfile\fP operand appears, and it is \fB'-'\fP , the +standard input shall be read; each line of the standard +input shall be taken to be the name of an SCCS file to be processed. +Non-SCCS files and unreadable files shall be silently +ignored. +.sp +.SH STDIN +.LP +The standard input shall be a text file used only when the \fIfile\fP +operand is specified as \fB'-'\fP . Each line of the +text file shall be interpreted as an SCCS pathname. +.SH INPUT FILES +.LP +Any SCCS files processed shall be files of an unspecified format. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIunget\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall consist of a line for each file, in the +following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fISID removed from file\fP\fB> +\fP +.fi +.RE +.LP +If there is more than one named file or if a directory or standard +input is named, each pathname shall be written before each of +the preceding lines: +.sp +.RS +.nf + +\fB"\\n%s:\\n", <\fP\fIpathname\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Any SCCS files updated shall be files of an unspecified format. During +processing of a \fIfile\fP, a locking \fIz-file\fP, as +described in \fIget\fP, and a \fIq-file\fP (a working copy of the +\fIp-file\fP), may be +created and deleted. The \fIp-file\fP and \fIg-file\fP, as described +in \fIget\fP, shall be +deleted. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIdelta\fP , \fIget\fP , \fIsact\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uniq.1p b/man1p/uniq.1p new file mode 100644 index 000000000..3444e72da --- /dev/null +++ b/man1p/uniq.1p @@ -0,0 +1,297 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNIQ" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uniq +.SH NAME +uniq \- report or filter out repeated lines in a file +.SH SYNOPSIS +.LP +\fBuniq\fP \fB[\fP\fB-c|-d|-u\fP\fB][\fP\fB-f\fP \fIfields\fP\fB][\fP\fB-s\fP +\fIchar\fP\fB][\fP\fIinput_file\fP \fB[\fP\fIoutput_file\fP\fB]]\fP +.SH DESCRIPTION +.LP +The \fIuniq\fP utility shall read an input file comparing adjacent +lines, and write one copy of each input line on the output. +The second and succeeding copies of repeated adjacent input lines +shall not be written. +.LP +Repeated lines in the input shall not be detected if they are not +adjacent. +.SH OPTIONS +.LP +The \fIuniq\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Precede each output line with a count of the number of times the line +occurred in the input. +.TP 7 +\fB-d\fP +Suppress the writing of lines that are not repeated in the input. +.TP 7 +\fB-f\ \fP \fIfields\fP +Ignore the first \fIfields\fP fields on each input line when doing +comparisons, where \fIfields\fP is a positive decimal +integer. A field is the maximal string matched by the basic regular +expression: +.sp +.RS +.nf + +\fB[[:blank:]]*[^[:blank:]]* +\fP +.fi +.RE +.LP +If the \fIfields\fP option-argument specifies more fields than appear +on an input line, a null string shall be used for +comparison. +.TP 7 +\fB-s\ \fP \fIchars\fP +Ignore the first \fIchars\fP characters when doing comparisons, where +\fIchars\fP shall be a positive decimal integer. If +specified in conjunction with the \fB-f\fP option, the first \fIchars\fP +characters after the first \fIfields\fP fields shall be +ignored. If the \fIchars\fP option-argument specifies more characters +than remain on an input line, a null string shall be used +for comparison. +.TP 7 +\fB-u\fP +Suppress the writing of lines that are repeated in the input. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIinput_file\fP +A pathname of the input file. If the \fIinput_file\fP operand is not +specified, or if the \fIinput_file\fP is \fB'-'\fP , +the standard input shall be used. +.TP 7 +\fIoutput_file\fP +A pathname of the output file. If the \fIoutput_file\fP operand is +not specified, the standard output shall be used. The +results are unspecified if the file named by \fIoutput_file\fP is +the file named by \fIinput_file\fP. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIinput_file\fP operand +is specified or if \fIinput_file\fP is \fB'-'\fP . See +the INPUT FILES section. +.SH INPUT FILES +.LP +The input file shall be a text file. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuniq\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for ordering rules. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +which characters constitute a <blank> in the current +locale. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall be used only if no \fIoutput_file\fP operand +is specified. See the OUTPUT FILES section. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +If the \fB-c\fP option is specified, the output file shall be empty +or each line shall be of the form: +.sp +.RS +.nf + +\fB"%d %s", <\fP\fInumber of duplicates\fP\fB>, <\fP\fIline\fP\fB> +\fP +.fi +.RE +.LP +otherwise, the output file shall be empty or each line shall be of +the form: +.sp +.RS +.nf + +\fB"%s", <\fP\fIline\fP\fB> +\fP +.fi +.RE +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +The utility executed successfully. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIsort\fP utility can be used to cause repeated lines to be adjacent +in the input +file. +.SH EXAMPLES +.LP +The following input file data (but flushed left) was used for a test +series on \fIuniq\fP: +.sp +.RS +.nf + +\fB#01 foo0 bar0 foo1 bar1 +#02 bar0 foo1 bar1 foo1 +#03 foo0 bar0 foo1 bar1 +#04 +#05 foo0 bar0 foo1 bar1 +#06 foo0 bar0 foo1 bar1 +#07 bar0 foo1 bar1 foo0 +\fP +.fi +.RE +.LP +What follows is a series of test invocations of the \fIuniq\fP utility +that use a mixture of \fIuniq\fP options against the +input file data. These tests verify the meaning of \fIadjacent\fP. +The \fIuniq\fP utility views the input data as a sequence of +strings delimited by \fB'\\n'\fP . Accordingly, for the \fIfields\fPth +member of the sequence, \fIuniq\fP interprets unique or +repeated adjacent lines strictly relative to the \fIfields\fP+1th +member. +.IP " 1." 4 +This first example tests the line counting option, comparing each +line of the input file data starting from the second +field: +.sp +.RS +.nf + +\fBuniq -c -f 1 uniq_0I.t + 1 #01 foo0 bar0 foo1 bar1 + 1 #02 bar0 foo1 bar1 foo0 + 1 #03 foo0 bar0 foo1 bar1 + 1 #04 + 2 #05 foo0 bar0 foo1 bar1 + 1 #07 bar0 foo1 bar1 foo0 +\fP +.fi +.RE +.LP +The number \fB'2'\fP , prefixing the fifth line of output, signifies +that the \fIuniq\fP utility detected a pair of repeated +lines. Given the input data, this can only be true when \fIuniq\fP +is run using the \fB-f\ 1\fP option (which shall cause +\fIuniq\fP to ignore the first field on each input line). +.LP +.IP " 2." 4 +The second example tests the option to suppress unique lines, comparing +each line of the input file data starting from the +second field: +.sp +.RS +.nf + +\fBuniq -d -f 1 uniq_0I.t +#05 foo0 bar0 foo1 bar1 +\fP +.fi +.RE +.LP +.IP " 3." 4 +This test suppresses repeated lines, comparing each line of the input +file data starting from the second field: +.sp +.RS +.nf + +\fBuniq -u -f 1 uniq_0I.t +#01 foo0 bar0 foo1 bar1 +#02 bar0 foo1 bar1 foo1 +#03 foo0 bar0 foo1 bar1 +#04 +#07 bar0 foo1 bar1 foo0 +\fP +.fi +.RE +.LP +.IP " 4." 4 +This suppresses unique lines, comparing each line of the input file +data starting from the third character: +.sp +.RS +.nf + +\fBuniq -d -s 2 uniq_0I.t +\fP +.fi +.RE +.LP +In the last example, the \fIuniq\fP utility found no input matching +the above criteria. +.LP +.SH RATIONALE +.LP +Some historical implementations have limited lines to be 1080 bytes +in length, which does not meet the implied {LINE_MAX} +limit. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcomm\fP , \fIsort\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/unlink.1p b/man1p/unlink.1p new file mode 100644 index 000000000..f27861ae6 --- /dev/null +++ b/man1p/unlink.1p @@ -0,0 +1,124 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNLINK" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" unlink +.SH NAME +unlink \- call the unlink function +.SH SYNOPSIS +.LP +\fBunlink\fP \fIfile\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIunlink\fP utility shall perform the function call: +.sp +.RS +.nf + +\fBunlink(\fP\fIfile\fP\fB); +\fP +.fi +.RE +.LP +A user may need appropriate privilege to invoke the \fIunlink\fP utility. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +The pathname of an existing file. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +Not used. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIunlink\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +.sp +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +None. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIlink\fP() , \fIrm\fP , the System Interfaces volume of +IEEE\ Std\ 1003.1-2001, \fIunlink\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/unset.1p b/man1p/unset.1p new file mode 100644 index 000000000..4a42f84bd --- /dev/null +++ b/man1p/unset.1p @@ -0,0 +1,142 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UNSET" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" unset +.SH NAME +unset \- unset values and attributes of variables and functions +.SH SYNOPSIS +.LP +\fBunset\fP \fB[\fP\fB-fv\fP\fB]\fP \fIname\fP \fB...\fP +.SH DESCRIPTION +.LP +Each variable or function specified by \fIname\fP shall be unset. +.LP +If \fB-v\fP is specified, \fIname\fP refers to a variable name and +the shell shall unset it and remove it from the +environment. Read-only variables cannot be unset. +.LP +If \fB-f\fP is specified, \fIname\fP refers to a function and the +shell shall unset the function definition. +.LP +If neither \fB-f\fP nor \fB-v\fP is specified, \fIname\fP refers to +a variable; if a variable by that name does not exist, it +is unspecified whether a function by that name, if any, shall be unset. +.LP +Unsetting a variable or function that was not previously set shall +not be considered an error and does not cause the shell to +abort. +.LP +The \fIunset\fP special built-in shall support the Base Definitions +volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +Note that: +.sp +.RS +.nf + +\fBVARIABLE= +\fP +.fi +.RE +.LP +is not equivalent to an \fIunset\fP of \fBVARIABLE\fP; in the example, +\fBVARIABLE\fP is set to \fB""\fP . Also, the +variables that can be \fIunset\fP should not be misinterpreted to +include the special parameters (see \fISpecial Parameters\fP ). +.SH OPTIONS +.LP +See the DESCRIPTION. +.SH OPERANDS +.LP +See the DESCRIPTION. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +None. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.TP 7 +\ 0 +All \fIname\fP operands were successfully unset. +.TP 7 +>0 +At least one \fIname\fP could not be unset. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +Unset \fIVISUAL\fP variable: +.sp +.RS +.nf + +\fBunset -v VISUAL +\fP +.fi +.RE +.LP +Unset the functions \fBfoo\fP and \fBbar\fP: +.sp +.RS +.nf + +\fBunset -f foo bar +\fP +.fi +.RE +.SH RATIONALE +.LP +Consideration was given to omitting the \fB-f\fP option in favor of +an +\fIunfunction\fP utility, but the standard developers decided to retain +historical +practice. +.LP +The \fB-v\fP option was introduced because System V historically used +one name space for both variables and functions. When +\fIunset\fP is used without options, System V historically unset either +a function or a variable, and there was no confusion about +which one was intended. A portable POSIX application can use \fIunset\fP +without an option to unset a variable, but not a +function; the \fB-f\fP option must be used. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fISpecial Built-In Utilities\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uucp.1p b/man1p/uucp.1p new file mode 100644 index 000000000..28b936f8b --- /dev/null +++ b/man1p/uucp.1p @@ -0,0 +1,263 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UUCP" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uucp +.SH NAME +uucp \- system-to-system copy +.SH SYNOPSIS +.LP +\fBuucp\fP \fB[\fP\fB-cCdfjmr\fP\fB][\fP\fB-n\fP \fIuser\fP\fB]\fP +\fIsource-file\fP\fB...\fP \fIdestination-file\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIuucp\fP utility shall copy files named by the \fIsource-file\fP +argument to the \fIdestination-file\fP argument. The +files named can be on local or remote systems. +.LP +The \fIuucp\fP utility cannot guarantee support for all character +encodings in all circumstances. For example, transmission +data may be restricted to 7 bits by the underlying network, 8-bit +data and filenames need not be portable to non-internationalized +systems, and so on. Under these circumstances, it is recommended that +only characters defined in the ISO/IEC\ 646:1991 standard +International Reference Version (equivalent to ASCII) 7-bit range +of characters be used, and that only characters defined in the +portable filename character set be used for naming files. The protocol +for transfer of files is unspecified by +IEEE\ Std\ 1003.1-2001. +.LP +Typical implementations of this utility require a communications line +configured to use the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface, but +other +communications means may be used. On systems where there are no available +communications means (either temporarily or permanently), +this utility shall write an error message describing the problem and +exit with a non-zero exit status. +.SH OPTIONS +.LP +The \fIuucp\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Do not copy local file to the spool directory for transfer to the +remote machine (default). +.TP 7 +\fB-C\fP +Force the copy of local files to the spool directory for transfer. +.TP 7 +\fB-d\fP +Make all necessary directories for the file copy (default). +.TP 7 +\fB-f\fP +Do not make intermediate directories for the file copy. +.TP 7 +\fB-j\fP +Write the job identification string to standard output. This job identification +can be used by \fIuustat\fP to obtain the status or terminate a job. +.TP 7 +\fB-m\fP +Send mail to the requester when the copy is completed. +.TP 7 +\fB-n\ \fP \fIuser\fP +Notify \fIuser\fP on the remote system that a file was sent. +.TP 7 +\fB-r\fP +Do not start the file transfer; just queue the job. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIdestination-file\fP,\ \fIsource-file\fP +.sp +A pathname of a file to be copied to, or from, respectively. Either +name can be a pathname on the local machine, or can have the +form: +.sp +.RS +.nf + +\fIsystem-name\fP\fB!\fP\fIpathname\fP +.fi +.RE +.LP +where \fIsystem-name\fP is taken from a list of system names that +\fIuucp\fP knows about. The destination \fIsystem-name\fP +can also be a list of names such as: +.sp +.RS +.nf + +\fIsystem-name\fP\fB!\fP\fIsystem-name\fP\fB!...!\fP\fIsystem-name\fP\fB!\fP\fIpathname\fP +.fi +.RE +.LP +in which case, an attempt is made to send the file via the specified +route to the destination. Care should be taken to ensure +that intermediate nodes in the route are willing to forward information. +.LP +The shell pattern matching notation characters \fB'?'\fP , \fB'*'\fP +, and \fB"[...]"\fP appearing in \fIpathname\fP +shall be expanded on the appropriate system. +.LP +Pathnames can be one of: +.RS +.IP " 1." 4 +An absolute pathname. +.LP +.IP " 2." 4 +A pathname preceded by ~ \fIuser\fP where \fIuser\fP is a login name +on the specified system and is replaced by that +user's login directory. Note that if an invalid login is specified, +the default is to the public directory (called \fIPUBDIR\fP; +the actual location of \fIPUBDIR\fP is implementation-defined). +.LP +.IP " 3." 4 +A pathname preceded by ~/ \fIdestination\fP where \fIdestination\fP +is appended to \fIPUBDIR\fP. +.TP 7 +\fBNote:\fP +.RS +This destination is treated as a filename unless more than one file +is being transferred by this request or the destination is +already a directory. To ensure that it is a directory, follow the +destination with a \fB'/'\fP . For example, \fB~/dan/\fP +as the destination makes the directory \fBPUBDIR/dan\fP if it does +not exist and puts the requested files in that directory. +.RE +.sp +.LP +.IP " 4." 4 +Anything else shall be prefixed by the current directory. +.LP +.RE +.LP +If the result is an erroneous pathname for the remote system, the +copy shall fail. If the \fIdestination-file\fP is a +directory, the last part of the \fIsource-file\fP name shall be used. +.LP +The read, write, and execute permissions given by \fIuucp\fP are implementation-defined. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The files to be copied are regular files. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuucp\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements within bracketed +filename patterns. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classes within bracketed filename +patterns (for example, \fB"'[[:lower:]]*'"\fP ). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error, +and informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output files (which may be on other systems) are copies of the +input files. +.LP +If \fB-m\fP is used, mail files are modified. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The domain of remotely accessible files can (and for obvious security +reasons usually should) be severely restricted. +.LP +Note that the \fB'!'\fP character in addresses has to be escaped when +using \fIcsh\fP as a command interpreter because of +its history substitution syntax. For \fIksh\fP and \fIsh\fP the escape +is not necessary, but +may be used. +.LP +As noted above, shell metacharacters appearing in pathnames are expanded +on the appropriate system. On an internationalized +system, this is done under the control of local settings of \fILC_COLLATE\fP +and \fILC_CTYPE .\fP Thus, care should be taken when +using bracketed filename patterns, as collation and typing rules may +vary from one system to another. Also be aware that certain +types of expression (that is, equivalence classes, character classes, +and collating symbols) need not be supported on +non-internationalized systems. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fImailx\fP , \fIuuencode\fP , \fIuustat\fP , +\fIuux\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uudecode.1p b/man1p/uudecode.1p new file mode 100644 index 000000000..3f290bd3f --- /dev/null +++ b/man1p/uudecode.1p @@ -0,0 +1,179 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UUDECODE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uudecode +.SH NAME +uudecode \- decode a binary file +.SH SYNOPSIS +.LP +\fBuudecode\fP \fB[\fP\fB-o\fP \fIoutfile\fP\fB][\fP\fIfile\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIuudecode\fP utility shall read a file, or standard input if +no file is specified, that includes data created by the \fIuuencode\fP +utility. The \fIuudecode\fP utility shall scan the input file, searching +for +data compatible with one of the formats specified in \fIuuencode\fP, +and attempt to +create or overwrite the file described by the data (or overridden +by the \fB-o\fP option). The pathname shall be contained in the +data or specified by the \fB-o\fP option. The file access permission +bits and contents for the file to be produced shall be +contained in that data. The mode bits of the created file (other than +standard output) shall be set from the file access permission +bits contained in the data; that is, other attributes of the mode, +including the file mode creation mask (see \fIumask\fP() ), shall +not affect the file being produced. +.LP +If the pathname of the file to be produced exists, and the user does +not have write permission on that file, \fIuudecode\fP +shall terminate with an error. If the pathname of the file to be produced +exists, and the user has write permission on that file, +the existing file shall be overwritten. +.LP +If the input data was produced by \fIuuencode\fP on a system with +a different number +of bits per byte than on the target system, the results of \fIuudecode\fP +are unspecified. +.SH OPTIONS +.LP +The \fIuudecode\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported by the implementation: +.TP 7 +\fB-o\ \fP \fIoutfile\fP +A pathname of a file that shall be used instead of any pathname contained +in the input data. Specifying an \fIoutfile\fP +option-argument of \fB/dev/stdout\fP shall indicate standard output. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +The pathname of a file containing the output of \fIuuencode\fP. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files shall be files containing the output of \fIuuencode\fP. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuudecode\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +If the file data header encoded by \fIuuencode\fP is \fB-\fP or \fB/dev/stdout\fP, +or the \fB-o\fP \fB/dev/stdout\fP option overrides the file data, +the standard output shall be in the same format as the file +originally encoded by \fIuuencode\fP. Otherwise, the standard output +shall not be +used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The output file shall be in the same format as the file originally +encoded by \fIuuencode\fP. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The user who is invoking \fIuudecode\fP must have write permission +on any file being created. +.LP +The output of \fIuuencode\fP is essentially an encoded bit stream +that is not +cognizant of byte boundaries. It is possible that a 9-bit byte target +machine can process input from an 8-bit source, if it is +aware of the requirement, but the reverse is unlikely to be satisfying. +Of course, the only data that is meaningful for such a +transfer between architectures is generally character data. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Input files are not necessarily text files, as stated by an early +proposal. Although the \fIuuencode\fP output is a text file, that +output could have been wrapped within another file or +mail message that is not a text file. +.LP +The \fB-o\fP option is not historical practice, but was added at the +request of WG15 so that the user could override the target +pathname without having to edit the input data itself. +.LP +In early drafts, the [ \fB-o\fP \fIoutfile\fP] option-argument allowed +the use of \fB-\fP to mean standard output. The symbol +\fB-\fP has only been used previously in IEEE\ Std\ 1003.1-2001 as +a standard input indicator. The developers of the +standard did not wish to overload the meaning of \fB-\fP in this manner. +The \fB/dev/stdout\fP concept exists on most modern +systems. The \fB/dev/stdout\fP syntax does not refer to a new special +file. It is just a magic cookie to specify standard +output. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIumask\fP() , \fIuuencode\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uuencode.1p b/man1p/uuencode.1p new file mode 100644 index 000000000..3aae92b1f --- /dev/null +++ b/man1p/uuencode.1p @@ -0,0 +1,352 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UUENCODE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uuencode +.SH NAME +uuencode \- encode a binary file +.SH SYNOPSIS +.LP +\fBuuencode\fP \fB[\fP\fB-m\fP\fB][\fP\fIfile\fP\fB]\fP \fIdecode_pathname\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIuuencode\fP utility shall write an encoded version of the named +input file, or standard input if no \fIfile\fP is +specified, to standard output. The output shall be encoded using one +of the algorithms described in the STDOUT section and shall +include the file access permission bits (in \fIchmod\fP octal or symbolic +notation) of the +input file and the \fIdecode_pathname\fP, for re-creation of the file +on another system that conforms to this volume of +IEEE\ Std\ 1003.1-2001. +.SH OPTIONS +.LP +The \fIuuencode\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported by the implementation: +.TP 7 +\fB-m\fP +Encode the output using the MIME Base64 algorithm described in STDOUT. +If \fB-m\fP is not specified, the historical algorithm +described in STDOUT shall be used. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIdecode_pathname\fP +.sp +The pathname of the file into which the \fIuudecode\fP utility shall +place the decoded +file. Specifying a \fIdecode_pathname\fP operand of \fB/dev/stdout\fP +shall indicate that \fIuudecode\fP is to use standard output. If there +are characters in \fIdecode_pathname\fP that +are not in the portable filename character set the results are unspecified. +.TP 7 +\fIfile\fP +A pathname of the file to be encoded. +.sp +.SH STDIN +.LP +See the INPUT FILES section. +.SH INPUT FILES +.LP +Input files can be files of any type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuuencode\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.SS uuencode Base64 Algorithm +.LP +The standard output shall be a text file (encoded in the character +set of the current locale) that begins with the line: +.sp +.RS +.nf + +\fB"begin-base64 %s %s\\n", <\fP\fImode\fP\fB>, <\fP\fIdecode_pathname\fP\fB> +\fP +.fi +.RE +.LP +and ends with the line: +.sp +.RS +.nf + +\fB"====\\n" +\fP +.fi +.RE +.LP +In both cases, the lines shall have no preceding or trailing <blank>s. +.LP +The encoding process represents 24-bit groups of input bits as output +strings of four encoded characters. Proceeding from left +to right, a 24-bit input group shall be formed by concatenating three +8-bit input groups. Each 24-bit input group then shall be +treated as four concatenated 6-bit groups, each of which shall be +translated into a single digit in the Base64 alphabet. When +encoding a bit stream via the Base64 encoding, the bit stream shall +be presumed to be ordered with the most-significant bit first. +That is, the first bit in the stream shall be the high-order bit in +the first byte, and the eighth bit shall be the low-order bit +in the first byte, and so on. Each 6-bit group is used as an index +into an array of 64 printable characters, as shown in uuencode Base64 +Values . +.sp +.ce 1 +\fBTable: uuencode Base64 Values\fP +.TS C +center; l1 l1 l1 l1 l1 l1 l1 l1 l1 l1 l. +\fBValue\fP \fBEncoding\fP Value \fBEncoding\fP \fBValue\fP Encoding \fBValue\fP \fBEncoding\fP \ \fB\ \fP \fB\ \fP +0 A 17 R 34 i 51 z \ \ \ +1 B 18 S 35 j 52 0 \ \ \ +2 C 19 T 36 k 53 1 \ \ \ +3 D 20 U 37 l 54 2 \ \ \ +4 E 21 V 38 m 55 3 \ \ \ +5 F 22 W 39 n 56 4 \ \ \ +6 G 23 X 40 o 57 5 \ \ \ +7 H 24 Y 41 p 58 6 \ \ \ +8 I 25 Z 42 q 59 7 \ \ \ +9 J 26 a 43 r 60 8 \ \ \ +10 K 27 b 44 s 61 9 \ \ \ +11 L 28 c 45 t 62 + \ \ \ +12 M 29 d 46 u 63 / \ \ \ +13 N 30 e 47 v \ \ \ \ \ +14 O 31 f 48 w (pad) = \ \ \ +15 P 32 g 49 x \ \ \ \ \ +16 Q 33 h 50 y \ \ \ \ \ +.TE +.LP +The character referenced by the index shall be placed in the output +string. +.LP +The output stream (encoded bytes) shall be represented in lines of +no more than 76 characters each. All line breaks or other +characters not found in the table shall be ignored by decoding software +(see \fIuudecode\fP ). +.LP +Special processing shall be performed if fewer than 24 bits are available +at the end of a message or encapsulated part of a +message. A full encoding quantum shall always be completed at the +end of a message. When fewer than 24 input bits are available in +an input group, zero bits shall be added (on the right) to form an +integral number of 6-bit groups. Output character positions that +are not required to represent actual input data shall be set to the +character \fB'='\fP . Since all Base64 input is an integral +number of octets, only the following cases can arise: +.IP " 1." 4 +The final quantum of encoding input is an integral multiple of 24 +bits; here, the final unit of encoded output shall be an +integral multiple of 4 characters with no \fB'='\fP padding. +.LP +.IP " 2." 4 +The final quantum of encoding input is exactly 16 bits; here, the +final unit of encoded output shall be three characters +followed by one \fB'='\fP padding character. +.LP +.IP " 3." 4 +The final quantum of encoding input is exactly 8 bits; here, the final +unit of encoded output shall be two characters followed +by two \fB'='\fP padding characters. +.LP +.LP +A terminating \fB"===="\fP evaluates to nothing and denotes the end +of the encoded data. +.SS uuencode Historical Algorithm +.LP +The standard output shall be a text file (encoded in the character +set of the current locale) that begins with the line: +.sp +.RS +.nf + +\fB"begin %s %s\\n" <\fP\fImode\fP\fB>, <\fP\fIdecode_pathname\fP\fB> +\fP +.fi +.RE +.LP +and ends with the line: +.sp +.RS +.nf + +\fB"end\\n" +\fP +.fi +.RE +.LP +In both cases, the lines shall have no preceding or trailing <blank>s. +.LP +The algorithm that shall be used for lines in between \fBbegin\fP +and \fBend\fP takes three octets as input and writes four +characters of output by splitting the input at six-bit intervals into +four octets, containing data in the lower six bits only. +These octets shall be converted to characters by adding a value of +0x20 to each octet, so that each octet is in the range +[0x20,0x5f], and then it shall be assumed to represent a printable +character in the ISO/IEC\ 646:1991 standard encoded +character set. It then shall be translated into the corresponding +character codes for the codeset in use in the current locale. +(For example, the octet 0x41, representing \fB'A'\fP , would be translated +to \fB'A'\fP in the current codeset, such as 0xc1 +if it were EBCDIC.) +.LP +Where the bits of two octets are combined, the least significant bits +of the first octet shall be shifted left and combined with +the most significant bits of the second octet shifted right. Thus +the three octets \fIA\fP, \fIB\fP, \fIC\fP shall be converted +into the four octets: +.sp +.RS +.nf + +\fB0x20 + (( A >> 2 ) & 0x3F) +0x20 + (((A << 4) | ((B >> 4) & 0xF)) & 0x3F) +0x20 + (((B << 2) | ((C >> 6) & 0x3)) & 0x3F) +0x20 + (( C ) & 0x3F) +\fP +.fi +.RE +.LP +These octets then shall be translated into the local character set. +.LP +Each encoded line contains a length character, equal to the number +of characters to be decoded plus 0x20 translated to the local +character set as described above, followed by the encoded characters. +The maximum number of octets to be encoded on each line shall +be 45. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The file is expanded by 35 percent (each three octets become four, +plus control information) causing it to take longer to +transmit. +.LP +Since this utility is intended to create files to be used for data +interchange between systems with possibly different codesets, +and to represent binary data as a text file, the ISO/IEC\ 646:1991 +standard was chosen for a midpoint in the algorithm as a +known reference point. The output from \fIuuencode\fP is a text file +on the local system. If the output were in the +ISO/IEC\ 646:1991 standard codeset, it might not be a text file (at +least because the <newline>s might not match), and +the goal of creating a text file would be defeated. If this text file +was then carried to another machine with the same codeset, it +would be perfectly compatible with that system's \fIuudecode\fP. If +it was transmitted +over a mail system or sent to a machine with a different codeset, +it is assumed that, as for every other text file, some +translation mechanism would convert it (by the time it reached a user +on the other system) into an appropriate codeset. This +translation only makes sense from the local codeset, not if the file +has been put into a ISO/IEC\ 646:1991 standard +representation first. Similarly, files processed by \fIuuencode\fP +can be placed in \fIpax\fP +archives, intermixed with other text files in the same codeset. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +A new algorithm was added at the request of the international community +to parallel work in RFC\ 2045 (MIME). As with the +historical \fIuuencode\fP format, the Base64 Content-Transfer-Encoding +is designed to represent arbitrary sequences of octets in a +form that is not humanly readable. A 65-character subset of the ISO/IEC\ 646:1991 +standard is used, enabling 6 bits to be +represented per printable character. (The extra 65th character, \fB'='\fP +, is used to signify a special processing +function.) +.LP +This subset has the important property that it is represented identically +in all versions of the ISO/IEC\ 646:1991 standard, +including US ASCII, and all characters in the subset are also represented +identically in all versions of EBCDIC. The historical +\fIuuencode\fP algorithm does not share this property, which is the +reason that a second algorithm was added to the +ISO\ POSIX-2 standard. +.LP +The string \fB"===="\fP was used for the termination instead of the +end used in the original format because the latter is a +string that could be valid encoded input. +.LP +In an early draft, the \fB-m\fP option was named \fB-b\fP (for Base64), +but it was renamed to reflect its relationship to the +RFC\ 2045. A \fB-u\fP was also present to invoke the default algorithm, +but since this was not historical practice, it was +omitted as being unnecessary. +.LP +See the RATIONALE section in \fIuudecode\fP for the derivation of +the \fB/dev/stdout\fP +symbol. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIchmod\fP() , \fImailx\fP , \fIuudecode\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uustat.1p b/man1p/uustat.1p new file mode 100644 index 000000000..8de5364b8 --- /dev/null +++ b/man1p/uustat.1p @@ -0,0 +1,159 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UUSTAT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uustat +.SH NAME +uustat \- uucp status inquiry and job control +.SH SYNOPSIS +.LP +\fBuustat\fP \fB[\fP \fB-q| -k\fP \fIjobid\fP\fB| -r\fP \fIjobid\fP\fB]\fP\fB +.br +.sp +uustat\fP \fB[\fP\fB-s\fP \fIsystem\fP\fB][\fP\fB-u\fP \fIuser\fP\fB]\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIuustat\fP utility shall display the status of, or cancel, previously +specified \fIuucp\fP requests, or provide general status on \fIuucp\fP +connections to other systems. +.LP +When no options are given, \fIuustat\fP shall write to standard output +the status of all \fIuucp\fP requests issued by the current user. +.LP +Typical implementations of this utility require a communications line +configured to use the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface, but +other +communications means may be used. On systems where there are no available +communications means (either temporarily or permanently), +this utility shall write an error message describing the problem and +exit with a non-zero exit status. +.SH OPTIONS +.LP +The \fIuustat\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-q\fP +Write the jobs queued for each machine. +.TP 7 +\fB-k\ \fP \fIjobid\fP +Kill the \fIuucp\fP request whose job identification is \fIjobid\fP. +The application +shall ensure that the killed \fIuucp\fP request belongs to the person +invoking \fIuustat\fP +unless that user has appropriate privileges. +.TP 7 +\fB-r\ \fP \fIjobid\fP +Rejuvenate \fIjobid\fP. The files associated with \fIjobid\fP are +touched so that their modification time is set to the +current time. This prevents the cleanup program from deleting the +job until the jobs modification time reaches the limit imposed by +the program. +.TP 7 +\fB-s\ \fP \fIsystem\fP +Write the status of all \fIuucp\fP requests for remote system \fIsystem\fP. +.TP 7 +\fB-u\ \fP \fIuser\fP +Write the status of all \fIuucp\fP requests issued by \fIuser\fP. +.sp +.SH OPERANDS +.LP +None. +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuustat\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error, +and informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall consist of information about each job selected, +in an unspecified format. The information shall +include at least the job ID, the user ID or name, and the remote system +name. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIuucp\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/uux.1p b/man1p/uux.1p new file mode 100644 index 000000000..053f98d35 --- /dev/null +++ b/man1p/uux.1p @@ -0,0 +1,295 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "UUX" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" uux +.SH NAME +uux \- remote command execution +.SH SYNOPSIS +.LP +\fBuux\fP \fB[\fP\fB-np\fP\fB]\fP \fIcommand-string\fP\fB +.br +.sp +uux\fP \fB[\fP\fB-jnp\fP\fB]\fP \fIcommand-string\fP\fB\fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIuux\fP utility shall gather zero or more files from various +systems, execute a shell pipeline (see \fIShell Commands\fP ) on a +specified system, and then send the standard output of the command +to +a file on a specified system. Only the first command of a pipeline +can have a \fIsystem-name\fP! prefix. All other commands in the +pipeline shall be executed on the system of the first command. +.LP +The following restrictions are applicable to the shell pipeline processed +by \fIuux\fP: +.IP " *" 3 +In gathering files from different systems, pathname expansion shall +not be performed by \fIuux\fP. Thus, a request such as: +.sp +.RS +.nf + +\fBuux "c99 remsys!~/*.c" +\fP +.fi +.RE +.LP +would attempt to copy the file named literally \fB*.c\fP to the local +system. +.LP +.IP " *" 3 +The redirection operators \fB">>"\fP , \fB"<<"\fP , \fB">|"\fP , and +\fB">&"\fP shall not be +accepted. Any use of these redirection operators shall cause this +utility to write an error message describing the problem and exit +with a non-zero exit status. +.LP +.IP " *" 3 +The reserved word \fB!\fP cannot be used at the head of the pipeline +to modify the exit status. (See the \fIcommand-string\fP +operand description below.) +.LP +.IP " *" 3 +Alias substitution shall not be performed. +.LP +.LP +A filename can be specified as for \fIuucp\fP; it can be an absolute +pathname, a pathname +preceded by ~ \fIname\fP (which is replaced by the corresponding login +directory), a pathname specified as ~/ +\fIdest\fP ( \fIdest\fP is prefixed by the public directory called +\fIPUBDIR\fP; the actual location of \fIPUBDIR\fP is +implementation-defined), or a simple filename (which is prefixed by +\fIuux\fP with the current directory). See \fIuucp\fP for the details. +.LP +The execution of commands on remote systems shall take place in an +execution directory known to the \fIuucp\fP system. All files required +for the execution shall be put into this directory unless they +already reside on that machine. Therefore, the application shall ensure +that non-local filenames (without path or machine +reference) are unique within the \fIuux\fP request. +.LP +The \fIuux\fP utility shall attempt to get all files to the execution +system. For files that are output files, the application +shall ensure that the filename is escaped using parentheses. +.LP +The remote system shall notify the user by mail if the requested command +on the remote system was disallowed or the files were +not accessible. This notification can be turned off by the \fB-n\fP +option. +.LP +Typical implementations of this utility require a communications line +configured to use the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Chapter 11, General Terminal Interface, but +other +communications means may be used. On systems where there are no available +communications means (either temporarily or permanently), +this utility shall write an error message describing the problem and +exit with a non-zero exit status. +.LP +The \fIuux\fP utility cannot guarantee support for all character encodings +in all circumstances. For example, transmission data +may be restricted to 7 bits by the underlying network, 8-bit data +and filenames need not be portable to non-internationalized +systems, and so on. Under these circumstances, it is recommended that +only characters defined in the ISO/IEC\ 646:1991 standard +International Reference Version (equivalent to ASCII) 7-bit range +of characters be used and that only characters defined in the +portable filename character set be used for naming files. +.SH OPTIONS +.LP +The \fIuux\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-p\fP +Make the standard input to \fIuux\fP the standard input to the \fIcommand-string\fP. +.TP 7 +\fB-j\fP +Write the job identification string to standard output. This job identification +can be used by \fIuustat\fP to obtain the status or terminate a job. +.TP 7 +\fB-n\fP +Do not notify the user if the command fails. +.sp +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIcommand-string\fP +.sp +A string made up of one or more arguments that are similar to normal +command arguments, except that the command and any filenames +can be prefixed by \fIsystem-name\fP!. A null \fIsystem-name\fP shall +be interpreted as the local system. +.sp +.SH STDIN +.LP +The standard input shall not be used unless the \fB'-'\fP or \fB-p\fP +option is specified; in those cases, the standard +input shall be made the standard input of the \fIcommand-string\fP. +.SH INPUT FILES +.LP +Input files shall be selected according to the contents of \fIcommand-string\fP. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIuux\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall not be used unless the \fB-j\fP option is +specified; in that case, the job identification string +shall be written to standard output in the following format: +.sp +.RS +.nf + +\fB"%s\\n", <\fP\fIjobid\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +Output files shall be created or written, or both, according to the +contents of \fIcommand-string\fP. +.LP +If \fB-n\fP is not used, mail files shall be modified following any +command or file-access failures on the remote system. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Note that, for security reasons, many installations limit the list +of commands executable on behalf of an incoming request from +\fIuux\fP. Many sites permit little more than the receipt of mail +via \fIuux\fP. +.LP +Any characters special to the command interpreter should be quoted +either by quoting the entire \fIcommand-string\fP or quoting +the special characters as individual arguments. +.LP +As noted in \fIuucp\fP, shell pattern matching notation characters +appearing in pathnames +are expanded on the appropriate local system. This is done under the +control of local settings of \fILC_COLLATE\fP and \fILC_CTYPE +\&.\fP Thus, care should be taken when using bracketed filename patterns, +as collation and typing rules may vary from one system to +another. Also be aware that certain types of expression (that is, +equivalence classes, character classes, and collating symbols) +need not be supported on non-internationalized systems. +.SH EXAMPLES +.IP " 1." 4 +The following command gets \fBfile1\fP from system \fBa\fP and \fBfile2\fP +from system \fBb\fP, executes \fIdiff\fP on the local system, and +puts the results in \fBfile.diff\fP in the local \fIPUBDIR\fP +directory. ( \fIPUBDIR\fP is the \fIuucp\fP public directory on the +local system.) +.sp +.RS +.nf + +\fBuux "!diff a!/usr/file1 b!/a4/file2 >!~/file.diff" +\fP +.fi +.RE +.LP +.IP " 2." 4 +The following command fails because \fIuux\fP places all files copied +to a system in the same working directory. Although the +files \fBxyz\fP are from two different systems, their filenames are +the same and conflict. +.sp +.RS +.nf + +\fBuux "!diff a!/usr1/xyz b!/usr2/xyz >!~/xyz.diff" +\fP +.fi +.RE +.LP +.IP " 3." 4 +The following command succeeds (assuming \fIdiff\fP is permitted on +system \fBa\fP) +because the file local to system \fBa\fP is not copied to the working +directory, and hence does not conflict with the file from +system \fBc\fP. +.sp +.RS +.nf + +\fBuux "a!diff a!/usr/xyz c!/usr/xyz >!~/xyz.diff" +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIuucp\fP , \fIuuencode\fP , \fIuustat\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/val.1p b/man1p/val.1p new file mode 100644 index 000000000..bc930deb1 --- /dev/null +++ b/man1p/val.1p @@ -0,0 +1,229 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "VAL" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" val +.SH NAME +val \- validate SCCS files (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBval - +.br +.sp +val\fP \fB[\fP\fB-s\fP\fB][\fP\fB-m\fP \fIname\fP\fB][\fP\fB-r\fP +\fISID\fP\fB][\fP\fB-y\fP +\fItype\fP\fB]\fP \fIfile\fP\fB... \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIval\fP utility shall determine whether the specified \fIfile\fP +is an SCCS file meeting the characteristics specified +by the options. +.SH OPTIONS +.LP +The \fIval\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines, +except that the usage of the \fB'-'\fP +operand is not strictly as intended by the guidelines (that is, reading +options and operands from standard input). +.LP +The following options shall be supported: +.TP 7 +\fB-m\ \fP \fIname\fP +Specify a \fIname\fP, which is compared with the SCCS %\fBM\fP% keyword +in \fIfile\fP; see \fIget\fP +\&. +.TP 7 +\fB-r\ \fP \fISID\fP +Specify a \fISID\fP (SCCS Identification String), an SCCS delta number. +A check shall be made to determine whether the +\fISID\fP is ambiguous (for example, \fB-r\ 1\fP is ambiguous because +it physically does not exist but implies 1.1, 1.2, and +so on, which may exist) or invalid (for example, \fB-r\ 1.0\fP or +\fB-r\ 1.1.0\fP are invalid because neither case can +exist as a valid delta number). If the \fISID\fP is valid and not +ambiguous, a check shall be made to determine whether it +actually exists. +.TP 7 +\fB-s\fP +Silence the diagnostic message normally written to standard output +for any error that is detected while processing each named +file on a given command line. +.TP 7 +\fB-y\ \fP \fItype\fP +Specify a \fItype\fP, which shall be compared with the SCCS %\fBY\fP% +keyword in \fIfile\fP; see \fIget\fP . +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of an existing SCCS file. If exactly one \fIfile\fP operand +appears, and it is \fB'-'\fP , the standard input +shall be read: each line shall be independently processed as if it +were a command line argument list. (However, the line is not +subjected to any of the shell word expansions, such as parameter expansion +or quote removal.) +.sp +.SH STDIN +.LP +The standard input shall be a text file used only when the \fIfile\fP +operand is specified as \fB'-'\fP . +.SH INPUT FILES +.LP +Any SCCS files processed shall be files of an unspecified format. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIval\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error, +and informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall consist of informative messages about either: +.IP " 1." 4 +Each file processed +.LP +.IP " 2." 4 +Each command line read from standard input +.LP +.LP +If the standard input is not used, for each \fIfile\fP operand yielding +a discrepancy, the output line shall have the following +format: +.sp +.RS +.nf + +\fB"%s: %s\\n", <\fP\fIpathname\fP\fB>, <\fP\fIunspecified string\fP\fB> +\fP +.fi +.RE +.LP +If standard input is used, a line of input shall be written before +each of the preceding lines for files containing +discrepancies: +.sp +.RS +.nf + +\fB"%s:\\n", <\fP\fIinput line\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +Not used. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The 8-bit code returned by \fIval\fP shall be a disjunction of the +possible errors; that is, it can be interpreted as a bit +string where set bits are interpreted as follows: +.TS C +center; l l l. +0x80 = Missing file argument. +0x40 = Unknown or duplicate option. +0x20 = Corrupted SCCS file. +0x10 = Cannot open file or file not SCCS. +0x08 = \fISID\fP is invalid or ambiguous. +0x04 = \fISID\fP does not exist. +0x02 = %\fBY\fP%, \fB-y\fP mismatch. +0x01 = %\fBM\fP%, \fB-m\fP mismatch. +.TE +.LP +Note that \fIval\fP can process two or more files on a given command +line and can process multiple command lines (when reading +the standard input). In these cases an aggregate code shall be returned: +a logical OR of the codes generated for each command line +and file processed. +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Since the \fIval\fP exit status sets the 0x80 bit, shell applications +checking \fB"$?"\fP cannot tell if it terminated due +to a missing file argument or receipt of a signal. +.SH EXAMPLES +.LP +In a directory with three SCCS files- \fBs.x\fP (of \fBt\fP type "text"), +\fBs.y\fP, and \fBs.z\fP (a corrupted file)-the +following command could produce the output shown: +.sp +.RS +.nf + +\fBval - <<EOF +-y source s.x +-m y s.y +s.z +EOF +.sp + +-y source s.x +.sp + + s.x: %Y%, -y mismatch +s.z +.sp + + s.z: corrupted SCCS file +\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIadmin\fP , \fIdelta\fP , \fIget\fP , \fIprs\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/vi.1p b/man1p/vi.1p new file mode 100644 index 000000000..5680e3332 --- /dev/null +++ b/man1p/vi.1p @@ -0,0 +1,4963 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "VI" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" vi +.SH NAME +vi \- screen-oriented (visual) display editor +.SH SYNOPSIS +.LP +\fBvi\fP \fB[\fP\fB-rR\fP\fB][\fP\fB-c\fP \fIcommand\fP\fB][\fP\fB-t\fP +\fItagstring\fP\fB][\fP\fB-w\fP \fIsize\fP\fB][\fP\fIfile\fP \fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +This utility shall be provided on systems that both support the User +Portability Utilities option and define the +POSIX2_CHAR_TERM symbol. On other systems it is optional. +.LP +The \fIvi\fP (visual) utility is a screen-oriented text editor. Only +the open and visual modes of the editor are described in +IEEE\ Std\ 1003.1-2001; see the line editor \fIex\fP for additional +editing +capabilities used in \fIvi\fP. The user can switch back and forth +between \fIvi\fP and \fIex\fP and execute \fIex\fP commands from within +\fIvi\fP. +.LP +This reference page uses the term \fIedit buffer\fP to describe the +current working text. No specific implementation is implied +by this term. All editing changes are performed on the edit buffer, +and no changes to it shall affect any file until an editor +command writes the file. +.LP +When using \fIvi\fP, the terminal screen acts as a window into the +editing buffer. Changes made to the editing buffer shall be +reflected in the screen display; the position of the cursor on the +screen shall indicate the position within the editing +buffer. +.LP +Certain terminals do not have all the capabilities necessary to support +the complete \fIvi\fP definition. When these commands +cannot be supported on such terminals, this condition shall not produce +an error message such as "not an editor command" or +report a syntax error. The implementation may either accept the commands +and produce results on the screen that are the result of +an unsuccessful attempt to meet the requirements of this volume of +IEEE\ Std\ 1003.1-2001 or report an error describing the +terminal-related deficiency. +.SH OPTIONS +.LP +The \fIvi\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\ \fP \fIcommand\fP +See the \fIex\fP command description of the \fB-c\fP option. +.TP 7 +\fB-r\fP +See the \fIex\fP command description of the \fB-r\fP option. +.TP 7 +\fB-R\fP +See the \fIex\fP command description of the \fB-R\fP option. +.TP 7 +\fB-t\ \fP \fItagstring\fP +See the \fIex\fP command description of the \fB-t\fP option. +.TP 7 +\fB-w\ \fP \fIsize\fP +See the \fIex\fP command description of the \fB-w\fP option. +.sp +.SH OPERANDS +.LP +See the OPERANDS section of the \fIex\fP command for a description +of the operands supported +by the \fIvi\fP command. +.SH STDIN +.LP +If standard input is not a terminal device, the results are undefined. +The standard input consists of a series of commands and +input text, as described in the EXTENDED DESCRIPTION section. +.LP +If a read from the standard input returns an error, or if the editor +detects an end-of-file condition from the standard input, +it shall be equivalent to a SIGHUP asynchronous event. +.SH INPUT FILES +.LP +See the INPUT FILES section of the \fIex\fP command for a description +of the input files +supported by the \fIvi\fP command. +.SH ENVIRONMENT VARIABLES +.LP +See the ENVIRONMENT VARIABLES section of the \fIex\fP command for +the environment variables +that affect the execution of the \fIvi\fP command. +.SH ASYNCHRONOUS EVENTS +.LP +See the ASYNCHRONOUS EVENTS section of the \fIex\fP for the asynchronous +events that affect +the execution of the \fIvi\fP command. +.SH STDOUT +.LP +If standard output is not a terminal device, undefined results occur. +.LP +Standard output may be used for writing prompts to the user, for informational +messages, and for writing lines from the +file. +.SH STDERR +.LP +If standard output is not a terminal device, undefined results occur. +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +See the OUTPUT FILES section of the \fIex\fP command for a description +of the output files +supported by the \fIvi\fP command. +.SH EXTENDED DESCRIPTION +.LP +If the terminal does not have the capabilities necessary to support +an unspecified portion of the \fIvi\fP definition, +implementations shall start initially in \fIex\fP mode or open mode. +Otherwise, after +initialization, \fIvi\fP shall be in command mode; text input mode +can be entered by one of several commands used to insert or +change text. In text input mode, <ESC> can be used to return to command +mode; other uses of <ESC> are described later +in this section; see Terminate Command or Input Mode . +.SS Initialization in ex and vi +.LP +See \fIInitialization in ex and vi\fP for a description of \fIex\fP +and \fIvi\fP initialization for the \fIvi\fP utility. +.SS Command Descriptions in vi +.LP +The following symbols are used in this reference page to represent +arguments to commands. +.TP 7 +\fIbuffer\fP +See the description of \fIbuffer\fP in the EXTENDED DESCRIPTION section +of the \fIex\fP +utility; see \fICommand Descriptions in ex\fP . +.LP +In open and visual mode, when a command synopsis shows both [ \fIbuffer\fP] +and [ \fIcount\fP] preceding the command name, +they can be specified in either order. +.TP 7 +\fIcount\fP +A positive integer used as an optional argument to most commands, +either to give a repeat count or as a size. This argument is +optional and shall default to 1 unless otherwise specified. +.LP +The Synopsis lines for the \fIvi\fP commands <control>-G, <control>-L, +<control>-R, <control>-], +\fB%\fP, \fB&\fP, \fB^\fP, \fBD\fP, \fBm\fP, \fBM\fP, \fBQ\fP, \fBu\fP, +\fBU\fP, and \fBZZ\fP do not have +\fIcount\fP as an optional argument. Regardless, it shall not be an +error to specify a \fIcount\fP to these commands, and any +specified \fIcount\fP shall be ignored. +.TP 7 +\fImotion\fP +An optional trailing argument used by the \fB!\fP, \fB<\fP, \fB>\fP, +\fBc\fP, \fBd\fP, and \fBy\fP commands, which +is used to indicate the region of text that shall be affected by the +command. The motion can be either one of the command +characters repeated or one of several other \fIvi\fP commands (listed +in the following table). Each of the applicable commands +specifies the region of text matched by repeating the command; each +command that can be used as a motion command specifies the +region of text it affects. +.LP +Commands that take \fImotion\fP arguments operate on either lines +or characters, depending on the circumstances. When operating +on lines, all lines that fall partially or wholly within the text +region specified for the command shall be affected. When +operating on characters, only the exact characters in the specified +text region shall be affected. Each motion command specifies +this individually. +.LP +When commands that may be motion commands are not used as motion commands, +they shall set the current position to the current +line and column as specified. +.LP +The following commands shall be valid cursor motion commands: +.sp +.RS +.nf + +\fB<apostrophe> ( - j H +<carriage-return> ) $ k L +<comma> [[ % l M +<control>-H ]] _ n N +<control>-N { ; t T +<control>-P } ? w W +<grave accent> ^ b B +<newline> + e E +<space> | f F +<zero> / h G +\fP +.fi +.RE +.LP +Any \fIcount\fP that is specified to a command that has an associated +motion command shall be applied to the motion command. If +a \fIcount\fP is applied to both the command and its associated motion +command, the effect shall be multiplicative. +.sp +.LP +The following symbols are used in this section to specify locations +in the edit buffer: +.TP 7 +\fIcurrent\ character\fP +.sp +The character that is currently indicated by the cursor. +.TP 7 +\fIend\ of\ a\ line\fP +.sp +The point located between the last non- <newline> (if any) and the +terminating <newline> of a line. For an empty line, +this location coincides with the beginning of the line. +.TP 7 +\fIend\ of\ the\ edit\ buffer\fP +.sp +The location corresponding to the end of the last line in the edit +buffer. +.sp +.LP +The following symbols are used in this section to specify command +actions: +.TP 7 +\fIbigword\fP +In the POSIX locale, \fIvi\fP shall recognize four kinds of \fIbigwords\fP: +.RS +.IP " 1." 4 +A maximal sequence of non- <blank>s preceded and followed by <blank>s +or the beginning or end of a line or the edit +buffer +.LP +.IP " 2." 4 +One or more sequential blank lines +.LP +.IP " 3." 4 +The first character in the edit buffer +.LP +.IP " 4." 4 +The last non- <newline> in the edit buffer +.LP +.RE +.TP 7 +\fIword\fP +In the POSIX locale, \fIvi\fP shall recognize five kinds of words: +.RS +.IP " 1." 4 +A maximal sequence of letters, digits, and underscores, delimited +at both ends by: +.RS +.IP " *" 3 +Characters other than letters, digits, or underscores +.LP +.IP " *" 3 +The beginning or end of a line +.LP +.IP " *" 3 +The beginning or end of the edit buffer +.LP +.RE +.LP +.IP " 2." 4 +A maximal sequence of characters other than letters, digits, underscores, +or <blank>s, delimited at both ends by: +.RS +.IP " *" 3 +A letter, digit, underscore +.LP +.IP " *" 3 +<blank>s +.LP +.IP " *" 3 +The beginning or end of a line +.LP +.IP " *" 3 +The beginning or end of the edit buffer +.LP +.RE +.LP +.IP " 3." 4 +One or more sequential blank lines +.LP +.IP " 4." 4 +The first character in the edit buffer +.LP +.IP " 5." 4 +The last non- <newline> in the edit buffer +.LP +.RE +.TP 7 +\fIsection\ boundary\fP +.sp +A \fIsection boundary\fP is one of the following: +.RS +.IP " 1." 4 +A line whose first character is a <form-feed> +.LP +.IP " 2." 4 +A line whose first character is an open curly brace ( \fB'{'\fP ) +.LP +.IP " 3." 4 +A line whose first character is a period and whose second and third +characters match a two-character pair in the \fBsections\fP +edit option (see \fIed\fP) +.LP +.IP " 4." 4 +A line whose first character is a period and whose only other character +matches the first character of a two-character pair in +the \fBsections\fP edit option, where the second character of the +two-character pair is a <space> +.LP +.IP " 5." 4 +The first line of the edit buffer +.LP +.IP " 6." 4 +The last line of the edit buffer if the last line of the edit buffer +is empty or if it is a \fB]]\fP or \fB}\fP command; +otherwise, the last non- <newline> of the last line of the edit buffer +.LP +.RE +.TP 7 +\fIparagraph\ boundary\fP +.sp +A \fIparagraph boundary\fP is one of the following: +.RS +.IP " 1." 4 +A section boundary +.LP +.IP " 2." 4 +A line whose first character is a period and whose second and third +characters match a two-character pair in the +\fBparagraphs\fP edit option (see \fIed\fP) +.LP +.IP " 3." 4 +A line whose first character is a period and whose only other character +matches the first character of a two-character pair in +the \fIparagraphs\fP edit option, where the second character of the +two-character pair is a <space> +.LP +.IP " 4." 4 +One or more sequential blank lines +.LP +.RE +.TP 7 +\fIremembered\ search\ direction\fP +.sp +See the description of \fIremembered search direction\fP in \fIed\fP. +.TP 7 +\fIsentence\ boundary\fP +.sp +A \fIsentence boundary\fP is one of the following: +.RS +.IP " 1." 4 +A paragraph boundary +.LP +.IP " 2." 4 +The first non- <blank> that occurs after a paragraph boundary +.LP +.IP " 3." 4 +The first non- <blank> that occurs after a period ( \fB'.'\fP ), exclamation +mark ( \fB'!'\fP ), or question mark ( +\fB'?'\fP ), followed by two <space>s or the end of a line; any number +of closing parenthesis ( \fB')'\fP ), closing +brackets ( \fB']'\fP ), double quote ( \fB' ),'\fP or single quote +( \fB'"\fP ) characters can appear between the +punctuation mark and the two <space>s or end-of-line +.LP +.RE +.sp +.LP +In the remainder of the description of the \fIvi\fP utility, the term +"buffer line" refers to a line in the edit buffer and +the term "display line" refers to the line or lines on the display +screen used to display one buffer line. The term "current +line" refers to a specific "buffer line". +.LP +If there are display lines on the screen for which there are no corresponding +buffer lines because they correspond to lines that +would be after the end of the file, they shall be displayed as a single +tilde ( \fB'~'\fP ) character, plus the terminating +<newline>. +.LP +The last line of the screen shall be used to report errors or display +informational messages. It shall also be used to display +the input for "line-oriented commands" ( \fB/\fP, \fB?\fP, \fB:\fP, +and \fB!\fP). When a line-oriented command is executed, +the editor shall enter text input mode on the last line on the screen, +using the respective command characters as prompt +characters. (In the case of the \fB!\fP command, the associated motion +shall be entered by the user before the editor enters text +input mode.) The line entered by the user shall be terminated by a +<newline>, a non- <control>-V-escaped +<carriage-return>, or unescaped <ESC>. It is unspecified if more characters +than require a display width minus one +column number of screen columns can be entered. +.LP +If any command is executed that overwrites a portion of the screen +other than the last line of the screen (for example, the \fIex\fP +\fBsuspend\fP or \fB!\fP commands), other than the \fIex\fP \fBshell\fP +command, the user shall be prompted for a character before the screen +is +refreshed and the edit session continued. +.LP +<tab>s shall take up the number of columns on the screen set by the +\fBtabstop\fP edit option (see \fIed\fP), unless there are less than +that number of columns before the display margin that will cause +the displayed line to be folded; in this case, they shall only take +up the number of columns up to that boundary. +.LP +The cursor shall be placed on the current line and relative to the +current column as specified by each command described in the +following sections. +.LP +In open mode, if the current line is not already displayed, then it +shall be displayed. +.LP +In visual mode, if the current line is not displayed, then the lines +that are displayed shall be expanded, scrolled, or redrawn +to cause an unspecified portion of the current line to be displayed. +If the screen is redrawn, no more than the number of display +lines specified by the value of the \fBwindow\fP edit option shall +be displayed (unless the current line cannot be completely +displayed in the number of display lines specified by the \fBwindow\fP +edit option) and the current line shall be positioned as +close to the center of the displayed lines as possible (within the +constraints imposed by the distance of the line from the +beginning or end of the edit buffer). If the current line is before +the first line in the display and the screen is scrolled, an +unspecified portion of the current line shall be placed on the first +line of the display. If the current line is after the last +line in the display and the screen is scrolled, an unspecified portion +of the current line shall be placed on the last line of the +display. +.LP +In visual mode, if a line from the edit buffer (other than the current +line) does not entirely fit into the lines at the bottom +of the display that are available for its presentation, the editor +may choose not to display any portion of the line. The lines of +the display that do not contain text from the edit buffer for this +reason shall each consist of a single \fB'@'\fP +character. +.LP +In visual mode, the editor may choose for unspecified reasons to not +update lines in the display to correspond to the underlying +edit buffer text. The lines of the display that do not correctly correspond +to text from the edit buffer for this reason shall +consist of a single \fB'@'\fP character (plus the terminating <newline>), +and the <control>-R command shall cause +the editor to update the screen to correctly represent the edit buffer. +.LP +Open and visual mode commands that set the current column set it to +a column position in the display, and not a character +position in the line. In this case, however, the column position in +the display shall be calculated for an infinite width display; +for example, the column related to a character that is part of a line +that has been folded onto additional screen lines will be +offset from the display line column where the buffer line begins, +not from the beginning of a particular display line. +.LP +The display cursor column in the display is based on the value of +the current column, as follows, with each rule applied in +turn: +.IP " 1." 4 +If the current column is after the last display line column used by +the displayed line, the display cursor column shall be set +to the last display line column occupied by the last non- <newline> +in the current line; otherwise, the display cursor column +shall be set to the current column. +.LP +.IP " 2." 4 +If the character of which some portion is displayed in the display +line column specified by the display cursor column requires +more than a single display line column: +.RS +.IP " a." 4 +If in text input mode, the display cursor column shall be adjusted +to the first display line column in which any portion of that +character is displayed. +.LP +.IP " b." 4 +Otherwise, the display cursor column shall be adjusted to the last +display line column in which any portion of that character is +displayed. +.LP +.RE +.LP +.LP +The current column shall not be changed by these adjustments to the +display cursor column. +.LP +If an error occurs during the parsing or execution of a \fIvi\fP command: +.IP " *" 3 +The terminal shall be alerted. Execution of the \fIvi\fP command shall +stop, and the cursor (for example, the current line and +column) shall not be further modified. +.LP +.IP " *" 3 +Unless otherwise specified by the following command sections, it is +unspecified whether an informational message shall be +displayed. +.LP +.IP " *" 3 +Any partially entered \fIvi\fP command shall be discarded. +.LP +.IP " *" 3 +If the \fIvi\fP command resulted from a \fBmap\fP expansion, all characters +from that \fBmap\fP expansion shall be discarded, +except as otherwise specified by the \fBmap\fP command (see \fIed\fP). +.LP +.IP " *" 3 +If the \fIvi\fP command resulted from the execution of a buffer, no +further commands caused by the execution of the buffer +shall be executed. +.LP +.SS Page Backwards +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-B +\fP +.fi +.RE +.sp +.LP +If in open mode, the <control>-B command shall behave identically +to the \fBz\fP command. Otherwise, if the current line +is the first line of the edit buffer, it shall be an error. +.LP +If the \fBwindow\fP edit option is less than 3, display a screen where +the last line of the display shall be some portion +of: +.sp +.RS +.nf + +\fB(\fP\fIcurrent first line\fP\fB) -1 +\fP +.fi +.RE +.LP +otherwise, display a screen where the first line of the display shall +be some portion of: +.sp +.RS +.nf + +\fB(\fP\fIcurrent first line\fP\fB) -\fP \fIcount\fP \fBx ((window edit option) -2) +\fP +.fi +.RE +.LP +If this calculation would result in a line that is before the first +line of the edit buffer, the first line of the display shall +display some portion of the first line of the edit buffer. +.LP +\fICurrent line\fP: If no lines from the previous display remain on +the screen, set to the last line of the display; otherwise, +set to ( \fIline\fP - the number of new lines displayed on this screen). +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Scroll Forward +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-D +\fP +.fi +.RE +.sp +.LP +If the current line is the last line of the edit buffer, it shall +be an error. +.LP +If no \fIcount\fP is specified, \fIcount\fP shall default to the \fIcount\fP +associated with the previous <control>-D +or <control>-U command. If there was no previous <control>-D or <control>-U +command, \fIcount\fP shall default +to the value of the \fBscroll\fP edit option. +.LP +If in open mode, write lines starting with the line after the current +line, until \fIcount\fP lines or the last line of the +file have been written. +.LP +\fICurrent line\fP: If the current line + \fIcount\fP is past the +last line of the edit buffer, set to the last line of the +edit buffer; otherwise, set to the current line + \fIcount\fP. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Scroll Forward by Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-E +\fP +.fi +.RE +.sp +.LP +Display the line count lines after the last line currently displayed. +.LP +If the last line of the edit buffer is displayed, it shall be an error. +If there is no line \fIcount\fP lines after the last +line currently displayed, the last line of the display shall display +some portion of the last line of the edit buffer. +.LP +\fICurrent line\fP: Unchanged if the previous current character is +displayed; otherwise, set to the first line displayed. +.LP +\fICurrent column\fP: Unchanged. +.SS Page Forward +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-F +\fP +.fi +.RE +.sp +.LP +If in open mode, the <control>-F command shall behave identically +to the \fBz\fP command. Otherwise, if the current line +is the last line of the edit buffer, it shall be an error. +.LP +If the \fBwindow\fP edit option is less than 3, display a screen where +the first line of the display shall be some portion +of: +.sp +.RS +.nf + +\fB(\fP\fIcurrent last line\fP\fB) +1 +\fP +.fi +.RE +.LP +otherwise, display a screen where the first line of the display shall +be some portion of: +.sp +.RS +.nf + +\fB(\fP\fIcurrent first line\fP\fB) +\fP \fIcount\fP \fBx ((window edit option) -2) +\fP +.fi +.RE +.LP +If this calculation would result in a line that is after the last +line of the edit buffer, the last line of the display shall +display some portion of the last line of the edit buffer. +.LP +\fICurrent line\fP: If no lines from the previous display remain on +the screen, set to the first line of the display; +otherwise, set to ( \fIline\fP + the number of new lines displayed +on this screen). +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Display Information +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-G +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIex\fP \fBfile\fP command. +.SS Move Cursor Backwards +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-H +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fBh +.sp + +the current\fP \fIerase\fP \fBcharacter (see stty) +\fP +.fi +.RE +.sp +.LP +If there are no characters before the current character on the current +line, it shall be an error. If there are less than +\fIcount\fP previous characters on the current line, \fIcount\fP shall +be adjusted to the number of previous characters on the +line. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall be from the character before the starting cursor +up to and including the \fIcount\fPth character before +the starting cursor. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to ( \fIcolumn\fP - the number of columns +occupied by \fIcount\fP characters ending with the +previous current column). +.SS Move Down +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<newline> +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fB<control>-J +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fB<control>-M +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fB<control>-N +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fBj +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fB<carriage-return> +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fB+ +\fP +.fi +.RE +.sp +.LP +If there are less than \fIcount\fP lines after the current line in +the edit buffer, it shall be an error. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall include the starting line and the next \fIcount\fP +- 1 lines. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in line mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to \fIcurrent line\fP+ \fIcount\fP. +.LP +\fICurrent column\fP: Set to non- <blank> for the <carriage-return>, +<control>-M, and \fB+\fP commands; +otherwise, unchanged. +.SS Clear and Redisplay +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-L +\fP +.fi +.RE +.sp +.LP +If in open mode, clear the screen and redisplay the current line. +Otherwise, clear and redisplay the screen. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Move Up +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-P +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fBk +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fB- +\fP +.fi +.RE +.sp +.LP +If there are less than \fIcount\fP lines before the current line in +the edit buffer, it shall be an error. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall include the starting line and the previous \fIcount\fP +lines. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in line mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to \fIcurrent line\fP - \fIcount\fP. +.LP +\fICurrent column\fP: Set to non- <blank> for the \fB-\fP command; +otherwise, unchanged. +.SS Redraw Screen +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-R +\fP +.fi +.RE +.sp +.LP +If any lines have been deleted from the display screen and flagged +as deleted on the terminal using the \fB@\fP convention (see +the beginning of the EXTENDED DESCRIPTION section), they shall be +redisplayed to match the contents of the edit buffer. +.LP +It is unspecified whether lines flagged with \fB@\fP because they +do not fit on the terminal display shall be affected. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Scroll Backward +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-U +\fP +.fi +.RE +.sp +.LP +If the current line is the first line of the edit buffer, it shall +be an error. +.LP +If no \fIcount\fP is specified, \fIcount\fP shall default to the \fIcount\fP +associated with the previous <control>-D +or <control>-U command. If there was no previous <control>-D or <control>-U +command, \fIcount\fP shall default +to the value of the \fBscroll\fP edit option. +.LP +\fICurrent line\fP: If \fIcount\fP is greater than the current line, +set to 1; otherwise, set to the current line - +\fIcount\fP. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Scroll Backward by Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<control>-Y +\fP +.fi +.RE +.sp +.LP +Display the line \fIcount\fP lines before the first line currently +displayed. +.LP +If the current line is the first line of the edit buffer, it shall +be an error. If this calculation would result in a line that +is before the first line of the edit buffer, the first line of the +display shall display some portion of the first line of the edit +buffer. +.LP +\fICurrent line\fP: Unchanged if the previous current character is +displayed; otherwise, set to the first line displayed. +.LP +\fICurrent column\fP: Unchanged. +.SS Edit the Alternate File +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-^ +\fP +.fi +.RE +.sp +This command shall be equivalent to the \fIex\fP \fBedit\fP command, +with the alternate +pathname as its argument. +.SS Terminate Command or Input Mode +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<ESC> +\fP +.fi +.RE +.sp +.LP +If a partial \fIvi\fP command (as defined by at least one, non- \fIcount\fP +character) has been entered, discard the +\fIcount\fP and the command character(s). +.LP +Otherwise, if no command characters have been entered, and the <ESC> +was the result of a map expansion, the terminal shall +be alerted and the <ESC> character shall be discarded, but it shall +not be an error. +.LP +Otherwise, it shall be an error. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Search for tagstring +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-] +\fP +.fi +.RE +.sp +.LP +If the current character is not a word or <blank>, it shall be an +error. +.LP +This command shall be equivalent to the \fIex\fP \fBtag\fP command, +with the argument to +that command defined as follows. +.LP +If the current character is a <blank>: +.IP " 1." 4 +Skip all <blank>s after the cursor up to the end of the line. +.LP +.IP " 2." 4 +If the end of the line is reached, it shall be an error. +.LP +.LP +Then, the argument to the \fIex\fP \fBtag\fP command shall be the +current character and all +subsequent characters, up to the first non-word character or the end +of the line. +.SS Move Cursor Forward +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<space> +.sp + +\fP\fB[\fP\fIcount\fP\fB]\fP \fBl\fP (ell) +.fi +.RE +.sp +.LP +If there are less than \fIcount\fP non- <newline>s after the cursor +on the current line, \fIcount\fP shall be adjusted +to the number of non- <newline>s after the cursor on the line. +.LP +If used as a motion command: +.IP " 1." 4 +If the current or \fIcount\fPth character after the cursor is the +last non- <newline> in the line, the text region shall +be comprised of the current character up to and including the last +non- <newline> in the line. Otherwise, the text region +shall be from the current character up to, but not including, the +\fIcount\fPth character after the cursor. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +If there are no non- <newline>s after the current character on the +current line, it shall be an error. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to the last column that displays any portion +of the \fIcount\fPth character after the current +character. +.SS Replace Text with Results from Shell Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB!\fP \fImotion shell-commands\fP \fB<newline> +\fP +.fi +.RE +.sp +.LP +If the motion command is the \fB!\fP command repeated: +.IP " 1." 4 +If the edit buffer is empty and no \fIcount\fP was supplied, the command +shall be the equivalent of the \fIex\fP \fB:read\fP \fB!\fP command, +with the text input, and no text shall be copied to any +buffer. +.LP +.IP " 2." 4 +Otherwise: +.RS +.IP " a." 4 +If there are less than \fIcount\fP -1 lines after the current line +in the edit buffer, it shall be an error. +.LP +.IP " b." 4 +The text region shall be from the current line up to and including +the next \fIcount\fP -1 lines. +.LP +.RE +.LP +.LP +Otherwise, the text region shall be the lines in which any character +of the text region specified by the motion command +appear. +.LP +Any text copied to a buffer shall be in line mode. +.LP +This command shall be equivalent to the \fIex\fP \fB!\fP command for +the specified +lines. +.SS Move Cursor to End-of-Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB$ +\fP +.fi +.RE +.sp +.LP +It shall be an error if there are less than ( \fIcount\fP -1) lines +after the current line in the edit buffer. +.LP +If used as a motion command: +.IP " 1." 4 +If \fIcount\fP is 1: +.RS +.IP " a." 4 +It shall be an error if the line is empty. +.LP +.IP " b." 4 +Otherwise, the text region shall consist of all characters from the +starting cursor to the last non- <newline> in the +line, inclusive, and any text copied to a buffer shall be in character +mode. +.LP +.RE +.LP +.IP " 2." 4 +Otherwise, if the starting cursor position is at or before the first +non- <blank> in the line, the text region shall +consist of the current and the next \fIcount\fP -1 lines, and any +text saved to a buffer shall be in line mode. +.LP +.IP " 3." 4 +Otherwise, the text region shall consist of all characters from the +starting cursor to the last non- <newline> in the line +that is \fIcount\fP -1 lines forward from the current line, and any +text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the \fIcurrent line\fP + \fIcount\fP-1. +.LP +\fICurrent column\fP: The current column is set to the last display +line column of the last non- <newline> in the line, +or column position 1 if the line is empty. +.LP +The current column shall be adjusted to be on the last display line +column of the last non- <newline> of the current line +as subsequent commands change the current line, until a command changes +the current column. +.SS Move to Matching Character +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB% +\fP +.fi +.RE +.sp +.LP +If the character at the current position is not a parenthesis, bracket, +or curly brace, search forward in the line to the first +one of those characters. If no such character is found, it shall be +an error. +.LP +The matching character shall be the parenthesis, bracket, or curly +brace matching the parenthesis, bracket, or curly brace, +respectively, that was at the current position or that was found on +the current line. +.LP +Matching shall be determined as follows, for an open parenthesis: +.IP " 1." 4 +Set a counter to 1. +.LP +.IP " 2." 4 +Search forwards until a parenthesis is found or the end of the edit +buffer is reached. +.LP +.IP " 3." 4 +If the end of the edit buffer is reached, it shall be an error. +.LP +.IP " 4." 4 +If an open parenthesis is found, increment the counter by 1. +.LP +.IP " 5." 4 +If a close parenthesis is found, decrement the counter by 1. +.LP +.IP " 6." 4 +If the counter is zero, the current character is the matching character. +.LP +.LP +Matching for a close parenthesis shall be equivalent, except that +the search shall be backwards, from the starting character to +the beginning of the buffer, a close parenthesis shall increment the +counter by 1, and an open parenthesis shall decrement the +counter by 1. +.LP +Matching for brackets and curly braces shall be equivalent, except +that searching shall be done for open and close brackets or +open and close curly braces. It is implementation-defined whether +other characters are searched for and matched as well. +.LP +If used as a motion command: +.IP " 1." 4 +If the matching cursor was after the starting cursor in the edit buffer, +and the starting cursor position was at or before the +first non- <blank> non- <newline> in the starting line, and the matching +cursor position was at or after the last non- +<blank> non- <newline> in the matching line, the text region shall +consist of the current line to the matching line, +inclusive, and any text copied to a buffer shall be in line mode. +.LP +.IP " 2." 4 +If the matching cursor was before the starting cursor in the edit +buffer, and the starting cursor position was at or after the +last non- <blank> non- <newline> in the starting line, and the matching +cursor position was at or before the first non- +<blank> non- <newline> in the matching line, the text region shall +consist of the current line to the matching line, +inclusive, and any text copied to a buffer shall be in line mode. +.LP +.IP " 3." 4 +Otherwise, the text region shall consist of the starting character +to the matching character, inclusive, and any text copied to +a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the line where the matching character is +located. +.LP +\fICurrent column\fP: Set to the last column where any portion of +the matching character is displayed. +.SS Repeat Substitution +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB& +\fP +.fi +.RE +.sp +.LP +Repeat the previous substitution command. This command shall be equivalent +to the \fIex\fP +\fB&\fP command with the current line as its addresses, and without +\fIoptions\fP, \fIcount\fP, or \fIflags\fP. +.SS Return to Previous Context at Beginning of Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB'\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +It shall be an error if there is no line in the edit buffer marked +by \fIcharacter\fP. +.LP +If used as a motion command: +.IP " 1." 4 +If the starting cursor is after the marked cursor, then the locations +of the starting cursor and the marked cursor in the edit +buffer shall be logically swapped. +.LP +.IP " 2." 4 +The text region shall consist of the starting line up to and including +the marked line, and any text copied to a buffer shall be +in line mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the line referenced by the mark. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Return to Previous Context +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB`\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +It shall be an error if the marked line is no longer in the edit buffer. +If the marked line no longer contains a character in +the saved numbered character position, it shall be as if the marked +position is the first non- <blank>. +.LP +If used as a motion command: +.IP " 1." 4 +It shall be an error if the marked cursor references the same character +in the edit buffer as the starting cursor. +.LP +.IP " 2." 4 +If the starting cursor is after the marked cursor, then the locations +of the starting cursor and the marked cursor in the edit +buffer shall be logically swapped. +.LP +.IP " 3." 4 +If the starting line is empty or the starting cursor is at or before +the first non- <blank> non- <newline> of the +starting line, and the marked cursor line is empty or the marked cursor +references the first character of the marked cursor line, +the text region shall consist of all lines containing characters from +the starting cursor to the line before the marked cursor +line, inclusive, and any text copied to a buffer shall be in line +mode. +.LP +.IP " 4." 4 +Otherwise, if the marked cursor line is empty or the marked cursor +references a character at or before the first non- +<blank> non- <newline> of the marked cursor line, the region of text +shall be from the starting cursor to the last non- +<newline> of the line before the marked cursor line, inclusive, and +any text copied to a buffer shall be in character +mode. +.LP +.IP " 5." 4 +Otherwise, the region of text shall be from the starting cursor (inclusive), +to the marked cursor (exclusive), and any text +copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the line referenced by the mark. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the character referenced by the mark is displayed. +.SS Return to Previous Section +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB[[ +\fP +.fi +.RE +.sp +.LP +Move the cursor backward through the edit buffer to the first character +of the previous section boundary, \fIcount\fP +times. +.LP +If used as a motion command: +.IP " 1." 4 +If the starting cursor was at the first character of the starting +line or the starting line was empty, and the first character +of the boundary was the first character of the boundary line, the +text region shall consist of the current line up to and including +the line where the \fIcount\fPth next boundary starts, and any text +copied to a buffer shall be in line mode. +.LP +.IP " 2." 4 +If the boundary was the last line of the edit buffer or the last non- +<newline> of the last line of the edit buffer, the +text region shall consist of the last character in the edit buffer +up to and including the starting character, and any text saved +to a buffer shall be in character mode. +.LP +.IP " 3." 4 +Otherwise, the text region shall consist of the starting character +up to but not including the first character in the +\fIcount\fPth next boundary, and any text copied to a buffer shall +be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the line where the \fIcount\fPth next boundary +in the edit buffer starts. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the first character of the \fIcount\fPth next boundary is +displayed, or column position 1 if the line is empty. +.SS Move to Next Section +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB]] +\fP +.fi +.RE +.sp +.LP +Move the cursor forward through the edit buffer to the first character +of the next section boundary, \fIcount\fP times. +.LP +If used as a motion command: +.IP " 1." 4 +If the starting cursor was at the first character of the starting +line or the starting line was empty, and the first character +of the boundary was the first character of the boundary line, the +text region shall consist of the current line up to and including +the line where the \fIcount\fPth previous boundary starts, and any +text copied to a buffer shall be in line mode. +.LP +.IP " 2." 4 +If the boundary was the first line of the edit buffer, the text region +shall consist of the first character in the edit buffer +up to but not including the starting character, and any text copied +to a buffer shall be in character mode. +.LP +.IP " 3." 4 +Otherwise, the text region shall consist of the first character in +the \fIcount\fPth previous section boundary up to but not +including the starting character, and any text copied to a buffer +shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the line where the \fIcount\fPth previous +boundary in the edit buffer starts. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the first character of the \fIcount\fPth previous +boundary is displayed, or column position 1 if the line is empty. +.SS Move to First Non-<blank> Position on Current Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB^ +\fP +.fi +.RE +.sp +If used as a motion command: +.IP " 1." 4 +If the line has no non- <blank> non- <newline>s, or if the cursor +is at the first non- <blank> non- +<newline> of the line, it shall be an error. +.LP +.IP " 2." 4 +If the cursor is before the first non- <blank> non- <newline> of the +line, the text region shall be comprised of the +current character, up to, but not including, the first non- <blank> +non- <newline> of the line. +.LP +.IP " 3." 4 +If the cursor is after the first non- <blank> non- <newline> of the +line, the text region shall be from the +character before the starting cursor up to and including the first +non- <blank> non- <newline> of the line. +.LP +.IP " 4." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Current and Line Above +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB_ +\fP +.fi +.RE +.sp +.LP +If there are less than \fIcount\fP -1 lines after the current line +in the edit buffer, it shall be an error. +.LP +If used as a motion command: +.IP " 1." 4 +If \fIcount\fP is less than 2, the text region shall be the current +line. +.LP +.IP " 2." 4 +Otherwise, the text region shall include the starting line and the +next \fIcount\fP -1 lines. +.LP +.IP " 3." 4 +Any text copied to a buffer shall be in line mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to current line + \fIcount\fP -1. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Move Back to Beginning of Sentence +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB( +\fP +.fi +.RE +.sp +.LP +Move backward to the beginning of a sentence. This command shall be +equivalent to the \fB[[\fP command, with the exception that +sentence boundaries shall be used instead of section boundaries. +.SS Move Forward to Beginning of Sentence +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB) +\fP +.fi +.RE +.sp +.LP +Move forward to the beginning of a sentence. This command shall be +equivalent to the \fB]]\fP command, with the exception that +sentence boundaries shall be used instead of section boundaries. +.SS Move Back to Preceding Paragraph +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB{ +\fP +.fi +.RE +.sp +.LP +Move back to the beginning of the preceding paragraph. This command +shall be equivalent to the \fB[[\fP command, with the +exception that paragraph boundaries shall be used instead of section +boundaries. +.SS Move Forward to Next Paragraph +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB} +\fP +.fi +.RE +.sp +.LP +Move forward to the beginning of the next paragraph. This command +shall be equivalent to the \fB]]\fP command, with the +exception that paragraph boundaries shall be used instead of section +boundaries. +.SS Move to Specific Column Position +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB| +\fP +.fi +.RE +.sp +.LP +For the purposes of this command, lines that are too long for the +current display and that have been folded shall be treated as +having a single, 1-based, number of columns. +.LP +If there are less than \fIcount\fP columns in which characters from +the current line are displayed on the screen, \fIcount\fP +shall be adjusted to be the last column in which any portion of the +line is displayed on the screen. +.LP +If used as a motion command: +.IP " 1." 4 +If the line is empty, or the cursor character is the same as the character +on the \fIcount\fPth column of the line, it shall be +an error. +.LP +.IP " 2." 4 +If the cursor is before the \fIcount\fPth column of the line, the +text region shall be comprised of the current character, up +to but not including the character on the \fIcount\fPth column of +the line. +.LP +.IP " 3." 4 +If the cursor is after the \fIcount\fPth column of the line, the text +region shall be from the character before the starting +cursor up to and including the character on the \fIcount\fPth column +of the line. +.LP +.IP " 4." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the character that is displayed in the \fIcount\fP column +of the line is displayed. +.SS Reverse Find Character +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB, +\fP +.fi +.RE +.sp +.LP +If the last \fBF\fP, \fBf\fP, \fBT\fP, or \fBt\fP command was \fBF\fP, +\fBf\fP, \fBT\fP, or \fBt\fP, this command shall +be equivalent to an \fBf\fP, \fBF\fP, \fBt\fP, or \fBT\fP command, +respectively, with the specified \fIcount\fP and the same +search character. +.LP +If there was no previous \fBF\fP, \fBf\fP, \fBT\fP, or \fBt\fP command, +it shall be an error. +.SS Repeat +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB. +\fP +.fi +.RE +.sp +.LP +Repeat the last \fB!\fP, \fB<\fP, \fB>\fP, \fBA\fP, \fBC\fP, \fBD\fP, +\fBI\fP, \fBJ\fP, \fBO\fP, \fBP\fP, +\fBR\fP, \fBS\fP, \fBX\fP, \fBY\fP, \fBa\fP, \fBc\fP, \fBd\fP, \fBi\fP, +\fBo\fP, \fBp\fP, \fBr\fP, \fBs\fP, \fBx\fP, +\fBy\fP, or \fB~\fP command. It shall be an error if none of these +commands have been executed. Commands (other than +commands that enter text input mode) executed as a result of map expansions, +shall not change the value of the last repeatable +command. +.LP +Repeated commands with associated motion commands shall repeat the +motion command as well; however, any specified \fIcount\fP +shall replace the \fIcount\fP(s) that were originally specified to +the repeated command or its associated motion command. +.LP +If the motion component of the repeated command is \fBf\fP, \fBF\fP, +\fBt\fP, or \fBT\fP, the repeated command shall not set +the remembered search character for the \fB;\fP and \fB,\fP commands. +.LP +If the repeated command is \fBp\fP or \fBP\fP, and the buffer associated +with that command was a numeric buffer named with a +number less than 9, the buffer associated with the repeated command +shall be set to be the buffer named by the name of the previous +buffer logically incremented by 1. +.LP +If the repeated character is a text input command, the input text +associated with that command is repeated literally: +.IP " *" 3 +Input characters are neither macro or abbreviation-expanded. +.LP +.IP " *" 3 +Input characters are not interpreted in any special way with the exception +that <newline>, <carriage-return>, and +<control>-T behave as described in Input Mode Commands in vi . +.LP +.LP +\fICurrent line\fP: Set as described for the repeated command. +.LP +\fICurrent column\fP: Set as described for the repeated command. +.SS Find Regular Expression +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB/ +\fP +.fi +.RE +.sp +.LP +If the input line contains no non- <newline>s, it shall be equivalent +to a line containing only the last regular +expression encountered. The enhanced regular expressions supported +by \fIvi\fP are described in \fIRegular Expressions in ex\fP . +.LP +Otherwise, the line shall be interpreted as one or more regular expressions, +optionally followed by an address offset or a +\fIvi\fP \fBz\fP command. +.LP +If the regular expression is not the last regular expression on the +line, or if a line offset or \fBz\fP command is specified, +the regular expression shall be terminated by an unescaped \fB'/'\fP +character, which shall not be used as part of the regular +expression. If the regular expression is not the first regular expression +on the line, it shall be preceded by zero or more +<blank>s, a semicolon, zero or more <blank>s, and a leading \fB'/'\fP +character, which shall not be interpreted as +part of the regular expression. It shall be an error to precede any +regular expression with any characters other than these. +.LP +Each search shall begin from the character after the first character +of the last match (or, if it is the first search, after the +cursor). If the \fBwrapscan\fP edit option is set, the search shall +continue to the character before the starting cursor +character; otherwise, to the end of the edit buffer. It shall be an +error if any search fails to find a match, and an informational +message to this effect shall be displayed. +.LP +An optional address offset (see \fIAddressing in ex\fP ) can be specified +after the last +regular expression by including a trailing \fB'/'\fP character after +the regular expression and specifying the address offset. +This offset will be from the line containing the match for the last +regular expression specified. It shall be an error if the line +offset would indicate a line address less than 1 or greater than the +last line in the edit buffer. An address offset of zero shall +be supported. It shall be an error to follow the address offset with +any other characters than <blank>s. +.LP +If not used as a motion command, an optional \fBz\fP command (see +Redraw Window ) can be +specified after the last regular expression by including a trailing +\fB'/'\fP character after the regular expression, zero or +more <blank>s, a \fB'z'\fP , zero or more <blank>s, an optional new +\fBwindow\fP edit option value, zero or more +<blank>s, and a location character. The effect shall be as if the +\fBz\fP command was executed after the \fB/\fP command. +It shall be an error to follow the \fBz\fP command with any other +characters than <blank>s. +.LP +The remembered search direction shall be set to forward. +.LP +If used as a motion command: +.IP " 1." 4 +It shall be an error if the last match references the same character +in the edit buffer as the starting cursor. +.LP +.IP " 2." 4 +If any address offset is specified, the last match shall be adjusted +by the specified offset as described previously. +.LP +.IP " 3." 4 +If the starting cursor is after the last match, then the locations +of the starting cursor and the last match in the edit buffer +shall be logically swapped. +.LP +.IP " 4." 4 +If any address offset is specified, the text region shall consist +of all lines containing characters from the starting cursor to +the last match line, inclusive, and any text copied to a buffer shall +be in line mode. +.LP +.IP " 5." 4 +Otherwise, if the starting line is empty or the starting cursor is +at or before the first non- <blank> non- +<newline> of the starting line, and the last match line is empty or +the last match starts at the first character of the last +match line, the text region shall consist of all lines containing +characters from the starting cursor to the line before the last +match line, inclusive, and any text copied to a buffer shall be in +line mode. +.LP +.IP " 6." 4 +Otherwise, if the last match line is empty or the last match begins +at a character at or before the first non- <blank> +non- <newline> of the last match line, the region of text shall be +from the current cursor to the last non- <newline> +of the line before the last match line, inclusive, and any text copied +to a buffer shall be in character mode. +.LP +.IP " 7." 4 +Otherwise, the region of text shall be from the current cursor (inclusive), +to the first character of the last match +(exclusive), and any text copied to a buffer shall be in character +mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: If a match is found, set to the last matched line +plus the address offset, if any; otherwise, +unchanged. +.LP +\fICurrent column\fP: Set to the last column on which any portion +of the first character in the last matched string is +displayed, if a match is found; otherwise, unchanged. +.SS Move to First Character in Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB0 \fP (zero) +.fi +.RE +.sp +.LP +Move to the first character on the current line. The character \fB'0'\fP +shall not be interpreted as a command if it is +immediately preceded by a digit. +.LP +If used as a motion command: +.IP " 1." 4 +If the cursor character is the first character in the line, it shall +be an error. +.LP +.IP " 2." 4 +The text region shall be from the character before the cursor character +up to and including the first character in the line. +.LP +.IP " 3." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: The last column in which any portion of the +first character in the line is displayed, or if the line is +empty, unchanged. +.SS Execute an ex Command +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB: +\fP +.fi +.RE +.sp +.LP +Execute one or more \fIex\fP commands. +.LP +If any portion of the screen other than the last line of the screen +was overwritten by any \fIex\fP command (except \fBshell\fP), \fIvi\fP +shall display a message indicating that it is waiting +for an input from the user, and shall then read a character. This +action may also be taken for other, unspecified reasons. +.LP +If the next character entered is a \fB':'\fP , another \fIex\fP command +shall be accepted +and executed. Any other character shall cause the screen to be refreshed +and \fIvi\fP shall return to command mode. +.LP +\fICurrent line\fP: As specified for the \fIex\fP command. +.LP +\fICurrent column\fP: As specified for the \fIex\fP command. +.SS Repeat Find +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB; +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the last \fBF\fP, \fBf\fP, \fBT\fP, +or \fBt\fP command, with the specified \fIcount\fP, +and with the same search character used for the last \fBF\fP, \fBf\fP, +\fBT\fP, or \fBt\fP command. If there was no previous +\fBF\fP, \fBf\fP, \fBT\fP, or \fBt\fP command, it shall be an error. +.SS Shift Left +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB<\fP \fImotion\fP +.fi +.RE +.sp +.LP +If the motion command is the \fB<\fP command repeated: +.IP " 1." 4 +If there are less than \fIcount\fP -1 lines after the current line +in the edit buffer, it shall be an error. +.LP +.IP " 2." 4 +The text region shall be from the current line, up to and including +the next \fIcount\fP -1 lines. +.LP +.LP +Shift any line in the text region specified by the \fIcount\fP and +motion command one shiftwidth (see the \fIex\fP \fBshiftwidth\fP option) +toward the start of the line, as described by the \fIex\fP \fB<\fP +command. The unshifted lines shall be copied to the unnamed buffer +in line +mode. +.LP +\fICurrent line\fP: If the motion was from the current cursor position +toward the end of the edit buffer, unchanged. Otherwise, +set to the first line in the edit buffer that is part of the text +region specified by the motion command. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Shift Right +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB>\fP \fImotion\fP +.fi +.RE +.sp +.LP +If the motion command is the \fB>\fP command repeated: +.IP " 1." 4 +If there are less than \fIcount\fP -1 lines after the current line +in the edit buffer, it shall be an error. +.LP +.IP " 2." 4 +The text region shall be from the current line, up to and including +the next \fIcount\fP -1 lines. +.LP +.LP +Shift any line with characters in the text region specified by the +\fIcount\fP and motion command one shiftwidth (see the \fIex\fP \fBshiftwidth\fP +option) away from the start of the line, as described by the \fIex\fP +\fB>\fP command. The unshifted lines shall be copied into the unnamed +buffer in line +mode. +.LP +\fICurrent line\fP: If the motion was from the current cursor position +toward the end of the edit buffer, unchanged. Otherwise, +set to the first line in the edit buffer that is part of the text +region specified by the motion command. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Scan Backwards for Regular Expression +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB? +\fP +.fi +.RE +.sp +.LP +Scan backwards; the \fB?\fP command shall be equivalent to the \fB/\fP +command (see Find Regular +Expression ) with the following exceptions: +.IP " 1." 4 +The input prompt shall be a \fB'?'\fP . +.LP +.IP " 2." 4 +Each search shall begin from the character before the first character +of the last match (or, if it is the first search, the +character before the cursor character). +.LP +.IP " 3." 4 +The search direction shall be from the cursor toward the beginning +of the edit buffer, and the \fBwrapscan\fP edit option shall +affect whether the search wraps to the end of the edit buffer and +continues. +.LP +.IP " 4." 4 +The remembered search direction shall be set to backward. +.LP +.SS Execute +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB@\fP\fIbuffer\fP +.fi +.RE +.sp +.LP +If the \fIbuffer\fP is specified as \fB@\fP, the last buffer executed +shall be used. If no previous buffer has been executed, +it shall be an error. +.LP +Behave as if the contents of the named buffer were entered as standard +input. After each line of a line-mode buffer, and all but +the last line of a character mode buffer, behave as if a <newline> +were entered as standard input. +.LP +If an error occurs during this process, an error message shall be +written, and no more characters resulting from the execution +of this command shall be processed. +.LP +If a \fIcount\fP is specified, behave as if that count were entered +as user input before the characters from the \fB@\fP +buffer were entered. +.LP +\fICurrent line\fP: As specified for the individual commands. +.LP +\fICurrent column\fP: As specified for the individual commands. +.SS Reverse Case +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fB~ +\fP +.fi +.RE +.sp +.LP +Reverse the case of the current character and the next \fIcount\fP +-1 characters, such that lowercase characters that have +uppercase counterparts shall be changed to uppercase characters, and +uppercase characters that have lowercase counterparts shall be +changed to lowercase characters, as prescribed by the current locale. +No other characters shall be affected by this command. +.LP +If there are less than \fIcount\fP -1 characters after the cursor +in the edit buffer, \fIcount\fP shall be adjusted to the +number of characters after the cursor in the edit buffer minus 1. +.LP +For the purposes of this command, the next character after the last +non- <newline> on the line shall be the next character +in the edit buffer. +.LP +\fICurrent line\fP: Set to the line including the ( \fIcount\fP-1)th +character after the cursor. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the ( \fIcount\fP-1)th character after the cursor is +displayed. +.SS Append +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBa +\fP +.fi +.RE +.sp +.LP +Enter text input mode after the current cursor position. No characters +already in the edit buffer shall be affected by this +command. A \fIcount\fP shall cause the input text to be appended \fIcount\fP +-1 more times to the end of the input. +.LP +\fICurrent line/column\fP: As specified for the text input commands +(see Input Mode Commands in +vi ). +.SS Append at End-of-Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBA +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIvi\fP command: +.sp +.RS +.nf + +\fB$\fP \fB[\fP \fIcount\fP \fB]\fP \fBa +\fP +.fi +.RE +.LP +(see Append ). +.SS Move Backward to Preceding Word +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBb +\fP +.fi +.RE +.sp +.LP +With the exception that words are used as the delimiter instead of +bigwords, this command shall be equivalent to the \fBB\fP +command. +.SS Move Backward to Preceding Bigword +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBB +\fP +.fi +.RE +.sp +.LP +If the edit buffer is empty or the cursor is on the first character +of the edit buffer, it shall be an error. If less than +\fIcount\fP bigwords begin between the cursor and the start of the +edit buffer, \fIcount\fP shall be adjusted to the number of +bigword beginnings between the cursor and the start of the edit buffer. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall be from the first character of the \fIcount\fPth +previous bigword beginning up to but not including the +cursor character. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the line containing the \fIcurrent column\fP. +.LP +\fICurrent column\fP: Set to the last column upon which any part of +the first character of the \fIcount\fPth previous bigword +is displayed. +.SS Change +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBc\fP \fImotion\fP +.fi +.RE +.sp +.LP +If the motion command is the \fBc\fP command repeated: +.IP " 1." 4 +The buffer text shall be in line mode. +.LP +.IP " 2." 4 +If there are less than \fIcount\fP -1 lines after the current line +in the edit buffer, it shall be an error. +.LP +.IP " 3." 4 +The text region shall be from the current line up to and including +the next \fIcount\fP -1 lines. +.LP +.LP +Otherwise, the buffer text mode and text region shall be as specified +by the motion command. +.LP +The replaced text shall be copied into \fIbuffer\fP, if specified, +and into the unnamed buffer. If the text to be replaced +contains characters from more than a single line, or the buffer text +is in line mode, the replaced text shall be copied into the +numeric buffers as well. +.LP +If the buffer text is in line mode: +.IP " 1." 4 +Any lines that contain characters in the region shall be deleted, +and the editor shall enter text input mode at the beginning of +a new line which shall replace the first line deleted. +.LP +.IP " 2." 4 +If the \fBautoindent\fP edit option is set, \fBautoindent\fP characters +equal to the \fBautoindent\fP characters on the first +line deleted shall be inserted as if entered by the user. +.LP +.LP +Otherwise, if characters from more than one line are in the region +of text: +.IP " 1." 4 +The text shall be deleted. +.LP +.IP " 2." 4 +Any text remaining in the last line in the text region shall be appended +to the first line in the region, and the last line in +the region shall be deleted. +.LP +.IP " 3." 4 +The editor shall enter text input mode after the last character not +deleted from the first line in the text region, if any; +otherwise, on the first column of the first line in the region. +.LP +.LP +Otherwise: +.IP " 1." 4 +If the glyph for \fB'$'\fP is smaller than the region, the end of +the region shall be marked with a \fB'$'\fP . +.LP +.IP " 2." 4 +The editor shall enter text input mode, overwriting the region of +text. +.LP +.LP +\fICurrent line/column\fP: As specified for the text input commands +(see Input Mode Commands in +vi ). +.SS Change to End-of-Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBC +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIvi\fP command: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBc$ +\fP +.fi +.RE +.LP +See the \fBc\fP command. +.SS Delete +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBd\fP \fImotion\fP +.fi +.RE +.sp +.LP +If the motion command is the \fBd\fP command repeated: +.IP " 1." 4 +The buffer text shall be in line mode. +.LP +.IP " 2." 4 +If there are less than \fIcount\fP -1 lines after the current line +in the edit buffer, it shall be an error. +.LP +.IP " 3." 4 +The text region shall be from the current line up to and including +the next \fIcount\fP -1 lines. +.LP +.LP +Otherwise, the buffer text mode and text region shall be as specified +by the motion command. +.LP +If in open mode, and the current line is deleted, and the line remains +on the display, an \fB'@'\fP character shall be +displayed as the first glyph of that line. +.LP +Delete the region of text into \fIbuffer\fP, if specified, and into +the unnamed buffer. If the text to be deleted contains +characters from more than a single line, or the buffer text is in +line mode, the deleted text shall be copied into the numeric +buffers, as well. +.LP +\fICurrent line\fP: Set to the first text region line that appears +in the edit buffer, unless that line has been deleted, in +which case it shall be set to the last line in the edit buffer, or +line 1 if the edit buffer is empty. +.LP +\fICurrent column\fP: +.IP " 1." 4 +If the line is empty, set to column position 1. +.LP +.IP " 2." 4 +Otherwise, if the buffer text is in line mode or the motion was from +the cursor toward the end of the edit buffer: +.RS +.IP " a." 4 +If a character from the current line is displayed in the current column, +set to the last column that displays any portion of +that character. +.LP +.IP " b." 4 +Otherwise, set to the last column in which any portion of any character +in the line is displayed. +.LP +.RE +.LP +.IP " 3." 4 +Otherwise, if a character is displayed in the column that began the +text region, set to the last column that displays any +portion of that character. +.LP +.IP " 4." 4 +Otherwise, set to the last column in which any portion of any character +in the line is displayed. +.LP +.SS Delete to End-of-Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB]\fP \fBD +\fP +.fi +.RE +.sp +.LP +Delete the text from the current position to the end of the current +line; equivalent to the \fIvi\fP command: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB]\fP \fBd$ +\fP +.fi +.RE +.SS Move to End-of-Word +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBe +\fP +.fi +.RE +.sp +.LP +With the exception that words are used instead of bigwords as the +delimiter, this command shall be equivalent to the \fBE\fP +command. +.SS Move to End-of-Bigword +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBE +\fP +.fi +.RE +.sp +.LP +If the edit buffer is empty it shall be an error. If less than \fIcount\fP +bigwords end between the cursor and the end of the +edit buffer, \fIcount\fP shall be adjusted to the number of bigword +endings between the cursor and the end of the edit buffer. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall be from the last character of the \fIcount\fPth +next bigword up to and including the cursor +character. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to the line containing the current column. +.LP +\fICurrent column\fP: Set to the last column upon which any part of +the last character of the \fIcount\fPth next bigword is +displayed. +.SS Find Character in Current Line (Forward) +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBf\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +It shall be an error if \fIcount\fP occurrences of the character do +not occur after the cursor in the line. +.LP +If used as a motion command: +.IP " 1." 4 +The text range shall be from the cursor character up to and including +the \fIcount\fPth occurrence of the specified character +after the cursor. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the \fIcount\fPth occurrence of the specified character +after the cursor appears in the line. +.SS Find Character in Current Line (Reverse) +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBF\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +It shall be an error if \fIcount\fP occurrences of the character do +not occur before the cursor in the line. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall be from the \fIcount\fPth occurrence of the +specified character before the cursor, up to, but not +including the cursor character. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the \fIcount\fPth occurrence of the specified character +before the cursor appears in the line. +.SS Move to Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBG +\fP +.fi +.RE +.sp +.LP +If \fIcount\fP is not specified, it shall default to the last line +of the edit buffer. If \fIcount\fP is greater than the last +line of the edit buffer, it shall be an error. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall be from the cursor line up to and including +the specified line. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in line mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Set to \fIcount\fP if \fIcount\fP is specified; +otherwise, the last line. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Move to Top of Screen +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBH +\fP +.fi +.RE +.sp +.LP +If the beginning of the line \fIcount\fP greater than the first line +of which any portion appears on the display does not +exist, it shall be an error. +.LP +If used as a motion command: +.IP " 1." 4 +If in open mode, the text region shall be the current line. +.LP +.IP " 2." 4 +Otherwise, the text region shall be from the starting line up to and +including (the first line of the display + \fIcount\fP +-1). +.LP +.IP " 3." 4 +Any text copied to a buffer shall be in line mode. +.LP +.LP +If not used as a motion command: +.LP +If in open mode, this command shall set the current column to non- +<blank> and do nothing else. +.LP +Otherwise, it shall set the current line and current column as follows. +.LP +\fICurrent line\fP: Set to (the first line of the display + \fIcount\fP +-1). +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Insert Before Cursor +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBi +\fP +.fi +.RE +.sp +.LP +Enter text input mode before the current cursor position. No characters +already in the edit buffer shall be affected by this +command. A \fIcount\fP shall cause the input text to be appended \fIcount\fP +-1 more times to the end of the input. +.LP +\fICurrent line/column\fP: As specified for the text input commands +(see Input Mode Commands in +vi ). +.SS Insert at Beginning of Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBI +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIvi\fP command ^[ \fIcount\fP] +\fBi\fP. +.SS Join +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBJ +\fP +.fi +.RE +.sp +.LP +If the current line is the last line in the edit buffer, it shall +be an error. +.LP +This command shall be equivalent to the \fIex\fP \fBjoin\fP command +with no addresses, and +an \fIex\fP command \fIcount\fP value of 1 if \fIcount\fP was not +specified or if a +\fIcount\fP of 1 was specified, and an \fIex\fP command \fIcount\fP +value of \fIcount\fP -1 +for any other value of \fIcount\fP, except that the current line and +column shall be set as follows. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: The last column in which any portion of the +character following the last character in the initial line is +displayed, or the last non- <newline> in the line if no characters +were appended. +.SS Move to Bottom of Screen +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBL +\fP +.fi +.RE +.sp +.LP +If the beginning of the line \fIcount\fP less than the last line of +which any portion appears on the display does not exist, it +shall be an error. +.LP +If used as a motion command: +.IP " 1." 4 +If in open mode, the text region shall be the current line. +.LP +.IP " 2." 4 +Otherwise, the text region shall include all lines from the starting +cursor line to (the last line of the display -( +\fIcount\fP -1)). +.LP +.IP " 3." 4 +Any text copied to a buffer shall be in line mode. +.LP +.LP +If not used as a motion command: +.IP " 1." 4 +If in open mode, this command shall set the current column to non- +<blank> and do nothing else. +.LP +.IP " 2." 4 +Otherwise, it shall set the current line and current column as follows. +.LP +.LP +\fICurrent line\fP: Set to (the last line of the display -( \fIcount\fP +-1)). +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Mark Position +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBm\fP \fIletter\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIex\fP \fBmark\fP command +with the specified +character as an argument. +.SS Move to Middle of Screen +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBM +\fP +.fi +.RE +.sp +.LP +The middle line of the display shall be calculated as follows: +.sp +.RS +.nf + +\fB(the top line of the display) + (((number of lines displayed) +1) /2) -1 +\fP +.fi +.RE +.LP +If used as a motion command: +.IP " 1." 4 +If in open mode, the text region shall be the current line. +.LP +.IP " 2." 4 +Otherwise, the text region shall include all lines from the starting +cursor line up to and including the middle line of the +display. +.LP +.IP " 3." 4 +Any text copied to a buffer shall be in line mode. +.LP +.LP +If not used as a motion command: +.LP +If in open mode, this command shall set the current column to non- +<blank> and do nothing else. +.LP +Otherwise, it shall set the current line and current column as follows. +.LP +\fICurrent line\fP: Set to the middle line of the display. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Repeat Regular Expression Find (Forward) +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBn +\fP +.fi +.RE +.sp +.LP +If the remembered search direction was forward, the \fBn\fP command +shall be equivalent to the \fIvi\fP \fB/\fP command with +no characters entered by the user. Otherwise, it shall be equivalent +to the \fIvi\fP \fB?\fP command with no characters entered +by the user. +.LP +If the \fBn\fP command is used as a motion command for the \fB!\fP +command, the editor shall not enter text input mode on the +last line on the screen, and shall behave as if the user entered a +single \fB'!'\fP character as the text input. +.SS Repeat Regular Expression Find (Reverse) +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBN +\fP +.fi +.RE +.sp +.LP +Scan for the next match of the last pattern given to \fB/\fP or \fB?\fP, +but in the reverse direction; this is the reverse of +\fBn\fP. +.LP +If the remembered search direction was forward, the \fBN\fP command +shall be equivalent to the \fIvi\fP \fB?\fP command with +no characters entered by the user. Otherwise, it shall be equivalent +to the \fIvi\fP \fB/\fP command with no characters entered +by the user. If the \fBN\fP command is used as a motion command for +the \fB!\fP command, the editor shall not enter text input +mode on the last line on the screen, and shall behave as if the user +entered a single \fB!\fP character as the text input. +.SS Insert Empty Line Below +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBo +\fP +.fi +.RE +.sp +.LP +Enter text input mode in a new line appended after the current line. +A \fIcount\fP shall cause the input text to be appended +\fIcount\fP -1 more times to the end of the already added text, each +time starting on a new, appended line. +.LP +\fICurrent line/column\fP: As specified for the text input commands +(see Input Mode Commands in +vi ). +.SS Insert Empty Line Above +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBO +\fP +.fi +.RE +.sp +.LP +Enter text input mode in a new line inserted before the current line. +A \fIcount\fP shall cause the input text to be appended +\fIcount\fP -1 more times to the end of the already added text, each +time starting on a new, appended line. +.LP +\fICurrent line/column\fP: As specified for the text input commands +(see Input Mode Commands in +vi ). +.SS Put from Buffer Following +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB]\fP \fBp +\fP +.fi +.RE +.sp +.LP +If no \fIbuffer\fP is specified, the unnamed buffer shall be used. +.LP +If the buffer text is in line mode, the text shall be appended below +the current line, and each line of the buffer shall become +a new line in the edit buffer. A \fIcount\fP shall cause the buffer +text to be appended \fIcount\fP -1 more times to the end of +the already added text, each time starting on a new, appended line. +.LP +If the buffer text is in character mode, the text shall be appended +into the current line after the cursor, and each line of the +buffer other than the first and last shall become a new line in the +edit buffer. A \fIcount\fP shall cause the buffer text to be +appended \fIcount\fP -1 more times to the end of the already added +text, each time starting after the last added character. +.LP +\fICurrent line\fP: If the buffer text is in line mode, set the line +to line +1; otherwise, unchanged. +.LP +\fICurrent column\fP: If the buffer text is in line mode: +.IP " 1." 4 +If there is a non- <blank> in the first line of the buffer, set to +the last column on which any portion of the first non- +<blank> in the line is displayed. +.LP +.IP " 2." 4 +If there is no non- <blank> in the first line of the buffer, set to +the last column on which any portion of the last non- +<newline> in the first line of the buffer is displayed. +.LP +.LP +If the buffer text is in character mode: +.IP " 1." 4 +If the text in the buffer is from more than a single line, then set +to the last column on which any portion of the first +character from the buffer is displayed. +.LP +.IP " 2." 4 +Otherwise, if the buffer is the unnamed buffer, set to the last column +on which any portion of the last character from the +buffer is displayed. +.LP +.IP " 3." 4 +Otherwise, set to the first column on which any portion of the first +character from the buffer is displayed. +.LP +.SS Put from Buffer Before +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB]\fP \fBP +\fP +.fi +.RE +.sp +.LP +If no \fIbuffer\fP is specified, the unnamed buffer shall be used. +.LP +If the buffer text is in line mode, the text shall be inserted above +the current line, and each line of the buffer shall become +a new line in the edit buffer. A \fIcount\fP shall cause the buffer +text to be appended \fIcount\fP -1 more times to the end of +the already added text, each time starting on a new, appended line. +.LP +If the buffer text is in character mode, the text shall be inserted +into the current line before the cursor, and each line of +the buffer other than the first and last shall become a new line in +the edit buffer. A \fIcount\fP shall cause the buffer text to +be appended \fIcount\fP -1 more times to the end of the already added +text, each time starting after the last added character. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: If the buffer text is in line mode: +.IP " 1." 4 +If there is a non- <blank> in the first line of the buffer, set to +the last column on which any portion of that character +is displayed. +.LP +.IP " 2." 4 +If there is no non- <blank> in the first line of the buffer, set to +the last column on which any portion of the last non- +<newline> in the first line of the buffer is displayed. +.LP +.LP +If the buffer text is in character mode: +.IP " 1." 4 +If the buffer is the unnamed buffer, set to the last column on which +any portion of the last character from the buffer is +displayed. +.LP +.IP " 2." 4 +Otherwise, set to the first column on which any portion of the first +character from the buffer is displayed. +.LP +.SS Enter ex Mode +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBQ +\fP +.fi +.RE +.sp +.LP +Leave visual or open mode and enter \fIex\fP command mode. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS Replace Character +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBr\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +Replace the \fIcount\fP characters at and after the cursor with the +specified character. If there are less than \fIcount\fP +non- <newline>s at and after the cursor on the line, it shall be an +error. +.LP +If character is <control>-V, any next character other than the <newline> +shall be stripped of any special meaning +and used as a literal character. +.LP +If character is <ESC>, no replacement shall be made and the current +line and current column shall be unchanged. +.LP +If character is <carriage-return> or <newline>, \fIcount\fP new lines +shall be appended to the current line. All +but the last of these lines shall be empty. \fIcount\fP characters +at and after the cursor shall be discarded, and any remaining +characters after the cursor in the current line shall be moved to +the last of the new lines. If the \fBautoindent\fP edit option +is set, they shall be preceded by the same number of \fBautoindent\fP +characters found on the line from which the command was +executed. +.LP +\fICurrent line\fP: Unchanged unless the replacement character is +a <carriage-return> or <newline>, in which case +it shall be set to line + \fIcount\fP. +.LP +\fICurrent column\fP: Set to the last column position on which a portion +of the last replaced character is displayed, or if the +replacement character caused new lines to be created, set to non- +<blank>. +.SS Replace Characters +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBR +\fP +.fi +.RE +.sp +.LP +Enter text input mode at the current cursor position possibly replacing +text on the current line. A \fIcount\fP shall cause the +input text to be appended \fIcount\fP -1 more times to the end of +the input. +.LP +\fICurrent line/column\fP: As specified for the text input commands +(see Input Mode Commands in +vi ). +.SS Substitute Character +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBs +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIvi\fP command: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBc<space> +\fP +.fi +.RE +.SS Substitute Lines +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBS +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIvi\fP command: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBc_ +\fP +.fi +.RE +.SS Move Cursor to Before Character (Forward) +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBt\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +It shall be an error if \fIcount\fP occurrences of the character do +not occur after the cursor in the line. +.LP +If used as a motion command: +.IP " 1." 4 +The text region shall be from the cursor up to but not including the +\fIcount\fPth occurrence of the specified character after +the cursor. +.LP +.IP " 2." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the character before the \fIcount\fPth occurrence of the +specified character after the cursor appears in the line. +.SS Move Cursor to After Character (Reverse) +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBT\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +It shall be an error if \fIcount\fP occurrences of the character do +not occur before the cursor in the line. +.LP +If used as a motion command: +.IP " 1." 4 +If the character before the cursor is the specified character, it +shall be an error. +.LP +.IP " 2." 4 +The text region shall be from the character before the cursor up to +but not including the \fIcount\fPth occurrence of the +specified character before the cursor. +.LP +.IP " 3." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to the last column in which any portion +of the character after the \fIcount\fPth occurrence of the +specified character before the cursor appears in the line. +.SS Undo +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBu +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIex\fP \fBundo\fP command +except that the current +line and current column shall be set as follows: +.LP +\fICurrent line\fP: Set to the first line added or changed if any; +otherwise, move to the line preceding any deleted text if +one exists; otherwise, move to line 1. +.LP +\fICurrent column\fP: If undoing an \fIex\fP command, set to the first +non- +<blank>. +.LP +Otherwise, if undoing a text input command: +.IP " 1." 4 +If the command was a \fBC\fP, \fBc\fP, \fBO\fP, \fBo\fP, \fBR\fP, +\fBS\fP, or \fBs\fP command, the current column shall +be set to the value it held when the text input command was entered. +.LP +.IP " 2." 4 +Otherwise, set to the last column in which any portion of the first +character after the deleted text is displayed, or, if no +non- <newline>s follow the text deleted from this line, set to the +last column in which any portion of the last non- +<newline> in the line is displayed, or 1 if the line is empty. +.LP +.LP +Otherwise, if a single line was modified (that is, not added or deleted) +by the \fBu\fP command: +.IP " 1." 4 +If text was added or changed, set to the last column in which any +portion of the first character added or changed is +displayed. +.LP +.IP " 2." 4 +If text was deleted, set to the last column in which any portion of +the first character after the deleted text is displayed, or, +if no non- <newline>s follow the deleted text, set to the last column +in which any portion of the last non- <newline> +in the line is displayed, or 1 if the line is empty. +.LP +.LP +Otherwise, set to non- <blank>. +.SS Undo Current Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBU +\fP +.fi +.RE +.sp +.LP +Restore the current line to its state immediately before the most +recent time that it became the current line. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to the first column in the line in which +any portion of the first character in the line is +displayed. +.SS Move to Beginning of Word +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBw +\fP +.fi +.RE +.sp +.LP +With the exception that words are used as the delimiter instead of +bigwords, this command shall be equivalent to the \fBW\fP +command. +.SS Move to Beginning of Bigword +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBW +\fP +.fi +.RE +.sp +.LP +If the edit buffer is empty, it shall be an error. If there are less +than \fIcount\fP bigwords between the cursor and the end +of the edit buffer, \fIcount\fP shall be adjusted to move the cursor +to the last bigword in the edit buffer. +.LP +If used as a motion command: +.IP " 1." 4 +If the associated command is \fBc\fP, \fIcount\fP is 1, and the cursor +is on a <blank>, the region of text shall be the +current character and no further action shall be taken. +.LP +.IP " 2." 4 +If there are less than \fIcount\fP bigwords between the cursor and +the end of the edit buffer, then the command shall succeed, +and the region of text shall include the last character of the edit +buffer. +.LP +.IP " 3." 4 +If there are <blank>s or an end-of-line that precede the \fIcount\fPth +bigword, and the associated command is \fBc\fP, +the region of text shall be up to and including the last character +before the preceding <blank>s or end-of-line. +.LP +.IP " 4." 4 +If there are <blank>s or an end-of-line that precede the bigword, +and the associated command is \fBd\fP or \fBy\fP, the +region of text shall be up to and including the last <blank> before +the start of the bigword or end-of-line. +.LP +.IP " 5." 4 +Any text copied to a buffer shall be in character mode. +.LP +.LP +If not used as a motion command: +.IP " 1." 4 +If the cursor is on the last character of the edit buffer, it shall +be an error. +.LP +.LP +\fICurrent line\fP: Set to the line containing the current column. +.LP +\fICurrent column\fP: Set to the last column in which any part of +the first character of the \fIcount\fPth next bigword is +displayed. +.SS Delete Character at Cursor +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBx +\fP +.fi +.RE +.sp +.LP +Delete the \fIcount\fP characters at and after the current character +into \fIbuffer\fP, if specified, and into the unnamed +buffer. +.LP +If the line is empty, it shall be an error. If there are less than +\fIcount\fP non- <newline>s at and after the cursor on +the current line, \fIcount\fP shall be adjusted to the number of non- +<newline>s at and after the cursor. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: If the line is empty, set to column position +1. Otherwise, if there were \fIcount\fP or less non- +<newline>s at and after the cursor on the current line, set to the +last column that displays any part of the last non- +<newline> of the line. Otherwise, unchanged. +.SS Delete Character Before Cursor +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBX +\fP +.fi +.RE +.sp +.LP +Delete the \fIcount\fP characters before the current character into +\fIbuffer\fP, if specified, and into the unnamed +buffer. +.LP +If there are no characters before the current character on the current +line, it shall be an error. If there are less than +\fIcount\fP previous characters on the current line, \fIcount\fP shall +be adjusted to the number of previous characters on the +line. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to (current column - the width of the deleted +characters). +.SS Yank +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBy\fP \fImotion\fP +.fi +.RE +.sp +.LP +Copy (yank) the region of text into \fIbuffer\fP, if specified, and +into the unnamed buffer. +.LP +If the motion command is the \fBy\fP command repeated: +.IP " 1." 4 +The buffer shall be in line mode. +.LP +.IP " 2." 4 +If there are less than \fIcount\fP -1 lines after the current line +in the edit buffer, it shall be an error. +.LP +.IP " 3." 4 +The text region shall be from the current line up to and including +the next \fIcount\fP -1 lines. +.LP +.LP +Otherwise, the buffer text mode and text region shall be as specified +by the motion command. +.LP +\fICurrent line\fP: If the motion was from the current cursor position +toward the end of the edit buffer, unchanged. Otherwise, +set to the first line in the edit buffer that is part of the text +region specified by the motion command. +.LP +\fICurrent column\fP: +.IP " 1." 4 +If the motion was from the current cursor position toward the end +of the edit buffer, unchanged. +.LP +.IP " 2." 4 +Otherwise, if the current line is empty, set to column position 1. +.LP +.IP " 3." 4 +Otherwise, set to the last column that displays any part of the first +character in the file that is part of the text region +specified by the motion command. +.LP +.SS Yank Current Line +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBY +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIvi\fP command: +.sp +.RS +.nf + +\fB[\fP\fIbuffer\fP\fB][\fP\fIcount\fP\fB]\fP \fBy_ +\fP +.fi +.RE +.SS Redraw Window +.LP +If in open mode, the \fBz\fP command shall have the Synopsis: +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIcount\fP\fB]\fP \fBz +\fP +.fi +.RE +.sp +.LP +If \fIcount\fP is not specified, it shall default to the \fBwindow\fP +edit option -1. The \fBz\fP command shall be equivalent +to the \fIex\fP \fBz\fP command, with a type character of \fB=\fP +and a \fIcount\fP of +\fIcount\fP -2, except that the current line and current column shall +be set as follows, and the \fBwindow\fP edit option shall +not be affected. If the calculation for the \fIcount\fP argument would +result in a negative number, the \fIcount\fP argument to +the \fIex\fP \fBz\fP command shall be zero. A blank line shall be +written after the last line +is written. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.LP +If not in open mode, the \fBz\fP command shall have the following +Synopsis: +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB[\fP\fIline\fP\fB]\fP \fBz\fP \fB[\fP\fIcount\fP\fB]\fP \fIcharacter\fP +.fi +.RE +.sp +.LP +If \fIline\fP is not specified, it shall default to the current line. +If \fIline\fP is specified, but is greater than the +number of lines in the edit buffer, it shall default to the number +of lines in the edit buffer. +.LP +If \fIcount\fP is specified, the value of the \fBwindow\fP edit option +shall be set to \fIcount\fP (as described in the \fIex\fP \fBwindow\fP +command), and the screen shall be redrawn. +.LP +\fIline\fP shall be placed as specified by the following characters: +.TP 7 +<newline>,\ <carriage-return> +.sp +Place the beginning of the line on the first line of the display. +.TP 7 +\fB\&.\fP +Place the beginning of the line in the center of the display. The +middle line of the display shall be calculated as described +for the \fBM\fP command. +.TP 7 +\fB-\fP +Place an unspecified portion of the line on the last line of the display. +.TP 7 +\fB+\fP +If \fIline\fP was specified, equivalent to the <newline> case. If +\fIline\fP was not specified, display a screen where +the first line of the display shall be (current last line) +1. If +there are no lines after the last line in the display, it shall +be an error. +.TP 7 +\fB^\fP +If \fIline\fP was specified, display a screen where the last line +of the display shall contain an unspecified portion of the +first line of a display that had an unspecified portion of the specified +line on the last line of the display. If this calculation +results in a line before the beginning of the edit buffer, display +the first screen of the edit buffer. +.LP +Otherwise, display a screen where the last line of the display shall +contain an unspecified portion of (current first line -1). +If this calculation results in a line before the beginning of the +edit buffer, it shall be an error. +.sp +.LP +\fICurrent line\fP: If \fIline\fP and the \fB'^'\fP character were +specified: +.IP " 1." 4 +If the first screen was displayed as a result of the command attempting +to display lines before the beginning of the edit +buffer: if the first screen was already displayed, unchanged; otherwise, +set to (current first line -1). +.LP +.IP " 2." 4 +Otherwise, set to the last line of the display. +.LP +.LP +If \fIline\fP and the \fB'+'\fP character were specified, set to the +first line of the display. +.LP +Otherwise, if \fIline\fP was specified, set to \fIline\fP. +.LP +Otherwise, unchanged. +.LP +\fICurrent column\fP: Set to non- <blank>. +.SS Exit +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBZZ +\fP +.fi +.RE +.sp +.LP +This command shall be equivalent to the \fIex\fP \fBxit\fP command +with no addresses, +trailing \fB!\fP, or filename (see the \fIex\fP \fBxit\fP command). +.SS Input Mode Commands in vi +.LP +In text input mode, the current line shall consist of zero or more +of the following categories, plus the terminating +<newline>: +.IP " 1." 4 +Characters preceding the text input entry point +.LP +Characters in this category shall not be modified during text input +mode. +.LP +.IP " 2." 4 +\fBautoindent\fP characters +.LP +\fBautoindent\fP characters shall be automatically inserted into each +line that is created in text input mode, either as a +result of entering a <newline> or <carriage-return> while in text +input mode, or as an effect of the command itself; +for example, \fBO\fP or \fBo\fP (see the \fIex\fP \fBautoindent\fP +command), as if entered +by the user. +.LP +It shall be possible to erase \fBautoindent\fP characters with the +<control>-D command; it is unspecified whether they +can be erased by <control>-H, <control>-U, and <control>-W characters. +Erasing any \fBautoindent\fP character +turns the glyph into erase-columns and deletes the character from +the edit buffer, but does not change its representation on the +screen. +.LP +.IP " 3." 4 +Text input characters +.LP +Text input characters are the characters entered by the user. Erasing +any text input character turns the glyph into +erase-columns and deletes the character from the edit buffer, but +does not change its representation on the screen. +.LP +Each text input character entered by the user (that does not have +a special meaning) shall be treated as follows: +.RS +.IP " a." 4 +The text input character shall be appended to the last character in +the edit buffer from the first, second, or third +categories. +.LP +.IP " b." 4 +If there are no erase-columns on the screen, the text input command +was the \fBR\fP command, and characters in the fifth +category from the original line follow the cursor, the next such character +shall be deleted from the edit buffer. If the +\fBslowopen\fP edit option is not set, the corresponding glyph on +the screen shall become erase-columns. +.LP +.IP " c." 4 +If there are erase-columns on the screen, as many columns as they +occupy, or as are necessary, shall be overwritten to display +the text input character. (If only part of a multi-column glyph is +overwritten, the remainder shall be left on the screen, and +continue to be treated as erase-columns; it is unspecified whether +the remainder of the glyph is modified in any way.) +.LP +.IP " d." 4 +If additional display line columns are needed to display the text +input character: +.RS +.IP " 1." 4 +If the \fBslowopen\fP edit option is set, the text input characters +shall be displayed on subsequent display line columns, +overwriting any characters displayed in those columns. +.LP +.IP " 2." 4 +Otherwise, any characters currently displayed on or after the column +on the display line where the text input character is to be +displayed shall be pushed ahead the number of display line columns +necessary to display the rest of the text input character. +.LP +.RE +.LP +.RE +.LP +.IP " 4." 4 +Erase-columns +.LP +Erase-columns are not logically part of the edit buffer, appearing +only on the screen, and may be overwritten on the screen by +subsequent text input characters. When text input mode ends, all erase-columns +shall no longer appear on the screen. +.LP +Erase-columns are initially the region of text specified by the \fBc\fP +command (see Change ); +however, erasing \fBautoindent\fP or text input characters causes +the glyphs of the erased characters to be treated as +erase-columns. +.LP +.IP " 5." 4 +Characters following the text region for the \fBc\fP command, or the +text input entry point for all other commands +.LP +Characters in this category shall not be modified during text input +mode, except as specified in category 3.b. for the \fBR\fP +text input command, or as <blank>s deleted when a <newline> or <carriage-return> +is entered. +.LP +.LP +It is unspecified whether it is an error to attempt to erase past +the beginning of a line that was created by the entry of a +<newline> or <carriage-return> during text input mode. If it is not +an error, the editor shall behave as if the erasing +character was entered immediately after the last text input character +entered on the previous line, and all of the non- +<newline>s on the current line shall be treated as erase-columns. +.LP +When text input mode is entered, or after a text input mode character +is entered (except as specified for the special characters +below), the cursor shall be positioned as follows: +.IP " 1." 4 +On the first column that displays any part of the first erase-column, +if one exists +.LP +.IP " 2." 4 +Otherwise, if the \fBslowopen\fP edit option is set, on the first +display line column after the last character in the first, +second, or third categories, if one exists +.LP +.IP " 3." 4 +Otherwise, the first column that displays any part of the first character +in the fifth category, if one exists +.LP +.IP " 4." 4 +Otherwise, the display line column after the last character in the +first, second, or third categories, if one exists +.LP +.IP " 5." 4 +Otherwise, on column position 1 +.LP +.LP +The characters that are updated on the screen during text input mode +are unspecified, other than that the last text input +character shall always be updated, and, if the \fBslowopen\fP edit +option is not set, the current cursor character shall always be +updated. +.LP +The following specifications are for command characters entered during +text input mode. +.SS NUL +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fBNUL +\fP +.fi +.RE +.sp +.LP +If the first character of the text input is a NUL, the most recently +input text shall be input as if entered by the user, and +then text input mode shall be exited. The text shall be input literally; +that is, characters are neither macro or abbreviation +expanded, nor are any characters interpreted in any special manner. +It is unspecified whether implementations shall support more +than 256 bytes of remembered input text. +.SS <control>-D +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-D +\fP +.fi +.RE +.sp +.LP +The <control>-D character shall have no special meaning when in text +input mode for a line-oriented command (see Command Descriptions in +vi ). +.LP +This command need not be supported on block-mode terminals. +.LP +If the cursor does not follow an \fBautoindent\fP character, or an +\fBautoindent\fP character and a \fB'0'\fP or +\fB'^'\fP character: +.IP " 1." 4 +If the cursor is in column position 1, the <control>-D character shall +be discarded and no further action taken. +.LP +.IP " 2." 4 +Otherwise, the <control>-D character shall have no special meaning. +.LP +.LP +If the last input character was a \fB'0'\fP , the cursor shall be +moved to column position 1. +.LP +Otherwise, if the last input character was a \fB'^'\fP , the cursor +shall be moved to column position 1. In addition, the +\fBautoindent\fP level for the next input line shall be derived from +the same line from which the \fBautoindent\fP level for the +current input line was derived. +.LP +Otherwise, the cursor shall be moved back to the column after the +previous shiftwidth (see the \fIex\fP \fBshiftwidth\fP command) boundary. +.LP +All of the glyphs on columns between the starting cursor position +and (inclusively) the ending cursor position shall become +erase-columns as described in Input Mode Commands in vi . +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to 1 if the <control>-D was preceded by +a \fB'^'\fP or \fB'0'\fP ; otherwise, set to +(column -1) -((column -2) % \fBshiftwidth\fP). +.SS <control>-H +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-H +\fP +.fi +.RE +.sp +.LP +If in text input mode for a line-oriented command, and there are no +characters to erase, text input mode shall be terminated, no +further action shall be done for this command, and the current line +and column shall be unchanged. +.LP +If there are characters other than \fBautoindent\fP characters that +have been input on the current line before the cursor, the +cursor shall move back one character. +.LP +Otherwise, if there are \fBautoindent\fP characters on the current +line before the cursor, it is implementation-defined whether +the <control>-H command is an error or if the cursor moves back one +\fBautoindent\fP character. +.LP +Otherwise, if the cursor is in column position 1 and there are previous +lines that have been input, it is implementation-defined +whether the <control>-H command is an error or if it is equivalent +to entering <control>-H after the last input +character on the previous input line. +.LP +Otherwise, it shall be an error. +.LP +All of the glyphs on columns between the starting cursor position +and (inclusively) the ending cursor position shall become +erase-columns as described in Input Mode Commands in vi . +.LP +The current erase character (see \fIstty\fP) shall cause an equivalent +action to the +<control>-H command, unless the previously inserted character was +a backslash, in which case it shall be as if the literal +current erase character had been inserted instead of the backslash. +.LP +\fICurrent line\fP: Unchanged, unless previously input lines are erased, +in which case it shall be set to line -1. +.LP +\fICurrent column\fP: Set to the first column that displays any portion +of the character backed up over. +.SS <newline> +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<newline> +.sp + +<carriage-return> +.sp + +<control>-J +.sp + +<control>-M +\fP +.fi +.RE +.sp +.LP +If input was part of a line-oriented command, text input mode shall +be terminated and the command shall continue execution with +the input provided. +.LP +Otherwise, terminate the current line. If there are no characters +other than \fBautoindent\fP characters on the line, all +characters on the line shall be discarded. Otherwise, it is unspecified +whether the \fBautoindent\fP characters in the line are +modified by entering these characters. +.LP +Continue text input mode on a new line appended after the current +line. If the \fBslowopen\fP edit option is set, the lines on +the screen below the current line shall not be pushed down, but the +first of them shall be cleared and shall appear to be +overwritten. Otherwise, the lines of the screen below the current +line shall be pushed down. +.LP +If the \fBautoindent\fP edit option is set, an appropriate number +of \fBautoindent\fP characters shall be added as a prefix to +the line as described by the \fIex\fP \fBautoindent\fP edit option. +.LP +All columns after the cursor that are erase-columns (as described +in Input Mode Commands in vi ) +shall be discarded. +.LP +If the \fBautoindent\fP edit option is set, all <blank>s immediately +following the cursor shall be discarded. +.LP +All remaining characters after the cursor shall be transferred to +the new line, positioned after any \fBautoindent\fP +characters. +.LP +\fICurrent line\fP: Set to current line +1. +.LP +\fICurrent column\fP: Set to the first column that displays any portion +of the first character after the \fBautoindent\fP +characters on the new line, if any, or the first column position after +the last \fBautoindent\fP character, if any, or column +position 1. +.SS <control>-T +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-T +\fP +.fi +.RE +.sp +.LP +The <control>-T character shall have no special meaning when in text +input mode for a line-oriented command (see Command Descriptions in +vi ). +.LP +This command need not be supported on block-mode terminals. +.LP +Behave as if the user entered the minimum number of <blank>s necessary +to move the cursor forward to the column position +after the next \fBshiftwidth\fP (see the \fIex\fP \fBshiftwidth\fP +command) boundary. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Set to \fIcolumn\fP + \fBshiftwidth\fP - ((column +-1) % \fBshiftwidth\fP). +.SS <control>-U +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-U +\fP +.fi +.RE +.sp +.LP +If there are characters other than \fBautoindent\fP characters that +have been input on the current line before the cursor, the +cursor shall move to the first character input after the \fBautoindent\fP +characters. +.LP +Otherwise, if there are \fBautoindent\fP characters on the current +line before the cursor, it is implementation-defined whether +the <control>-U command is an error or if the cursor moves to the +first column position on the line. +.LP +Otherwise, if the cursor is in column position 1 and there are previous +lines that have been input, it is implementation-defined +whether the <control>-U command is an error or if it is equivalent +to entering <control>-U after the last input +character on the previous input line. +.LP +Otherwise, it shall be an error. +.LP +All of the glyphs on columns between the starting cursor position +and (inclusively) the ending cursor position shall become +erase-columns as described in Input Mode Commands in vi . +.LP +The current \fIkill\fP character (see \fIstty\fP) shall cause an equivalent +action to the +<control>-U command, unless the previously inserted character was +a backslash, in which case it shall be as if the literal +current \fIkill\fP character had been inserted instead of the backslash. +.LP +\fICurrent line\fP: Unchanged, unless previously input lines are erased, +in which case it shall be set to line -1. +.LP +\fICurrent column\fP: Set to the first column that displays any portion +of the last character backed up over. +.SS <control>-V +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-V +.sp + +<control>-Q +\fP +.fi +.RE +.sp +.LP +Allow the entry of any subsequent character, other than <control>-J +or the <newline>, as a literal character, +removing any special meaning that it may have to the editor in text +input mode. If a <control>-V or <control>-Q is +entered before a <control>-J or <newline>, the <control>-V or <control>-Q +character shall be discarded, and +the <control>-J or <newline> shall behave as described in the <newline> +command character during input mode. +.LP +For purposes of the display only, the editor shall behave as if a +\fB'^'\fP character was entered, and the cursor shall be +positioned as if overwriting the \fB'^'\fP character. When a subsequent +character is entered, the editor shall behave as if that +character was entered instead of the original <control>-V or <control>-Q +character. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: Unchanged. +.SS <control>-W +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<control>-W +\fP +.fi +.RE +.sp +.LP +If there are characters other than \fBautoindent\fP characters that +have been input on the current line before the cursor, the +cursor shall move back over the last word preceding the cursor (including +any <blank>s between the end of the last word and +the current cursor); the cursor shall not move to before the first +character after the end of any \fBautoindent\fP characters. +.LP +Otherwise, if there are \fBautoindent\fP characters on the current +line before the cursor, it is implementation-defined whether +the <control>-W command is an error or if the cursor moves to the +first column position on the line. +.LP +Otherwise, if the cursor is in column position 1 and there are previous +lines that have been input, it is implementation-defined +whether the <control>-W command is an error or if it is equivalent +to entering <control>-W after the last input +character on the previous input line. +.LP +Otherwise, it shall be an error. +.LP +All of the glyphs on columns between the starting cursor position +and (inclusively) the ending cursor position shall become +erase-columns as described in Input Mode Commands in vi . +.LP +\fICurrent line\fP: Unchanged, unless previously input lines are erased, +in which case it shall be set to line -1. +.LP +\fICurrent column\fP: Set to the first column that displays any portion +of the last character backed up over. +.SS <ESC> +.TP 7 +\fISynopsis\fP: +.sp +.RS +.nf + +\fB<ESC> +\fP +.fi +.RE +.sp +.LP +If input was part of a line-oriented command: +.IP " 1." 4 +If \fIinterrupt\fP was entered, text input mode shall be terminated +and the editor shall return to command mode. The terminal +shall be alerted. +.LP +.IP " 2." 4 +If <ESC> was entered, text input mode shall be terminated and the +command shall continue execution with the input +provided. +.LP +.LP +Otherwise, terminate text input mode and return to command mode. +.LP +Any \fBautoindent\fP characters entered on newly created lines that +have no other non- <newline>s shall be deleted. +.LP +Any leading \fBautoindent\fP and <blank>s on newly created lines shall +be rewritten to be the minimum number of +<blank>s possible. +.LP +The screen shall be redisplayed as necessary to match the contents +of the edit buffer. +.LP +\fICurrent line\fP: Unchanged. +.LP +\fICurrent column\fP: +.IP " 1." 4 +If there are text input characters on the current line, the column +shall be set to the last column where any portion of the last +text input character is displayed. +.LP +.IP " 2." 4 +Otherwise, if a character is displayed in the current column, unchanged. +.LP +.IP " 3." 4 +Otherwise, set to column position 1. +.LP +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +When any error is encountered and the standard input is not a terminal +device file, \fIvi\fP shall not write the file or return +to command or text input mode, and shall terminate with a non-zero +exit status. +.LP +Otherwise, when an unrecoverable error is encountered it shall be +equivalent to a SIGHUP asynchronous event. +.LP +Otherwise, when an error is encountered, the editor shall behave as +specified in Command +Descriptions in vi . +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +See the RATIONALE for \fIex\fP for more information on \fIvi\fP. Major +portions of the \fIvi\fP utility +specification point to \fIex\fP to avoid inadvertent divergence. While +\fIex\fP and \fIvi\fP have historically been implemented as a single +utility, this is not required by +IEEE\ Std\ 1003.1-2001. +.LP +It is recognized that portions of \fIvi\fP would be difficult, if +not impossible, to implement satisfactorily on a block-mode +terminal, or a terminal without any form of cursor addressing, thus +it is not a mandatory requirement that such features should +work on all terminals. It is the intention, however, that a \fIvi\fP +implementation should provide the full set of capabilities on +all terminals capable of supporting them. +.LP +Historically, \fIvi\fP exited immediately if the standard input was +not a terminal. IEEE\ Std\ 1003.1-2001 permits, but +does not require, this behavior. An end-of-file condition is not equivalent +to an end-of-file character. A common end-of-file +character, <control>-D, is historically a \fIvi\fP command. +.LP +The text in the STDOUT section reflects the usage of the verb \fIdisplay\fP +in this section; some implementations of \fIvi\fP +use standard output to write to the terminal, but IEEE\ Std\ 1003.1-2001 +does not require that to be the case. +.LP +Historically, implementations reverted to open mode if the terminal +was incapable of supporting full visual mode. +IEEE\ Std\ 1003.1-2001 requires this behavior. Historically, the open +mode of \fIvi\fP behaved roughly equivalently to the +visual mode, with the exception that only a single line from the edit +buffer (one "buffer line") was kept current at any time. +This line was normally displayed on the next-to-last line of a terminal +with cursor addressing (and the last line performed its +normal visual functions for line-oriented commands and messages). +In addition, some few commands behaved differently in open mode +than in visual mode. IEEE\ Std\ 1003.1-2001 requires conformance to +historical practice. +.LP +Historically, \fIex\fP and \fIvi\fP implementations have expected +text to proceed in the +usual European/Latin order of left to right, top to bottom. There +is no requirement in IEEE\ Std\ 1003.1-2001 that this be +the case. The specification was deliberately written using words like +"before", "after", "first", and "last" in order to +permit implementations to support the natural text order of the language. +.LP +Historically, lines past the end of the edit buffer were marked with +single tilde ( \fB'~'\fP ) characters; that is, if +the one-based display was 20 lines in length, and the last line of +the file was on line one, then lines 2-20 would contain only a +single \fB'~'\fP character. +.LP +Historically, the \fIvi\fP editor attempted to display only complete +lines at the bottom of the screen (it did display partial +lines at the top of the screen). If a line was too long to fit in +its entirety at the bottom of the screen, the screen lines where +the line would have been displayed were displayed as single \fB'@'\fP +characters, instead of displaying part of the line. +IEEE\ Std\ 1003.1-2001 permits, but does not require, this behavior. +Implementations are encouraged to attempt always to +display a complete line at the bottom of the screen when doing scrolling +or screen positioning by buffer lines. +.LP +Historically, lines marked with \fB'@'\fP were also used to minimize +output to dumb terminals over slow lines; that is, +changes local to the cursor were updated, but changes to lines on +the screen that were not close to the cursor were simply marked +with an \fB'@'\fP sign instead of being updated to match the current +text. IEEE\ Std\ 1003.1-2001 permits, but does not +require this feature because it is used ever less frequently as terminals +become smarter and connections are faster. +.SS Initialization in ex and vi +.LP +Historically, \fIvi\fP always had a line in the edit buffer, even +if the edit buffer was "empty". For example: +.IP " 1." 4 +The \fIex\fP command \fB=\fP executed from visual mode wrote "1" when +the buffer was +empty. +.LP +.IP " 2." 4 +Writes from visual mode of an empty edit buffer wrote files of a single +character (a <newline>), while writes from \fIex\fP mode of an empty +edit buffer wrote empty files. +.LP +.IP " 3." 4 +Put and read commands into an empty edit buffer left an empty line +at the top of the edit buffer. +.LP +.LP +For consistency, IEEE\ Std\ 1003.1-2001 does not permit any of these +behaviors. +.LP +Historically, \fIvi\fP did not always return the terminal to its original +modes; for example, ICRNL was modified if it was not +originally set. IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.SS Command Descriptions in vi +.LP +Motion commands are among the most complicated aspects of \fIvi\fP +to describe. With some exceptions, the text region and +buffer type effect of a motion command on a \fIvi\fP command are described +on a case-by-case basis. The descriptions of text +regions in IEEE\ Std\ 1003.1-2001 are not intended to imply direction; +that is, an inclusive region from line \fIn\fP to +line \fIn\fP+5 is identical to a region from line \fIn\fP+5 to line +\fIn\fP. This is of more than academic interest-movements to +marks can be in either direction, and, if the \fBwrapscan\fP option +is set, so can movements to search points. Historically, lines +are always stored into buffers in text order; that is, from the start +of the edit buffer to the end. IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice. +.LP +Historically, command counts were applied to any associated motion, +and were multiplicative to any supplied motion count. For +example, \fB2cw\fP is the same as \fBc2w\fP, and \fB2c3w\fP is the +same as \fBc6w\fP. IEEE\ Std\ 1003.1-2001 requires +this behavior. Historically, \fIvi\fP commands that used bigwords, +words, paragraphs, and sentences as objects treated groups of +empty lines, or lines that contained only <blank>s, inconsistently. +Some commands treated them as a single entity, while +others treated each line separately. For example, the \fBw\fP, \fBW\fP, +and \fBB\fP commands treated groups of empty lines as +individual words; that is, the command would move the cursor to each +new empty line. The \fBe\fP and \fBE\fP commands treated +groups of empty lines as a single word; that is, the first use would +move past the group of lines. The \fBb\fP command would just +beep at the user, or if done from the start of the line as a motion +command, fail in unexpected ways. If the lines contained only +(or ended with) <blank>s, the \fBw\fP and \fBW\fP commands would just +beep at the user, the \fBE\fP and \fBe\fP commands +would treat the group as a single word, and the \fBB\fP and \fBb\fP +commands would treat the lines as individual words. For +consistency and simplicity of specification, IEEE\ Std\ 1003.1-2001 +requires that all \fIvi\fP commands treat groups of +empty or blank lines as a single entity, and that movement through +lines ending with <blank>s be consistent with other +movements. +.LP +Historically, \fIvi\fP documentation indicated that any number of +double quotes were skipped after punctuation marks at +sentence boundaries; however, implementations only skipped single +quotes. IEEE\ Std\ 1003.1-2001 requires both to be +skipped. +.LP +Historically, the first and last characters in the edit buffer were +word boundaries. This historical practice is required by +IEEE\ Std\ 1003.1-2001. +.LP +Historically, \fIvi\fP attempted to update the minimum number of columns +on the screen possible, which could lead to misleading +information being displayed. IEEE\ Std\ 1003.1-2001 makes no requirements +other than that the current character being +entered is displayed correctly, leaving all other decisions in this +area up to the implementation. +.LP +Historically, lines were arbitrarily folded between columns of any +characters that required multiple column positions on the +screen, with the exception of tabs, which terminated at the right-hand +margin. IEEE\ Std\ 1003.1-2001 permits the former +and requires the latter. Implementations that do not arbitrarily break +lines between columns of characters that occupy multiple +column positions should not permit the cursor to rest on a column +that does not contain any part of a character. +.LP +The historical \fIvi\fP had a problem in that all movements were by +buffer lines, not by display or screen lines. This is often +the right thing to do; for example, single line movements, such as +\fBj\fP or \fBk\fP, should work on buffer lines. Commands like +\fBdj\fP, or \fBj.\fP, where \fB.\fP is a change command, only make +sense for buffer lines. It is not, however, the right thing +to do for screen motion or scrolling commands like <control>-D, <control>-F, +and \fBH\fP. If the window is fairly +small, using buffer lines in these cases can result in completely +random motion; for example, \fB1\fP <control>-D can result +in a completely changed screen, without any overlap. This is clearly +not what the user wanted. The problem is even worse in the +case of the \fBH\fP, \fBL\fP, and \fBM\fP commands-as they position +the cursor at the first non- <blank> of the line, they +may all refer to the same location in large lines, and will result +in no movement at all. +.LP +In addition, if the line is larger than the screen, using buffer lines +can make it impossible to display parts of the line-there +are not any commands that do not display the beginning of the line +in historical \fIvi\fP, and if both the beginning and end of +the line cannot be on the screen at the same time, the user suffers. +Finally, the page and half-page scrolling commands +historically moved to the first non- <blank> in the new line. If the +line is approximately the same size as the screen, this +is inadequate because the cursor before and after a <control>-D command +will refer to the same location on the screen. +.LP +Implementations of \fIex\fP and \fIvi\fP exist that do not have these +problems because the +relevant commands ( <control>-B, <control>-D, <control>-F, <control>-U, +<control>-Y, +<control>-E, \fBH\fP, \fBL\fP, and \fBM)\fP operate on display (screen) +lines, not (edit) buffer lines. +.LP +IEEE\ Std\ 1003.1-2001 does not permit this behavior by default because +the standard developers believed that users +would find it too confusing. However, historical practice has been +relaxed. For example, \fIex\fP and \fIvi\fP historically attempted, +albeit sometimes unsuccessfully, to never put part of a +line on the last lines of a screen; for example, if a line would not +fit in its entirety, no part of the line was displayed, and +the screen lines corresponding to the line contained single \fB'@'\fP +characters. This behavior is permitted, but not required +by IEEE\ Std\ 1003.1-2001, so that it is possible for implementations +to support long lines in small screens more +reasonably without changing the commands to be oriented to the display +(instead of oriented to the buffer). +IEEE\ Std\ 1003.1-2001 also permits implementations to refuse to edit +any edit buffer containing a line that will not fit +on the screen in its entirety. +.LP +The display area (for example, the value of the \fBwindow\fP edit +option) has historically been "grown", or expanded, to +display new text when local movements are done in displays where the +number of lines displayed is less than the maximum possible. +Expansion has historically been the first choice, when the target +line is less than the maximum possible expansion value away. +Scrolling has historically been the next choice, done when the target +line is less than half a display away, and otherwise, the +screen was redrawn. There were exceptions, however, in that \fIex\fP +commands generally always +caused the screen to be redrawn. IEEE\ Std\ 1003.1-2001 does not specify +a standard behavior because there may be external +issues, such as connection speed, the number of characters necessary +to redraw as opposed to scroll, or terminal capabilities that +implementations will have to accommodate. +.LP +The current line in IEEE\ Std\ 1003.1-2001 maps one-to-one to a buffer +line in the file. The current column does not. +There are two different column values that are described by IEEE\ Std\ 1003.1-2001. +The first is the current column value +as set by many of the \fIvi\fP commands. This value is remembered +for the lifetime of the editor. The second column value is the +actual position on the screen where the cursor rests. The two are +not always the same. For example, when the cursor is backed by a +multi-column character, the actual cursor position on the screen has +historically been the last column of the character in command +mode, and the first column of the character in input mode. +.LP +Commands that set the current line, but that do not set the current +cursor value (for example, \fBj\fP and \fBk\fP) attempt to +get as close as possible to the remembered column position, so that +the cursor tends to restrict itself to a vertical column as the +user moves around in the edit buffer. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice, requiring that +the display location of the cursor on the display line be adjusted +from the current column value as necessary to support this +historical behavior. +.LP +Historically, only a single line (and for some terminals, a single +line minus 1 column) of characters could be entered by the +user for the line-oriented commands; that is, \fB:\fP, \fB!\fP, \fB/\fP, +or \fB?\fP. IEEE\ Std\ 1003.1-2001 permits, +but does not require, this limitation. +.LP +Historically, "soft" errors in \fIvi\fP caused the terminal to be +alerted, but no error message was displayed. As a general +rule, no error message was displayed for errors in command execution +in \fIvi\fP, when the error resulted from the user attempting +an invalid or impossible action, or when a searched-for object was +not found. Examples of soft errors included \fBh\fP at the left +margin, <control>-B or \fB[[\fP at the beginning of the file, \fB2G\fP +at the end of the file, and so on. In addition, +errors such as \fB%\fP, \fB]]\fP, \fB}\fP, \fB)\fP, \fBN\fP, \fBn\fP, +\fBf\fP, \fBF\fP, \fBt\fP, and \fBT\fP failing to +find the searched-for object were soft as well. Less consistently, +\fB/\fP and \fB?\fP displayed an error message if the pattern +was not found, \fB/\fP, \fB?\fP, \fBN\fP, and \fBn\fP displayed an +error message if no previous regular expression had been +specified, and \fB;\fP did not display an error message if no previous +\fBf\fP, \fBF\fP, \fBt\fP, or \fBT\fP command had +occurred. Also, behavior in this area might reasonably be based on +a runtime evaluation of the speed of a network connection. +Finally, some implementations have provided error messages for soft +errors in order to assist naive users, based on the value of a +verbose edit option. IEEE\ Std\ 1003.1-2001 does not list specific +errors for which an error message shall be displayed. +Implementations should conform to historical practice in the absence +of any strong reason to diverge. +.SS Page Backwards +.LP +The <control>-B and <control>-F commands historically considered it +an error to attempt to page past the beginning +or end of the file, whereas the <control>-D and <control>-U commands +simply moved to the beginning or end of the file. +For consistency, IEEE\ Std\ 1003.1-2001 requires the latter behavior +for all four commands. All four commands still +consider it an error if the current line is at the beginning ( <control>-B, +<control>-U) or end ( <control>-F, +<control>-D) of the file. Historically, the <control>-B and <control>-F +commands skip two lines in order to +include overlapping lines when a single command is entered. This makes +less sense in the presence of a \fIcount\fP, as there will +be, by definition, no overlapping lines. The actual calculation used +by historical implementations of the \fIvi\fP editor for +<control>-B was: +.sp +.RS +.nf + +\fB((current first line) - count x (window edit option)) +2 +\fP +.fi +.RE +.LP +and for <control>-F was: +.sp +.RS +.nf + +\fB((current first line) + count x (window edit option)) -2 +\fP +.fi +.RE +.LP +This calculation does not work well when intermixing commands with +and without counts; for example, \fB3\fP <control>-F +is not equivalent to entering the <control>-F command three times, +and is not reversible by entering the <control>-B +command three times. For consistency with other \fIvi\fP commands +that take counts, IEEE\ Std\ 1003.1-2001 requires a +different calculation. +.SS Scroll Forward +.LP +The 4BSD and System V implementations of \fIvi\fP differed on the +initial value used by the \fBscroll\fP command. 4BSD +used: +.sp +.RS +.nf + +\fB((window edit option) +1) /2 +\fP +.fi +.RE +.LP +while System V used the value of the \fBscroll\fP edit option. The +System V version is specified by +IEEE\ Std\ 1003.1-2001 because the standard developers believed that +it was more intuitive and permitted the user a method +of setting the scroll value initially without also setting the number +of lines that are displayed. +.SS Scroll Forward by Line +.LP +Historically, the <control>-E and <control>-Y commands considered +it an error if the last and first lines, +respectively, were already on the screen. IEEE\ Std\ 1003.1-2001 requires +conformance to historical practice. Historically, +the <control>-E and <control>-Y commands had no effect in open mode. +For simplicity and consistency of specification, +IEEE\ Std\ 1003.1-2001 requires that they behave as usual, albeit +with a single line screen. +.SS Clear and Redisplay +.LP +The historical <control>-L command refreshed the screen exactly as +it was supposed to be currently displayed, replacing +any \fB'@'\fP characters for lines that had been deleted but not updated +on the screen with refreshed \fB'@'\fP characters. +The intent of the <control>-L command is to refresh when the screen +has been accidentally overwritten; for example, by a +\fBwrite\fP command from another user, or modem noise. +.SS Redraw Screen +.LP +The historical <control>-R command redisplayed only when necessary +to update lines that had been deleted but not updated +on the screen and that were flagged with \fB'@'\fP characters. There +is no requirement that the screen be in any way refreshed +if no lines of this form are currently displayed. IEEE\ Std\ 1003.1-2001 +permits implementations to extend this command to +refresh lines on the screen flagged with \fB'@'\fP characters because +they are too long to be displayed in the current +framework; however, the current line and column need not be modified. +.SS Search for tagstring +.LP +Historically, the first non- <blank> at or after the cursor was the +first character, and all subsequent characters that +were word characters, up to the end of the line, were included. For +example, with the cursor on the leading space or on the +\fB'#'\fP character in the text \fB"#bar@"\fP , the tag was \fB"#bar"\fP +\&. On the character \fB'b'\fP it was +\fB"bar"\fP , and on the \fB'a'\fP it was \fB"ar"\fP . IEEE\ Std\ 1003.1-2001 +requires this behavior. +.SS Replace Text with Results from Shell Command +.LP +Historically, the \fB<\fP, \fB>\fP, and \fB!\fP commands considered +most cursor motions other than line-oriented +motions an error; for example, the command \fB>/foo<CR>\fP succeeded, +while the command \fB>l\fP failed, even though +the text region described by the two commands might be identical. +For consistency, all three commands only consider entire lines +and not partial lines, and the region is defined as any line that +contains a character that was specified by the motion. +.SS Move to Matching Character +.LP +Other matching characters have been left implementation-defined in +order to allow extensions such as matching \fB'<'\fP +and \fB'>'\fP for searching HTML, or \fB#ifdef\fP, \fB#else\fP, and +\fB#endif\fP for searching C source. +.SS Repeat Substitution +.LP +IEEE\ Std\ 1003.1-2001 requires that any \fBc\fP and \fBg\fP flags +specified to the previous substitute command be +ignored; however, the \fBr\fP flag may still apply, if supported by +the implementation. +.SS Return to Previous (Context or Section) +.LP +The \fB[[\fP, \fB]]\fP, \fB(\fP, \fB)\fP, \fB{\fP, and \fB}\fP commands +are all affected by "section boundaries", but in +some historical implementations not all of the commands recognize +the same section boundaries. This is a bug, not a feature, and a +unique section-boundary algorithm was not described for each command. +One special case that is preserved is that the sentence +command moves to the end of the last line of the edit buffer while +the other commands go to the beginning, in order to preserve the +traditional character cut semantics of the sentence command. Historically, +\fIvi\fP section boundaries at the beginning and end of +the edit buffer were the first non- <blank> on the first and last +lines of the edit buffer if one exists; otherwise, the last +character of the first and last lines of the edit buffer if one exists. +To increase consistency with other section locations, this +has been simplified by IEEE\ Std\ 1003.1-2001 to the first character +of the first and last lines of the edit buffer, or the +first and the last lines of the edit buffer if they are empty. +.LP +Sentence boundaries were problematic in the historical \fIvi\fP. They +were not only the boundaries as defined for the section +and paragraph commands, but they were the first non- <blank> that +occurred after those boundaries, as well. Historically, the +\fIvi\fP section commands were documented as taking an optional window +size as a \fIcount\fP preceding the command. This was not +implemented in historical versions, so IEEE\ Std\ 1003.1-2001 requires +that the \fIcount\fP repeat the command, for +consistency with other \fIvi\fP commands. +.SS Repeat +.LP +Historically, mapped commands other than text input commands could +not be repeated using the \fBperiod\fP command. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.LP +The restrictions on the interpretation of special characters (for +example, <control>-H) in the repetition of text input +mode commands is intended to match historical practice. For example, +given the input sequence: +.sp +.RS +.nf + +\fBiab<control>-H<control>-H<control>-Hdef<escape> +\fP +.fi +.RE +.LP +the user should be informed of an error when the sequence is first +entered, but not during a command repetition. The character +<control>-T is specifically exempted from this restriction. Historical +implementations of \fIvi\fP ignored <control>-T +characters that were input in the original command during command +repetition. IEEE\ Std\ 1003.1-2001 prohibits this +behavior. +.SS Find Regular Expression +.LP +Historically, commands did not affect the line searched to or from +if the motion command was a search ( \fB/\fP, \fB?\fP, +\fBN\fP, \fBn\fP) and the final position was the start/end of the +line. There were some special cases and \fIvi\fP was not +consistent. IEEE\ Std\ 1003.1-2001 does not permit this behavior, +for consistency. Historical implementations permitted but +were unable to handle searches as motion commands that wrapped (that +is, due to the edit option \fBwrapscan\fP) to the original +location. IEEE\ Std\ 1003.1-2001 requires that this behavior be treated +as an error. +.LP +Historically, the syntax \fB"/RE/0"\fP was used to force the command +to cut text in line mode. IEEE\ Std\ 1003.1-2001 +requires conformance to historical practice. +.LP +Historically, in open mode, a \fBz\fP specified to a search command +redisplayed the current line instead of displaying the +current screen with the current line highlighted. For consistency +and simplicity of specification, IEEE\ Std\ 1003.1-2001 +does not permit this behavior. +.LP +Historically, trailing \fBz\fP commands were permitted and ignored +if entered as part of a search used as a motion command. For +consistency and simplicity of specification, IEEE\ Std\ 1003.1-2001 +does not permit this behavior. +.SS Execute an ex Command +.LP +Historically, \fIvi\fP implementations restricted the commands that +could be entered on the colon command line (for example, +\fBappend\fP and \fBchange\fP), and some other commands were known +to cause them to fail catastrophically. For consistency, +IEEE\ Std\ 1003.1-2001 does not permit these restrictions. When executing +an \fIex\fP +command by entering \fB:\fP, it is not possible to enter a <newline> +as part of the command because it is considered the end +of the command. A different approach is to enter \fIex\fP command +mode by using the \fIvi\fP +\fBQ\fP command (and later resuming visual mode with the \fIex\fP +\fBvi\fP command). In \fIex\fP command mode, the single-line limitation +does not exist. So, for example, the following +is valid: +.sp +.RS +.nf + +\fBQ +s/break here/break\\ +here/ +vi +\fP +.fi +.RE +.LP +IEEE\ Std\ 1003.1-2001 requires that, if the \fIex\fP command overwrites +any part of +the screen that would be erased by a refresh, \fIvi\fP pauses for +a character from the user. Historically, this character could be +any character; for example, a character input by the user before the +message appeared, or even a mapped character. This is probably +a bug, but implementations that have tried to be more rigorous by +requiring that the user enter a specific character, or that the +user enter a character after the message was displayed, have been +forced by user indignation back into historical behavior. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.SS Shift Left (Right) +.LP +Refer to the Rationale for the \fB!\fP and \fB/\fP commands. Historically, +the \fB<\fP and \fB>\fP commands sometimes +moved the cursor to the first non- <blank> (for example if the command +was repeated or with \fB_\fP as the motion command), +and sometimes left it unchanged. IEEE\ Std\ 1003.1-2001 does not permit +this inconsistency, requiring instead that the +cursor always move to the first non- <blank>. Historically, the \fB<\fP +and \fB>\fP commands did not support buffer +arguments, although some implementations allow the specification of +an optional buffer. This behavior is neither required nor +disallowed by IEEE\ Std\ 1003.1-2001. +.SS Execute +.LP +Historically, buffers could execute other buffers, and loops, infinite +and otherwise, were possible. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +The * \fIbuffer\fP syntax of \fIex\fP is not required in \fIvi\fP, +because it is not historical practice and has been used in some +\fIvi\fP implementations to support additional scripting languages. +.SS Reverse Case +.LP +Historically, the \fB~\fP command ignored any associated \fIcount\fP, +and acted only on the characters in the current +line. For consistency with other \fIvi\fP commands, IEEE\ Std\ 1003.1-2001 +requires that an associated \fIcount\fP act on +the next \fIcount\fP characters, and that the command move to subsequent +lines if warranted by \fIcount\fP, to make it possible +to modify large pieces of text in a reasonably efficient manner. There +exist \fIvi\fP implementations that optionally require an +associated motion command for the \fB~\fP command. Implementations +supporting this functionality are encouraged to base it on +the \fBtildedop\fP edit option and handle the text regions and cursor +positioning identically to the \fByank\fP command. +.SS Append +.LP +Historically, \fIcount\fPs specified to the \fBA\fP, \fBa\fP, \fBI\fP, +and \fBi\fP commands repeated the input of the first +line \fIcount\fP times, and did not repeat the subsequent lines of +the input text. IEEE\ Std\ 1003.1-2001 requires that +the entire text input be repeated \fIcount\fP times. +.SS Move Backward to Preceding Word +.LP +Historically, \fIvi\fP became confused if word commands were used +as motion commands in empty files. +IEEE\ Std\ 1003.1-2001 requires that this be an error. Historical +implementations of \fIvi\fP had a large number of bugs +in the word movement commands, and they varied greatly in behavior +in the presence of empty lines, "words" made up of a single +character, and lines containing only <blank>s. For consistency and +simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.SS Change to End-of-Line +.LP +Some historical implementations of the \fBC\fP command did not behave +as described by IEEE\ Std\ 1003.1-2001 when the +\fB$\fP key was remapped because they were implemented by pushing +the \fB$\fP key onto the input queue and reprocessing it. +IEEE\ Std\ 1003.1-2001 does not permit this behavior. Historically, +the \fBC\fP, \fBS\fP, and \fBs\fP commands did not +copy replaced text into the numeric buffers. For consistency and simplicity +of specification, IEEE\ Std\ 1003.1-2001 +requires that they behave like their respective \fBc\fP commands in +all respects. +.SS Delete +.LP +Historically, lines in open mode that were deleted were scrolled up, +and an \fB@\fP glyph written over the beginning of the +line. In the case of terminals that are incapable of the necessary +cursor motions, the editor erased the deleted line from the +screen. IEEE\ Std\ 1003.1-2001 requires conformance to historical +practice; that is, if the terminal cannot display the +\fB'@'\fP character, the line cannot remain on the screen. +.SS Delete to End-of-Line +.LP +Some historical implementations of the \fBD\fP command did not behave +as described by IEEE\ Std\ 1003.1-2001 when the +\fB$\fP key was remapped because they were implemented by pushing +the \fB$\fP key onto the input queue and reprocessing it. +IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.SS Join +.LP +An historical oddity of \fIvi\fP is that the commands \fBJ\fP, \fB1J\fP, +and \fB2J\fP are all equivalent. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +The \fIvi\fP \fBJ\fP command is specified in terms of +the \fIex\fP \fBjoin\fP command with an \fIex\fP command +\fIcount\fP value. The address correction for a \fIcount\fP that is +past the end of the edit buffer is necessary for historical +compatibility for both \fIex\fP and \fIvi\fP. +.SS Mark Position +.LP +Historical practice is that only lowercase letters, plus \fB'`'\fP +and \fB'"\fP , could be used to mark a cursor +position. IEEE\ Std\ 1003.1-2001 requires conformance to historical +practice, but encourages implementations to support +other characters as marks as well. +.SS Repeat Regular Expression Find (Forward and Reverse) +.LP +Historically, the \fBN\fP and \fBn\fP commands could not be used as +motion components for the \fBc\fP command. With the +exception of the \fBcN\fP command, which worked if the search crossed +a line boundary, the text region would be discarded, and the +user would not be in text input mode. For consistency and simplicity +of specification, IEEE\ Std\ 1003.1-2001 does not +permit this behavior. +.SS Insert Empty Line (Below and Above) +.LP +Historically, counts to the \fBO\fP and \fBo\fP commands were used +as the number of physical lines to open, if the terminal +was dumb and the \fBslowopen\fP option was not set. This was intended +to minimize traffic over slow connections and repainting for +dumb terminals. IEEE\ Std\ 1003.1-2001 does not permit this behavior, +requiring that a \fIcount\fP to the open command +behave as for other text input commands. This change to historical +practice was made for consistency, and because a superset of the +functionality is provided by the \fBslowopen\fP edit option. +.SS Put from Buffer (Following and Before) +.LP +Historically, \fIcount\fPs to the \fBp\fP and \fBP\fP commands were +ignored if the buffer was a line mode buffer, but were +(mostly) implemented as described in IEEE\ Std\ 1003.1-2001 if the +buffer was a character mode buffer. Because +implementations exist that do not have this limitation, and because +pasting lines multiple times is generally useful, +IEEE\ Std\ 1003.1-2001 requires that \fIcount\fP be supported for +all \fBp\fP and \fBP\fP commands. +.LP +Historical implementations of \fIvi\fP were widely known to have major +problems in the \fBp\fP and \fBP\fP commands, +particularly when unusual regions of text were copied into the edit +buffer. The standard developers viewed these as bugs, and they +are not permitted for consistency and simplicity of specification. +.LP +Historically, a \fBP\fP or \fBp\fP command (or an \fIex\fP \fBput\fP +command executed +from open or visual mode) executed in an empty file, left an empty +line as the first line of the file. For consistency and +simplicity of specification, IEEE\ Std\ 1003.1-2001 does not permit +this behavior. +.SS Replace Character +.LP +Historically, the \fBr\fP command did not correctly handle the \fIerase\fP +and \fIword erase\fP characters as arguments, nor +did it handle an associated \fIcount\fP greater than 1 with a <carriage-return> +argument, for which it replaced \fIcount\fP +characters with a single <newline>. IEEE\ Std\ 1003.1-2001 does not +permit these inconsistencies. +.LP +Historically, the \fBr\fP command permitted the <control>-V escaping +of entered characters, such as <ESC> and the +<carriage-return>; however, it required two leading <control>-V characters +instead of one. +IEEE\ Std\ 1003.1-2001 requires that this be changed for consistency +with the other text input commands of \fIvi\fP. +.LP +Historically, it is an error to enter the \fBr\fP command if there +are less than \fIcount\fP characters at or after the cursor +in the line. While a reasonable and unambiguous extension would be +to permit the \fBr\fP command on empty lines, it would require +that too large a \fIcount\fP be adjusted to match the number of characters +at or after the cursor for consistency, which is +sufficiently different from historical practice to be avoided. IEEE\ Std\ 1003.1-2001 +requires conformance to historical +practice. +.SS Replace Characters +.LP +Historically, if there were \fBautoindent\fP characters in the line +on which the \fBR\fP command was run, and +\fBautoindent\fP was set, the first <newline> would be properly indented +and no characters would be replaced by the +<newline>. Each additional <newline> would replace \fIn\fP characters, +where \fIn\fP was the number of characters +that were needed to indent the rest of the line to the proper indentation +level. This behavior is a bug and is not permitted by +IEEE\ Std\ 1003.1-2001. +.SS Undo +.LP +Historical practice for cursor positioning after undoing commands +was mixed. In most cases, when undoing commands that affected +a single line, the cursor was moved to the start of added or changed +text, or immediately after deleted text. However, if the user +had moved from the line being changed, the column was either set to +the first non- <blank>, returned to the origin of the +command, or remained unchanged. When undoing commands that affected +multiple lines or entire lines, the cursor was moved to the +first character in the first line restored. As an example of how inconsistent +this was, a search, followed by an \fBo\fP text +input command, followed by an \fBundo\fP would return the cursor to +the location where the \fBo\fP command was entered, but a +\fBcw\fP command followed by an \fBo\fP command followed by an \fBundo\fP +would return the cursor to the first non- +<blank> of the line. IEEE\ Std\ 1003.1-2001 requires the most useful +of these behaviors, and discards the least +useful, in the interest of consistency and simplicity of specification. +.SS Yank +.LP +Historically, the \fByank\fP command did not move to the end of the +motion if the motion was in the forward direction. It moved +to the end of the motion if the motion was in the backward direction, +except for the \fB_\fP command, or for the \fBG\fP and +\fB'\fP commands when the end of the motion was on the current line. +This was further complicated by the fact that for a number of +motion commands, the \fByank\fP command moved the cursor but did not +update the screen; for example, a subsequent command would +move the cursor from the end of the motion, even though the cursor +on the screen had not reflected the cursor movement for the +\fByank\fP command. IEEE\ Std\ 1003.1-2001 requires that all \fByank\fP +commands associated with backward motions move +the cursor to the end of the motion for consistency, and specifically, +to make \fB'\fP commands as motions consistent with search +patterns as motions. +.SS Yank Current Line +.LP +Some historical implementations of the \fBY\fP command did not behave +as described by IEEE\ Std\ 1003.1-2001 when the +\fB'_'\fP key was remapped because they were implemented by pushing +the \fB'_'\fP key onto the input queue and reprocessing +it. IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.SS Redraw Window +.LP +Historically, the \fBz\fP command always redrew the screen. This is +permitted but not required by +IEEE\ Std\ 1003.1-2001, because of the frequent use of the \fBz\fP +command in macros such as \fBmap n nz.\fP for screen +positioning, instead of its use to change the screen size. The standard +developers believed that expanding or scrolling the screen +offered a better interface for users. The ability to redraw the screen +is preserved if the optional new window size is specified, +and in the <control>-L and <control>-R commands. +.LP +The semantics of \fBz^\fP are confusing at best. Historical practice +is that the screen before the screen that ended with the +specified line is displayed. IEEE\ Std\ 1003.1-2001 requires conformance +to historical practice. +.LP +Historically, the \fBz\fP command would not display a partial line +at the top or bottom of the screen. If the partial line +would normally have been displayed at the bottom of the screen, the +command worked, but the partial line was replaced with +\fB'@'\fP characters. If the partial line would normally have been +displayed at the top of the screen, the command would fail. +For consistency and simplicity of specification, IEEE\ Std\ 1003.1-2001 +does not permit this behavior. +.LP +Historically, the \fBz\fP command with a line specification of 1 ignored +the command. For consistency and simplicity of +specification, IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.LP +Historically, the \fBz\fP command did not set the cursor column to +the first non- <blank> for the character if the first +screen was to be displayed, and was already displayed. For consistency +and simplicity of specification, +IEEE\ Std\ 1003.1-2001 does not permit this behavior. +.SS Input Mode Commands in vi +.LP +Historical implementations of \fIvi\fP did not permit the user to +erase more than a single line of input, or to use normal +erase characters such as \fIline erase\fP, \fIworderase\fP, and \fIerase\fP +to erase \fBautoindent\fP characters. As there +exist implementations of \fIvi\fP that do not have these limitations, +both behaviors are permitted, but only historical practice +is required. In the case of these extensions, \fIvi\fP is required +to pause at the \fBautoindent\fP and previous line +boundaries. +.LP +Historical implementations of \fIvi\fP updated only the portion of +the screen where the current cursor character was displayed. +For example, consider the \fIvi\fP input keystrokes: +.sp +.RS +.nf + +\fBiabcd<escape>0C<tab> +\fP +.fi +.RE +.LP +Historically, the <tab> would overwrite the characters \fB"abcd"\fP +when it was displayed. Other implementations +replace only the \fB'a'\fP character with the <tab>, and then push +the rest of the characters ahead of the cursor. Both +implementations have problems. The historical implementation is probably +visually nicer for the above example; however, for the +keystrokes: +.sp +.RS +.nf + +\fBiabcd<ESC>0R<tab><ESC> +\fP +.fi +.RE +.LP +the historical implementation results in the string \fB"bcd"\fP disappearing +and then magically reappearing when the +<ESC> character is entered. IEEE\ Std\ 1003.1-2001 requires the former +behavior when overwriting erase-columns-that +is, overwriting characters that are no longer logically part of the +edit buffer-and the latter behavior otherwise. +.LP +Historical implementations of \fIvi\fP discarded the <control>-D and +<control>-T characters when they were entered +at places where their command functionality was not appropriate. IEEE\ Std\ 1003.1-2001 +requires that the <control>-T +functionality always be available, and that <control>-D be treated +as any other key when not operating on \fBautoindent\fP +characters. +.SS NUL +.LP +Some historical implementations of \fIvi\fP limited the number of +characters entered using the NUL input character to 256 +bytes. IEEE\ Std\ 1003.1-2001 permits this limitation; however, implementations +are encouraged to remove this limit. +.SS <control>-D +.LP +See also Rationale for the input mode command <newline>. The hidden +assumptions in the <control>-D command (and in +the \fIvi\fP \fBautoindent\fP specification in general) is that <space>s +take up a single column on the screen and that +<tab>s are comprised of an integral number of <space>s. +.SS <newline> +.LP +Implementations are permitted to rewrite \fBautoindent\fP characters +in the line when <newline>, <carriage-return>, +<control>-D, and <control>-T are entered, or when the \fBshift\fP +commands are used, because historical +implementations have both done so and found it necessary to do so. +For example, a <control>-D when the cursor is preceded by +a single <tab>, with \fBtabstop\fP set to 8, and \fBshiftwidth\fP +set to 3, will result in the <tab> being replaced +by several <space>s. +.SS <control>-T +.LP +See also the Rationale for the input mode command <newline>. Historically, +<control>-T only worked if no non- +<blank>s had yet been input in the current input line. In addition, +the characters inserted by <control>-T were treated +as \fBautoindent\fP characters, and could not be erased using normal +user erase characters. Because implementations exist that do +not have these limitations, and as moving to a column boundary is +generally useful, IEEE\ Std\ 1003.1-2001 requires that +both limitations be removed. +.SS <control>-V +.LP +Historically, \fIvi\fP used \fB^V\fP, regardless of the value of the +literal-next character of the terminal. +IEEE\ Std\ 1003.1-2001 requires conformance to historical practice. +.LP +The uses described for <control>-V can also be accomplished with <control>-Q, +which is useful on terminals that use +<control>-V for the down-arrow function. However, most historical +implementations use <control>-Q for the +\fItermios\fP START character, so the editor will generally not receive +the <control>-Q unless \fBstty ixon\fP mode is set +to off. (In addition, some historical implementations of \fIvi\fP +explicitly set \fBixon\fP mode to on, so it was difficult for +the user to set it to off.) Any of the command characters described +in IEEE\ Std\ 1003.1-2001 can be made ineffective by +their selection as \fItermios\fP control characters, using the \fIstty\fP +utility or other +methods described in the System Interfaces volume of IEEE\ Std\ 1003.1-2001. +.SS <ESC> +.LP +Historically, SIGINT alerted the terminal when used to end input mode. +This behavior is permitted, but not required, by +IEEE\ Std\ 1003.1-2001. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIed\fP , \fIex\fP , \fIstty\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/wait.1p b/man1p/wait.1p new file mode 100644 index 000000000..cfb1a04c1 --- /dev/null +++ b/man1p/wait.1p @@ -0,0 +1,314 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "WAIT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" wait +.SH NAME +wait \- await process completion +.SH SYNOPSIS +.LP +\fBwait\fP \fB[\fP\fIpid\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +When an asynchronous list (see \fIAsynchronous Lists\fP ) is started +by the +shell, the process ID of the last command in each element of the asynchronous +list shall become known in the current shell +execution environment; see \fIShell Execution Environment\fP . +.LP +If the \fIwait\fP utility is invoked with no operands, it shall wait +until all process IDs known to the invoking shell have +terminated and exit with a zero exit status. +.LP +If one or more \fIpid\fP operands are specified that represent known +process IDs, the \fIwait\fP utility shall wait until all +of them have terminated. If one or more \fIpid\fP operands are specified +that represent unknown process IDs, \fIwait\fP shall +treat them as if they were known process IDs that exited with exit +status 127. The exit status returned by the \fIwait\fP utility +shall be the exit status of the process requested by the last \fIpid\fP +operand. +.LP +The known process IDs are applicable only for invocations of \fIwait\fP +in the current shell execution environment. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIpid\fP +One of the following: +.RS +.IP " 1." 4 +The unsigned decimal integer process ID of a command, for which the +utility is to wait for the termination. +.LP +.IP " 2." 4 +A job control job ID (see the Base Definitions volume of IEEE\ Std\ 1003.1-2001, +Section 3.203, Job Control Job ID) that identifies a background process +group to be +waited for. The job control job ID notation is applicable only for +invocations of \fIwait\fP in the current shell execution +environment; see \fIShell Execution Environment\fP . The exit status +of \fIwait\fP shall +be determined by the last command in the pipeline. +.TP 7 +\fBNote:\fP +.RS +The job control job ID type of \fIpid\fP is only available on systems +supporting the User Portability Utilities option. +.RE +.sp +.LP +.RE +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIwait\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +If one or more operands were specified, all of them have terminated +or were not known by the invoking shell, and the status of +the last operand specified is known, then the exit status of \fIwait\fP +shall be the exit status information of the command +indicated by the last operand specified. If the process terminated +abnormally due to the receipt of a signal, the exit status shall +be greater than 128 and shall be distinct from the exit status generated +by other signals, but the exact value is unspecified. (See +the \fIkill\fP \fB-l\fP option.) Otherwise, the \fIwait\fP utility +shall exit with one of +the following values: +.TP 7 +\ \ \ \ 0 +The \fIwait\fP utility was invoked with no operands and all process +IDs known by the invoking shell have terminated. +.TP 7 +1-126 +The \fIwait\fP utility detected an error. +.TP 7 +\ \ 127 +The command identified by the last \fIpid\fP operand specified is +unknown. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +On most implementations, \fIwait\fP is a shell built-in. If it is +called in a subshell or separate utility execution +environment, such as one of the following: +.sp +.RS +.nf + +\fB(wait) +nohup wait ... +find . -exec wait ... \\; +\fP +.fi +.RE +.LP +it returns immediately because there are no known process IDs to wait +for in those environments. +.LP +Historical implementations of interactive shells have discarded the +exit status of terminated background processes before each +shell prompt. Therefore, the status of background processes was usually +lost unless it terminated while \fIwait\fP was waiting for +it. This could be a serious problem when a job that was expected to +run for a long time actually terminated quickly with a syntax +or initialization error because the exit status returned was usually +zero if the requested process ID was not found. This volume of +IEEE\ Std\ 1003.1-2001 requires the implementation to keep the status +of terminated jobs available until the status is +requested, so that scripts like: +.sp +.RS +.nf + +\fBj1& +p1=$! +j2& +wait $p1 +echo Job 1 exited with status $? +wait $! +echo Job 2 exited with status $? +\fP +.fi +.RE +.LP +work without losing status on any of the jobs. The shell is allowed +to discard the status of any process if it determines that +the application cannot get the process ID for that process from the +shell. It is also required to remember only {CHILD_MAX} number +of processes in this way. Since the only way to get the process ID +from the shell is by using the \fB'!'\fP shell parameter, the +shell is allowed to discard the status of an asynchronous list if +\fB"$!"\fP was not referenced before another asynchronous list +was started. (This means that the shell only has to keep the status +of the last asynchronous list started if the application did +not reference \fB"$!"\fP . If the implementation of the shell is smart +enough to determine that a reference to \fB"$!"\fP was +not saved anywhere that the application can retrieve it later, it +can use this information to trim the list of saved information. +Note also that a successful call to \fIwait\fP with no operands discards +the exit status of all asynchronous lists.) +.LP +If the exit status of \fIwait\fP is greater than 128, there is no +way for the application to know if the waited-for process +exited with that value or was killed by a signal. Since most utilities +exit with small values, there is seldom any ambiguity. Even +in the ambiguous cases, most applications just need to know that the +asynchronous job failed; it does not matter whether it +detected an error and failed or was killed and did not complete its +job normally. +.SH EXAMPLES +.LP +Although the exact value used when a process is terminated by a signal +is unspecified, if it is known that a signal terminated a +process, a script can still reliably determine which signal by using +\fIkill\fP as shown by +the following script: +.sp +.RS +.nf + +\fBsleep 1000& +pid=$! +kill -kill $pid +wait $pid +echo $pid was terminated by a SIG$(kill -l $?) signal. +\fP +.fi +.RE +.LP +If the following sequence of commands is run in less than 31 seconds: +.sp +.RS +.nf + +\fBsleep 257 | sleep 31 & +jobs -l %% +\fP +.fi +.RE +.LP +either of the following commands returns the exit status of the second +\fIsleep\fP in the +pipeline: +.sp +.RS +.nf + +\fBwait\fP \fI<pid of sleep 31>\fP\fBwait %% +\fP +.fi +.RE +.SH RATIONALE +.LP +The description of \fIwait\fP does not refer to the \fIwaitpid\fP() +function from the +System Interfaces volume of IEEE\ Std\ 1003.1-2001 because that would +needlessly overspecify this interface. However, the +wording means that \fIwait\fP is required to wait for an explicit +process when it is given an argument so that the status +information of other processes is not consumed. Historical implementations +use the \fIwait\fP() function defined in the System Interfaces volume +of IEEE\ Std\ 1003.1-2001 until +\fIwait\fP() returns the requested process ID or finds that the requested +process does not +exist. Because this means that a shell script could not reliably get +the status of all background children if a second background +job was ever started before the first job finished, it is recommended +that the \fIwait\fP utility use a method such as the +functionality provided by the \fIwaitpid\fP() function. +.LP +The ability to wait for multiple \fIpid\fP operands was adopted from +the KornShell. +.LP +This new functionality was added because it is needed to determine +the exit status of any asynchronous list accurately. The only +compatibility problem that this change creates is for a script like +.sp +.RS +.nf + +\fBwhile sleep 60 do + job& echo Job started $(date) as $! done +\fP +.fi +.RE +.LP +which causes the shell to monitor all of the jobs started until the +script terminates or runs out of memory. This would not be a +problem if the loop did not reference \fB"$!"\fP or if the script +would occasionally \fIwait\fP for jobs it started. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIkill\fP() , \fIsh\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIwait\fP(), \fIwaitpid\fP() +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/wc.1p b/man1p/wc.1p new file mode 100644 index 000000000..8a71c8c60 --- /dev/null +++ b/man1p/wc.1p @@ -0,0 +1,230 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "WC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" wc +.SH NAME +wc \- word, line, and byte or character count +.SH SYNOPSIS +.LP +\fBwc\fP \fB[\fP\fB-c|-m\fP\fB][\fP\fB-lw\fP\fB][\fP\fIfile\fP\fB...\fP\fB]\fP +.SH DESCRIPTION +.LP +The \fIwc\fP utility shall read one or more input files and, by default, +write the number of <newline>s, words, and bytes +contained in each input file to the standard output. +.LP +The utility also shall write a total count for all named files, if +more than one input file is specified. +.LP +The \fIwc\fP utility shall consider a \fIword\fP to be a non-zero-length +string of characters delimited by white space. +.SH OPTIONS +.LP +The \fIwc\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-c\fP +Write to the standard output the number of bytes in each input file. +.TP 7 +\fB-l\fP +Write to the standard output the number of <newline>s in each input +file. +.TP 7 +\fB-m\fP +Write to the standard output the number of characters in each input +file. +.TP 7 +\fB-w\fP +Write to the standard output the number of words in each input file. +.sp +.LP +When any option is specified, \fIwc\fP shall report only the information +requested by the specified options. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +A pathname of an input file. If no \fIfile\fP operands are specified, +the standard input shall be used. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified. See the INPUT FILES section. +.SH INPUT FILES +.LP +The input files may be of any type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIwc\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +which characters are defined as white space characters. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +By default, the standard output shall contain an entry for each input +file of the form: +.sp +.RS +.nf + +\fB"%d %d %d %s\\n", <\fP\fInewlines\fP\fB>, <\fP\fIwords\fP\fB>, <\fP\fIbytes\fP\fB>, <\fP\fIfile\fP\fB> +\fP +.fi +.RE +.LP +If the \fB-m\fP option is specified, the number of characters shall +replace the <\fIbytes\fP> field in this format. +.LP +If any options are specified and the \fB-l\fP option is not specified, +the number of <newline>s shall not be written. +.LP +If any options are specified and the \fB-w\fP option is not specified, +the number of words shall not be written. +.LP +If any options are specified and neither \fB-c\fP nor \fB-m\fP is +specified, the number of bytes or characters shall not be +written. +.LP +If no input \fIfile\fP operands are specified, no name shall be written +and no <blank>s preceding the pathname shall be +written. +.LP +If more than one input \fIfile\fP operand is specified, an additional +line shall be written, of the same format as the other +lines, except that the word \fBtotal\fP (in the POSIX locale) shall +be written instead of a pathname and the total of each column +shall be written as appropriate. Such an additional line, if any, +is written at the end of the output. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fB-m\fP option is not a switch, but an option at the same level +as \fB-c\fP. Thus, to produce the full default output +with character counts instead of bytes, the command required is: +.sp +.RS +.nf + +\fBwc -mlw +\fP +.fi +.RE +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The output file format pseudo- \fIprintf\fP() string differs from +the System V version +of \fIwc\fP: +.sp +.RS +.nf + +\fB"%7d%7d%7d %s\\n" +\fP +.fi +.RE +.LP +which produces possibly ambiguous and unparsable results for very +large files, as it assumes no number shall exceed six +digits. +.LP +Some historical implementations use only <space>, <tab>, and <newline> +as word separators. The equivalent of +the ISO\ C standard \fIisspace\fP() function is more appropriate. +.LP +The \fB-c\fP option stands for "character" count, even though it counts +bytes. This stems from the sometimes erroneous +historical view that bytes and characters are the same size. Due to +international requirements, the \fB-m\fP option (reminiscent +of "multi-byte") was added to obtain actual character counts. +.LP +Early proposals only specified the results when input files were text +files. The current specification more closely matches +historical practice. (Bytes, words, and <newline>s are counted separately +and the results are written when an end-of-file is +detected.) +.LP +Historical implementations of the \fIwc\fP utility only accepted one +argument to specify the options \fB-c\fP, \fB-l\fP, and +\fB-w\fP. Some of them also had multiple occurrences of an option +cause the corresponding count to be written multiple times and +had the order of specification of the options affect the order of +the fields on output, but did not document either of these. +Because common usage either specifies no options or only one option, +and because none of this was documented, the changes required +by this volume of IEEE\ Std\ 1003.1-2001 should not break many historical +applications (and do not break any historical +conforming applications). +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcksum\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/what.1p b/man1p/what.1p new file mode 100644 index 000000000..08f24b4b2 --- /dev/null +++ b/man1p/what.1p @@ -0,0 +1,185 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "WHAT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" what +.SH NAME +what \- identify SCCS files (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fBwhat\fP \fB[\fP\fB-s\fP\fB]\fP \fIfile\fP\fB... \fP +.SH DESCRIPTION +.LP +The \fIwhat\fP utility shall search the given files for all occurrences +of the pattern that \fIget\fP (see \fIget\fP ) substitutes for the +%\fBZ\fP% keyword ( +\fB"@(#)"\fP ) and shall write to standard output what follows until +the first occurrence of one of the following: +.sp +.RS +.nf + +\fB" > newline \\ NUL +\fP +.fi +.RE +.SH OPTIONS +.LP +The \fIwhat\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following option shall be supported: +.TP 7 +\fB-s\fP +Quit after finding the first occurrence of the pattern in each file. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIfile\fP +A pathname of a file to search. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The input files shall be of any file type. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIwhat\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The standard output shall consist of the following for each \fIfile\fP +operand: +.sp +.RS +.nf + +\fB"%s:\\n\\t%s\\n", <\fP\fIpathname\fP\fB>, <\fP\fIidentification string\fP\fB> +\fP +.fi +.RE +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +0 +Any matches were found. +.TP 7 +1 +Otherwise. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fIwhat\fP utility is intended to be used in conjunction with +the SCCS command \fIget\fP, which automatically inserts identifying +information, but it can also be used where the +information is inserted by any other means. +.LP +When the string \fB"@(#)"\fP is included in a library routine in a +shared library, it might not be found in an \fBa.out\fP +file using that library routine. +.SH EXAMPLES +.LP +If the C-language program in file \fBf.c\fP contains: +.sp +.RS +.nf + +\fBchar ident[] = "@(#)identification information"; +\fP +.fi +.RE +.LP +and \fBf.c\fP is compiled to yield \fBf.o\fP and \fBa.out\fP, then +the command: +.sp +.RS +.nf + +\fBwhat f.c f.o a.out +\fP +.fi +.RE +.LP +writes: +.sp +.RS +.nf + +\fBf.c: + identification information + ... +f.o: + identification information + ... +a.out: + identification information + ... +\fP +.fi +.RE +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIget\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/who.1p b/man1p/who.1p new file mode 100644 index 000000000..e9245ed86 --- /dev/null +++ b/man1p/who.1p @@ -0,0 +1,311 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "WHO" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" who +.SH NAME +who \- display who is on the system +.SH SYNOPSIS +.LP +\fBwho\fP \fB[\fP\fB-mTu\fP\fB]\fP\fB +.br +.sp +\fP +.LP +\fBwho\fP +\fB[\fP\fB-mu\fP\fB]\fP\fB-s\fP\fB[\fP\fB-bHlprt\fP\fB][\fP\fIfile\fP\fB]\fP\fB +.br +.sp +who\fP \fB[\fP\fB-mTu\fP\fB][\fP\fB-abdHlprt\fP\fB][\fP\fIfile\fP\fB]\fP\fB +.br +.sp +who -q\fP \fB[\fP\fIfile\fP\fB]\fP\fB +.br +.sp +who am i +.br +.sp +who am I \fP +\fB +.br +\fP +.SH DESCRIPTION +.LP +The \fIwho\fP utility shall list various pieces of information about +accessible users. The domain of accessibility is +implementation-defined. +.LP +Based on the options given, \fIwho\fP can also list the user's name, +terminal line, login time, elapsed time since activity +occurred on the line, and the process ID of the command interpreter +for each current system user. +.SH OPTIONS +.LP +The \fIwho\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported. The metavariables, such +as <\fIline\fP>, refer to fields described in the +STDOUT section. +.TP 7 +\fB-a\fP +Process the implementation-defined database or named file with the +\fB-b\fP, \fB-d\fP, \fB-l\fP, \fB-p\fP, \fB-r\fP, +\fB-t\fP, \fB-T\fP and \fB-u\fP options turned on. +.TP 7 +\fB-b\fP +Write the time and date of the last reboot. +.TP 7 +\fB-d\fP +Write a list of all processes that have expired and not been respawned +by the \fIinit\fP system process. The <\fIexit\fP> +field shall appear for dead processes and contain the termination +and exit values of the dead process. This can be useful in +determining why a process terminated. +.TP 7 +\fB-H\fP +Write column headings above the regular output. +.TP 7 +\fB-l\fP +(The letter ell.) List only those lines on which the system is waiting +for someone to login. The <\fIname\fP> field shall be +\fBLOGIN\fP in such cases. Other fields shall be the same as for user +entries except that the <\fIstate\fP> field does not +exist. +.TP 7 +\fB-m\fP +Output only information about the current terminal. +.TP 7 +\fB-p\fP +List any other process that is currently active and has been previously +spawned by \fIinit\fP. +.TP 7 +\fB-q\fP +(Quick.) List only the names and the number of users currently logged +on. When this option is used, all other options shall be +ignored. +.TP 7 +\fB-r\fP +Write the current \fIrun-level\fP of the \fIinit\fP process. +.TP 7 +\fB-s\fP +List only the <\fIname\fP>, <\fIline\fP>, and <\fItime\fP> fields. +This is the default case. +.TP 7 +\fB-t\fP +Indicate the last change to the system clock. +.TP 7 +\fB-T\fP +Show the state of each terminal, as described in the STDOUT section. +.TP 7 +\fB-u\fP +Write "idle time" for each displayed user in addition to any other +information. The idle time is the time since any activity +occurred on the user's terminal. The method of determining this is +unspecified. \ This option +shall list only those users who are currently logged in. The <\fIname\fP> +is the user's login name. The <\fIline\fP> +is the name of the line as found in the directory \fB/dev\fP. The +<\fItime\fP> is the time that the user logged in. The +<\fIactivity\fP> is the number of hours and minutes since activity +last occurred on that particular line. A dot indicates +that the terminal has seen activity in the last minute and is therefore +"current". If more than twenty-four hours have elapsed or +the line has not been used since boot time, the entry shall be marked +<\fIold\fP>. This field is useful when trying to +determine whether a person is working at the terminal or not. The +<\fIpid\fP> is the process ID of the user's login process. +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fBam\ i\fP,\ \fBam\ I\fP +In the POSIX locale, limit the output to describing the invoking user, +equivalent to the \fB-m\fP option. The \fBam\fP and +\fBi\fP or \fBI\fP must be separate arguments. +.TP 7 +\fIfile\fP +Specify a pathname of a file to substitute for the implementation-defined +database of logged-on users that \fIwho\fP uses by +default. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIwho\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fILC_TIME\fP +Determine the locale used for the format and contents of the date +and time strings. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fITZ\fP +Determine the timezone used when writing date and time information. +If \fITZ\fP is unset or null, an unspecified default +timezone shall be used. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The \fIwho\fP utility shall write its default format to the standard +output in an implementation-defined format, subject only +to the requirement of containing the information described above. +.LP +XSI-conformant systems shall write the default information to the +standard output in the following general format: +.sp +.RS +.nf + +\fB<\fP\fIname\fP\fB>\fP\fB[\fP\fB<\fP\fIstate\fP\fB>\fP\fB]\fP\fB<\fP\fIline\fP\fB><\fP\fItime\fP\fB>\fP\fB[\fP\fB<\fP\fIactivity\fP\fB>\fP\fB][\fP\fB<\fP\fIpid\fP\fB>\fP\fB][\fP\fB<\fP\fIcomment\fP\fB>\fP\fB][\fP\fB<\fP\fIexit\fP\fB>\fP\fB]\fP \fB +\fP +.fi +.RE +.LP +The following format shall be used for the \fB-T\fP option: +.sp +.RS +.nf + +\fB"%s %c %s %s\\n" <\fP\fIname\fP\fB>, <\fP\fIterminal state\fP\fB>, <\fP\fIterminal name\fP\fB>, + <\fP\fItime of login\fP\fB> +\fP +.fi +.RE +.LP +where <\fIterminal\ state\fP> is one of the following characters: +.TP 7 +\fB+\fP +The terminal allows write access to other users. +.TP 7 +\fB-\fP +The terminal denies write access to other users. +.TP 7 +\fB?\fP +The terminal write-access state cannot be determined. +.sp +.LP +In the POSIX locale, the <\fItime\ of\ login\fP> shall be equivalent +in format to the output of: +.sp +.RS +.nf + +\fBdate +"%b %e %H:%M" +\fP +.fi +.RE +.LP +If the \fB-u\fP option is used with \fB-T\fP, the idle time shall +be added to the end of the previous format in an unspecified +format. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The name \fIinit\fP used for the system process is the most commonly +used on historical systems, but it may vary. +.LP +The "domain of accessibility" referred to is a broad concept that +permits interpretation either on a very secure basis or even +to allow a network-wide implementation like the historical \fIrwho\fP. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +Due to differences between historical implementations, the base options +provided were a compromise to allow users to work with +those functions. The standard developers also considered removing +all the options, but felt that these options offered users +valuable functionality. Additional options to match historical systems +are available on XSI-conformant systems. +.LP +It is recognized that the \fIwho\fP command may be of limited usefulness, +especially in a multi-level secure environment. The +standard developers considered, however, that having some standard +method of determining the "accessibility" of other users would +aid user portability. +.LP +No format was specified for the default \fIwho\fP output for systems +not supporting the XSI Extension. In such a user-oriented +command, designed only for human use, this was not considered to be +a deficiency. +.LP +The format of the terminal name is unspecified, but the descriptions +of \fIps\fP, \fItalk\fP, and \fIwrite\fP require that they use the +same +format. +.LP +It is acceptable for an implementation to produce no output for an +invocation of \fIwho\fP \fBmil\fP. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fImesg\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/write.1p b/man1p/write.1p new file mode 100644 index 000000000..e7906c138 --- /dev/null +++ b/man1p/write.1p @@ -0,0 +1,219 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "WRITE" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" write +.SH NAME +write \- write to another user +.SH SYNOPSIS +.LP +\fBwrite\fP \fIuser_name\fP \fB[\fP\fIterminal\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIwrite\fP utility shall read lines from the user's standard +input and write them to the terminal of another user. When +first invoked, it shall write the message: +.sp +.RS +.nf + +\fBMessage from\fP \fIsender-login-id\fP \fB(\fP\fIsending-terminal\fP\fB)\fP \fB[\fP\fIdate\fP\fB]\fP\fB... +\fP +.fi +.RE +.LP +to \fIuser_name\fP. When it has successfully completed the connection, +the sender's terminal shall be alerted twice to indicate +that what the sender is typing is being written to the recipient's +terminal. +.LP +If the recipient wants to reply, this can be accomplished by typing: +.sp +.RS +.nf + +\fBwrite\fP \fIsender-login-id\fP \fB[\fP\fIsending-terminal\fP\fB]\fP +.fi +.RE +.LP +upon receipt of the initial message. Whenever a line of input as delimited +by an NL, EOF, or EOL special character (see the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General +Terminal +Interface) is accumulated while in canonical input mode, the accumulated +data shall be written on the other user's terminal. +Characters shall be processed as follows: +.IP " *" 3 +Typing <alert> shall write the alert character to the recipient's +terminal. +.LP +.IP " *" 3 +Typing the erase and kill characters shall affect the sender's terminal +in the manner described by the \fBtermios\fP interface +in the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter +11, General +Terminal Interface. +.LP +.IP " *" 3 +Typing the interrupt or end-of-file characters shall cause \fIwrite\fP +to write an appropriate message ( \fB"EOT\\n"\fP in +the POSIX locale) to the recipient's terminal and exit. +.LP +.IP " *" 3 +Typing characters from \fILC_CTYPE\fP classifications \fBprint\fP +or \fBspace\fP shall cause those characters to be sent to +the recipient's terminal. +.LP +.IP " *" 3 +When and only when the \fIstty\fP \fBiexten\fP local mode is enabled, +the existence and +processing of additional special control characters and multi-byte +or single-byte functions is implementation-defined. +.LP +.IP " *" 3 +Typing other non-printable characters shall cause implementation-defined +sequences of printable characters to be written to the +recipient's terminal. +.LP +.LP +To write to a user who is logged in more than once, the \fIterminal\fP +argument can be used to indicate which terminal to write +to; otherwise, the recipient's terminal is selected in an implementation-defined +manner and an informational message is written to +the sender's standard output, indicating which terminal was chosen. +.LP +Permission to be a recipient of a \fIwrite\fP message can be denied +or granted by use of the \fImesg\fP utility. However, a user's privilege +may further constrain the domain of accessibility of +other users' terminals. The \fIwrite\fP utility shall fail when the +user lacks the appropriate privileges to perform the requested +action. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIuser_name\fP +Login name of the person to whom the message shall be written. The +application shall ensure that this operand is of the form +returned by the \fIwho\fP utility. +.TP 7 +\fIterminal\fP +Terminal identification in the same format provided by the \fIwho\fP +utility. +.sp +.SH STDIN +.LP +Lines to be copied to the recipient's terminal are read from standard +input. +.SH INPUT FILES +.LP +None. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIwrite\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). If +the recipient's locale does not use an \fILC_CTYPE\fP +equivalent to the sender's, the results are undefined. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard error and +informative messages written to standard output. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +If an interrupt signal is received, \fIwrite\fP shall write an appropriate +message on the recipient's terminal and exit with a +status of zero. It shall take the standard action for all other signals. +.SH STDOUT +.LP +An informational message shall be written to standard output if a +recipient is logged in more than once. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +The recipient's terminal is used for output. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +The addressed user is not logged on or the addressed user denies permission. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The \fItalk\fP utility is considered by some users to be a more usable +utility on +full-screen terminals. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +The \fIwrite\fP utility was included in this volume of IEEE\ Std\ 1003.1-2001 +since it can be implemented on all +terminal types. The standard developers considered the \fItalk\fP +utility, which cannot be +implemented on certain terminals, to be a "better" communications +interface. Both of these programs are in widespread use on +historical implementations. Therefore, the standard developers decided +that both utilities should be specified. +.LP +The format of the terminal name is unspecified, but the descriptions +of \fIps\fP, \fItalk\fP, \fIwho\fP, and \fIwrite\fP require that they +all +use or accept the same format. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fImesg\fP , \fItalk\fP , \fIwho\fP , the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 11, General +Terminal +Interface +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/xargs.1p b/man1p/xargs.1p new file mode 100644 index 000000000..a86964952 --- /dev/null +++ b/man1p/xargs.1p @@ -0,0 +1,515 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "XARGS" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" xargs +.SH NAME +xargs \- construct argument lists and invoke utility +.SH SYNOPSIS +.LP +\fBxargs\fP +\fB[\fP\fB-t\fP\fB][\fP\fB-p\fP\fB]][\fP\fB-E\fP \fIeofstr\fP\fB][\fP\fB-I\fP +\fIreplstr\fP\fB][\fP\fB-L\fP \fInumber\fP\fB][\fP\fB-n\fP \fInumber\fP +\fB[\fP\fB-x\fP\fB]] +.br +\fP \fB\ \ \ \ \ \ \fP \fB[\fP\fB-s\fP \fIsize\fP\fB][\fP\fIutility\fP +\fB[\fP\fIargument\fP\fB...\fP\fB]]\fP +.SH DESCRIPTION +.LP +The \fIxargs\fP utility shall construct a command line consisting +of the \fIutility\fP and \fIargument\fP operands specified +followed by as many arguments read in sequence from standard input +as fit in length and number constraints specified by the +options. The \fIxargs\fP utility shall then invoke the constructed +command line and wait for its completion. This sequence shall +be repeated until one of the following occurs: +.IP " *" 3 +An end-of-file condition is detected on standard input. +.LP +.IP " *" 3 +The logical end-of-file string (see the \fB-E\fP \fIeofstr\fP option) +is found on standard input after double-quote +processing, apostrophe processing, and backslash escape processing +(see next paragraph). +.LP +.IP " *" 3 +An invocation of a constructed command line returns an exit status +of 255. +.LP +.LP +The application shall ensure that arguments in the standard input +are separated by unquoted <blank>s, unescaped +<blank>s, or <newline>s. A string of zero or more non-double-quote +( \fB' )'\fP characters and non- <newline>s +can be quoted by enclosing them in double-quotes. A string of zero +or more non-apostrophe ( \fB'"\fP ) characters and non- +<newline>s can be quoted by enclosing them in apostrophes. Any unquoted +character can be escaped by preceding it with a +backslash. The utility named by \fIutility\fP shall be executed one +or more times until the end-of-file is reached or the logical +end-of file string is found. The results are unspecified if the utility +named by \fIutility\fP attempts to read from its standard +input. +.LP +The generated command line length shall be the sum of the size in +bytes of the utility name and each argument treated as +strings, including a null byte terminator for each of these strings. +The \fIxargs\fP utility shall limit the command line length +such that when the command line is invoked, the combined argument +and environment lists (see the \fIexec\fP family of functions in +the System Interfaces volume of IEEE\ Std\ 1003.1-2001) shall not +exceed {ARG_MAX}-2048 bytes. Within this constraint, if +neither the \fB-n\fP nor the \fB-s\fP option is specified, the default +command line length shall be at least {LINE_MAX}. +.SH OPTIONS +.LP +The \fIxargs\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-E\ \fP \fIeofstr\fP +Use \fIeofstr\fP as the logical end-of-file string. If \fB-E\fP is +not specified, it is unspecified whether the logical +end-of-file string is the underscore character ( \fB'_'\fP ) or the +end-of-file string capability is disabled. When +\fIeofstr\fP is the null string, the logical end-of-file string capability +shall be disabled and underscore characters shall be +taken literally. +.TP 7 +\fB-I\ \fP \fIreplstr\fP +Insert mode: \fIutility\fP is executed for each line from standard +input, taking the entire line as a single argument, inserting +it in \fIargument\fPs for each occurrence of \fIreplstr\fP. A maximum +of five arguments in \fIargument\fPs can each contain one +or more instances of \fIreplstr\fP. Any <blank>s at the beginning +of each line shall be ignored. Constructed arguments +cannot grow larger than 255 bytes. Option \fB-x\fP shall be forced +on. +.TP 7 +\fB-L\ \fP \fInumber\fP +The \fIutility\fP shall be executed for each non-empty \fInumber\fP +lines of arguments from standard input. The last invocation +of \fIutility\fP shall be with fewer lines of arguments if fewer than +\fInumber\fP remain. A line is considered to end with the +first <newline> unless the last character of the line is a <blank>; +a trailing <blank> signals continuation to +the next non-empty line, inclusive. The \fB-L\fP and \fB-n\fP options +are mutually-exclusive; the last one specified shall take +effect. +.TP 7 +\fB-n\ \fP \fInumber\fP +Invoke \fIutility\fP using as many standard input arguments as possible, +up to \fInumber\fP (a positive decimal integer) +arguments maximum. Fewer arguments shall be used if: +.RS +.IP " *" 3 +The command line length accumulated exceeds the size specified by +the \fB-s\fP option (or {LINE_MAX} if there is no \fB-s\fP +option). +.LP +.IP " *" 3 +The last iteration has fewer than \fInumber\fP, but not zero, operands +remaining. +.LP +.RE +.TP 7 +\fB-p\fP +Prompt mode: the user is asked whether to execute \fIutility\fP at +each invocation. Trace mode ( \fB-t\fP) is turned on to +write the command instance to be executed, followed by a prompt to +standard error. An affirmative response read from +\fB/dev/tty\fP shall execute the command; otherwise, that particular +invocation of \fIutility\fP shall be skipped. +.TP 7 +\fB-s\ \fP \fIsize\fP +Invoke \fIutility\fP using as many standard input arguments as possible +yielding a command line length less than \fIsize\fP +(a positive decimal integer) bytes. Fewer arguments shall be used +if: +.RS +.IP " *" 3 +The total number of arguments exceeds that specified by the \fB-n\fP +option. +.LP +.IP " *" 3 +The total number of lines exceeds that specified by the \fB-L\fP option. +.LP +.IP " *" 3 +End-of-file is encountered on standard input before \fIsize\fP bytes +are accumulated. +.LP +.RE +.LP +Values of \fIsize\fP up to at least {LINE_MAX} bytes shall be supported, +provided that the constraints specified in the +DESCRIPTION are met. It shall not be considered an error if a value +larger than that supported by the implementation or exceeding +the constraints specified in the DESCRIPTION is given; \fIxargs\fP +shall use the largest value it supports within the +constraints. +.TP 7 +\fB-t\fP +Enable trace mode. Each generated command line shall be written to +standard error just prior to invocation. +.TP 7 +\fB-x\fP +Terminate if a command line containing \fInumber\fP arguments (see +the \fB-n\fP option above) \ or +\fInumber\fP lines (see the \fB-L\fP option above) will not fit +in the implied or specified size (see the \fB-s\fP option above). +.sp +.SH OPERANDS +.LP +The following operands shall be supported: +.TP 7 +\fIutility\fP +The name of the utility to be invoked, found by search path using +the \fIPATH\fP environment variable, described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables. +If \fIutility\fP is omitted, the default shall be the \fIecho\fP utility. +If the +\fIutility\fP operand names any of the special built-in utilities +in \fISpecial Built-In +Utilities\fP , the results are undefined. +.TP 7 +\fIargument\fP +An initial option or operand for the invocation of \fIutility\fP. +.sp +.SH STDIN +.LP +The standard input shall be a text file. The results are unspecified +if an end-of-file condition is detected immediately +following an escaped <newline>. +.SH INPUT FILES +.LP +The file \fB/dev/tty\fP shall be used to read responses required by +the \fB-p\fP option. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIxargs\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_COLLATE\fP +.sp +Determine the locale for the behavior of ranges, equivalence classes, +and multi-character collating elements used in the extended +regular expression defined for the \fByesexpr\fP locale keyword in +the \fILC_MESSAGES\fP category. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files) and +the behavior of character classes used in the extended regular +expression defined for the \fByesexpr\fP locale keyword in the \fILC_MESSAGES\fP +category. +.TP 7 +\fILC_MESSAGES\fP +Determine the locale for the processing of affirmative responses and +that should be used to affect the format and contents of +diagnostic messages written to standard error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.TP 7 +\fIPATH\fP +Determine the location of \fIutility\fP, as described in the Base +Definitions volume of IEEE\ Std\ 1003.1-2001, Chapter 8, Environment +Variables. +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +The standard error shall be used for diagnostic messages and the \fB-t\fP +and \fB-p\fP options. If the \fB-t\fP option is +specified, the \fIutility\fP and its constructed argument list shall +be written to standard error, as it will be invoked, prior to +invocation. If \fB-p\fP is specified, a prompt of the following format +shall be written (in the POSIX locale): +.sp +.RS +.nf + +\fB"?..." +\fP +.fi +.RE +.LP +at the end of the line of the output from \fB-t\fP. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ \ \ \ 0 +All invocations of \fIutility\fP returned exit status zero. +.TP 7 +1-125 +A command line meeting the specified requirements could not be assembled, +one or more of the invocations of \fIutility\fP +returned a non-zero exit status, or some other error occurred. +.TP 7 +\ \ 126 +The utility specified by \fIutility\fP was found but could not be +invoked. +.TP 7 +\ \ 127 +The utility specified by \fIutility\fP could not be found. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If a command line meeting the specified requirements cannot be assembled, +the utility cannot be invoked, an invocation of the +utility is terminated by a signal, or an invocation of the utility +exits with exit status 255, the \fIxargs\fP utility shall write +a diagnostic message and exit without processing any remaining input. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +The 255 exit status allows a utility being used by \fIxargs\fP to +tell \fIxargs\fP to terminate if it knows no further +invocations using the current data stream will succeed. Thus, \fIutility\fP +should explicitly \fIexit\fP with an appropriate value to avoid accidentally +returning with 255. +.LP +Note that input is parsed as lines; <blank>s separate arguments. If +\fIxargs\fP is used to bundle output of commands like +\fIfind\fP \fIdir\fP \fB-print\fP or \fIls\fP into +commands to be executed, unexpected results are likely if any filenames +contain any <blank>s or <newline>s. This can be +fixed by using \fIfind\fP to call a script that converts each file +found into a quoted string +that is then piped to \fIxargs\fP. Note that the quoting rules used +by \fIxargs\fP are not the same as in the shell. They were +not made consistent here because existing applications depend on the +current rules and the shell syntax is not fully compatible +with it. An easy rule that can be used to transform any string into +a quoted form that \fIxargs\fP interprets correctly is to +precede each character in the string with a backslash. +.LP +On implementations with a large value for {ARG_MAX}, \fIxargs\fP may +produce command lines longer than {LINE_MAX}. For +invocation of utilities, this is not a problem. If \fIxargs\fP is +being used to create a text file, users should explicitly set +the maximum command line length with the \fB-s\fP option. +.LP +The \fIcommand\fP, \fIenv\fP, \fInice\fP, \fInohup\fP, \fItime\fP, +and \fIxargs\fP utilities have been specified to use exit code 127 +if an error occurs so +that applications can distinguish "failure to find a utility" from +"invoked utility exited with an error indication". The value +127 was chosen because it is not commonly used for other meanings; +most utilities use small values for "normal error conditions'' +and the values above 128 can be confused with termination due to receipt +of a signal. The value 126 was chosen in a similar manner +to indicate that the utility could be found, but not invoked. Some +scripts produce meaningful error messages differentiating the +126 and 127 cases. The distinction between exit codes 126 and 127 +is based on KornShell practice that uses 127 when all attempts to +\fIexec\fP the utility fail with [ENOENT], and uses 126 when any attempt +to \fIexec\fP the utility fails for any other +reason. +.SH EXAMPLES +.IP " 1." 4 +The following command combines the output of the parenthesised commands +onto one line, which is then written to the end-of-file +\fBlog\fP: +.sp +.RS +.nf + +\fB(logname; date; printf "%s\\n" "$0 $*") | xargs >>log +\fP +.fi +.RE +.LP +.IP " 2." 4 +The following command invokes \fIdiff\fP with successive pairs of +arguments originally +typed as command line arguments (assuming there are no embedded <blank>s +in the elements of the original argument list): +.sp +.RS +.nf + +\fBprintf "%s\\n" "$*" | xargs -n 2 -x diff +\fP +.fi +.RE +.LP +.IP " 3." 4 +In the following commands, the user is asked which files in the current +directory are to be archived. The files are archived +into \fBarch\fP; \fIa\fP, one at a time, or \fIb\fP, many at a time. +.sp +.RS +.nf + +\fBa. ls | xargs -p -L 1 ar -r arch +.sp + +b. ls | xargs -p -L 1 | xargs ar -r arch +\fP +.fi +.RE +.LP +.IP " 4." 4 +The following executes with successive pairs of arguments originally +typed as command line arguments: +.sp +.RS +.nf + +\fBecho $* | xargs -n 2 diff +\fP +.fi +.RE +.LP +.IP " 5." 4 +On XSI-conformant systems, the following moves all files from directory +\fB$1\fP to directory \fB$2\fP, and echoes each move +command just before doing it: +.sp +.RS +.nf + +\fBls $1 | xargs -I {} -t mv $1/{} $2/{} +\fP +.fi +.RE +.LP +.SH RATIONALE +.LP +The \fIxargs\fP utility was usually found only in System V-based systems; +BSD systems included an \fIapply\fP utility that +provided functionality similar to \fIxargs\fP \fB-n\fP \fInumber\fP. +The SVID lists \fIxargs\fP as a software development +extension. This volume of IEEE\ Std\ 1003.1-2001 does not share the +view that it is used only for development, and +therefore it is not optional. +.LP +The classic application of the \fIxargs\fP utility is in conjunction +with the \fIfind\fP +utility to reduce the number of processes launched by a simplistic +use of the \fIfind\fP +\fB-exec\fP combination. The \fIxargs\fP utility is also used to enforce +an upper limit on memory required to launch a process. +With this basis in mind, this volume of IEEE\ Std\ 1003.1-2001 selected +only the minimal features required. +.LP +Although the 255 exit status is mostly an accident of historical implementations, +it allows a utility being used by \fIxargs\fP +to tell \fIxargs\fP to terminate if it knows no further invocations +using the current data stream shall succeed. Any non-zero exit +status from a utility falls into the 1-125 range when \fIxargs\fP +exits. There is no statement of how the various non-zero utility +exit status codes are accumulated by \fIxargs\fP. The value could +be the addition of all codes, their highest value, the last one +received, or a single value such as 1. Since no algorithm is arguably +better than the others, and since many of the standard +utilities say little more (portably) than "pass/fail", no new algorithm +was invented. +.LP +Several other \fIxargs\fP options were withdrawn because simple alternatives +already exist within this volume of +IEEE\ Std\ 1003.1-2001. For example, the \fB-i\fP \fIreplstr\fP option +can be just as efficiently performed using a shell +\fBfor\fP loop. Since \fIxargs\fP calls an \fIexec\fP function with +each input line, the \fB-i\fP option does not usually +exploit the grouping capabilities of \fIxargs\fP. +.LP +The requirement that \fIxargs\fP never produces command lines such +that invocation of \fIutility\fP is within 2048 bytes of +hitting the POSIX \fIexec\fP {ARG_MAX} limitations is intended to +guarantee that the invoked utility has room to modify its +environment variables and command line arguments and still be able +to invoke another utility. Note that the minimum {ARG_MAX} +allowed by the System Interfaces volume of IEEE\ Std\ 1003.1-2001 +is 4096 bytes and the minimum value allowed by this +volume of IEEE\ Std\ 1003.1-2001 is 2048 bytes; therefore, the 2048 +bytes difference seems reasonable. Note, however, that +\fIxargs\fP may never be able to invoke a utility if the environment +passed in to \fIxargs\fP comes close to using {ARG_MAX} +bytes. +.LP +The version of \fIxargs\fP required by this volume of IEEE\ Std\ 1003.1-2001 +is required to wait for the completion of +the invoked command before invoking another command. This was done +because historical scripts using \fIxargs\fP assumed sequential +execution. Implementations wanting to provide parallel operation of +the invoked utilities are encouraged to add an option enabling +parallel invocation, but should still wait for termination of all +of the children before \fIxargs\fP terminates normally. +.LP +The \fB-e\fP option was omitted from the ISO\ POSIX-2:1993 standard +in the belief that the \fIeofstr\fP option-argument +was recognized only when it was on a line by itself and before quote +and escape processing were performed, and that the logical +end-of-file processing was only enabled if a \fB-e\fP option was specified. +In that case, a simple \fIsed\fP script could be used to duplicate +the \fB-e\fP functionality. Further investigation +revealed that: +.IP " *" 3 +The logical end-of-file string was checked for after quote and escape +processing, making a \fIsed\fP script that provided equivalent functionality +much more difficult to write. +.LP +.IP " *" 3 +The default was to perform logical end-of-file processing with an +underscore as the logical end-of-file string. +.LP +.LP +To correct this misunderstanding, the \fB-E\fP \fIeofstr\fP option +was adopted from the X/Open Portability Guide. Users should +note that the description of the \fB-E\fP option matches historical +documentation of the \fB-e\fP option (which was not adopted +because it did not support the Utility Syntax Guidelines), by saying +that if \fIeofstr\fP is the null string, logical end-of-file +processing is disabled. Historical implementations of \fIxargs\fP +actually did not disable logical end-of-file processing; they +treated a null argument found in the input as a logical end-of-file +string. (A null \fIstring\fP argument could be generated using +single or double quotes ( \fB''\fP or \fB""\fP ). Since this behavior +was not documented historically, it is considered to be +a bug. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIShell Command Language\fP , \fIecho\fP , \fIfind\fP , the System +Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIexec\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/yacc.1p b/man1p/yacc.1p new file mode 100644 index 000000000..bc80e4f22 --- /dev/null +++ b/man1p/yacc.1p @@ -0,0 +1,1285 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "YACC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" yacc +.SH NAME +yacc \- yet another compiler compiler (\fBDEVELOPMENT\fP) +.SH SYNOPSIS +.LP +\fByacc\fP \fB[\fP\fB-dltv\fP\fB][\fP\fB-b\fP \fIfile_prefix\fP\fB][\fP\fB-p\fP +\fIsym_prefix\fP\fB]\fP \fIgrammar\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIyacc\fP utility shall read a description of a context-free +grammar in \fIgrammar\fP and write C source code, conforming +to the ISO\ C standard, to a code file, and optionally header information +into a header file, in the current directory. The C +code shall define a function and related routines and macros for an +automaton that executes a parsing algorithm meeting the +requirements in Algorithms . +.LP +The form and meaning of the grammar are described in the EXTENDED +DESCRIPTION section. +.LP +The C source code and header file shall be produced in a form suitable +as input for the C compiler (see \fIc99\fP ). +.SH OPTIONS +.LP +The \fIyacc\fP utility shall conform to the Base Definitions volume +of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. +.LP +The following options shall be supported: +.TP 7 +\fB-b\ \fP \fIfile_prefix\fP +Use \fIfile_prefix\fP instead of \fBy\fP as the prefix for all output +filenames. The code file \fBy.tab.c\fP, the header +file \fBy.tab.h\fP (created when \fB-d\fP is specified), and the description +file \fBy.output\fP (created when \fB-v\fP is +specified), shall be changed to \fIfile_prefix\fP \fB.tab.c\fP, \fIfile_prefix\fP +\fB\&.tab.h\fP, and \fIfile_prefix\fP +\fB\&.output\fP, respectively. +.TP 7 +\fB-d\fP +Write the header file; by default only the code file is written. The +\fB#define\fP statements associate the token codes +assigned by \fIyacc\fP with the user-declared token names. This allows +source files other than \fBy.tab.c\fP to access the token +codes. +.TP 7 +\fB-l\fP +Produce a code file that does not contain any \fB#line\fP constructs. +If this option is not present, it is unspecified whether +the code file or header file contains \fB#line\fP directives. This +should only be used after the grammar and the associated +actions are fully debugged. +.TP 7 +\fB-p\ \fP \fIsym_prefix\fP +.sp +Use \fIsym_prefix\fP instead of \fByy\fP as the prefix for all external +names produced by \fIyacc\fP. The names affected shall +include the functions \fIyyparse\fP(), \fIyylex\fP(), and \fIyyerror\fP(), +and the variables \fIyylval\fP, \fIyychar\fP, and +\fIyydebug\fP. (In the remainder of this section, the six symbols +cited are referenced using their default names only as a +notational convenience.) Local names may also be affected by the \fB-p\fP +option; however, the \fB-p\fP option shall not affect +\fB#define\fP symbols generated by \fIyacc\fP. +.TP 7 +\fB-t\fP +Modify conditional compilation directives to permit compilation of +debugging code in the code file. Runtime debugging +statements shall always be contained in the code file, but by default +conditional compilation directives prevent their +compilation. +.TP 7 +\fB-v\fP +Write a file containing a description of the parser and a report of +conflicts generated by ambiguities in the grammar. +.sp +.SH OPERANDS +.LP +The following operand is required: +.TP 7 +\fIgrammar\fP +A pathname of a file containing instructions, hereafter called \fIgrammar\fP, +for which a parser is to be created. The format +for the grammar is described in the EXTENDED DESCRIPTION section. +.sp +.SH STDIN +.LP +Not used. +.SH INPUT FILES +.LP +The file \fIgrammar\fP shall be a text file formatted as specified +in the EXTENDED DESCRIPTION section. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIyacc\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments and input files). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.LP +The \fILANG\fP and \fILC_*\fP variables affect the execution of the +\fIyacc\fP utility as stated. The \fImain\fP() function +defined in Yacc Library shall call: +.sp +.RS +.nf + +\fBsetlocale(LC_ALL, "") +\fP +.fi +.RE +.LP +and thus the program generated by \fIyacc\fP shall also be affected +by the contents of these variables at runtime. +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +Not used. +.SH STDERR +.LP +If shift/reduce or reduce/reduce conflicts are detected in \fIgrammar\fP, +\fIyacc\fP shall write a report of those conflicts +to the standard error in an unspecified format. +.LP +Standard error shall also be used for diagnostic messages. +.SH OUTPUT FILES +.LP +The code file, the header file, and the description file shall be +text files. All are described in the following sections. +.SS Code File +.LP +This file shall contain the C source code for the \fIyyparse\fP() +function. It shall contain code for the various semantic +actions with macro substitution performed on them as described in +the EXTENDED DESCRIPTION section. It also shall contain a copy of +the \fB#define\fP statements in the header file. If a \fB%union\fP +declaration is used, the declaration for YYSTYPE shall also be +included in this file. +.SS Header File +.LP +The header file shall contain \fB#define\fP statements that associate +the token numbers with the token names. This allows +source files other than the code file to access the token codes. If +a \fB%union\fP declaration is used, the declaration for +YYSTYPE and an \fIextern YYSTYPE yylval\fP declaration shall also +be included in this file. +.SS Description File +.LP +The description file shall be a text file containing a description +of the state machine corresponding to the parser, using an +unspecified format. Limits for internal tables (see Limits ) shall +also be reported, in an +implementation-defined manner. (Some implementations may use dynamic +allocation techniques and have no specific limit values to +report.) +.SH EXTENDED DESCRIPTION +.LP +The \fIyacc\fP command accepts a language that is used to define a +grammar for a target language to be parsed by the tables and +code generated by \fIyacc\fP. The language accepted by \fIyacc\fP +as a grammar for the target language is described below using +the \fIyacc\fP input language itself. +.LP +The input \fIgrammar\fP includes rules describing the input structure +of the target language and code to be invoked when these +rules are recognized to provide the associated semantic action. The +code to be executed shall appear as bodies of text that are +intended to be C-language code. The C-language inclusions are presumed +to form a correct function when processed by \fIyacc\fP +into its output files. The code included in this way shall be executed +during the recognition of the target language. +.LP +Given a grammar, the \fIyacc\fP utility generates the files described +in the OUTPUT FILES section. The code file can be +compiled and linked using \fIc99\fP. If the declaration and programs +sections of the grammar +file did not include definitions of \fImain\fP(), \fIyylex\fP(), and +\fIyyerror\fP(), the compiled output requires linking with +externally supplied versions of those functions. Default versions +of \fImain\fP() and \fIyyerror\fP() are supplied in the +\fIyacc\fP library and can be linked in by using the \fB-l\ y\fP operand +to \fIc99\fP. +The \fIyacc\fP library interfaces need not support interfaces with +other than the default \fByy\fP symbol prefix. The application +provides the lexical analyzer function, \fIyylex\fP(); the \fIlex\fP +utility is specifically +designed to generate such a routine. +.SS Input Language +.LP +The application shall ensure that every specification file consists +of three sections in order: \fIdeclarations\fP, \fIgrammar +rules\fP, and \fIprograms\fP, separated by double percent signs ( +\fB"%%"\fP ). The declarations and programs sections can be +empty. If the latter is empty, the preceding \fB"%%"\fP mark separating +it from the rules section can be omitted. +.LP +The input is free form text following the structure of the grammar +defined below. +.SS Lexical Structure of the Grammar +.LP +The <blank>s, <newline>s, and <form-feed>s shall be ignored, except +that the application shall ensure that +they do not appear in names or multi-character reserved symbols. Comments +shall be enclosed in \fB"/*\ ...\ */"\fP , and +can appear wherever a name is valid. +.LP +Names are of arbitrary length, made up of letters, periods ( \fB'.'\fP +), underscores ( \fB'_'\fP ), and non-initial +digits. Uppercase and lowercase letters are distinct. Conforming applications +shall not use names beginning in \fByy\fP or +\fBYY\fP since the \fIyacc\fP parser uses such names. Many of the +names appear in the final output of \fIyacc\fP, and thus they +should be chosen to conform with any additional rules created by the +C compiler to be used. In particular they appear in +\fB#define\fP statements. +.LP +A literal shall consist of a single character enclosed in single-quotes +( \fB'"\fP ). All of the escape sequences supported +for character constants by the ISO\ C standard shall be supported +by \fIyacc\fP. +.LP +The relationship with the lexical analyzer is discussed in detail +below. +.LP +The application shall ensure that the NUL character is not used in +grammar rules or literals. +.SS Declarations Section +.LP +The declarations section is used to define the symbols used to define +the target language and their relationship with each +other. In particular, much of the additional information required +to resolve ambiguities in the context-free grammar for the target +language is provided here. +.LP +Usually \fIyacc\fP assigns the relationship between the symbolic names +it generates and their underlying numeric value. The +declarations section makes it possible to control the assignment of +these values. +.LP +It is also possible to keep semantic information associated with the +tokens currently on the parse stack in a user-defined +C-language \fBunion\fP, if the members of the union are associated +with the various names in the grammar. The declarations section +provides for this as well. +.LP +The first group of declarators below all take a list of names as arguments. +That list can optionally be preceded by the name of +a C union member (called a \fItag\fP below) appearing within \fB'<'\fP +and \fB'>'\fP . (As an exception to the +typographical conventions of the rest of this volume of IEEE\ Std\ 1003.1-2001, +in this case <\fItag\fP> does not +represent a metavariable, but the literal angle bracket characters +surrounding a symbol.) The use of \fItag\fP specifies that the +tokens named on this line shall be of the same C type as the union +member referenced by \fItag\fP. This is discussed in more +detail below. +.LP +For lists used to define tokens, the first appearance of a given token +can be followed by a positive integer (as a string of +decimal digits). If this is done, the underlying value assigned to +it for lexical purposes shall be taken to be that number. +.LP +The following declares \fIname\fP to be a token: +.sp +.RS +.nf + +\fB%token\fP \fB[\fP\fB<\fP\fItag\fP\fB>\fP\fB]\fP \fIname\fP \fB[\fP\fInumber\fP\fB][\fP\fIname\fP \fB[\fP\fInumber\fP\fB]]\fP\fB... +\fP +.fi +.RE +.LP +If \fItag\fP is present, the C type for all tokens on this line shall +be declared to be the type referenced by \fItag\fP. If a +positive integer, \fInumber\fP, follows a \fIname\fP, that value shall +be assigned to the token. +.LP +The following declares \fIname\fP to be a token, and assigns precedence +to it: +.sp +.RS +.nf + +\fB%left\fP \fB[\fP\fB<\fP\fItag\fP\fB>\fP\fB]\fP \fIname\fP \fB[\fP\fInumber\fP\fB][\fP\fIname\fP \fB[\fP\fInumber\fP\fB]]\fP\fB... +%right\fP \fB[\fP\fB<\fP\fItag\fP\fB>\fP\fB]\fP \fIname\fP \fB[\fP\fInumber\fP\fB][\fP\fIname\fP \fB[\fP\fInumber\fP\fB]]\fP\fB... +\fP +.fi +.RE +.LP +One or more lines, each beginning with one of these symbols, can appear +in this section. All tokens on the same line have the +same precedence level and associativity; the lines are in order of +increasing precedence or binding strength. \fB%left\fP denotes +that the operators on that line are left associative, and \fB%right\fP +similarly denotes right associative operators. If +\fItag\fP is present, it shall declare a C type for \fIname\fPs as +described for \fB%token\fP. +.LP +The following declares \fIname\fP to be a token, and indicates that +this cannot be used associatively: +.sp +.RS +.nf + +\fB%nonassoc\fP \fB[\fP\fB<\fP\fItag\fP\fB>\fP\fB]\fP \fIname\fP \fB[\fP\fInumber\fP\fB][\fP\fIname\fP \fB[\fP\fInumber\fP\fB]]\fP\fB... +\fP +.fi +.RE +.LP +If the parser encounters associative use of this token it reports +an error. If \fItag\fP is present, it shall declare a C type +for \fIname\fPs as described for \fB%token\fP. +.LP +The following declares that union member \fIname\fPs are non-terminals, +and thus it is required to have a \fItag\fP field at +its beginning: +.sp +.RS +.nf + +\fB%type <\fP\fItag\fP\fB>\fP \fIname\fP\fB... +\fP +.fi +.RE +.LP +Because it deals with non-terminals only, assigning a token number +or using a literal is also prohibited. If this construct is +present, \fIyacc\fP shall perform type checking; if this construct +is not present, the parse stack shall hold only the \fBint\fP +type. +.LP +Every name used in \fIgrammar\fP not defined by a \fB%token\fP, \fB%left\fP, +\fB%right\fP, or \fB%nonassoc\fP declaration +is assumed to represent a non-terminal symbol. The \fIyacc\fP utility +shall report an error for any non-terminal symbol that does +not appear on the left side of at least one grammar rule. +.LP +Once the type, precedence, or token number of a name is specified, +it shall not be changed. If the first declaration of a token +does not assign a token number, \fIyacc\fP shall assign a token number. +Once this assignment is made, the token number shall not +be changed by explicit assignment. +.LP +The following declarators do not follow the previous pattern. +.LP +The following declares the non-terminal \fIname\fP to be the \fIstart +symbol\fP, which represents the largest, most general +structure described by the grammar rules: +.sp +.RS +.nf + +\fB%start\fP \fIname\fP +.fi +.RE +.LP +By default, it is the left-hand side of the first grammar rule; this +default can be overridden with this declaration. +.LP +The following declares the \fIyacc\fP value stack to be a union of +the various types of values desired: +.sp +.RS +.nf + +\fB%union {\fP \fIbody of union\fP \fB(\fP\fIin C\fP\fB) } +\fP +.fi +.RE +.LP +By default, the values returned by actions (see below) and the lexical +analyzer shall be of type \fBint\fP. The \fIyacc\fP +utility keeps track of types, and it shall insert corresponding union +member names in order to perform strict type checking of the +resulting parser. +.LP +Alternatively, given that at least one <\fItag\fP> construct is used, +the union can be declared in a header file (which +shall be included in the declarations section by using a \fB#include\fP +construct within \fB%{\fP and \fB%}\fP), and a +\fBtypedef\fP used to define the symbol YYSTYPE to represent this +union. The effect of \fB%union\fP is to provide the declaration +of YYSTYPE directly from the \fIyacc\fP input. +.LP +C-language declarations and definitions can appear in the declarations +section, enclosed by the following marks: +.sp +.RS +.nf + +\fB%{ ... %} +\fP +.fi +.RE +.LP +These statements shall be copied into the code file, and have global +scope within it so that they can be used in the rules and +program sections. +.LP +The application shall ensure that the declarations section is terminated +by the token \fB%%\fP. +.SS Grammar Rules in yacc +.LP +The rules section defines the context-free grammar to be accepted +by the function \fIyacc\fP generates, and associates with +those rules C-language actions and additional precedence information. +The grammar is described below, and a formal definition +follows. +.LP +The rules section is comprised of one or more grammar rules. A grammar +rule has the form: +.sp +.RS +.nf + +\fBA : BODY ; +\fP +.fi +.RE +.LP +The symbol \fBA\fP represents a non-terminal name, and \fBBODY\fP +represents a sequence of zero or more \fIname\fPs, +\fIliteral\fPs, and \fIsemantic action\fPs that can then be followed +by optional \fIprecedence rule\fPs. Only the names and +literals participate in the formation of the grammar; the semantic +actions and precedence rules are used in other ways. The colon +and the semicolon are \fIyacc\fP punctuation. If there are several +successive grammar rules with the same left-hand side, the +vertical bar \fB'|'\fP can be used to avoid rewriting the left-hand +side; in this case the semicolon appears only after the last +rule. The BODY part can be empty (or empty of names and literals) +to indicate that the non-terminal symbol matches the empty +string. +.LP +The \fIyacc\fP utility assigns a unique number to each rule. Rules +using the vertical bar notation are distinct rules. The +number assigned to the rule appears in the description file. +.LP +The elements comprising a BODY are: +.TP 7 +\fIname\fP,\ \fIliteral\fP +These form the rules of the grammar: \fIname\fP is either a \fItoken\fP +or a \fInon-terminal\fP; \fIliteral\fP stands for +itself (less the lexically required quotation marks). +.TP 7 +\fIsemantic action\fP +.sp +With each grammar rule, the user can associate actions to be performed +each time the rule is recognized in the input process. (Note +that the word "action" can also refer to the actions of the parser-shift, +reduce, and so on.) +.LP +These actions can return values and can obtain the values returned +by previous actions. These values are kept in objects of type +YYSTYPE (see \fB%union\fP). The result value of the action shall be +kept on the parse stack with the left-hand side of the rule, +to be accessed by other reductions as part of their right-hand side. +By using the <\fItag\fP> information provided in the +declarations section, the code generated by \fIyacc\fP can be strictly +type checked and contain arbitrary information. In +addition, the lexical analyzer can provide the same kinds of values +for tokens, if desired. +.LP +An action is an arbitrary C statement and as such can do input or +output, call subprograms, and alter external variables. An +action is one or more C statements enclosed in curly braces \fB'{'\fP +and \fB'}'\fP . +.LP +Certain pseudo-variables can be used in the action. These are macros +for access to data structures known internally to +\fIyacc\fP. +.TP 7 +$$ +.RS +The value of the action can be set by assigning it to $$. If type +checking is enabled and the type of the value to be assigned +cannot be determined, a diagnostic message may be generated. +.RE +.TP 7 +$\fInumber\fP +.RS +This refers to the value returned by the component specified by the +token \fInumber\fP in the right side of a rule, reading +from left to right; \fInumber\fP can be zero or negative. If \fInumber\fP +is zero or negative, it refers to the data associated +with the name on the parser's stack preceding the leftmost symbol +of the current rule. (That is, \fB"$0"\fP refers to the name +immediately preceding the leftmost name in the current rule to be +found on the parser's stack and \fB"$-1"\fP refers to the +symbol to \fIits\fP left.) If \fInumber\fP refers to an element past +the current point in the rule, or beyond the bottom of the +stack, the result is undefined. If type checking is enabled and the +type of the value to be assigned cannot be determined, a +diagnostic message may be generated. +.RE +.TP 7 +$<\fItag\fP>\fInumber\fP +.RS +.sp +These correspond exactly to the corresponding symbols without the +\fItag\fP inclusion, but allow for strict type checking (and +preclude unwanted type conversions). The effect is that the macro +is expanded to use \fItag\fP to select an element from the +YYSTYPE union (using \fIdataname.tag\fP). This is particularly useful +if \fInumber\fP is not positive. +.RE +.TP 7 +$<\fItag\fP>$ +.RS +This imposes on the reference the type of the union member referenced +by \fItag\fP. This construction is applicable when a +reference to a left context value occurs in the grammar, and provides +\fIyacc\fP with a means for selecting a type. +.RE +.sp +.LP +Actions can occur anywhere in a rule (not just at the end); an action +can access values returned by actions to its left, and in +turn the value it returns can be accessed by actions to its right. +An action appearing in the middle of a rule shall be equivalent +to replacing the action with a new non-terminal symbol and adding +an empty rule with that non-terminal symbol on the left-hand +side. The semantic action associated with the new rule shall be equivalent +to the original action. The use of actions within rules +might introduce conflicts that would not otherwise exist. +.LP +By default, the value of a rule shall be the value of the first element +in it. If the first element does not have a type +(particularly in the case of a literal) and type checking is turned +on by \fB%type\fP, an error message shall result. +.TP 7 +\fIprecedence\fP +The keyword \fB%prec\fP can be used to change the precedence level +associated with a particular grammar rule. Examples of this +are in cases where a unary and binary operator have the same symbolic +representation, but need to be given different precedences, +or where the handling of an ambiguous if-else construction is necessary. +The reserved symbol \fB%prec\fP can appear immediately +after the body of the grammar rule and can be followed by a token +name or a literal. It shall cause the precedence of the grammar +rule to become that of the following token name or literal. The action +for the rule as a whole can follow \fB%prec\fP. +.sp +.LP +If a program section follows, the application shall ensure that the +grammar rules are terminated by \fB%%\fP. +.SS Programs Section +.LP +The \fIprograms\fP section can include the definition of the lexical +analyzer \fIyylex\fP(), and any other functions; for +example, those used in the actions specified in the grammar rules. +It is unspecified whether the programs section precedes or +follows the semantic actions in the output file; therefore, if the +application contains any macro definitions and declarations +intended to apply to the code in the semantic actions, it shall place +them within \fB"%{\ ...\ %}"\fP in the +declarations section. +.SS Input Grammar +.LP +The following input to \fIyacc\fP yields a parser for the input to +\fIyacc\fP. This formal syntax takes precedence over the +preceding text syntax description. +.LP +The lexical structure is defined less precisely; Lexical Structure +of the Grammar defines most +terms. The correspondence between the previous terms and the tokens +below is as follows. +.TP 7 +\fBIDENTIFIER\fP +This corresponds to the concept of \fIname\fP, given previously. It +also includes literals as defined previously. +.TP 7 +\fBC_IDENTIFIER\fP +This is a name, and additionally it is known to be followed by a colon. +A literal cannot yield this token. +.TP 7 +\fBNUMBER\fP +A string of digits (a non-negative decimal integer). +.TP 7 +\fBTYPE\fP,\ \fBLEFT\fP,\ \fBMARK\fP,\ \fBLCURL\fP,\ \fBRCURL\fP +.sp +These correspond directly to \fB%type\fP, \fB%left\fP, \fB%%\fP, \fB%{\fP, +and \fB%}\fP. +.TP 7 +\fB{\ ...\ }\fP +This indicates C-language source code, with the possible inclusion +of \fB'$'\fP macros as discussed previously. +.sp +.sp +.RS +.nf + +\fB/* Grammar for the input to yacc. */ +/* Basic entries. */ +/* The following are recognized by the lexical analyzer. */ +.sp + +%token IDENTIFIER /* Includes identifiers and literals */ +%token C_IDENTIFIER /* identifier (but not literal) + followed by a :. */ +%token NUMBER /* [0-9][0-9]* */ +.sp + +/* Reserved words : %type=>TYPE %left=>LEFT, and so on */ +.sp + +%token LEFT RIGHT NONASSOC TOKEN PREC TYPE START UNION +.sp + +%token MARK /* The %% mark. */ +%token LCURL /* The %{ mark. */ +%token RCURL /* The %} mark. */ +.sp + +/* 8-bit character literals stand for themselves; */ +/* tokens have to be defined for multi-byte characters. */ +.sp + +%start spec +.sp + +%% +.sp + +spec : defs MARK rules tail + ; +tail : MARK + { + /* In this action, set up the rest of the file. */ + } + | /* Empty; the second MARK is optional. */ + ; +defs : /* Empty. */ + | defs def + ; +def : START IDENTIFIER + | UNION + { + /* Copy union definition to output. */ + } + | LCURL + { + /* Copy C code to output file. */ + } + RCURL + | rword tag nlist + ; +rword : TOKEN + | LEFT + | RIGHT + | NONASSOC + | TYPE + ; +tag : /* Empty: union tag ID optional. */ + | '<' IDENTIFIER '>' + ; +nlist : nmno + | nlist nmno + ; +nmno : IDENTIFIER /* Note: literal invalid with % type. */ + | IDENTIFIER NUMBER /* Note: invalid with % type. */ + ; +.sp + +/* Rule section */ +.sp + +rules : C_IDENTIFIER rbody prec + | rules rule + ; +rule : C_IDENTIFIER rbody prec + | '|' rbody prec + ; +rbody : /* empty */ + | rbody IDENTIFIER + | rbody act + ; +act : '{' + { + /* Copy action, translate $$, and so on. */ + } + '}' + ; +prec : /* Empty */ + | PREC IDENTIFIER + | PREC IDENTIFIER act + | prec ';' + ; +\fP +.fi +.RE +.SS Conflicts +.LP +The parser produced for an input grammar may contain states in which +conflicts occur. The conflicts occur because the grammar is +not LALR(1). An ambiguous grammar always contains at least one LALR(1) +conflict. The \fIyacc\fP utility shall resolve all +conflicts, using either default rules or user-specified precedence +rules. +.LP +Conflicts are either shift/reduce conflicts or reduce/reduce conflicts. +A shift/reduce conflict is where, for a given state and +lookahead symbol, both a shift action and a reduce action are possible. +A reduce/reduce conflict is where, for a given state and +lookahead symbol, reductions by two different rules are possible. +.LP +The rules below describe how to specify what actions to take when +a conflict occurs. Not all shift/reduce conflicts can be +successfully resolved this way because the conflict may be due to +something other than ambiguity, so incautious use of these +facilities can cause the language accepted by the parser to be much +different from that which was intended. The description file +shall contain sufficient information to understand the cause of the +conflict. Where ambiguity is the reason either the default or +explicit rules should be adequate to produce a working parser. +.LP +The declared precedences and associativities (see Declarations Section +) are used to resolve +parsing conflicts as follows: +.IP " 1." 4 +A precedence and associativity is associated with each grammar rule; +it is the precedence and associativity of the last token or +literal in the body of the rule. If the \fB%prec\fP keyword is used, +it overrides this default. Some grammar rules might not have +both precedence and associativity. +.LP +.IP " 2." 4 +If there is a shift/reduce conflict, and both the grammar rule and +the input symbol have precedence and associativity associated +with them, then the conflict is resolved in favor of the action (shift +or reduce) associated with the higher precedence. If the +precedences are the same, then the associativity is used; left associative +implies reduce, right associative implies shift, and +non-associative implies an error in the string being parsed. +.LP +.IP " 3." 4 +When there is a shift/reduce conflict that cannot be resolved by rule +2, the shift is done. Conflicts resolved this way are +counted in the diagnostic output described in Error Handling . +.LP +.IP " 4." 4 +When there is a reduce/reduce conflict, a reduction is done by the +grammar rule that occurs earlier in the input sequence. +Conflicts resolved this way are counted in the diagnostic output described +in Error Handling . +.LP +.LP +Conflicts resolved by precedence or associativity shall not be counted +in the shift/reduce and reduce/reduce conflicts reported +by \fIyacc\fP on either standard error or in the description file. +.SS Error Handling +.LP +The token \fBerror\fP shall be reserved for error handling. The name +\fBerror\fP can be used in grammar rules. It indicates +places where the parser can recover from a syntax error. The default +value of \fBerror\fP shall be 256. Its value can be changed +using a \fB%token\fP declaration. The lexical analyzer should not +return the value of \fBerror\fP. +.LP +The parser shall detect a syntax error when it is in a state where +the action associated with the lookahead symbol is +\fBerror\fP. A semantic action can cause the parser to initiate error +handling by executing the macro YYERROR. When YYERROR is +executed, the semantic action passes control back to the parser. YYERROR +cannot be used outside of semantic actions. +.LP +When the parser detects a syntax error, it normally calls \fIyyerror\fP() +with the character string +\fB"syntax\ error"\fP as its argument. The call shall not be made +if the parser is still recovering from a previous error +when the error is detected. The parser is considered to be recovering +from a previous error until the parser has shifted over at +least three normal input symbols since the last error was detected +or a semantic action has executed the macro \fIyyerrok\fP. The +parser shall not call \fIyyerror\fP() when YYERROR is executed. +.LP +The macro function YYRECOVERING shall return 1 if a syntax error has +been detected and the parser has not yet fully recovered +from it. Otherwise, zero shall be returned. +.LP +When a syntax error is detected by the parser, the parser shall check +if a previous syntax error has been detected. If a +previous error was detected, and if no normal input symbols have been +shifted since the preceding error was detected, the parser +checks if the lookahead symbol is an endmarker (see Interface to the +Lexical Analyzer ). If it is, +the parser shall return with a non-zero value. Otherwise, the lookahead +symbol shall be discarded and normal parsing shall +resume. +.LP +When YYERROR is executed or when the parser detects a syntax error +and no previous error has been detected, or at least one +normal input symbol has been shifted since the previous error was +detected, the parser shall pop back one state at a time until the +parse stack is empty or the current state allows a shift over \fBerror\fP. +If the parser empties the parse stack, it shall return +with a non-zero value. Otherwise, it shall shift over \fBerror\fP +and then resume normal parsing. If the parser reads a lookahead +symbol before the error was detected, that symbol shall still be the +lookahead symbol when parsing is resumed. +.LP +The macro \fIyyerrok\fP in a semantic action shall cause the parser +to act as if it has fully recovered from any previous +errors. The macro \fIyyclearin\fP shall cause the parser to discard +the current lookahead token. If the current lookahead token +has not yet been read, \fIyyclearin\fP shall have no effect. +.LP +The macro YYACCEPT shall cause the parser to return with the value +zero. The macro YYABORT shall cause the parser to return with +a non-zero value. +.SS Interface to the Lexical Analyzer +.LP +The \fIyylex\fP() function is an integer-valued function that returns +a \fItoken number\fP representing the kind of token +read. If there is a value associated with the token returned by \fIyylex\fP() +(see the discussion of \fItag\fP above), it shall +be assigned to the external variable \fIyylval\fP. +.LP +If the parser and \fIyylex\fP() do not agree on these token numbers, +reliable communication between them cannot occur. For +(single-byte character) literals, the token is simply the numeric +value of the character in the current character set. The numbers +for other tokens can either be chosen by \fIyacc\fP, or chosen by +the user. In either case, the \fB#define\fP construct of C is +used to allow \fIyylex\fP() to return these numbers symbolically. +The \fB#define\fP statements are put into the code file, and +the header file if that file is requested. The set of characters permitted +by \fIyacc\fP in an identifier is larger than that +permitted by C. Token names found to contain such characters shall +not be included in the \fB#define\fP declarations. +.LP +If the token numbers are chosen by \fIyacc\fP, the tokens other than +literals shall be assigned numbers greater than 256, +although no order is implied. A token can be explicitly assigned a +number by following its first appearance in the declarations +section with a number. Names and literals not defined this way retain +their default definition. All token numbers assigned by +\fIyacc\fP shall be unique and distinct from the token numbers used +for literals and user-assigned tokens. If duplicate token +numbers cause conflicts in parser generation, \fIyacc\fP shall report +an error; otherwise, it is unspecified whether the token +assignment is accepted or an error is reported. +.LP +The end of the input is marked by a special token called the \fIendmarker\fP, +which has a token number that is zero or +negative. (These values are invalid for any other token.) All lexical +analyzers shall return zero or negative as a token number +upon reaching the end of their input. If the tokens up to, but excluding, +the endmarker form a structure that matches the start +symbol, the parser shall accept the input. If the endmarker is seen +in any other context, it shall be considered an error. +.SS Completing the Program +.LP +In addition to \fIyyparse\fP() and \fIyylex\fP(), the functions \fIyyerror\fP() +and \fImain\fP() are required to make a +complete program. The application can supply \fImain\fP() and \fIyyerror\fP(), +or those routines can be obtained from the +\fIyacc\fP library. +.SS Yacc Library +.LP +The following functions shall appear only in the \fIyacc\fP library +accessible through the \fB-l\ y\fP operand to \fIc99\fP; they can +therefore be redefined by a conforming application: +.TP 7 +\fBint\ \fP \fImain\fP(\fBvoid\fP) +.sp +This function shall call \fIyyparse\fP() and exit with an unspecified +value. Other actions within this function are +unspecified. +.TP 7 +\fBint\ \fP \fIyyerror\fP(\fBconst\ char\fP\ *\fIs\fP) +.sp +This function shall write the NUL-terminated argument to standard +error, followed by a <newline>. +.sp +.LP +The order of the \fB-l\ y\fP and \fB-l\ l\fP operands given to \fIc99\fP +is +significant; the application shall either provide its own \fImain\fP() +function or ensure that \fB-l\ y\fP precedes +\fB-l\ l\fP. +.SS Debugging the Parser +.LP +The parser generated by \fIyacc\fP shall have diagnostic facilities +in it that can be optionally enabled at either compile time +or at runtime (if enabled at compile time). The compilation of the +runtime debugging code is under the control of YYDEBUG, a +preprocessor symbol. If YYDEBUG has a non-zero value, the debugging +code shall be included. If its value is zero, the code shall +not be included. +.LP +In parsers where the debugging code has been included, the external +\fBint\fP \fIyydebug\fP can be used to turn debugging on +(with a non-zero value) and off (zero value) at runtime. The initial +value of \fIyydebug\fP shall be zero. +.LP +When \fB-t\fP is specified, the code file shall be built such that, +if YYDEBUG is not already defined at compilation time +(using the \fIc99\fP \fB-D\fP YYDEBUG option, for example), YYDEBUG +shall be set explicitly +to 1. When \fB-t\fP is not specified, the code file shall be built +such that, if YYDEBUG is not already defined, it shall be set +explicitly to zero. +.LP +The format of the debugging output is unspecified but includes at +least enough information to determine the shift and reduce +actions, and the input symbols. It also provides information about +error recovery. +.SS Algorithms +.LP +The parser constructed by \fIyacc\fP implements an LALR(1) parsing +algorithm as documented in the literature. It is unspecified +whether the parser is table-driven or direct-coded. +.LP +A parser generated by \fIyacc\fP shall never request an input symbol +from \fIyylex\fP() while in a state where the only +actions other than the error action are reductions by a single rule. +.LP +The literature of parsing theory defines these concepts. +.SS Limits +.LP +The \fIyacc\fP utility may have several internal tables. The minimum +maximums for these tables are shown in the following +table. The exact meaning of these values is implementation-defined. +The implementation shall define the relationship between these +values and between them and any error messages that the implementation +may generate should it run out of space for any internal +structure. An implementation may combine groups of these resources +into a single pool as long as the total available to the user +does not fall below the sum of the sizes specified by this section. +.br +.sp +.ce 1 +\fBTable: Internal Limits in \fIyacc\fP\fP +.TS C +center; l l lw(40). +\fB\ \fP \fBMinimum\fP T{ +.na +\fB\ \fP +.ad +T} +\fBLimit\fP \fBMaximum\fP T{ +.na +\fBDescription\fP +.ad +T} +{NTERMS} 126 T{ +.na +Number of tokens. +.ad +T} +{NNONTERM} 200 T{ +.na +Number of non-terminals. +.ad +T} +{NPROD} 300 T{ +.na +Number of rules. +.ad +T} +{NSTATES} 600 T{ +.na +Number of states. +.ad +T} +{MEMSIZE} 5200 T{ +.na +Length of rules. The total length, in names (tokens and non-terminals), of all the rules of the grammar. The left-hand side is counted for each rule, even if it is not explicitly repeated, as specified in Grammar Rules in yacc . +.ad +T} +{ACTSIZE} 4000 T{ +.na +Number of actions. "Actions" here (and in the description file) refer to parser actions (shift, reduce, and so on) not to semantic actions defined in Grammar Rules in yacc . +.ad +T} +.TE +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +If any errors are encountered, the run is aborted and \fIyacc\fP exits +with a non-zero status. Partial code files and header +files may be produced. The summary information in the description +file shall always be produced if the \fB-v\fP flag is +present. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +Historical implementations experience name conflicts on the names +\fByacc.tmp\fP, \fByacc.acts\fP, \fByacc.debug\fP, +\fBy.tab.c\fP, \fBy.tab.h\fP, and \fBy.output\fP if more than one +copy of \fIyacc\fP is running in a single directory at one +time. The \fB-b\fP option was added to overcome this problem. The +related problem of allowing multiple \fIyacc\fP parsers to be +placed in the same file was addressed by adding a \fB-p\fP option +to override the previously hard-coded \fByy\fP variable +prefix. +.LP +The description of the \fB-p\fP option specifies the minimal set of +function and variable names that cause conflict when +multiple parsers are linked together. YYSTYPE does not need to be +changed. Instead, the programmer can use \fB-b\fP to give the +header files for different parsers different names, and then the file +with the \fIyylex\fP() for a given parser can include the +header for that parser. Names such as \fIyyclearerr\fP do not need +to be changed because they are used only in the actions; they +do not have linkage. It is possible that an implementation has other +names, either internal ones for implementing things such as +\fIyyclearerr\fP, or providing non-standard features that it wants +to change with \fB-p\fP. +.LP +Unary operators that are the same token as a binary operator in general +need their precedence adjusted. This is handled by the +\fB%prec\fP advisory symbol associated with the particular grammar +rule defining that unary operator. (See Grammar Rules in yacc .) Applications +are not required to use this operator for unary operators, but the +grammars that do not require it are rare. +.SH EXAMPLES +.LP +Access to the \fIyacc\fP library is obtained with library search operands +to \fIc99\fP. To +use the \fIyacc\fP library \fImain\fP(): +.sp +.RS +.nf + +\fBc99 y.tab.c -l y +\fP +.fi +.RE +.LP +Both the \fIlex\fP library and the \fIyacc\fP library contain \fImain\fP(). +To access the +\fIyacc\fP \fImain\fP(): +.sp +.RS +.nf + +\fBc99 y.tab.c lex.yy.c -l y -l l +\fP +.fi +.RE +.LP +This ensures that the \fIyacc\fP library is searched first, so that +its \fImain\fP() is used. +.LP +The historical \fIyacc\fP libraries have contained two simple functions +that are normally coded by the application programmer. +These functions are similar to the following code: +.sp +.RS +.nf + +\fB#include <locale.h> +int main(void) +{ + extern int yyparse(); +.sp + + setlocale(LC_ALL, ""); +.sp + + /* If the following parser is one created by lex, the + application must be careful to ensure that LC_CTYPE + and LC_COLLATE are set to the POSIX locale. */ + (void) yyparse(); + return (0); +} +.sp + +#include <stdio.h> +.sp + +int yyerror(const char *msg) +{ + (void) fprintf(stderr, "%s\\n", msg); + return (0); +} +\fP +.fi +.RE +.SH RATIONALE +.LP +The references in may be helpful in constructing the parser generator. +The referenced DeRemer and Pennello article (along with +the works it references) describes a technique to generate parsers +that conform to this volume of IEEE\ Std\ 1003.1-2001. +Work in this area continues to be done, so implementors should consult +current literature before doing any new implementations. The +original Knuth article is the theoretical basis for this kind of parser, +but the tables it generates are impractically large for +reasonable grammars and should not be used. The "equivalent to" wording +is intentional to assure that the best tables that are +LALR(1) can be generated. +.LP +There has been confusion between the class of grammars, the algorithms +needed to generate parsers, and the algorithms needed to +parse the languages. They are all reasonably orthogonal. In particular, +a parser generator that accepts the full range of LR(1) +grammars need not generate a table any more complex than one that +accepts SLR(1) (a relatively weak class of LR grammars) for a +grammar that happens to be SLR(1). Such an implementation need not +recognize the case, either; table compression can yield the +SLR(1) table (or one even smaller than that) without recognizing that +the grammar is SLR(1). The speed of an LR(1) parser for any +class is dependent more upon the table representation and compression +(or the code generation if a direct parser is generated) than +upon the class of grammar that the table generator handles. +.LP +The speed of the parser generator is somewhat dependent upon the class +of grammar it handles. However, the original Knuth +article algorithms for constructing LR parsers were judged by its +author to be impractically slow at that time. Although full LR is +more complex than LALR(1), as computer speeds and algorithms improve, +the difference (in terms of acceptable wall-clock execution +time) is becoming less significant. +.LP +Potential authors are cautioned that the referenced DeRemer and Pennello +article previously cited identifies a bug (an +over-simplification of the computation of LALR(1) lookahead sets) +in some of the LALR(1) algorithm statements that preceded it to +publication. They should take the time to seek out that paper, as +well as current relevant work, particularly Aho's. +.LP +The \fB-b\fP option was added to provide a portable method for permitting +\fIyacc\fP to work on multiple separate parsers in +the same directory. If a directory contains more than one \fIyacc\fP +grammar, and both grammars are constructed at the same time +(by, for example, a parallel \fImake\fP program), conflict results. +While the solution is not +historical practice, it corrects a known deficiency in historical +implementations. Corresponding changes were made to all sections +that referenced the filenames \fBy.tab.c\fP (now "the code file"), +\fBy.tab.h\fP (now "the header file"), and \fBy.output\fP +(now "the description file"). +.LP +The grammar for \fIyacc\fP input is based on System V documentation. +The textual description shows there that the \fB';'\fP +is required at the end of the rule. The grammar and the implementation +do not require this. (The use of \fBC_IDENTIFIER\fP causes +a reduce to occur in the right place.) +.LP +Also, in that implementation, the constructs such as \fB%token\fP +can be terminated by a semicolon, but this is not permitted +by the grammar. The keywords such as \fB%token\fP can also appear +in uppercase, which is again not discussed. In most places where +\fB'%'\fP is used, \fB'\\'\fP can be substituted, and there are alternate +spellings for some of the symbols (for example, +\fB%LEFT\fP can be \fB"%<"\fP or even \fB"\\<"\fP ). +.LP +Historically, <\fItag\fP> can contain any characters except \fB'>'\fP +, including white space, in the +implementation. However, since the \fItag\fP must reference an ISO\ C +standard union member, in practice conforming +implementations need to support only the set of characters for ISO\ C +standard identifiers in this context. +.LP +Some historical implementations are known to accept actions that are +terminated by a period. Historical implementations often +allow \fB'$'\fP in names. A conforming implementation does not need +to support either of these behaviors. +.LP +Deciding when to use \fB%prec\fP illustrates the difficulty in specifying +the behavior of \fIyacc\fP. There may be situations +in which the \fIgrammar\fP is not, strictly speaking, in error, and +yet \fIyacc\fP cannot interpret it unambiguously. The +resolution of ambiguities in the grammar can in many instances be +resolved by providing additional information, such as using +\fB%type\fP or \fB%union\fP declarations. It is often easier and it +usually yields a smaller parser to take this alternative when +it is appropriate. +.LP +The size and execution time of a program produced without the runtime +debugging code is usually smaller and slightly faster in +historical implementations. +.LP +Statistics messages from several historical implementations include +the following types of information: +.sp +.RS +.nf + +\fIn\fP\fB/512 terminals,\fP \fIn\fP\fB/300 non-terminals +\fP\fIn\fP\fB/600 grammar rules,\fP \fIn\fP\fB/1500 states +\fP\fIn\fP \fBshift/reduce,\fP \fIn\fP \fBreduce/reduce conflicts reported +\fP\fIn\fP\fB/350 working sets used +Memory: states, etc.\fP \fIn\fP\fB/15000, parser\fP \fIn\fP\fB/15000 +\fP\fIn\fP\fB/600 distinct lookahead sets +\fP\fIn\fP \fBextra closures +\fP\fIn\fP \fBshift entries,\fP \fIn\fP \fBexceptions +\fP\fIn\fP \fBgoto entries +\fP\fIn\fP \fBentries saved by goto default +Optimizer space used: input\fP \fIn\fP\fB/15000, output\fP \fIn\fP\fB/15000 +\fP\fIn\fP \fBtable entries,\fP \fIn\fP \fBzero +Maximum spread:\fP \fIn\fP\fB, Maximum offset:\fP \fIn\fP +.fi +.RE +.LP +The report of internal tables in the description file is left implementation-defined +because all aspects of these limits are +also implementation-defined. Some implementations may use dynamic +allocation techniques and have no specific limit values to +report. +.LP +The format of the \fBy.output\fP file is not given because specification +of the format was not seen to enhance applications +portability. The listing is primarily intended to help human users +understand and debug the parser; use of \fBy.output\fP by a +conforming application script would be unusual. Furthermore, implementations +have not produced consistent output and no popular +format was apparent. The format selected by the implementation should +be human-readable, in addition to the requirement that it be +a text file. +.LP +Standard error reports are not specifically described because they +are seldom of use to conforming applications and there was no +reason to restrict implementations. +.LP +Some implementations recognize \fB"={"\fP as equivalent to \fB'{'\fP +because it appears in historical documentation. This +construction was recognized and documented as obsolete as long ago +as 1978, in the referenced \fIYacc: Yet Another +Compiler-Compiler\fP. This volume of IEEE\ Std\ 1003.1-2001 chose +to leave it as obsolete and omit it. +.LP +Multi-byte characters should be recognized by the lexical analyzer +and returned as tokens. They should not be returned as +multi-byte character literals. The token \fBerror\fP that is used +for error recovery is normally assigned the value 256 in the +historical implementation. Thus, the token value 256, which is used +in many multi-byte character sets, is not available for use as +the value of a user-defined token. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIc99\fP , \fIlex\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . diff --git a/man1p/zcat.1p b/man1p/zcat.1p new file mode 100644 index 000000000..d75f13f16 --- /dev/null +++ b/man1p/zcat.1p @@ -0,0 +1,124 @@ +.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved +.TH "ZCAT" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" +.\" zcat +.SH NAME +zcat \- expand and concatenate data +.SH SYNOPSIS +.LP +\fBzcat\fP \fB[\fP\fIfile\fP\fB...\fP\fB]\fP\fB\fP +.SH DESCRIPTION +.LP +The \fIzcat\fP utility shall write to standard output the uncompressed +form of files that have been compressed using the \fIcompress\fP utility. +It is the equivalent of \fIuncompress\fP \fB-c\fP. Input files are +not affected. +.SH OPTIONS +.LP +None. +.SH OPERANDS +.LP +The following operand shall be supported: +.TP 7 +\fIfile\fP +The pathname of a file previously processed by the \fIcompress\fP +utility. If +\fIfile\fP already has the \fB.Z\fP suffix specified, it is used as +submitted. Otherwise, the \fB.Z\fP suffix is appended to the +filename prior to processing. +.sp +.SH STDIN +.LP +The standard input shall be used only if no \fIfile\fP operands are +specified, or if a \fIfile\fP operand is \fB'-'\fP +\&. +.SH INPUT FILES +.LP +Input files shall be compressed files that are in the format produced +by the \fIcompress\fP utility. +.SH ENVIRONMENT VARIABLES +.LP +The following environment variables shall affect the execution of +\fIzcat\fP: +.TP 7 +\fILANG\fP +Provide a default value for the internationalization variables that +are unset or null. (See the Base Definitions volume of +IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables +for +the precedence of internationalization variables used to determine +the values of locale categories.) +.TP 7 +\fILC_ALL\fP +If set to a non-empty string value, override the values of all the +other internationalization variables. +.TP 7 +\fILC_CTYPE\fP +Determine the locale for the interpretation of sequences of bytes +of text data as characters (for example, single-byte as +opposed to multi-byte characters in arguments). +.TP 7 +\fILC_MESSAGES\fP +Determine the locale that should be used to affect the format and +contents of diagnostic messages written to standard +error. +.TP 7 +\fINLSPATH\fP +Determine the location of message catalogs for the processing of \fILC_MESSAGES +\&.\fP +.sp +.SH ASYNCHRONOUS EVENTS +.LP +Default. +.SH STDOUT +.LP +The compressed files given as input shall be written on standard output +in their uncompressed form. +.SH STDERR +.LP +The standard error shall be used only for diagnostic messages. +.SH OUTPUT FILES +.LP +None. +.SH EXTENDED DESCRIPTION +.LP +None. +.SH EXIT STATUS +.LP +The following exit values shall be returned: +.TP 7 +\ 0 +Successful completion. +.TP 7 +>0 +An error occurred. +.sp +.SH CONSEQUENCES OF ERRORS +.LP +Default. +.LP +\fIThe following sections are informative.\fP +.SH APPLICATION USAGE +.LP +None. +.SH EXAMPLES +.LP +None. +.SH RATIONALE +.LP +None. +.SH FUTURE DIRECTIONS +.LP +None. +.SH SEE ALSO +.LP +\fIcompress\fP , \fIuncompress\fP +.SH COPYRIGHT +Portions of this text are reprinted and reproduced in electronic form +from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology +-- Portable Operating System Interface (POSIX), The Open Group Base +Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of +Electrical and Electronics Engineers, Inc and The Open Group. In the +event of any discrepancy between this version and the original IEEE and +The Open Group Standard, the original IEEE and The Open Group Standard +is the referee document. The original Standard can be obtained online at +http://www.opengroup.org/unix/online.html . |