diff options
-rw-r--r-- | bin/cat/cat.1 | 8 | ||||
-rw-r--r-- | bin/chio/chio.1 | 10 | ||||
-rw-r--r-- | bin/chmod/chmod.1 | 37 | ||||
-rw-r--r-- | bin/cp/cp.1 | 5 | ||||
-rw-r--r-- | bin/csh/csh.1 | 625 | ||||
-rw-r--r-- | bin/dd/dd.1 | 12 | ||||
-rw-r--r-- | bin/ksh/ksh.1 | 596 | ||||
-rw-r--r-- | bin/ksh/ksh.1tbl | 596 | ||||
-rw-r--r-- | bin/ksh/sh.1 | 327 | ||||
-rw-r--r-- | bin/ksh/sh.1tbl | 327 |
10 files changed, 1398 insertions, 1145 deletions
diff --git a/bin/cat/cat.1 b/bin/cat/cat.1 index 8cd7d85a1fa..3f0d5dd0a52 100644 --- a/bin/cat/cat.1 +++ b/bin/cat/cat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cat.1,v 1.10 1999/05/29 19:11:10 aaron Exp $ +.\" $OpenBSD: cat.1,v 1.11 1999/05/30 17:44:54 aaron Exp $ .\" $NetBSD: cat.1,v 1.12 1995/09/27 05:38:55 cgd Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 @@ -76,7 +76,8 @@ Control characters print as .Ql ^X for control-X. The only exception is the tab character, control-I (see the .Fl t -option). The DEL +option). The +.Tn DEL character (octal 0177) prints as .Ql ^? . .Pf Non- Ns Tn ASCII @@ -186,7 +187,8 @@ are extensions to the specification. .Sh HISTORY A .Nm -utility appeared in Version 6 AT&T UNIX. +utility appeared in +.At v6 . .Sh BUGS Because of the shell language mechanism used to perform output redirection, the command diff --git a/bin/chio/chio.1 b/bin/chio/chio.1 index 630f87b5e5f..6e9137aaa6e 100644 --- a/bin/chio/chio.1 +++ b/bin/chio/chio.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: chio.1,v 1.10 1999/03/03 01:14:56 aaron Exp $ +.\" $OpenBSD: chio.1,v 1.11 1999/05/30 17:44:54 aaron Exp $ .\" $NetBSD: chio.1,v 1.1.1.1 1996/04/03 00:34:38 thorpej Exp $ .\" .\" Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com> @@ -76,9 +76,9 @@ There are four element types: (import/export), and .Pa drive (data transfer). In this command description, the shorthand -.Dq ET +.Sq ET will be used to represent an element type, and -.Dq EU +.Sq EU will be used to represent an element unit. For example, to represent the first robotic arm in the changer, the ET would be .Dq picker @@ -214,5 +214,7 @@ default changer device .Sh AUTHOR The .Nm -program and SCSI changer driver were written by Jason R. Thorpe +program and +.Tn SCSI +changer driver were written by Jason R. Thorpe <thorpej@and.com> for And Communications (http://www.and.com/). diff --git a/bin/chmod/chmod.1 b/bin/chmod/chmod.1 index b131fe5577d..d1920158eb2 100644 --- a/bin/chmod/chmod.1 +++ b/bin/chmod/chmod.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: chmod.1,v 1.11 1999/05/16 19:54:36 alex Exp $ +.\" $OpenBSD: chmod.1,v 1.12 1999/05/30 17:44:55 aaron Exp $ .\" $NetBSD: chmod.1,v 1.8 1995/03/21 09:02:07 cgd Exp $ .\" .\" Copyright (c) 1989, 1990, 1993, 1994 @@ -144,7 +144,6 @@ execute permission is needed on and, of course, the .Pa ls binary itself. - .Pp The symbolic mode is described by the following grammar: .Bd -literal -offset indent @@ -160,23 +159,23 @@ perm ::= r | s | t | w | x | X | u | g | o The .Ar who symbols -.Dq u , -.Dq g , +.Sq u , +.Sq g , and -.Dq o +.Sq o specify the user, group, and other parts of the mode bits, respectively. The .Ar who symbol -.Dq a +.Sq a is equivalent to -.Dq ugo . +.Sq ugo . Do not confuse the -.Dq o +.Sq o symbol with .Dq owner . It is the user bit, -.Dq u , +.Sq u , that refers to the owner of the file. .Pp .ne 1i @@ -201,11 +200,11 @@ execute/search bits are set in the original (unmodified) mode. Operations with the .Ar perm symbol -.Dq X +.Sq X are only meaningful in conjunction with the .Ar op symbol -.Dq + , +.Sq + , and are ignored in all other cases. .It u The user permission bits in the mode of the original file. @@ -223,7 +222,7 @@ symbols represent the operation performed, as follows: If no value is supplied for .Ar perm , the -.Dq + +.Sq + operation has no effect. If no value is supplied for .Ar who , @@ -240,7 +239,7 @@ values are set. If no value is supplied for .Ar perm , the -.Dq \- +.Sq \- operation has no effect. If no value is supplied for .Ar who , @@ -280,18 +279,18 @@ bits, and each operation is applied to the mode bits in the order specified. .Pp Operations upon the other permissions only (specified by the symbol -.Dq o +.Sq o by itself), in combination with the .Ar perm symbols -.Dq s +.Sq s or -.Dq t , +.Sq t , are ignored. .Pp Care must be taken when granting elevated privileges to a program through the set-user-ID (suid) and set-group-ID (sgid) bits. Do not apply -.Dq s +.Sq s bits to executables you do not trust. Indeed, the source code which makes up the suid/sgid binaries shipped with .Bx Open @@ -343,9 +342,9 @@ utility is expected to be compatible with the exception of the .Ar perm symbols -.Dq t +.Sq t and -.Dq X +.Sq X which are not included in that standard. .Sh BUGS There's no diff --git a/bin/cp/cp.1 b/bin/cp/cp.1 index e03d7aef633..5721ad578bc 100644 --- a/bin/cp/cp.1 +++ b/bin/cp/cp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cp.1,v 1.9 1999/05/23 14:10:46 aaron Exp $ +.\" $OpenBSD: cp.1,v 1.10 1999/05/30 17:44:54 aaron Exp $ .\" $NetBSD: cp.1,v 1.9 1995/07/25 19:36:45 jtc Exp $ .\" .\" Copyright (c) 1989, 1990, 1993, 1994 @@ -191,7 +191,8 @@ utility had a option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links -or FIFOs. +or +.Tn FIFO Ns s. .Sh SEE ALSO .Xr mv 1 , .Xr rcp 1 , diff --git a/bin/csh/csh.1 b/bin/csh/csh.1 index 06bfd6957a9..a4b1c7d9f47 100644 --- a/bin/csh/csh.1 +++ b/bin/csh/csh.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: csh.1,v 1.26 1999/05/24 13:11:18 aaron Exp $ +.\" $OpenBSD: csh.1,v 1.27 1999/05/30 17:44:55 aaron Exp $ .\" $NetBSD: csh.1,v 1.10 1995/03/21 09:02:35 cgd Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 @@ -153,14 +153,14 @@ options were given, the first argument is taken as the name of a file of commands to be executed. The shell opens this file, and saves its name for possible resubstitution by -.Dq $0 . +.Sq $0 . Since many systems use either the standard version 6 or version 7 shells whose shell scripts are not compatible with this shell, the shell will execute such a .Dq standard shell if the first character of a script is not a hash mark -.Pq Ql \&# ; +.Pq Ql # ; i.e., if the script does not start with a comment. Remaining arguments initialize the variable .Va argv . @@ -175,12 +175,13 @@ if this is a login shell, It then executes commands from .Pa \&.cshrc -in the -.Ar home -directory of the invoker, and, if this is a login shell, the file +in the home directory of the invoker, +and, if this is a login shell, the file .Pa \&.login in the same location. -It is typical for users on CRTs to put the command +It is typical for users on +.Tn CRT Ns s +to put the command .Ic stty crt in their .Pa \&.login @@ -190,102 +191,100 @@ there. .Pp In the normal case, the shell will begin reading commands from the terminal, prompting with -.Dq %\ . +.Sq %\ . Processing of arguments and the use of the shell to process files containing command scripts will be described later. .Pp The shell repeatedly performs the following actions: a line of command input is read and broken into -.Ar words . +.Dq words . This sequence of words is placed on the command history list and parsed. Finally each command in the current line is executed. .Pp When a login shell terminates it executes commands from the files .Pa .logout -in the user's -.Ar home -directory and +in the user's home directory and .Pa /etc/csh.logout . .Ss Lexical structure The shell splits input lines into words at blanks and tabs with the following exceptions. The characters -.Dq & , -.Dq \&| , -.Dq \&; , -.Dq < , -.Dq > , -.Dq ( , +.Ql & , +.Ql | , +.Ql \&; , +.Ql < , +.Ql > , +.Ql ( , and -.Dq \&) +.Ql \&) form separate words. If doubled in -.Dq && , -.Dq \&|\&| , -.Dq << , +.Ql && , +.Ql || , +.Ql << , or -.Dq >> , +.Ql >> , these pairs form single words. These parser metacharacters may be made part of other words, or prevented their special meaning, by preceding them with a backslash .Pq Ql \e . A newline preceded by a -.Dq \e +.Ql \e is equivalent to a blank. .Pp Strings enclosed in matched pairs of quotations, -.Dq ' , -.Dq ` , +.Ql ' , +.Ql ` , or -.Dq \&" , +.Ql \&" , form parts of a word; metacharacters in these strings, including blanks and tabs, do not form separate words. These quotations have semantics to be described later. Within pairs of -.Dq ' +.Ql ' or -.Dq \&" +.Ql \&" characters, a newline preceded by a -.Dq \e +.Ql \e gives a true newline character. .Pp When the shell's input is not a terminal, the character -.Dq # +.Ql # introduces a comment that continues to the end of the input line. It is prevented this special meaning when preceded by -.Dq \e +.Ql \e and in quotations using -.Dq ` , -.Dq ' , +.Ql ` , +.Ql ' , and -.Dq \&" . +.Ql \&" . .Ss Commands A simple command is a sequence of words, the first of which specifies the command to be executed. A simple command or a sequence of simple commands separated by -.Dq \&| +.Ql | characters forms a pipeline. The output of each command in a pipeline is connected to the input of the next. Sequences of pipelines may be separated by -.Dq \&; , +.Ql \&; , and are then executed sequentially. A sequence of pipelines may be executed without immediately waiting for it to terminate by following it with a -.Dq & . +.Ql & . .Pp Any of the above may be placed in -.Dq \&( -.Dq \&) +.Ql ( +.Ql \&) to form a simple command (that may be a component of a pipeline, for example). It is also possible to separate pipelines with -.Dq \&|\&| +.Ql || or -.Dq && +.Ql && showing, as in the C language, that the second is to be executed only if the first fails or succeeds, @@ -293,13 +292,13 @@ respectively. (See .Em Expressions . ) .Ss Jobs The shell associates a -.Ar job +.Em job with each pipeline. It keeps a table of current jobs, printed by the -.Ar jobs +.Ic jobs command, and assigns them small integer numbers. When a job is started asynchronously with -.Dq & , +.Ql & , the shell prints a line that looks like: .Bd -filled -offset indent @@ -312,7 +311,9 @@ showing that the job which was started asynchronously was job number .Pp If you are running a job and wish to do something else you may hit .Ic ^Z -(control-Z) which sends a STOP signal to the current job. +(control-Z) which sends a +.Dv SIGSTOP +signal to the current job. The shell will then normally show that the job has been .Dq Stopped , and print another prompt. You can then manipulate the state of this job, @@ -332,7 +333,9 @@ takes effect immediately and is like an interrupt in that pending output and unread input are discarded when it is typed. There is another special key .Ic ^Y -that does not generate a STOP signal until a program attempts to +that does not generate a +.Dv SIGSTOP +signal until a program attempts to .Xr read 2 it. This request can usefully be typed ahead when you have prepared some commands @@ -347,46 +350,46 @@ tty option, then background jobs will stop when they try to produce output like they do when they try to read input. .Pp There are several ways to refer to jobs in the shell. The character -.Dq % +.Ql % introduces a job name. If you wish to refer to job number 1, you can name it as -.Dq %1 . +.Ql %1 . Just naming a job brings it to the foreground; thus -.Dq %1 +.Ic %1 is a synonym for -.Dq fg %1 , +.Ic fg %1 , bringing job number 1 back into the foreground. Similarly, saying -.Dq %1 & +.Ic %1 & resumes job number 1 in the background. Jobs can also be named by prefixes of the string typed in to start them, if these prefixes are unambiguous; thus -.Dq %ex +.Ic %ex would normally restart a suspended .Xr ex 1 job, if there were only one suspended job whose name began with the string -.Dq ex . +.Qq ex . It is also possible to say -.Dq %?string +.Ic %?string which specifies a job whose text contains .Ar string , if there is only one such job. .Pp The shell maintains a notion of the current and previous jobs. In output about jobs, the current job is marked with a -.Dq + +.Ql + and the previous job with a -.Dq \- . +.Ql \- . The abbreviation -.Dq %+ +.Ql %+ refers to the current job and -.Dq %\- +.Ql %\- refers to the previous job. For close analogy with the syntax of the .Ic history mechanism (described below), -.Dq %% +.Ql %% is also a synonym for the current job. .Pp The job control mechanism requires that the @@ -472,7 +475,7 @@ will only expand the input to .Pp and will sound the terminal bell to indicate that the expansion is incomplete, since there are two file names matching the prefix -.Dq D . +.Ql D . .Pp If a partial file name is followed by the end-of-file character (usually control-D), then, instead of completing the name, @@ -483,7 +486,7 @@ the input .Dl % vi D<control-D> .Pp causes all files beginning with -.Dq D +.Ql D to be listed: .Pp .Dl DSC.NEW DSC.OLD @@ -526,7 +529,10 @@ would result in the completion to .Pp .Dl % vi xmpl.c .Pp -ignoring the files "xmpl.o" and "xmpl.out". +ignoring the files +.Qq xmpl.o +and +.Qq xmpl.out . However, if the only completion possible requires not ignoring these suffixes, then they are not ignored. In addition, .Va fignore @@ -541,26 +547,26 @@ of new commands, making it easy to repeat commands, repeat arguments of a previous command in the current command, or fix spelling mistakes in the previous command with little typing and a high degree of confidence. History substitutions begin with the character -.Dq ! +.Ql ! and may begin .Em anywhere in the input stream (with the proviso that they do .Em not nest.) This -.Dq ! +.Ql ! may be preceded by a -.Dq \e +.Ql \e to prevent its special meaning; for convenience, a -.Dq ! +.Ql ! character is passed unchanged when it is followed by a blank, tab, newline, -.Dq = +.Ql = or -.Dq \&( . +.Ql ( . (History substitutions also occur when an input line begins with -.Dq ^ . +.Ql ^ . This special abbreviation will be described later.) Any input line that contains history substitution is echoed on the terminal before it is executed as it could have been typed without history substitution. @@ -587,39 +593,37 @@ command: .Pp The commands are shown with their event numbers. It is not usually necessary to use event numbers, but the current event -number can be made part of the -.Ar prompt -by placing a -.Dq ! +number can be made part of the prompt by placing a +.Ql ! in the prompt string. .Pp With the current event 13 we can refer to previous events by event number -.Dq !11 , +.Ql !11 , relatively as in -.Dq !\-2 +.Ql !\-2 (referring to the same event), by a prefix of a command word as in -.Dq !d +.Ql !d for event 12 or -.Dq !wri +.Ql !wri for event 9, or by a string contained in a word in the command as in -.Dq !?mic? +.Ql !?mic? also referring to event 9. These forms, without further change, simply reintroduce the words of the specified events, each separated by a single blank. As a special case, -.Dq !! +.Ql !! refers to the previous command; thus -.Dq !! +.Ql !! alone is a .Em redo . .Pp To select words from an event we can follow the event specification by a -.Dq \&: +.Ql \&: and a designator for the desired words. The words of an input line are numbered from 0, the first (usually command) word being 0, the second word (first argument) @@ -634,7 +638,7 @@ first (command) word argument .It ^ first argument; i.e., -.Dq 1 +.Ql 1 .It $ last argument .It % @@ -645,34 +649,34 @@ search range of words .It Ar \&\-y abbreviates -.Dq \&0\-y +.Ql \&0\-y .It * abbreviates -.Dq ^\-$ , +.Ql ^\-$ , or nothing if only 1 word in event .It Ar x* abbreviates -.Dq x\-$ +.Ql x\-$ .It Ar x\- like -.Dq x* +.Ql x* but omitting word -.Dq $ +.Ql $ .El .Pp The -.Dq \&: +.Ql \&: separating the event specification from the word designator can be omitted if the argument selector begins with a -.Dq ^ , -.Dq $ , -.Dq * , -.Dq \- , +.Ql ^ , +.Ql $ , +.Ql * , +.Ql \- , or -.Dq % . +.Ql % . After the optional word designator can be placed a sequence of modifiers, each preceded by a -.Dq \&: . +.Ql \&: . The following modifiers are defined: .Pp .Bl -tag -width Ds -compact -offset indent @@ -680,11 +684,11 @@ The following modifiers are defined: Remove a trailing pathname component, leaving the head. .It r Remove a trailing -.Dq .xxx +.Ql .xxx component, leaving the root name. .It e Remove all but the extension -.Dq .xxx +.Ql .xxx part. .It s Ns Ar /l/r/ Substitute @@ -697,64 +701,65 @@ Remove all leading pathname components, leaving the tail. Repeat the previous substitution. .It g Apply the change once on each word, prefixing the above; e.g., -.Dq g& . +.Ql g& . .It a Apply the change as many times as possible on a single word, prefixing the above. It can be used together with -.Dq g +.Ql g to apply a substitution globally. .It p -Print the new command line but do not execute it. +Print the new command-line but do not execute it. .It q Quote the substituted words, preventing further substitutions. .It x Like -.Dq q , +.Ql q , but break into words at blanks, tabs and newlines. .El .Pp Unless preceded by a -.Dq g +.Ql g the change is applied only to the first modifiable word. With substitutions, it is an error for no word to be applicable. .Pp -The left hand side of substitutions are not regular expressions in the sense +The left-hand side of substitutions are not regular expressions in the sense of the editors, but instead strings. Any character may be used as the delimiter in place of -.Dq / ; +.Ql / ; a -.Dq \e +.Ql \e quotes the delimiter into the .Ar l " " and .Ar r " " strings. The character -.Dq & -in the right hand side is replaced by the text from +.Ql & +in the right-hand side is replaced by the text from the left. A -.Dq \e +.Ql \e also quotes -.Dq & . -A null +.Ql & . +A +.Dv NULL .Ar l -.Pq Dq // +.Pq Ql // uses the previous string either from an .Ar l or from a contextual scan string .Ar s in -.Dq !? Ns Ar s Ns \e? . +.Ql !? Ns Ar s Ns \e? . The trailing delimiter in the substitution may be omitted if a newline follows immediately as may the trailing -.Dq ? +.Ql ? in a contextual scan. .Pp A history reference may be given without an event specification; e.g., -.Dq !$ . +.Ql !$ . Here, the reference is to the previous command unless a previous history reference occurred on the same line in which case this form repeats the previous reference. @@ -766,53 +771,53 @@ from the command matching .Pp A special abbreviation of a history reference occurs when the first non-blank character of an input line is a -.Dq ^ . +.Ql ^ . This is equivalent to .Dq !:s^ providing a convenient shorthand for substitutions on the text of the previous line. Thus -.Dq ^lb^lib +.Ic ^lb^lib fixes the spelling of .Dq lib in the previous command. Finally, a history substitution may be surrounded with -.Dq { +.Ql { and -.Dq } +.Ql } if necessary to insulate it from the characters that follow. Thus, after -.Dq ls -ld ~paul +.Ic ls -ld ~paul we might do -.Dq !{l}a +.Ic !{l}a to do -.Dq ls -ld ~paula , +.Ic ls -ld ~paula , while -.Dq !la +.Ic !la would look for a command starting with .Dq la . .Pp .Ss Quotations with \' and \&" The quotation of strings by -.Dq ' +.Ql ' and -.Dq \&" +.Ql \&" can be used to prevent all or some of the remaining substitutions. Strings enclosed in -.Dq ' +.Ql ' are prevented any further interpretation. Strings enclosed in -.Dq \&" +.Ql \&" may be expanded as described below. .Pp In both cases the resulting text becomes (all or part of) a single word; only in one special case (see .Em Command Substitution below) does a -.Dq \&" +.Ql \&" quoted string yield parts of more than one word; -.Dq ' +.Ql ' quoted strings never do. .Ss Alias substitution The shell maintains a list of aliases that can be established, displayed @@ -821,7 +826,7 @@ and modified by the and .Ic unalias commands. -After a command line is scanned, it is parsed into distinct commands and +After a command-line is scanned, it is parsed into distinct commands and the first word of each command, left-to-right, is checked to see if it has an alias. If it does, then the text that is the alias for that command is reread @@ -837,18 +842,18 @@ Thus if the alias for is .Dq ls \-l , the command -.Dq ls /usr +.Ic ls /usr would map to -.Dq ls \-l /usr , +.Ic ls \-l /usr , the argument list here being undisturbed. Similarly, if the alias for .Dq lookup was .Dq grep !^ /etc/passwd then -.Dq lookup bill +.Ic lookup bill would map to -.Dq grep bill /etc/passwd . +.Ic grep bill /etc/passwd . .Pp If an alias is found, the word transformation of the input text is performed and the aliasing process begins again on the reformed input line. @@ -884,11 +889,11 @@ For instance, the variable is a toggle that causes command input to be echoed. The setting of this variable results from the .Fl v -command line option. +command-line option. .Pp Other operations treat variables numerically. The -.Dq @ +.Ic @ command permits numeric calculations to be performed and the result assigned to a variable. Variable values are, however, always represented as (zero or more) strings. @@ -898,12 +903,12 @@ zero, and the second and additional words of multiword values are ignored. After the input line is aliased and parsed, and before each command is executed, variable substitution is performed keyed by -.Dq $ +.Ql $ characters. This expansion can be prevented by preceding the -.Dq $ +.Ql $ with a -.Dq \e +.Ql \e except within "'s where it .Em always @@ -915,10 +920,10 @@ Strings quoted by backticks are interpreted later (see .Sx Command substitution below) so -.Dq $ +.Ql $ substitution does not occur there until later, if at all. A -.Dq $ +.Ql $ is passed unchanged if followed by a blank, tab, or end-of-line. .Pp Input/output redirections are recognized before variable expansion, @@ -929,18 +934,18 @@ more than one word, the first of which becomes the command name, and the rest of which become arguments. .Pp Unless enclosed in -.Dq \&" +.Ql \&" or given the -.Dq :q +.Ql :q modifier, the results of variable substitution may eventually be command and filename substituted. Within -.Dq \&" , +.Ql \&" , a variable whose value consists of multiple words expands to a (portion of) a single word, with the words of the variables value separated by blanks. When the -.Dq :q +.Ql :q modifier is applied to a substitution the variable will expand to multiple words with each word separated by a blank and quoted to prevent later command or filename substitution. @@ -964,7 +969,7 @@ If .Ar name is not a shell variable, but is set in the environment, then that value is returned (but -.Dq : +.Ql \&: modifiers and the other forms given below are not available here). .It $name Ns Op selector @@ -972,18 +977,18 @@ given below are not available here). May be used to select only some of the words from the value of .Ar name . The selector is subjected to -.Dq $ +.Ql $ substitution and may consist of a single number or two numbers separated by a -.Dq \- . +.Ql \- . The first word of a variables value is numbered -.Dq 1 . +.Ql 1 . If the first number of a range is omitted it defaults to -.Dq 1 . +.Ql 1 . If the last number of a range is omitted it defaults to -.Dq $#name . +.Ql $#name . The selector -.Dq * +.Ql * selects all words. It is not an error for a range to be empty if the second argument is omitted or in range. @@ -1005,32 +1010,32 @@ Equivalent to .El .Pp The modifiers -.Dq :e , -.Dq :h , -.Dq :t , -.Dq :r , -.Dq :q , +.Ql :e , +.Ql :h , +.Ql :t , +.Ql :r , +.Ql :q , and -.Dq :x +.Ql :x may be applied to the substitutions above as may -.Dq :gh , -.Dq :gt , +.Ql :gh , +.Ql :gt , and -.Dq :gr . +.Ql :gr . If braces -.Dq { -.Dq } +.Ql { +.Ql } appear in the command form then the modifiers must appear within the braces. The current implementation allows only one -.Dq \&: +.Ql \&: modifier on each -.Dq $ +.Ql $ expansion. .Pp The following substitutions may not be modified with -.Dq \&: +.Ql \&: modifiers. .Bl -tag -width Ds -compact -offset indent .It $?name @@ -1042,9 +1047,9 @@ if name is set, if it is not. .It $?0 Substitutes -.Dq 1 +.Ql 1 if the current input filename is known, -.Dq 0 +.Ql 0 if it is not. .It \&$\&$\& Substitute the (decimal) process number of the (parent) shell. @@ -1068,7 +1073,7 @@ after input-output redirection is performed, and in a child of the main shell. .Ss Command substitution Command substitution is shown by a command enclosed in -.Dq ` . +.Ql ` . The output from such a command is normally broken into separate words at blanks, tabs and newlines, with null words being discarded; this text then replaces the original string. @@ -1079,13 +1084,13 @@ Note that it is thus possible for a command substitution to yield only part of a word, even if the command outputs a complete line. .Ss Filename substitution If a word contains any of the characters -.Dq * , -.Dq ? , -.Dq [ , +.Ql * , +.Ql ? , +.Ql [ , or -.Dq { , +.Ql { , or begins with the character -.Dq ~ , +.Ql ~ , then that word is a candidate for filename substitution, also known as .Dq globbing . @@ -1095,31 +1100,31 @@ In a list of words specifying filename substitution it is an error for no pattern to match an existing file name, but it is not required for each pattern to match. Only the metacharacters -.Dq * , -.Dq ? , +.Ql * , +.Ql ? , and -.Dq [ +.Ql [ imply pattern matching, the characters -.Dq ~ +.Ql ~ and -.Dq { +.Ql { being more akin to abbreviations. .Pp In matching filenames, the character -.Dq \&. +.Ql \&. at the beginning of a filename or immediately following a -.Dq / , +.Ql / , as well as the character -.Dq / +.Ql / must be matched explicitly. The character -.Dq * +.Ql * matches any string of characters, including the null string. The character -.Dq ? +.Ql ? matches any single character. The sequence .Dq Op ... @@ -1127,21 +1132,21 @@ matches any one of the characters enclosed. Within .Dq Op ... , a pair of characters separated by -.Dq \- +.Ql \- matches any character lexically between the two (inclusive). .Pp The character -.Dq ~ +.Ql ~ at the beginning of a filename refers to home directories. Standing alone, i.e., -.Dq ~ , +.Ql ~ , it expands to the invokers home directory as reflected in the value of the variable .Ar home . When followed by a name consisting of letters, digits and -.Dq \- +.Ql \- characters, the shell searches for a user with that name and substitutes their home directory; thus @@ -1153,9 +1158,9 @@ and to .Dq /usr/ken/chmach . If the character -.Dq ~ +.Ql ~ is followed by a character other than a letter or -.Dq / , +.Ql / , or does not appear at the beginning of a word, it is left undisturbed. .Pp @@ -1184,10 +1189,10 @@ might expand to was not sorted with the results of the match to .Dq *box . ) As a special case -.Dq { , -.Dq } , +.Ql { , +.Ql } , and -.Dq {} +.Ql {} are passed undisturbed. .Ss Input/output The standard input and the standard output of a command may be redirected @@ -1208,21 +1213,21 @@ and each input line is compared to .Ar word before any substitutions are done on the input line. Unless a quoting -.Dq \e , -.Dq \&" , -.Dq ' +.Ql \e , +.Ql \&" , +.Ql ' or -.Dq ` +.Ql ` appears in .Ar word , variable and command substitution is performed on the intervening lines, allowing -.Dq \e +.Ql \e to quote -.Dq $ , -.Dq \e +.Ql $ , +.Ql \e and -.Dq ` . +.Ql ` . Commands that are substituted have all blanks, tabs, and newlines preserved, except for the final newline which is dropped. The resultant text is placed in an anonymous temporary file that @@ -1245,16 +1250,16 @@ terminal or or an error results. This helps prevent accidental destruction of files. Here, the -.Dq ! +.Ql ! forms can be used to suppress this check. .Pp The forms involving -.Dq & +.Ql & route the standard error output into the specified file as well as the standard output. .Ar name is expanded in the same way as -.Dq < +.Ql < input filenames are. .It >> name .It >>& name @@ -1264,16 +1269,16 @@ Uses file .Ar name as the standard output; like -.Dq > +.Ql > but places output at the end of the file. If the variable .Va noclobber is set, then it is an error for the file not to exist unless one of the -.Dq ! +.Ql ! forms is given. Otherwise similar to -.Dq > . +.Ql > . .El .Pp A command receives the environment in which the shell was @@ -1283,7 +1288,7 @@ Thus, unlike some previous shells, commands run from a file of shell commands have no access to the text of the commands by default; instead they receive the original standard input of the shell. The -.Dq << +.Ql << mechanism should be used to present inline data. This permits shell command scripts to function as components of pipelines and allows the shell to block read its input. @@ -1301,9 +1306,9 @@ above). The standard error output may be directed through a pipe with the standard output. Simply use the form -.Dq \&|& +.Ql |& instead of just -.Dq \&| . +.Ql | . .Ss Expressions Several of the built-in commands (to be described later) take expressions, in which the operators are similar to those of C, with @@ -1324,79 +1329,79 @@ The following operators are available: .Ed .Pp Here the precedence increases to the right, -.Dq == -.Dq != -.Dq =~ +.Ql == +.Ql != +.Ql =~ and -.Dq !~ , -.Dq <= -.Dq >= -.Dq < +.Ql !~ , +.Ql <= +.Ql >= +.Ql < and -.Dq > , -.Dq << +.Ql > , +.Ql << and -.Dq >> , -.Dq + +.Ql >> , +.Ql + and -.Dq \- , -.Dq * -.Dq / +.Ql \- , +.Ql * +.Ql / and -.Dq % +.Ql % being, in groups, at the same level. The -.Dq == -.Dq != -.Dq =~ +.Ql == +.Ql != +.Ql =~ and -.Dq !~ +.Ql !~ operators compare their arguments as strings; all others operate on numbers. The operators -.Dq =~ +.Ql =~ and -.Dq !~ +.Ql !~ are like -.Dq != +.Ql != and -.Dq == +.Ql == except that the right hand side is a .Ar pattern (containing, e.g., *'s, ?'s, and instances of .Dq [...] ) -against which the left hand operand is matched. This reduces the +against which the left-hand operand is matched. This reduces the need for use of the .Ar switch statement in shell scripts when all that is really needed is pattern matching. .Pp Strings that begin with -.Dq 0 +.Ql 0 are considered octal numbers. Null or missing arguments are considered -.Dq 0 . +.Ql 0 . The result of all expressions are strings, which represent decimal numbers. It is important to note that no two components of an expression can appear in the same word; except when adjacent to components of expressions that are syntactically significant to the parser .Po -.Dq & , -.Dq \&| , -.Dq < , -.Dq > , -.Dq \&( , +.Ql & , +.Ql | , +.Ql < , +.Ql > , +.Ql ( , and -.Dq \&) +.Ql \&) .Pc , they should be surrounded by spaces. .Pp Also available in expressions as primitive operands are command executions enclosed in -.Dq { +.Ql { and -.Dq } +.Ql } and file enquiries of the form .Fl l .Ar name @@ -1418,12 +1423,12 @@ The specified name is command and filename expanded and then tested to see if it has the specified relationship to the real user. If the file does not exist or is inaccessible then all enquiries return false, i.e., -.Dq 0 . +.Ql 0 . Command executions succeed, returning true, i.e., -.Dq 1 , +.Ql 1 , if the command exits with status 0, otherwise they fail, returning false, i.e., -.Dq 0 . +.Ql 0 . If more detailed status information is required then the command should be executed outside an expression and the variable .Ar status @@ -1483,7 +1488,9 @@ free memory. With an argument shows the number of free and used blocks in each size category. The categories start at size 8 and double at each step. This command's output may vary across system types, since -systems other than the VAX may use a different memory allocator. +systems other than the +.Tn VAX +may use a different memory allocator. .Pp .It Ic bg .It Ic bg \&% Ns Ar job ... @@ -1522,10 +1529,10 @@ If .Ar name is not found as a subdirectory of the current directory (and does not begin with -.Dq / , -.Dq ./ +.Ql / , +.Ql ./ or -.Dq ../ ) , +.Ql ../ ) , then each component of the variable .Va cdpath @@ -1534,7 +1541,7 @@ is checked to see if it has a subdirectory Finally, if all else fails but .Ar name is a shell variable whose value begins with -.Dq / , +.Ql / , then this is tried to see if it is a directory. .Pp @@ -1627,7 +1634,7 @@ command to terminate it prematurely. When this command is read from the terminal, the loop is read once prompting with -.Dq ? +.Ql ? before any statements in the loop are executed. If you make a mistake typing in a loop at the terminal you can rub it out. .Pp @@ -1635,9 +1642,11 @@ If you make a mistake typing in a loop at the terminal you can rub it out. Like .Ic echo but no -.Dq \e +.Ql \e escapes are recognized and words are delimited -by null characters in the output. +by +.Tn NUL +characters in the output. Useful for programs that wish to use the shell to filename expand a list of words. .Pp @@ -1645,7 +1654,7 @@ of words. The specified .Ar word is filename and command expanded to yield a string of the form -.Dq label . +.Ql label . The shell rewinds its input as much as possible and searches for a line of the form .Dq label: , @@ -1662,7 +1671,7 @@ is attempted for each component of the .Em path where the hash function indicates a possible hit, and in each component that does not begin with a -.Dq / . +.Ql / . .Pp .It Ic history .It Ic history Ar n @@ -1751,7 +1760,9 @@ option lists process IDs in addition to the normal information. .Ar pid .It Ic kill Fl sig Ar pid ... .It Ic kill Fl l Op exit_status -Sends either the TERM (terminate) signal or the +Sends either the +.Dv SIGTERM +(terminate) signal or the specified signal to the specified jobs or processes. Signals are either given by number or by names (as given in .Aq Pa signal.h , @@ -1766,8 +1777,14 @@ There is no default; just saying .Dq kill does not send a signal to the current job. -If the signal being sent is TERM (terminate) or HUP (hangup), -then the job or process will be sent a CONT (continue) signal as well. +If the signal being sent is +.Dv SIGTERM +(terminate) or +.Dv SIGHUP +(hangup), +then the job or process will be sent a +.Dv SIGCONT +(continue) signal as well. .Pp .It Ic limit .It Ic limit Ar resource @@ -1816,12 +1833,12 @@ may be given as a (floating point or integer) number followed by a scale factor. For all limits other than .Ar cputime the default scale is -.Dq k +.Ql k or .Dq kilobytes (1024 bytes); a scale factor of -.Dq m +.Ql m or .Dq megabytes may also be used. @@ -1830,10 +1847,10 @@ For the default scale is .Dq seconds ; a scale factor of -.Dq m +.Ql m for minutes or -.Dq h +.Ql h for hours, or a time of the form .Dq mm:ss giving minutes @@ -1870,7 +1887,9 @@ to the given The final two forms run command at priority 4 and .Ar number respectively. -The greater the number, the less CPU the process will get. +The greater the number, the less +.Tn CPU +the process will get. The super-user may specify negative priority by using .Dq nice \-number ... . .Ar command @@ -1886,7 +1905,7 @@ ignored for the remainder of the script. The second form causes the specified command to be run with hangups ignored. All processes detached with -.Dq & +.Ql & are effectively .Ic nohup Ns \'ed . .Pp @@ -2114,8 +2133,8 @@ Each case label is successively matched against the specified .Ar string which is first command and filename expanded. The file metacharacters -.Dq * , -.Dq ? +.Ql * , +.Ql ? and .Dq [...] may be used in the case labels, @@ -2241,15 +2260,15 @@ The second form sets the specified to the value of .Ar expr . If the expression contains -.Dq < , -.Dq > , -.Dq & +.Ql < , +.Ql > , +.Ql & or -.Dq \&| +.Ql | then at least this part of the expression must be placed within -.Dq \&( -.Dq \&) . +.Ql ( +.Ql \&) . The third form assigns the value of .Ar expr to the @@ -2264,8 +2283,8 @@ component must already exist. .El .Pp The operators -.Dq *= , -.Dq += , +.Ql *= , +.Ql += , etc. are available as in C. The space separating the name from the assignment operator is optional. Spaces are, however, mandatory in separating components of @@ -2273,9 +2292,9 @@ Spaces are, however, mandatory in separating components of which would otherwise be single words. .Pp Special postfix -.Dq +\|+ +.Ql +\|+ and -.Dq \-\|\- +.Ql \-\|\- operators increment and decrement .Ar name respectively; i.e., @@ -2341,7 +2360,7 @@ The full pathname of the current directory. .It Ic echo Set when the .Fl x -command line option is given. +command-line option is given. Causes each command and its arguments to be echoed just before it is executed. For non-built-in commands all expansions occur before echoing. @@ -2353,9 +2372,9 @@ Enable file name completion. Can be given a string value to change the characters used in history substitution. The first character of its value is used as the history substitution character, replacing the default character -.Dq ! . +.Ql ! . The second character of its value replaces the character -.Dq ^ +.Ql ^ in quick substitutions. .It Ic histfile Can be set to the pathname where history is going to be saved/restored. @@ -2399,7 +2418,7 @@ As described in the section on .Sx Input/output , restrictions are placed on output redirection to insure that files are not accidentally destroyed, and that -.Dq >> +.Ql >> redirections refer to existing files. .It Ic noglob @@ -2457,10 +2476,10 @@ or the commands may not be found. The string that is printed before each command is read from an interactive terminal input. If a -.Dq ! +.Ql ! appears in the string it will be replaced by the current event number unless a preceding -.Dq \e +.Ql \e is given. Default is .Dq %\ , @@ -2495,20 +2514,20 @@ Initialized to the (system-dependent) home of the shell. .It Ic status The status returned by the last command. If it terminated abnormally, then 0200 is added to the status. -Built-in commands that fail return exit status -.Dq 1 , -all other built-in commands set status to -.Dq 0 . +Built-in commands that fail return exit status 1, +all other built-in commands set status to 0. .It Ic time Controls automatic timing of commands. -If set, then any command that takes more than this many CPU seconds +If set, then any command that takes more than this many +.Tn CPU +seconds will cause a line giving user, system, and real times and a utilization percentage which is the ratio of user plus system times to real time to be printed when it terminates. .It Ic verbose Set by the .Fl v -command line option, causes the words of each command to be printed +command-line option, causes the words of each command to be printed after history substitution. .El .Ss Non-built-in command execution @@ -2537,7 +2556,7 @@ or argument, and in any case for each directory component of .Ar path that does not begin with a -.Dq / , +.Ql / , the shell concatenates with the given command name to form a path name of a file which it then attempts to execute. .Pp @@ -2577,7 +2596,9 @@ Note that this is a special, late occurring, case of substitution, and only allows words to be prepended to the argument list without change. .Ss Signal handling -The shell normally ignores QUIT signals. +The shell normally ignores +.Dv SIGQUIT +signals. Jobs running detached (either by .Ic \&& or the @@ -2590,7 +2611,9 @@ Other signals have the values which the shell inherited from its parent. The shell's handling of interrupts and terminate signals in shell scripts can be controlled by .Ic onintr . -Login shells catch the TERM (terminate) signal; +Login shells catch the +.Dv SIGTERM +(terminate) signal; otherwise this signal is passed on to children from the state in the shell's parent. Interrupts are not allowed when a login shell is reading the file @@ -2614,10 +2637,10 @@ at login read by login shell, at logout .It Pa /bin/sh standard shell, for shell scripts not starting with a -.Dq # +.Ql # .It Pa /tmp/sh* temporary file for -.Dq << +.Ql << .It Pa /etc/passwd source of home directories for .Dq ~name @@ -2676,9 +2699,9 @@ Command sequences of the form .Dq a \&; b \&; c are also not handled gracefully when stopping is attempted. If you suspend -.Dq b , +.Ql b , the shell will immediately execute -.Dq c . +.Ql c . This is especially noticeable if this expansion results from an alias. It suffices to place the sequence of commands in ()'s to force it to @@ -2694,22 +2717,22 @@ Alias substitution is most often used to clumsily simulate shell procedures; shell procedures should be provided instead of aliases. .Pp Commands within loops, prompted for by -.Dq ? , +.Ql ? , are not placed on the .Ic history list. Control structure should be parsed instead of being recognized as built-in commands. This would allow control commands to be placed anywhere, to be combined with -.Dq \&| , +.Ql | , and to be used with -.Dq & +.Ql & and -.Dq \&; +.Ql \&; metasyntax. .Pp It should be possible to use the -.Dq \&: +.Ql \&: modifiers on the output of command substitutions. .Pp diff --git a/bin/dd/dd.1 b/bin/dd/dd.1 index 66f0d307002..0d380bc7472 100644 --- a/bin/dd/dd.1 +++ b/bin/dd/dd.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dd.1,v 1.7 1998/12/15 01:20:19 aaron Exp $ +.\" $OpenBSD: dd.1,v 1.8 1999/05/30 17:44:55 aaron Exp $ .\" $NetBSD: dd.1,v 1.5 1995/03/21 09:04:04 cgd Exp $ .\" .\" Copyright (c) 1990, 1993 @@ -279,16 +279,16 @@ appended. .Pp Where sizes are specified, a decimal number of bytes is expected. If the number ends with a -.Dq b , -.Dq k , -.Dq m +.Sq b , +.Sq k , +.Sq m or -.Dq w , +.Sq w , the number is multiplied by 512, 1024 (1K), 1048576 (1M) or the number of bytes in an integer, respectively. Two or more numbers may be separated by an -.Dq x +.Sq x to indicate a product. .Pp When finished, diff --git a/bin/ksh/ksh.1 b/bin/ksh/ksh.1 index e777cf112a2..9e12b7e4820 100644 --- a/bin/ksh/ksh.1 +++ b/bin/ksh/ksh.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ksh.1,v 1.17 1999/05/28 12:23:06 aaron Exp $ +.\" $OpenBSD: ksh.1,v 1.18 1999/05/30 17:44:56 aaron Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -96,10 +96,10 @@ if the option is used or if both standard input and standard error are attached to a tty. An interactive shell has job control enabled (if available), ignores the -.Dv INT , -.Dv QUIT , +.Dv SIGINT , +.Dv SIGQUIT , and -.Dv TERM +.Dv SIGTERM signals, and prints prompts before reading input (see .Ev PS1 and @@ -152,10 +152,10 @@ option of the built-in command can't be used. .It Redirections that create files can't be used (i.e., -.Sq > , -.Sq >| , -.Sq >> , -.Sq <> ) . +.Ql > , +.Ql >| , +.Ql >> , +.Ql <> ) . .El .Pp A shell is @@ -178,7 +178,7 @@ its effective user ID (group ID) to its real user ID (group ID). .Pp If the basename of the name the shell is called with (i.e., argv[0]) starts with -.Sq \&- +.Ql - or if the .Fl l option is used, @@ -218,47 +218,47 @@ The shells begins parsing its input by breaking it into Words, which are sequences of characters, are delimited by unquoted whitespace characters (space, tab, and newline) or meta-characters .Po -.Sq \&< , -.Sq \&> , -.Sq \&| , -.Sq \&; , -.Sq \&( , +.Ql < , +.Ql > , +.Ql | , +.Ql \&; , +.Ql ( , and -.Sq \&) +.Ql \&) .Pc . Aside from delimiting words, spaces and tabs are ignored, while newlines usually delimit commands. The meta-charcters are used in building the following tokens: -.Sq \&< , -.Sq \&<\&& , -.Sq \&> , -.Sq \&>\&& , -.Sq \&>\&> , +.Ql < , +.Ql <& , +.Ql > , +.Ql >& , +.Ql >> , etc. are used to specify redirections (see .Sx Input/output redirection below); -.Sq \&| +.Ql | is used to create pipelines; -.Sq \&|\&& +.Ql |& is used to create co-processes (see .Sx Co-processes below); -.Sq \&; +.Ql \&; is used to separate commands; -.Sq \&& +.Ql & is used to create asynchronous pipelines; -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || are used to specify conditional execution; -.Sq \&;\&; +.Ql \&;\&; is used in .Ic case statements; -.Sq \&(\&( .. \&)\&) +.Ql \&(\&( .. \&)\&) is used in arithmetic expressions; and lastly, -.Sq \&( .. \&) +.Ql \&( .. \&) is used to create subshells. .Pp Whitespace and meta-characters can be quoted individually using a backslash @@ -269,52 +269,52 @@ or single .Pq Sq \&' quotes. Note that the following characters are also treated specially by the shell and must be quoted if they are to represent themselves: -.Sq \e , -.Sq \&" , -.Sq \&' , -.Sq \&# , -.Sq \&$ , -.Sq \&` , -.Sq \&~ , -.Sq \&{ , -.Sq \&} , -.Sq \&* , -.Sq \&? , +.Ql \e , +.Ql \&" , +.Ql ' , +.Ql # , +.Ql $ , +.Ql ` , +.Ql ~ , +.Ql { , +.Ql } , +.Ql * , +.Ql ? , and -.Sq \&[ . +.Ql [ . The first three of these are the above mentioned quoting characters (see .Sx Quoting below); -.Sq \&# , +.Ql # , if used at the beginning of a word, introduces a comment -- everything after the -.Sq \&# +.Ql # up to the nearest newline is ignored; -.Sq \&$ +.Ql $ is used to introduce parameter, command and arithmetic substitutions (see .Sx Substitution below); -.Sq \&` +.Ql ` introduces an old-style command substitution (see .Sx Substitution below); -.Sq \&~ +.Ql ~ begins a directory expansion (see .Sx Tilde expansion below); -.Sq \&{ +.Ql { and -.Sq \&} +.Ql } delimit .Xr csh 1 style alterations (see .Sx Brace expansion below); and finally, -.Sq \&* , -.Sq \&? , +.Ql * , +.Ql ? , and -.Sq \&[ +.Ql [ are used in file name generation (see .Sx File name patterns below). @@ -358,13 +358,13 @@ assignments is that of the last command substitution performed during the parameter assignment or 0 is there were no command substitutions. .Pp Commands can be chained together using the -.Sq \&| +.Ql | token to form pipelines, in which the standard output of each command but the last is piped (see .Xr pipe 2 ) to the standard input of the following command. The exit status of a pipeline is that of its last command. A pipeline may be prefixed by the -.Sq \&! +.Ql ! reversed word which causes the exit status of the pipeline to be logically complemented: if the original status was 0 the complemented status will be 1; if the original status was not 0, the complemented status will be 0. @@ -372,12 +372,12 @@ if the original status was not 0, the complemented status will be 0. .Em Lists of commands can be created by separating pipelines by any of the following tokens: -.Sq \&&\&& , -.Sq \&|\&| , -.Sq \&& , -.Sq \&|\&& , +.Ql && , +.Ql || , +.Ql & , +.Ql |& , and -.Sq \&; . +.Ql \&; . The first two are for conditional execution: .Dq Ar cmd1 No && Ar cmd2 executes @@ -385,48 +385,48 @@ executes only if the exit status of .Ar cmd1 is zero; -.Sq \&|\&| +.Ql || is the opposite -- .Ar cmd2 is executed only if the exit status of .Ar cmd1 is non-zero. -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || have equal precedence which is higher than that of -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& and -.Sq \&; , +.Ql \&; , which also have equal precedence. The -.Sq \&& +.Ql & token causes the preceding command to be executed asynchronously; that is, the shell starts the command but does not wait for it to complete (the shell does keep track of the status of asynchronous commands, see .Sx Job control below). When an asynchronous command is started when job control is disabled (i.e., in most scripts), the command is started with signals -.Dv INT +.Dv SIGINT and -.Dv QUIT +.Dv SIGQUIT ignored and with input redirected from .Pa /dev/null (however, redirections specified in the asynchronous command have precedence). The -.Sq \&|\&& +.Ql |& operator starts a co-process which is a special kind of asynchronous process (see .Sx Co-processes below). Note that a command must follow the -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || operators, while it need not follow -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& or -.Sq \&; . +.Ql \&; . The exit status of a list is that of the last command executed, with the exception of asynchronous lists, for which the exit status is 0. .Pp @@ -450,7 +450,8 @@ elif for select while } .\".Ic then , time , until , while , .\".Ic \&! , \&[\&[ , \&{ , \&} .Pp -NOTE: Some shells (but not this one) execute control structure commands in a +.Sy Note: +Some shells (but not this one) execute control structure commands in a subshell when one or more of their file descriptors are redirected, so any environment changes inside them may fail. To be portable, the .Ic exec @@ -509,9 +510,9 @@ used in .Ic case statements are the same as those used for file name patterns except that the restrictions regarding -.Sq \&. +.Ql \&. and -.Sq \&/ +.Ql / are dropped. Note that any unquoted space before and after a pattern is stripped; any space with a pattern must be quoted. Both the word and the patterns are subject to parameter, command and arithmetic substitution as @@ -558,7 +559,7 @@ if is never executed, the exit status is zero. .Ar term is either a newline or a -.Sq \&; . +.Ql \&; . .It Xo Ic if Ar list Ic then .Ar list [ Ic elif Ar list Ic then .Ar list ] Ar ... [ Ic else @@ -699,29 +700,29 @@ The (and) and .Fl o (or) operators are replaced with -.Sq \&&\&& +.Ql && and -.Sq \&|\&| , +.Ql || , respectively. .It Operators (e.g., -.Sq Fl f , -.Sq = , -.Sq \&! , +.Ql Fl f , +.Ql = , +.Ql ! , etc.) must be unquoted. .It The second operand of the -.Sq \&!= +.Ql != and -.Sq = +.Ql = expressions are patterns (e.g., the comparison .Ic [[ foobar = f*r ]] succeeds). .It There are two additional binary operators: -.Sq \&< +.Ql < and -.Sq \&> +.Ql > which return true if their first string operand is less than, or greater than, their second string operand, respectively. .It @@ -735,9 +736,9 @@ use .It Parameter, command and arithmetic substitutions are performed as expressions are evaluated and lazy expression evaluation is used for the -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || operators. This means that in the statement .Pp .Ic \&[[ -r foo && $(< foo) = b*r ]] @@ -752,42 +753,43 @@ exists and is readable. .Ss Quoting Quoting is used to prevent the shell from treating characters or words specially. There are three methods of quoting. First, -.Sq \e +.Ql \e quotes the following character, unless it is at the end of a line, in which case both the -.Sq \e +.Ql \e and the newline are stripped. Second, a single quote .Pq Sq ' quotes everything up to the next single quote (this may span lines). Third, a double quote .Pq Sq \&" quotes all characters, except -.Sq \&$ , -.Sq \&` +.Ql $ , +.Ql ` and -.Sq \e , +.Ql \e , up to the next unquoted double quote. -.Sq $ +.Ql $ and -.Sq ` +.Ql ` inside double quotes have their usual meaning (i.e., parameter, command or arithmetic substitution) except no field splitting is carried out on the results of double-quoted substitutions. If a -.Sq \e +.Ql \e inside a double-quoted string is followed by -.Sq \e , -.Sq $ , -.Sq ` , +.Ql \e , +.Ql $ , +.Ql ` , or -.Sq \&" , +.Ql \&" , it is replaced by the second character; if it is followed by a newline, both the -.Sq \e +.Ql \e and the newline are stripped; otherwise, both the -.Sq \e +.Ql \e and the character following are unchanged. .Pp -NOTE: See +.Sy Note: +See .Sx POSIX mode below for a special rule regarding sequences of the form .Ic \&"...`...\e\&"...`..\&" . @@ -887,11 +889,15 @@ characters are called .Dq IFS whitespace . Sequences of one or more .Ev IFS -whitespace characters, in combination with zero or none non-IFS whitespace +whitespace characters, in combination with zero or no +.Pf non- Ev IFS +whitespace characters delimit a field. As a special case, leading and trailing .Ev IFS whitespace is stripped (i.e., no leading or trailing empty field is created by -it); leading or trailing non-IFS whitespace does create an empty field. +it); leading or trailing +.Pf non- Ev IFS +whitespace does create an empty field. Example: If .Ev IFS is set to @@ -922,14 +928,14 @@ substitutions, normal quoting rules are used when is parsed, however, for the .Ic ` Ns Ar command Ns Ic ` form, a -.Sq \e +.Ql \e followed by any of -.Sq $ , -.Sq ` , +.Ql $ , +.Ql ` , or -.Sq \e +.Ql \e is stripped (a -.Sq \e +.Ql \e followed by any other character is unchanged). As a special case in command substitutions, a command of the form .Ic \&< Ar file @@ -941,7 +947,7 @@ has the same effect as .Ic $(cat foo) , but it is carried out more efficiently because no process is started). .Pp -NOTE: +.Sy Note: .Ic $( Ns Ar command Ns Ic \&) expressions are currently parsed by finding the matching parenthesis, regardless of quoting. This will hopefully be fixed soon. @@ -958,7 +964,7 @@ can be accessed using a parameter substitution. A parameter name is either one of the special single punctuation or digit character parameters described below, or a letter followed by zero or more letters or digits .Po -.Sq _ +.Ql _ counts as a letter .Pc . Parameter substitutions take the form @@ -996,7 +1002,7 @@ can be followed by a simple-command, in which case the assignments are in effect only for the duration of the command (such assignments are also exported, see below for implications of this). Note that both the parameter name and the -.Sq = +.Ql = must be unquoted for the shell to recognize a parameter assignment. The fourth way of setting a parameter is with the .Ic export , @@ -1090,7 +1096,7 @@ is used instead. .El .Pp In the above modifiers, the -.Sq \&: +.Ql \&: can be omitted, in which case the conditions only depand on .Ar name being set (as opposed to set and not @@ -1108,8 +1114,8 @@ The following forms of parameter substitution can also be used: The number of positional parameters if .Ar name is -.Sq \&* , -.Sq \&@ , +.Ql * , +.Ql @ , not specified, or the length of the string value of parameter .Ar name . .It Xo Ic ${# Ns Ar name Ns @@ -1128,7 +1134,7 @@ If matches the beginning of the value of parameter .Ar name , the matched text is deleted from the result of substitution. A single -.Sq \&# +.Ql # results in the shortest match, two of them results in the longest match. .Sm off @@ -1151,7 +1157,9 @@ have been started, the parameter is not set. .It Ev \&# The number of positional parameters (i.e., $1, $2, etc.). .It Ev \&$ -The process ID of the shell, or the PID of the original shell if it is a +The process ID of the shell, or the +.Tn PID +of the original shell if it is a subshell. .It Ev \&- The concatenation of the current single letter options (see @@ -1222,7 +1230,7 @@ Search path for the built-in command. Works the same way as .Ev PATH for those directories not beginning with -.Sq \&/ +.Ql / in .Ic cd commands. Note that if @@ -1288,7 +1296,8 @@ running on the same machine will share history if their .Ev HISTFILE parameters all point to the same file. .Pp -NOTE: If +.Sy Note: +If .Ev HISTFILE isn't set, no history file is used. This is different from the original Korn shell, which uses @@ -1314,7 +1323,8 @@ and newline. See .Sx Substitution above for details. .Pp -NOTE: This parameter is not imported from the environment when the shell is +.Sy Note: +This parameter is not imported from the environment when the shell is started. .It Ev KSH_VERSION The version of the shell and the date the version was created (read-only). @@ -1344,7 +1354,7 @@ minutes). .It Ev MAILPATH A list of files to be checked for mail. The list is colon separated, and each file may be followed by a -.Sq \&? +.Ql ? and a message to be printed if new mail has arrived. Command, parameter and arithmetic substitution is performed on the message, and, during substitution, the parameter @@ -1383,13 +1393,13 @@ The process ID of the shell's parent (read-only). .It Ev PS1 The primary prompt for interactive shells. Parameter, command and arithmetic substitutions are performed, and -.Sq \&! +.Ql ! is replaced with the current command number (see .Ic fc command below). A literal -.Sq \&! +.Ql ! can be put in the prompt by placing -.Sq \&!\&! +.Ql !! in .Ev PS1 . Note that since the command line editors try to figure out how long the prompt @@ -1472,13 +1482,13 @@ or .Ss Tilde expansion Tilde expansion, which is done in parallel with parameter substitution, is done on words starting with an unquoted -.Sq ~ . +.Ql ~ . The characters following the tilde, up to the first -.Sq / , +.Ql / , if any, are assumed to be a login name. If the login name is empty, -.Sq \&+ +.Ql + or -.Sq \&- , +.Ql - , the value of the .Ev HOME , PWD or @@ -1537,9 +1547,9 @@ are not expanded). Brace expansion is carried out after parameter substitution and before file name generation. .Ss File name patterns A file name pattern is a word containing one or more unquoted -.Sq \&? +.Ql ? or -.Sq \&* +.Ql * characters or .Dq [..] sequences. Once brace expansion has been performed, the shell replaces file @@ -1554,19 +1564,19 @@ Matches any sequence of characters. .It Ic \&[ Ns No .. Ns Ic \&] Matches any of the characters inside the brackets. Ranges of characters can be specified by separating two characters by a -.Sq \&- +.Ql - (e.g., .Dq [a0-9] matches the letter .Dq a or any digit). In order to represent itself, a -.Sq \&- +.Ql - must either be quoted or the first or last character in the character list. Similarly, a -.Sq \&] +.Ql \&] must be quoted or the first character in the list if it is to represent itself instead of the end of the list. Also, a -.Sq \&! +.Ql ! appearing at the start of the list has special meaning (see below), so to represent itself it must be quoted or appear later in the list. .It Ic \&[\&! Ns No .. Ns Ic \&] @@ -1675,9 +1685,11 @@ If the .Ic markdirs option is set, any directories that result from file name generation are marked with a trailing -.Sq / . +.Ql / . .Pp -The POSIX character classes (i.e., +The +.Tn POSIX +character classes (i.e., .Ic \&[\&: Ns Ar class-name Ns Ic \&:\&] inside a .Ic \&[ Ns No .. Ns Ic \&] @@ -1745,11 +1757,11 @@ parameter, command and arithmetic substitutions are performed, along with backslash .Pq Sq \e escapes for -.Sq \&$ , -.Sq ` , -.Sq \e , +.Ql $ , +.Ql ` , +.Ql \e , and -.Sq \enewline . +.Ql \enewline . If multiple here documents are used on the same command line, they are saved in order. .It Ic \&<\&<\&- Ar marker @@ -1762,10 +1774,10 @@ Standard input is duplicated from file descriptor .Ar fd can be a single digit, indicating the number of an existing file descriptor; the letter -.Sq p , +.Ql p , indicating the file descriptor associated with the output of the current co-process; or the character -.Sq \&- , +.Ql - , indicating standard input is to be closed. .It Ic \&>\&& Ar fd Same as @@ -2107,19 +2119,26 @@ returns. .El .El .Ss POSIX mode -The shell is intended to be POSIX compliant, however, in some cases, POSIX +The shell is intended to be +.Tn POSIX +compliant, however, in some cases, +.Tn POSIX behaviour is contrary either to the original Korn shell behaviour or to user convenience. How the shell behaves in these cases is determined by the state of the .Ic posix option .Pq Ic set Fl o Ic posix . -If it is on, the POSIX behaviour is followed, otherwise it is not. The +If it is on, the +.Tn POSIX +behaviour is followed, otherwise it is not. The .Ic posix option is set automatically when the shell starts up if the environment contains the .Dv POSIXLY_CORRECT -parameter. (The shell can also be compiled so that it is in POSIX mode by +parameter. (The shell can also be compiled so that it is in +.Tn POSIX +mode by default, however this is usually not desirable). .Pp The following is a list of things that are affected by the state of the @@ -2131,22 +2150,34 @@ Occurrences of .Ic \e\&" inside double quoted .Ic `\&.\&.` -command substitutions. In POSIX mode, the +command substitutions. In +.Tn POSIX +mode, the .Ic \e\&" -is interpreted when the command is interpreted; in non-POSIX mode, the +is interpreted when the command is interpreted; in +.Pf non- Tn POSIX +mode, the backslash is stripped before the command substitution is interpreted. For example, .Ic echo \&"`echo \e\&"hi\e\&"`\&" produces .Dq \&"hi\&" -in POSIX mode, +in +.Tn POSIX +mode, .Dq hi -in non-POSIX mode. To avoid problems, use the +in +.Pf non- Tn POSIX +mode. To avoid problems, use the .Ic $(...) form of command substitution. .It .Ic kill -l -output. In POSIX mode, signal names are listed one per line; in non-POSIX mode, +output. In +.Tn POSIX +mode, signal names are listed one per line; in +.Pf non- Tn POSIX +mode, signal numbers, names and descriptions are printed in columns. In future, a new option .Po Fl v @@ -2155,19 +2186,30 @@ option will be added to distinguish the two behaviours. .It .Ic fg -exit status. In POSIX mode, the exit status is 0 if no errors occur; in -non-POSIX mode, the exit status is that of the last foregrounded job. +exit status. In +.Tn POSIX +mode, the exit status is 0 if no errors occur; in +.Pf non- Tn POSIX +mode,the exit status is that of the last foregrounded job. .It .Ic getopts . -In POSIX mode, options must start with a -.Sq \&- ; -in non-POSIX mode, options can start with either -.Sq \&- +In +.Tn POSIX +mode, options must start with a +.Ql - ; +in +.Pf non- Tn POSIX +mode, options can start with either +.Ql - or -.Sq \&+ . +.Ql + . .It -Brace expansion (also known as alternation). In POSIX mode, brace expansion is -disabled; in non-POSIX mode, brace expansion is enabled. Note that +Brace expansion (also known as alternation). In +.Tn POSIX +mode, brace expansion is +disabled; in +.Pf non- Tn POSIX +mode, brace expansion is enabled. Note that .Ic set Fl o Ic posix (or setting the .Ev POSIXLY_CORRECT @@ -2176,21 +2218,33 @@ parameter) automatically turns the option off, however, it can be explicitly turned on later. .It .Ic set \&- . -In POSIX mode, this does not clear the +In +.Tn POSIX +mode, this does not clear the .Ic verbose or .Ic xtrace -options; in non-POSIX mode, it does. +options; in +.Pf non- Tn POSIX +mode, it does. .It .Ic set -exit status. In POSIX mode, the exit status of +exit status. In +.Tn POSIX +mode, the exit status of .Ic set -is 0 if there are no errors; in non-POSIX mode, the exit status is that of any +is 0 if there are no errors; in +.Pf non- Tn POSIX +mode, the exit status is that of any command substitutions performed in generating the .Ic set command. For example, .Ic set \&-\&- `false`; echo $? -prints 0 in POSIX mode, 1 in non-POSIX mode. This construct is used in most +prints 0 in +.Tn POSIX +mode, 1 in +.Pf non- Tn POSIX +mode. This construct is used in most shell scripts that use the old .Xr getopt 1 command. @@ -2201,16 +2255,30 @@ Argument expansion of .Ic readonly , and .Ic typeset -commands. In POSIX mode, normal argument expansion is done; in non-POSIX mode, +commands. In +.Tn POSIX +mode, normal argument expansion is done; in +.Pf non- Tn POSIX +mode, field splitting, file globbing, brace expansion, and (normal) tilde expansion are turned off, while assignment tilde expansion is turned on. .It -Signal specification. In POSIX mode, signals can be specified as digits, only -if signal numbers match POSIX values (i.e., HUP=1, INT=2, QUIT=3, ABRT=6, -KILL=9, ALRM=14, and TERM=15); in non-POSIX mode, signals can always be digits. +Signal specification. In +.Tn POSIX +mode, signals can be specified as digits, only +if signal numbers match +.Tn POSIX +values (i.e., HUP=1, INT=2, QUIT=3, ABRT=6, +KILL=9, ALRM=14, and TERM=15); in +.Pf non- Tn POSIX +mode, signals can always be digits. .It -Alias expansion. In POSIX mode, alias expansion is only carried out when -reading command words; in non-POSIX mode, alias expansion is carried out on any +Alias expansion. In +.Tn POSIX +mode, alias expansion is only carried out when +reading command words; in +.Pf non- Tn POSIX +mode, alias expansion is carried out on any word following an alias that ended in a space. For example, the following .Ic for loop @@ -2224,15 +2292,23 @@ loop .Pp uses parameter .Ic i -in POSIX mode, +in +.Tn POSIX +mode, .Ic j -in non-POSIX mode. +in +.Pf non- Tn POSIX +mode. .It -Test. In POSIX mode, the expression +Test. In +.Tn POSIX +mode, the expression .Dq Fl t (preceded by some number of .Dq Ic \&! -arguments) is always true as it is a non-zero length string; in non-POSIX mode, +arguments) is always true as it is a non-zero length string; in +.Pf non- Tn POSIX +mode, it tests if file descriptor 1 is a tty (i.e., the .Ar fd argument to the @@ -2261,10 +2337,15 @@ different only in that the .Ev PATH parameter is not used to find them. .Pp -The original ksh and POSIX differ somewhat in which commands are considered +The original +.Nm +and +.Tn POSIX +differ somewhat in which commands are considered special or regular: .Pp -POSIX special commands +.Tn POSIX +special commands .Pp .Ic \&. , \&: , break , continue , .Ic eval , exec , exit , export , @@ -2275,11 +2356,13 @@ Additional ksh special commands .Pp .Ic builtin , times , typeset .Pp -Very special commands (non-POSIX mode) +Very special commands +.Pq Pf non- Tn POSIX .Pp .Ic alias , readonly , set , typset .Pp -POSIX regular commands +.Tn POSIX +regular commands .Pp .Ic alias , bg , cd , command , .Ic false , fc , fg , getopts , @@ -2292,7 +2375,9 @@ Additional ksh regular commands .Ic pwd , test , ulimit , whence .Pp In the future, the additional ksh special and regular commands may be treated -differently from the POSIX special and regular commands. +differently from the +.Tn POSIX +special and regular commands. .Pp Once the type of the command has been determined, any command line parameter assignments are performed and exported for the duration of the command. @@ -2329,9 +2414,9 @@ as where .Ar value is quoted. If options were preceded with -.Sq \&+ , +.Ql + , or a lone -.Sq \&+ +.Ql + is given on the command line, only .Ar name is printed. In addition, if the @@ -2417,7 +2502,7 @@ is missing, the home directory is used. If .Ar dir is -.Dq \&- , +.Dq - , the previous working directory is used (see .Ev OLDPWD parameter). If the @@ -2470,7 +2555,9 @@ exit, and command assignments are not permanent). If the .Fl p option is given, a default search path is used instead of the current value of .Ev PATH -(the actual value of the default path is system dependent; on POSIXish systems, +(the actual value of the default path is system dependent; on +.Tn POSIX Ns ish +systems, it is the value returned by .Ic getconf CS_PATH ) . .Pp @@ -2510,7 +2597,7 @@ defaults to 1. Prints its arguments (separated by spaces) followed by a newline, to the standard output. The newline is suppressed if any of the arguments contain the backslash sequence -.Sq \ec . +.Ql \ec . See the .Ic print command below for a list of other backslash sequences that are recognized. @@ -2628,11 +2715,11 @@ is invoked, it places the next option in the shell parameter and the index of the next argument to be processed in the shell parameter .Ev OPTIND . If the option was introduced with a -.Sq \&+ , +.Ql + , the option places in .Ar name is prefixed with a -.Sq \&+ . +.Ql + . When an option requires an argument, .Ic getopts places it in the shell parameter @@ -2651,9 +2738,9 @@ When the end of the options is encountered, .Ic getopts exits with a non-zero exit status. Options end at the first (non-option argument) argument that does not start with a -.Sq \&- , +.Ql - , or when a -.Sq \&-\&- +.Ql -- argument is encountered. .Pp Option parsing can be reset by setting @@ -2728,23 +2815,23 @@ terminated with a newline. The .Fl n option suppresses the newline. By default, certain C escapes are translated. These include -.Sq \eb , -.Sq \ef , -.Sq \en , -.Sq \er , -.Sq \et , -.Sq \ev , +.Ql \eb , +.Ql \ef , +.Ql \en , +.Ql \er , +.Ql \et , +.Ql \ev , and -.Sq \e0### +.Ql \e0### .Po -.Sq # +.Ql # is an octal digit, of which there may be 0 to 3 .Pc . -.Sq \ec +.Ql \ec is equivalent to using the .Fl n option. -.Sq \e +.Ql \e expansion may be inhibited with the .Fl r option. The @@ -2769,7 +2856,7 @@ option is used to emulate, to some degree, the .Bx .Xr echo command, which does not process -.Sq \e +.Ql \e sequences unless the .Fl e option is given. As above, the @@ -2971,10 +3058,10 @@ if is used). .It Fl u Ic nounset Referencing of an unset parameter is treated as an error, unless one of the -.Sq \&- , -.Sq \&+ +.Ql - , +.Ql + or -.Sq = +.Ql = modifiers is used. .It Fl v Ic verbose Write shell input to standard error as it is read. @@ -2984,7 +3071,7 @@ the value of .Ev PS4 . .It Fl X Ic markdirs Mark directories with a trailing -.Sq / +.Ql / during file name generation. .It Ic bgnice Background jobs are run with lower priority. @@ -3040,7 +3127,9 @@ and .Ic pwd commands above for more details. .It Ic posix -Enable POSIX mode. See +Enable +.Tn POSIX +mode. See .Sx POSIX mode above. .It Ic vi @@ -3049,7 +3138,8 @@ Enable vi-like command line editing (interactive shells only). No effect. In the original Korn shell, unless .Ic viraw was set, the vi command line mode would let the tty driver do the work until -ESC (^[) was entered. +.Tn ESC +(^[) was entered. .Nm pdksh is always in viraw mode. .It Ic vi-esccomplete @@ -3075,11 +3165,11 @@ will print the long names of all options that are currently on. .Pp Remaining arguments, if any, are positional parameters and are assigned, in order, to the positional parameters (i.e., $1, $2, etc.). If options end with -.Sq \&-\&- +.Ql -- and there are no remaining arguments, all positional parameters are cleared. If no options or arguments are given, the values of all names are printed. For unknown historical reasons, a lone -.Sq \&- +.Ql - option is treated specially -- it clears both the .Fl x and @@ -3187,7 +3277,7 @@ is set (see .Ic set command above for a list of options). As a non-standard extension, if the option starts with a -.Sq \&! , +.Ql ! , the test is negated; the test always fails if .Ar option doesn't exist (thus @@ -3219,7 +3309,9 @@ is a tty device. If the option is not set, .Ar fd may be left out, in which case it is taken to be 1 (the behaviour differs due -to the special POSIX rules described below). +to the special +.Tn POSIX +rules described below). .It Ar string .Ar string is not empty. @@ -3276,23 +3368,26 @@ test). For example, .Ic \&[ -w /dev/fd/2 \&] tests if file descriptor 2 is writable. .Pp -Note that some special rules are applied (courtesy of POSIX) if the number of +Note that some special rules are applied (courtesy of +.Tn POSIX ) +if the number of arguments to .Ic test or .Ic \&[ ... \&] is less than five; if leading -.Sq \&! +.Ql ! arguments can be stripped such that only one argument remains then a string length test is performed (again, even if the argument is a unary operator); if leading -.Sq \&! +.Ql ! arguments can be stripped such that three arguments remain and the second argument is a binary operator, then the binary operation is performed (even if the first argument is a unary operator, including an unstripped -.Sq \&! ) . +.Ql ! ) . .Pp -NOTE: A common mistake is to use +.Sy Note: +A common mistake is to use .Ic if \&[ $foo = bar \&] which fails if parameter .Ic foo @@ -3301,9 +3396,9 @@ is or unset, if it has embedded spaces (i.e., .Ev IFS characters), or if it is a unary operator like -.Sq Ic \&! +.Ql Ic \&! or -.Sq Fl n . +.Ql Fl n . Use tests like .Ic if \&[ \&"X$foo\&" = Xbar \&] instead. @@ -3374,10 +3469,10 @@ arguments, parameter attributes are displayed; if no options are used, the current attributes of all parameters are printed as .Ic typeset commands; if an option is given (or -.Sq \&- +.Ql - with no option letter), all parameters and their values with the specified attributes are printed; if options are introduced with -.Sq \&+ , +.Ql + , parameter values are not printed. .Pp If @@ -3399,7 +3494,7 @@ operates on the attributes of functions. As with parameters, if no .Ar name Ns s are given, functions are listed with their values (i.e., definitions) unless options are introduced with -.Sq \&+ , +.Ql + , in which case only the function names are reported. .Bl -tag -width 3n .It Fl L Ns Ar n @@ -3546,7 +3641,8 @@ kilobytes on the size of the stack area. .It Fl t Ar n Impose a time limit of .Ar n -CPU seconds to be used by each process. +.Tn CPU +seconds to be used by each process. .It Fl v Ar n Impose a limit of .Ar n @@ -3619,10 +3715,10 @@ below for the format of .Ar job . .Ic wait will return if a signal for which a trap has been set is received, or if a -.Dv HUP , -.Dv INT +.Dv SIGHUP , +.Dv SIGINT or -.Dv QUIT +.Dv SIGQUIT signal is received. .Pp If no jobs are specified, @@ -3741,9 +3837,9 @@ where is the job number of the job. .It Ar flag is the -.Sq \&+ +.Ql + or -.Sq \&- +.Ql - character if the job is the .Ic %\&+ or .Ic %\&- @@ -3753,7 +3849,9 @@ indicates the current state of the job and can be: .Bl -tag -width "Running" .It Cm Running The job has neither stopped nor exited (note that running does not necessarily -mean consuming CPU time -- the process could be blocked waiting for some +mean consuming +.Tn CPU +time -- the process could be blocked waiting for some event). .It Cm Done Op Ar number The job exited. @@ -3784,13 +3882,13 @@ When an attempt is made to exit the shell while there are jobs in the stopped state, the shell warns the user that there are stopped jobs and does not exit. If another attempt is immediately made to exit the shell, the stopped jobs are sent a -.Dv HUP +.Dv SIGHUP signal and the shell exits. Similarly, if the .Ic nohup option is not set and there are running jobs when an attempt is made to exit a login shell, the shell warns the user and does not exit. If another attempt is immediately made to exit the shell, the running jobs are sent a -.Dv HUP +.Dv SIGHUP signal and the shell exits. .Ss Emacs interactive input line editing When the @@ -3815,9 +3913,13 @@ notation, i.e., ^X), optionally preceded by one of the two prefix characters. Future input of the .Ar string will cause the editing command to be immediately invoked. Note that although -only two prefix characters (usually ESC and ^X) are supported, some +only two prefix characters (usually +.Tn ESC +and ^X) are supported, some multi-character sequences can be supported. The following binds the arrow keys -on an ANSI terminal, or xterm (these are in the default bindings). Of course +on an +.Tn ANSI +terminal, or xterm (these are in the default bindings). Of course some escape sequences won't work out quite this nicely. .Pp .Bl -item -compact @@ -3850,7 +3952,9 @@ The following is a list of available editing commands. Each description starts with the name of the command, an .Ar n (if the command can be prefixed with a count), and any keys the command is -bound to by default (written using caret notation, i.e., ASCII ESC character is +bound to by default (written using caret notation, i.e., +.Tn "ASCII ESC" +character is written as ^[). A count prefix for a command is entered using the sequence .Ic ^\&[ Ns Ar n , where @@ -3900,7 +4004,7 @@ Automatically completes as much as is unique of the command name or the file name containing the cursor. If the entire remaining command or file name is unique, a space is printed after its completion, unless it is a directory name in which case -.Sq / +.Ql / is appended. If there is no command or file name with the current partialword as its prefix, a bell character is output (usually causing a beep to be sounded). @@ -3969,7 +4073,7 @@ Error (ring the bell). Places the cursor where the mark is and sets the mark to where the cursor was. .It Ic expand-file ^[\&* Appends a -.Sq \&* +.Ql * to the current word and replaces the word with the result of performing file globbing on the word. If no files match the pattern, the bell is rung. .It Ic forward-char Ar n Ic ^F @@ -3995,7 +4099,7 @@ is not specified; otherwise deletes characters between the cursor and column .It Ic list ^[? Prints a sorted, columnated list of command named or file names (if any) that can complete the partial word containing the cursor. Directoary names have -.Sq / +.Ql / appended to them. .It Ic list-command ^X? Prints a sorted, columnated list of command names (if any) that can complete @@ -4041,7 +4145,7 @@ occurrence of the next character typed. .It Ic search-history ^R Enter incremental search mode. The internal history list is searched backwards for commands matching the input. An initial -.Sq ^ +.Ql ^ in the search string anchors the search. The abort key will leave search mode. Other commands will be executed after leaving search mode. Successive .Ic search-history @@ -4161,10 +4265,10 @@ above), enabled with If a line is longer than the screen width (see .Dv COLUMNS parameter), a -.Sq \&> , -.Sq \&+ +.Ql > , +.Ql + or -.Sq \&< +.Ql < character is displayed in the last column indicating that there are more characters after, before and after, or before the current position, respectively. The line is scrolled horizontally as necessary. @@ -4224,16 +4328,16 @@ is not specified, the current line is edited. The actual command executed is .It Ic \&* No and Ic ^X Command or file name expansion is applied to the current big-word (with an appended -.Sq \&* , +.Ql * , if the word contains no file globbing characters) -- the big-word is replaced with the resulting words. If the current big-word is the first on the line (or follows one of the following characters: -.Sq \&; , -.Sq \&| , -.Sq \&& , -.Sq \&( , +.Ql \&; , +.Ql | , +.Ql & , +.Ql ( , or -.Sq \&) ) +.Ql \&) ) and does not contain a slash .Pq Sq / then the command expansion is done; otherwise file name expansion is done. @@ -4388,7 +4492,7 @@ line containing if .Ar string starts with -.Sq ^ , +.Ql ^ , the remainder of the string must appear at the start of the history line for it to match. .It Ar n Ns Ic \&? Ns Ar string diff --git a/bin/ksh/ksh.1tbl b/bin/ksh/ksh.1tbl index 09bb56d0158..47a15a0b446 100644 --- a/bin/ksh/ksh.1tbl +++ b/bin/ksh/ksh.1tbl @@ -1,4 +1,4 @@ -.\" $OpenBSD: ksh.1tbl,v 1.17 1999/05/28 12:23:06 aaron Exp $ +.\" $OpenBSD: ksh.1tbl,v 1.18 1999/05/30 17:44:56 aaron Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -96,10 +96,10 @@ if the option is used or if both standard input and standard error are attached to a tty. An interactive shell has job control enabled (if available), ignores the -.Dv INT , -.Dv QUIT , +.Dv SIGINT , +.Dv SIGQUIT , and -.Dv TERM +.Dv SIGTERM signals, and prints prompts before reading input (see .Ev PS1 and @@ -152,10 +152,10 @@ option of the built-in command can't be used. .It Redirections that create files can't be used (i.e., -.Sq > , -.Sq >| , -.Sq >> , -.Sq <> ) . +.Ql > , +.Ql >| , +.Ql >> , +.Ql <> ) . .El .Pp A shell is @@ -178,7 +178,7 @@ its effective user ID (group ID) to its real user ID (group ID). .Pp If the basename of the name the shell is called with (i.e., argv[0]) starts with -.Sq \&- +.Ql - or if the .Fl l option is used, @@ -218,47 +218,47 @@ The shells begins parsing its input by breaking it into Words, which are sequences of characters, are delimited by unquoted whitespace characters (space, tab, and newline) or meta-characters .Po -.Sq \&< , -.Sq \&> , -.Sq \&| , -.Sq \&; , -.Sq \&( , +.Ql < , +.Ql > , +.Ql | , +.Ql \&; , +.Ql ( , and -.Sq \&) +.Ql \&) .Pc . Aside from delimiting words, spaces and tabs are ignored, while newlines usually delimit commands. The meta-charcters are used in building the following tokens: -.Sq \&< , -.Sq \&<\&& , -.Sq \&> , -.Sq \&>\&& , -.Sq \&>\&> , +.Ql < , +.Ql <& , +.Ql > , +.Ql >& , +.Ql >> , etc. are used to specify redirections (see .Sx Input/output redirection below); -.Sq \&| +.Ql | is used to create pipelines; -.Sq \&|\&& +.Ql |& is used to create co-processes (see .Sx Co-processes below); -.Sq \&; +.Ql \&; is used to separate commands; -.Sq \&& +.Ql & is used to create asynchronous pipelines; -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || are used to specify conditional execution; -.Sq \&;\&; +.Ql \&;\&; is used in .Ic case statements; -.Sq \&(\&( .. \&)\&) +.Ql \&(\&( .. \&)\&) is used in arithmetic expressions; and lastly, -.Sq \&( .. \&) +.Ql \&( .. \&) is used to create subshells. .Pp Whitespace and meta-characters can be quoted individually using a backslash @@ -269,52 +269,52 @@ or single .Pq Sq \&' quotes. Note that the following characters are also treated specially by the shell and must be quoted if they are to represent themselves: -.Sq \e , -.Sq \&" , -.Sq \&' , -.Sq \&# , -.Sq \&$ , -.Sq \&` , -.Sq \&~ , -.Sq \&{ , -.Sq \&} , -.Sq \&* , -.Sq \&? , +.Ql \e , +.Ql \&" , +.Ql ' , +.Ql # , +.Ql $ , +.Ql ` , +.Ql ~ , +.Ql { , +.Ql } , +.Ql * , +.Ql ? , and -.Sq \&[ . +.Ql [ . The first three of these are the above mentioned quoting characters (see .Sx Quoting below); -.Sq \&# , +.Ql # , if used at the beginning of a word, introduces a comment -- everything after the -.Sq \&# +.Ql # up to the nearest newline is ignored; -.Sq \&$ +.Ql $ is used to introduce parameter, command and arithmetic substitutions (see .Sx Substitution below); -.Sq \&` +.Ql ` introduces an old-style command substitution (see .Sx Substitution below); -.Sq \&~ +.Ql ~ begins a directory expansion (see .Sx Tilde expansion below); -.Sq \&{ +.Ql { and -.Sq \&} +.Ql } delimit .Xr csh 1 style alterations (see .Sx Brace expansion below); and finally, -.Sq \&* , -.Sq \&? , +.Ql * , +.Ql ? , and -.Sq \&[ +.Ql [ are used in file name generation (see .Sx File name patterns below). @@ -358,13 +358,13 @@ assignments is that of the last command substitution performed during the parameter assignment or 0 is there were no command substitutions. .Pp Commands can be chained together using the -.Sq \&| +.Ql | token to form pipelines, in which the standard output of each command but the last is piped (see .Xr pipe 2 ) to the standard input of the following command. The exit status of a pipeline is that of its last command. A pipeline may be prefixed by the -.Sq \&! +.Ql ! reversed word which causes the exit status of the pipeline to be logically complemented: if the original status was 0 the complemented status will be 1; if the original status was not 0, the complemented status will be 0. @@ -372,12 +372,12 @@ if the original status was not 0, the complemented status will be 0. .Em Lists of commands can be created by separating pipelines by any of the following tokens: -.Sq \&&\&& , -.Sq \&|\&| , -.Sq \&& , -.Sq \&|\&& , +.Ql && , +.Ql || , +.Ql & , +.Ql |& , and -.Sq \&; . +.Ql \&; . The first two are for conditional execution: .Dq Ar cmd1 No && Ar cmd2 executes @@ -385,48 +385,48 @@ executes only if the exit status of .Ar cmd1 is zero; -.Sq \&|\&| +.Ql || is the opposite -- .Ar cmd2 is executed only if the exit status of .Ar cmd1 is non-zero. -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || have equal precedence which is higher than that of -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& and -.Sq \&; , +.Ql \&; , which also have equal precedence. The -.Sq \&& +.Ql & token causes the preceding command to be executed asynchronously; that is, the shell starts the command but does not wait for it to complete (the shell does keep track of the status of asynchronous commands, see .Sx Job control below). When an asynchronous command is started when job control is disabled (i.e., in most scripts), the command is started with signals -.Dv INT +.Dv SIGINT and -.Dv QUIT +.Dv SIGQUIT ignored and with input redirected from .Pa /dev/null (however, redirections specified in the asynchronous command have precedence). The -.Sq \&|\&& +.Ql |& operator starts a co-process which is a special kind of asynchronous process (see .Sx Co-processes below). Note that a command must follow the -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || operators, while it need not follow -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& or -.Sq \&; . +.Ql \&; . The exit status of a list is that of the last command executed, with the exception of asynchronous lists, for which the exit status is 0. .Pp @@ -450,7 +450,8 @@ elif for select while } .\".Ic then , time , until , while , .\".Ic \&! , \&[\&[ , \&{ , \&} .Pp -NOTE: Some shells (but not this one) execute control structure commands in a +.Sy Note: +Some shells (but not this one) execute control structure commands in a subshell when one or more of their file descriptors are redirected, so any environment changes inside them may fail. To be portable, the .Ic exec @@ -509,9 +510,9 @@ used in .Ic case statements are the same as those used for file name patterns except that the restrictions regarding -.Sq \&. +.Ql \&. and -.Sq \&/ +.Ql / are dropped. Note that any unquoted space before and after a pattern is stripped; any space with a pattern must be quoted. Both the word and the patterns are subject to parameter, command and arithmetic substitution as @@ -558,7 +559,7 @@ if is never executed, the exit status is zero. .Ar term is either a newline or a -.Sq \&; . +.Ql \&; . .It Xo Ic if Ar list Ic then .Ar list [ Ic elif Ar list Ic then .Ar list ] Ar ... [ Ic else @@ -699,29 +700,29 @@ The (and) and .Fl o (or) operators are replaced with -.Sq \&&\&& +.Ql && and -.Sq \&|\&| , +.Ql || , respectively. .It Operators (e.g., -.Sq Fl f , -.Sq = , -.Sq \&! , +.Ql Fl f , +.Ql = , +.Ql ! , etc.) must be unquoted. .It The second operand of the -.Sq \&!= +.Ql != and -.Sq = +.Ql = expressions are patterns (e.g., the comparison .Ic [[ foobar = f*r ]] succeeds). .It There are two additional binary operators: -.Sq \&< +.Ql < and -.Sq \&> +.Ql > which return true if their first string operand is less than, or greater than, their second string operand, respectively. .It @@ -735,9 +736,9 @@ use .It Parameter, command and arithmetic substitutions are performed as expressions are evaluated and lazy expression evaluation is used for the -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || operators. This means that in the statement .Pp .Ic \&[[ -r foo && $(< foo) = b*r ]] @@ -752,42 +753,43 @@ exists and is readable. .Ss Quoting Quoting is used to prevent the shell from treating characters or words specially. There are three methods of quoting. First, -.Sq \e +.Ql \e quotes the following character, unless it is at the end of a line, in which case both the -.Sq \e +.Ql \e and the newline are stripped. Second, a single quote .Pq Sq ' quotes everything up to the next single quote (this may span lines). Third, a double quote .Pq Sq \&" quotes all characters, except -.Sq \&$ , -.Sq \&` +.Ql $ , +.Ql ` and -.Sq \e , +.Ql \e , up to the next unquoted double quote. -.Sq $ +.Ql $ and -.Sq ` +.Ql ` inside double quotes have their usual meaning (i.e., parameter, command or arithmetic substitution) except no field splitting is carried out on the results of double-quoted substitutions. If a -.Sq \e +.Ql \e inside a double-quoted string is followed by -.Sq \e , -.Sq $ , -.Sq ` , +.Ql \e , +.Ql $ , +.Ql ` , or -.Sq \&" , +.Ql \&" , it is replaced by the second character; if it is followed by a newline, both the -.Sq \e +.Ql \e and the newline are stripped; otherwise, both the -.Sq \e +.Ql \e and the character following are unchanged. .Pp -NOTE: See +.Sy Note: +See .Sx POSIX mode below for a special rule regarding sequences of the form .Ic \&"...`...\e\&"...`..\&" . @@ -887,11 +889,15 @@ characters are called .Dq IFS whitespace . Sequences of one or more .Ev IFS -whitespace characters, in combination with zero or none non-IFS whitespace +whitespace characters, in combination with zero or no +.Pf non- Ev IFS +whitespace characters delimit a field. As a special case, leading and trailing .Ev IFS whitespace is stripped (i.e., no leading or trailing empty field is created by -it); leading or trailing non-IFS whitespace does create an empty field. +it); leading or trailing +.Pf non- Ev IFS +whitespace does create an empty field. Example: If .Ev IFS is set to @@ -922,14 +928,14 @@ substitutions, normal quoting rules are used when is parsed, however, for the .Ic ` Ns Ar command Ns Ic ` form, a -.Sq \e +.Ql \e followed by any of -.Sq $ , -.Sq ` , +.Ql $ , +.Ql ` , or -.Sq \e +.Ql \e is stripped (a -.Sq \e +.Ql \e followed by any other character is unchanged). As a special case in command substitutions, a command of the form .Ic \&< Ar file @@ -941,7 +947,7 @@ has the same effect as .Ic $(cat foo) , but it is carried out more efficiently because no process is started). .Pp -NOTE: +.Sy Note: .Ic $( Ns Ar command Ns Ic \&) expressions are currently parsed by finding the matching parenthesis, regardless of quoting. This will hopefully be fixed soon. @@ -958,7 +964,7 @@ can be accessed using a parameter substitution. A parameter name is either one of the special single punctuation or digit character parameters described below, or a letter followed by zero or more letters or digits .Po -.Sq _ +.Ql _ counts as a letter .Pc . Parameter substitutions take the form @@ -996,7 +1002,7 @@ can be followed by a simple-command, in which case the assignments are in effect only for the duration of the command (such assignments are also exported, see below for implications of this). Note that both the parameter name and the -.Sq = +.Ql = must be unquoted for the shell to recognize a parameter assignment. The fourth way of setting a parameter is with the .Ic export , @@ -1090,7 +1096,7 @@ is used instead. .El .Pp In the above modifiers, the -.Sq \&: +.Ql \&: can be omitted, in which case the conditions only depand on .Ar name being set (as opposed to set and not @@ -1108,8 +1114,8 @@ The following forms of parameter substitution can also be used: The number of positional parameters if .Ar name is -.Sq \&* , -.Sq \&@ , +.Ql * , +.Ql @ , not specified, or the length of the string value of parameter .Ar name . .It Xo Ic ${# Ns Ar name Ns @@ -1128,7 +1134,7 @@ If matches the beginning of the value of parameter .Ar name , the matched text is deleted from the result of substitution. A single -.Sq \&# +.Ql # results in the shortest match, two of them results in the longest match. .Sm off @@ -1151,7 +1157,9 @@ have been started, the parameter is not set. .It Ev \&# The number of positional parameters (i.e., $1, $2, etc.). .It Ev \&$ -The process ID of the shell, or the PID of the original shell if it is a +The process ID of the shell, or the +.Tn PID +of the original shell if it is a subshell. .It Ev \&- The concatenation of the current single letter options (see @@ -1222,7 +1230,7 @@ Search path for the built-in command. Works the same way as .Ev PATH for those directories not beginning with -.Sq \&/ +.Ql / in .Ic cd commands. Note that if @@ -1288,7 +1296,8 @@ running on the same machine will share history if their .Ev HISTFILE parameters all point to the same file. .Pp -NOTE: If +.Sy Note: +If .Ev HISTFILE isn't set, no history file is used. This is different from the original Korn shell, which uses @@ -1314,7 +1323,8 @@ and newline. See .Sx Substitution above for details. .Pp -NOTE: This parameter is not imported from the environment when the shell is +.Sy Note: +This parameter is not imported from the environment when the shell is started. .It Ev KSH_VERSION The version of the shell and the date the version was created (read-only). @@ -1344,7 +1354,7 @@ minutes). .It Ev MAILPATH A list of files to be checked for mail. The list is colon separated, and each file may be followed by a -.Sq \&? +.Ql ? and a message to be printed if new mail has arrived. Command, parameter and arithmetic substitution is performed on the message, and, during substitution, the parameter @@ -1383,13 +1393,13 @@ The process ID of the shell's parent (read-only). .It Ev PS1 The primary prompt for interactive shells. Parameter, command and arithmetic substitutions are performed, and -.Sq \&! +.Ql ! is replaced with the current command number (see .Ic fc command below). A literal -.Sq \&! +.Ql ! can be put in the prompt by placing -.Sq \&!\&! +.Ql !! in .Ev PS1 . Note that since the command line editors try to figure out how long the prompt @@ -1472,13 +1482,13 @@ or .Ss Tilde expansion Tilde expansion, which is done in parallel with parameter substitution, is done on words starting with an unquoted -.Sq ~ . +.Ql ~ . The characters following the tilde, up to the first -.Sq / , +.Ql / , if any, are assumed to be a login name. If the login name is empty, -.Sq \&+ +.Ql + or -.Sq \&- , +.Ql - , the value of the .Ev HOME , PWD or @@ -1537,9 +1547,9 @@ are not expanded). Brace expansion is carried out after parameter substitution and before file name generation. .Ss File name patterns A file name pattern is a word containing one or more unquoted -.Sq \&? +.Ql ? or -.Sq \&* +.Ql * characters or .Dq [..] sequences. Once brace expansion has been performed, the shell replaces file @@ -1554,19 +1564,19 @@ Matches any sequence of characters. .It Ic \&[ Ns No .. Ns Ic \&] Matches any of the characters inside the brackets. Ranges of characters can be specified by separating two characters by a -.Sq \&- +.Ql - (e.g., .Dq [a0-9] matches the letter .Dq a or any digit). In order to represent itself, a -.Sq \&- +.Ql - must either be quoted or the first or last character in the character list. Similarly, a -.Sq \&] +.Ql \&] must be quoted or the first character in the list if it is to represent itself instead of the end of the list. Also, a -.Sq \&! +.Ql ! appearing at the start of the list has special meaning (see below), so to represent itself it must be quoted or appear later in the list. .It Ic \&[\&! Ns No .. Ns Ic \&] @@ -1675,9 +1685,11 @@ If the .Ic markdirs option is set, any directories that result from file name generation are marked with a trailing -.Sq / . +.Ql / . .Pp -The POSIX character classes (i.e., +The +.Tn POSIX +character classes (i.e., .Ic \&[\&: Ns Ar class-name Ns Ic \&:\&] inside a .Ic \&[ Ns No .. Ns Ic \&] @@ -1745,11 +1757,11 @@ parameter, command and arithmetic substitutions are performed, along with backslash .Pq Sq \e escapes for -.Sq \&$ , -.Sq ` , -.Sq \e , +.Ql $ , +.Ql ` , +.Ql \e , and -.Sq \enewline . +.Ql \enewline . If multiple here documents are used on the same command line, they are saved in order. .It Ic \&<\&<\&- Ar marker @@ -1762,10 +1774,10 @@ Standard input is duplicated from file descriptor .Ar fd can be a single digit, indicating the number of an existing file descriptor; the letter -.Sq p , +.Ql p , indicating the file descriptor associated with the output of the current co-process; or the character -.Sq \&- , +.Ql - , indicating standard input is to be closed. .It Ic \&>\&& Ar fd Same as @@ -2107,19 +2119,26 @@ returns. .El .El .Ss POSIX mode -The shell is intended to be POSIX compliant, however, in some cases, POSIX +The shell is intended to be +.Tn POSIX +compliant, however, in some cases, +.Tn POSIX behaviour is contrary either to the original Korn shell behaviour or to user convenience. How the shell behaves in these cases is determined by the state of the .Ic posix option .Pq Ic set Fl o Ic posix . -If it is on, the POSIX behaviour is followed, otherwise it is not. The +If it is on, the +.Tn POSIX +behaviour is followed, otherwise it is not. The .Ic posix option is set automatically when the shell starts up if the environment contains the .Dv POSIXLY_CORRECT -parameter. (The shell can also be compiled so that it is in POSIX mode by +parameter. (The shell can also be compiled so that it is in +.Tn POSIX +mode by default, however this is usually not desirable). .Pp The following is a list of things that are affected by the state of the @@ -2131,22 +2150,34 @@ Occurrences of .Ic \e\&" inside double quoted .Ic `\&.\&.` -command substitutions. In POSIX mode, the +command substitutions. In +.Tn POSIX +mode, the .Ic \e\&" -is interpreted when the command is interpreted; in non-POSIX mode, the +is interpreted when the command is interpreted; in +.Pf non- Tn POSIX +mode, the backslash is stripped before the command substitution is interpreted. For example, .Ic echo \&"`echo \e\&"hi\e\&"`\&" produces .Dq \&"hi\&" -in POSIX mode, +in +.Tn POSIX +mode, .Dq hi -in non-POSIX mode. To avoid problems, use the +in +.Pf non- Tn POSIX +mode. To avoid problems, use the .Ic $(...) form of command substitution. .It .Ic kill -l -output. In POSIX mode, signal names are listed one per line; in non-POSIX mode, +output. In +.Tn POSIX +mode, signal names are listed one per line; in +.Pf non- Tn POSIX +mode, signal numbers, names and descriptions are printed in columns. In future, a new option .Po Fl v @@ -2155,19 +2186,30 @@ option will be added to distinguish the two behaviours. .It .Ic fg -exit status. In POSIX mode, the exit status is 0 if no errors occur; in -non-POSIX mode, the exit status is that of the last foregrounded job. +exit status. In +.Tn POSIX +mode, the exit status is 0 if no errors occur; in +.Pf non- Tn POSIX +mode,the exit status is that of the last foregrounded job. .It .Ic getopts . -In POSIX mode, options must start with a -.Sq \&- ; -in non-POSIX mode, options can start with either -.Sq \&- +In +.Tn POSIX +mode, options must start with a +.Ql - ; +in +.Pf non- Tn POSIX +mode, options can start with either +.Ql - or -.Sq \&+ . +.Ql + . .It -Brace expansion (also known as alternation). In POSIX mode, brace expansion is -disabled; in non-POSIX mode, brace expansion is enabled. Note that +Brace expansion (also known as alternation). In +.Tn POSIX +mode, brace expansion is +disabled; in +.Pf non- Tn POSIX +mode, brace expansion is enabled. Note that .Ic set Fl o Ic posix (or setting the .Ev POSIXLY_CORRECT @@ -2176,21 +2218,33 @@ parameter) automatically turns the option off, however, it can be explicitly turned on later. .It .Ic set \&- . -In POSIX mode, this does not clear the +In +.Tn POSIX +mode, this does not clear the .Ic verbose or .Ic xtrace -options; in non-POSIX mode, it does. +options; in +.Pf non- Tn POSIX +mode, it does. .It .Ic set -exit status. In POSIX mode, the exit status of +exit status. In +.Tn POSIX +mode, the exit status of .Ic set -is 0 if there are no errors; in non-POSIX mode, the exit status is that of any +is 0 if there are no errors; in +.Pf non- Tn POSIX +mode, the exit status is that of any command substitutions performed in generating the .Ic set command. For example, .Ic set \&-\&- `false`; echo $? -prints 0 in POSIX mode, 1 in non-POSIX mode. This construct is used in most +prints 0 in +.Tn POSIX +mode, 1 in +.Pf non- Tn POSIX +mode. This construct is used in most shell scripts that use the old .Xr getopt 1 command. @@ -2201,16 +2255,30 @@ Argument expansion of .Ic readonly , and .Ic typeset -commands. In POSIX mode, normal argument expansion is done; in non-POSIX mode, +commands. In +.Tn POSIX +mode, normal argument expansion is done; in +.Pf non- Tn POSIX +mode, field splitting, file globbing, brace expansion, and (normal) tilde expansion are turned off, while assignment tilde expansion is turned on. .It -Signal specification. In POSIX mode, signals can be specified as digits, only -if signal numbers match POSIX values (i.e., HUP=1, INT=2, QUIT=3, ABRT=6, -KILL=9, ALRM=14, and TERM=15); in non-POSIX mode, signals can always be digits. +Signal specification. In +.Tn POSIX +mode, signals can be specified as digits, only +if signal numbers match +.Tn POSIX +values (i.e., HUP=1, INT=2, QUIT=3, ABRT=6, +KILL=9, ALRM=14, and TERM=15); in +.Pf non- Tn POSIX +mode, signals can always be digits. .It -Alias expansion. In POSIX mode, alias expansion is only carried out when -reading command words; in non-POSIX mode, alias expansion is carried out on any +Alias expansion. In +.Tn POSIX +mode, alias expansion is only carried out when +reading command words; in +.Pf non- Tn POSIX +mode, alias expansion is carried out on any word following an alias that ended in a space. For example, the following .Ic for loop @@ -2224,15 +2292,23 @@ loop .Pp uses parameter .Ic i -in POSIX mode, +in +.Tn POSIX +mode, .Ic j -in non-POSIX mode. +in +.Pf non- Tn POSIX +mode. .It -Test. In POSIX mode, the expression +Test. In +.Tn POSIX +mode, the expression .Dq Fl t (preceded by some number of .Dq Ic \&! -arguments) is always true as it is a non-zero length string; in non-POSIX mode, +arguments) is always true as it is a non-zero length string; in +.Pf non- Tn POSIX +mode, it tests if file descriptor 1 is a tty (i.e., the .Ar fd argument to the @@ -2261,10 +2337,15 @@ different only in that the .Ev PATH parameter is not used to find them. .Pp -The original ksh and POSIX differ somewhat in which commands are considered +The original +.Nm +and +.Tn POSIX +differ somewhat in which commands are considered special or regular: .Pp -POSIX special commands +.Tn POSIX +special commands .Pp .Ic \&. , \&: , break , continue , .Ic eval , exec , exit , export , @@ -2275,11 +2356,13 @@ Additional ksh special commands .Pp .Ic builtin , times , typeset .Pp -Very special commands (non-POSIX mode) +Very special commands +.Pq Pf non- Tn POSIX .Pp .Ic alias , readonly , set , typset .Pp -POSIX regular commands +.Tn POSIX +regular commands .Pp .Ic alias , bg , cd , command , .Ic false , fc , fg , getopts , @@ -2292,7 +2375,9 @@ Additional ksh regular commands .Ic pwd , test , ulimit , whence .Pp In the future, the additional ksh special and regular commands may be treated -differently from the POSIX special and regular commands. +differently from the +.Tn POSIX +special and regular commands. .Pp Once the type of the command has been determined, any command line parameter assignments are performed and exported for the duration of the command. @@ -2329,9 +2414,9 @@ as where .Ar value is quoted. If options were preceded with -.Sq \&+ , +.Ql + , or a lone -.Sq \&+ +.Ql + is given on the command line, only .Ar name is printed. In addition, if the @@ -2417,7 +2502,7 @@ is missing, the home directory is used. If .Ar dir is -.Dq \&- , +.Dq - , the previous working directory is used (see .Ev OLDPWD parameter). If the @@ -2470,7 +2555,9 @@ exit, and command assignments are not permanent). If the .Fl p option is given, a default search path is used instead of the current value of .Ev PATH -(the actual value of the default path is system dependent; on POSIXish systems, +(the actual value of the default path is system dependent; on +.Tn POSIX Ns ish +systems, it is the value returned by .Ic getconf CS_PATH ) . .Pp @@ -2510,7 +2597,7 @@ defaults to 1. Prints its arguments (separated by spaces) followed by a newline, to the standard output. The newline is suppressed if any of the arguments contain the backslash sequence -.Sq \ec . +.Ql \ec . See the .Ic print command below for a list of other backslash sequences that are recognized. @@ -2628,11 +2715,11 @@ is invoked, it places the next option in the shell parameter and the index of the next argument to be processed in the shell parameter .Ev OPTIND . If the option was introduced with a -.Sq \&+ , +.Ql + , the option places in .Ar name is prefixed with a -.Sq \&+ . +.Ql + . When an option requires an argument, .Ic getopts places it in the shell parameter @@ -2651,9 +2738,9 @@ When the end of the options is encountered, .Ic getopts exits with a non-zero exit status. Options end at the first (non-option argument) argument that does not start with a -.Sq \&- , +.Ql - , or when a -.Sq \&-\&- +.Ql -- argument is encountered. .Pp Option parsing can be reset by setting @@ -2728,23 +2815,23 @@ terminated with a newline. The .Fl n option suppresses the newline. By default, certain C escapes are translated. These include -.Sq \eb , -.Sq \ef , -.Sq \en , -.Sq \er , -.Sq \et , -.Sq \ev , +.Ql \eb , +.Ql \ef , +.Ql \en , +.Ql \er , +.Ql \et , +.Ql \ev , and -.Sq \e0### +.Ql \e0### .Po -.Sq # +.Ql # is an octal digit, of which there may be 0 to 3 .Pc . -.Sq \ec +.Ql \ec is equivalent to using the .Fl n option. -.Sq \e +.Ql \e expansion may be inhibited with the .Fl r option. The @@ -2769,7 +2856,7 @@ option is used to emulate, to some degree, the .Bx .Xr echo command, which does not process -.Sq \e +.Ql \e sequences unless the .Fl e option is given. As above, the @@ -2971,10 +3058,10 @@ if is used). .It Fl u Ic nounset Referencing of an unset parameter is treated as an error, unless one of the -.Sq \&- , -.Sq \&+ +.Ql - , +.Ql + or -.Sq = +.Ql = modifiers is used. .It Fl v Ic verbose Write shell input to standard error as it is read. @@ -2984,7 +3071,7 @@ the value of .Ev PS4 . .It Fl X Ic markdirs Mark directories with a trailing -.Sq / +.Ql / during file name generation. .It Ic bgnice Background jobs are run with lower priority. @@ -3040,7 +3127,9 @@ and .Ic pwd commands above for more details. .It Ic posix -Enable POSIX mode. See +Enable +.Tn POSIX +mode. See .Sx POSIX mode above. .It Ic vi @@ -3049,7 +3138,8 @@ Enable vi-like command line editing (interactive shells only). No effect. In the original Korn shell, unless .Ic viraw was set, the vi command line mode would let the tty driver do the work until -ESC (^[) was entered. +.Tn ESC +(^[) was entered. .Nm pdksh is always in viraw mode. .It Ic vi-esccomplete @@ -3075,11 +3165,11 @@ will print the long names of all options that are currently on. .Pp Remaining arguments, if any, are positional parameters and are assigned, in order, to the positional parameters (i.e., $1, $2, etc.). If options end with -.Sq \&-\&- +.Ql -- and there are no remaining arguments, all positional parameters are cleared. If no options or arguments are given, the values of all names are printed. For unknown historical reasons, a lone -.Sq \&- +.Ql - option is treated specially -- it clears both the .Fl x and @@ -3187,7 +3277,7 @@ is set (see .Ic set command above for a list of options). As a non-standard extension, if the option starts with a -.Sq \&! , +.Ql ! , the test is negated; the test always fails if .Ar option doesn't exist (thus @@ -3219,7 +3309,9 @@ is a tty device. If the option is not set, .Ar fd may be left out, in which case it is taken to be 1 (the behaviour differs due -to the special POSIX rules described below). +to the special +.Tn POSIX +rules described below). .It Ar string .Ar string is not empty. @@ -3276,23 +3368,26 @@ test). For example, .Ic \&[ -w /dev/fd/2 \&] tests if file descriptor 2 is writable. .Pp -Note that some special rules are applied (courtesy of POSIX) if the number of +Note that some special rules are applied (courtesy of +.Tn POSIX ) +if the number of arguments to .Ic test or .Ic \&[ ... \&] is less than five; if leading -.Sq \&! +.Ql ! arguments can be stripped such that only one argument remains then a string length test is performed (again, even if the argument is a unary operator); if leading -.Sq \&! +.Ql ! arguments can be stripped such that three arguments remain and the second argument is a binary operator, then the binary operation is performed (even if the first argument is a unary operator, including an unstripped -.Sq \&! ) . +.Ql ! ) . .Pp -NOTE: A common mistake is to use +.Sy Note: +A common mistake is to use .Ic if \&[ $foo = bar \&] which fails if parameter .Ic foo @@ -3301,9 +3396,9 @@ is or unset, if it has embedded spaces (i.e., .Ev IFS characters), or if it is a unary operator like -.Sq Ic \&! +.Ql Ic \&! or -.Sq Fl n . +.Ql Fl n . Use tests like .Ic if \&[ \&"X$foo\&" = Xbar \&] instead. @@ -3374,10 +3469,10 @@ arguments, parameter attributes are displayed; if no options are used, the current attributes of all parameters are printed as .Ic typeset commands; if an option is given (or -.Sq \&- +.Ql - with no option letter), all parameters and their values with the specified attributes are printed; if options are introduced with -.Sq \&+ , +.Ql + , parameter values are not printed. .Pp If @@ -3399,7 +3494,7 @@ operates on the attributes of functions. As with parameters, if no .Ar name Ns s are given, functions are listed with their values (i.e., definitions) unless options are introduced with -.Sq \&+ , +.Ql + , in which case only the function names are reported. .Bl -tag -width 3n .It Fl L Ns Ar n @@ -3546,7 +3641,8 @@ kilobytes on the size of the stack area. .It Fl t Ar n Impose a time limit of .Ar n -CPU seconds to be used by each process. +.Tn CPU +seconds to be used by each process. .It Fl v Ar n Impose a limit of .Ar n @@ -3619,10 +3715,10 @@ below for the format of .Ar job . .Ic wait will return if a signal for which a trap has been set is received, or if a -.Dv HUP , -.Dv INT +.Dv SIGHUP , +.Dv SIGINT or -.Dv QUIT +.Dv SIGQUIT signal is received. .Pp If no jobs are specified, @@ -3741,9 +3837,9 @@ where is the job number of the job. .It Ar flag is the -.Sq \&+ +.Ql + or -.Sq \&- +.Ql - character if the job is the .Ic %\&+ or .Ic %\&- @@ -3753,7 +3849,9 @@ indicates the current state of the job and can be: .Bl -tag -width "Running" .It Cm Running The job has neither stopped nor exited (note that running does not necessarily -mean consuming CPU time -- the process could be blocked waiting for some +mean consuming +.Tn CPU +time -- the process could be blocked waiting for some event). .It Cm Done Op Ar number The job exited. @@ -3784,13 +3882,13 @@ When an attempt is made to exit the shell while there are jobs in the stopped state, the shell warns the user that there are stopped jobs and does not exit. If another attempt is immediately made to exit the shell, the stopped jobs are sent a -.Dv HUP +.Dv SIGHUP signal and the shell exits. Similarly, if the .Ic nohup option is not set and there are running jobs when an attempt is made to exit a login shell, the shell warns the user and does not exit. If another attempt is immediately made to exit the shell, the running jobs are sent a -.Dv HUP +.Dv SIGHUP signal and the shell exits. .Ss Emacs interactive input line editing When the @@ -3815,9 +3913,13 @@ notation, i.e., ^X), optionally preceded by one of the two prefix characters. Future input of the .Ar string will cause the editing command to be immediately invoked. Note that although -only two prefix characters (usually ESC and ^X) are supported, some +only two prefix characters (usually +.Tn ESC +and ^X) are supported, some multi-character sequences can be supported. The following binds the arrow keys -on an ANSI terminal, or xterm (these are in the default bindings). Of course +on an +.Tn ANSI +terminal, or xterm (these are in the default bindings). Of course some escape sequences won't work out quite this nicely. .Pp .Bl -item -compact @@ -3850,7 +3952,9 @@ The following is a list of available editing commands. Each description starts with the name of the command, an .Ar n (if the command can be prefixed with a count), and any keys the command is -bound to by default (written using caret notation, i.e., ASCII ESC character is +bound to by default (written using caret notation, i.e., +.Tn "ASCII ESC" +character is written as ^[). A count prefix for a command is entered using the sequence .Ic ^\&[ Ns Ar n , where @@ -3900,7 +4004,7 @@ Automatically completes as much as is unique of the command name or the file name containing the cursor. If the entire remaining command or file name is unique, a space is printed after its completion, unless it is a directory name in which case -.Sq / +.Ql / is appended. If there is no command or file name with the current partialword as its prefix, a bell character is output (usually causing a beep to be sounded). @@ -3969,7 +4073,7 @@ Error (ring the bell). Places the cursor where the mark is and sets the mark to where the cursor was. .It Ic expand-file ^[\&* Appends a -.Sq \&* +.Ql * to the current word and replaces the word with the result of performing file globbing on the word. If no files match the pattern, the bell is rung. .It Ic forward-char Ar n Ic ^F @@ -3995,7 +4099,7 @@ is not specified; otherwise deletes characters between the cursor and column .It Ic list ^[? Prints a sorted, columnated list of command named or file names (if any) that can complete the partial word containing the cursor. Directoary names have -.Sq / +.Ql / appended to them. .It Ic list-command ^X? Prints a sorted, columnated list of command names (if any) that can complete @@ -4041,7 +4145,7 @@ occurrence of the next character typed. .It Ic search-history ^R Enter incremental search mode. The internal history list is searched backwards for commands matching the input. An initial -.Sq ^ +.Ql ^ in the search string anchors the search. The abort key will leave search mode. Other commands will be executed after leaving search mode. Successive .Ic search-history @@ -4161,10 +4265,10 @@ above), enabled with If a line is longer than the screen width (see .Dv COLUMNS parameter), a -.Sq \&> , -.Sq \&+ +.Ql > , +.Ql + or -.Sq \&< +.Ql < character is displayed in the last column indicating that there are more characters after, before and after, or before the current position, respectively. The line is scrolled horizontally as necessary. @@ -4224,16 +4328,16 @@ is not specified, the current line is edited. The actual command executed is .It Ic \&* No and Ic ^X Command or file name expansion is applied to the current big-word (with an appended -.Sq \&* , +.Ql * , if the word contains no file globbing characters) -- the big-word is replaced with the resulting words. If the current big-word is the first on the line (or follows one of the following characters: -.Sq \&; , -.Sq \&| , -.Sq \&& , -.Sq \&( , +.Ql \&; , +.Ql | , +.Ql & , +.Ql ( , or -.Sq \&) ) +.Ql \&) ) and does not contain a slash .Pq Sq / then the command expansion is done; otherwise file name expansion is done. @@ -4388,7 +4492,7 @@ line containing if .Ar string starts with -.Sq ^ , +.Ql ^ , the remainder of the string must appear at the start of the history line for it to match. .It Ar n Ns Ic \&? Ns Ar string diff --git a/bin/ksh/sh.1 b/bin/ksh/sh.1 index c1a2fad6976..2c5782e77db 100644 --- a/bin/ksh/sh.1 +++ b/bin/ksh/sh.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sh.1,v 1.10 1999/05/28 12:23:06 aaron Exp $ +.\" $OpenBSD: sh.1,v 1.11 1999/05/30 17:44:56 aaron Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -150,10 +150,10 @@ option of the built-in command can't be used. .It Redirections that create files can't be used (i.e., -.Sq > , -.Sq >| , -.Sq >> , -.Sq <> ) . +.Ql > , +.Ql >| , +.Ql >> , +.Ql <> ) . .El .Pp A shell is @@ -176,7 +176,7 @@ its effective user ID (group ID) to its real user ID (group ID). .Pp If the basename of the name the shell is called with (i.e., argv[0]) starts with -.Sq \&- +.Ql - or if the .Fl l option is used, @@ -216,42 +216,42 @@ The shells begins parsing its input by breaking it into Words, which are sequences of characters, are delimited by unquoted whitespace characters (space, tab, and newline) or meta-characters .Po -.Sq \&< , -.Sq \&> , -.Sq \&| , -.Sq \&; , -.Sq \&( , +.Ql < , +.Ql > , +.Ql | , +.Ql \&; , +.Ql ( , and -.Sq \&) +.Ql \&) .Pc . Aside from delimiting words, spaces and tabs are ignored, while newlines usually delimit commands. The meta-charcters are used in building the following tokens: -.Sq \&< , -.Sq \&<\&& , -.Sq \&<\&< , -.Sq \&> , -.Sq \&>\&& , -.Sq \&>\&> , +.Ql < , +.Ql <& , +.Ql << , +.Ql > , +.Ql >& , +.Ql >> , etc. are used to specify redirections (see .Sx Input/output redirection below); -.Sq \&| +.Ql | is used to create pipelines; -.Sq \&; +.Ql \&; is used to separate commands; -.Sq \&& +.Ql & is used to create asynchronous pipelines; -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || are used to specify conditional execution; -.Sq \&;\&; +.Ql \&;\&; is used in .Ic case statements; and lastly, -.Sq \&( .. \&) +.Ql \&( .. \&) is used to create subshells. .Pp Whitespace and meta-characters can be quoted individually using a backslash @@ -262,52 +262,52 @@ or single .Pq Sq \&' quotes. Note that the following characters are also treated specially by the shell and must be quoted if they are to represent themselves: -.Sq \e , -.Sq \&" , -.Sq \&' , -.Sq \&# , -.Sq \&$ , -.Sq \&` , -.Sq \&~ , -.Sq \&{ , -.Sq \&} , -.Sq \&* , -.Sq \&? , +.Ql \e , +.Ql \&" , +.Ql ' , +.Ql # , +.Ql $ , +.Ql ` , +.Ql ~ , +.Ql { , +.Ql } , +.Ql * , +.Ql ? , and -.Sq \&[ . +.Ql [ . The first three of these are the above mentioned quoting characters (see .Sx Quoting below); -.Sq \&# , +.Ql # , if used at the beginning of a word, introduces a comment -- everything after the -.Sq \&# +.Ql # up to the nearest newline is ignored; -.Sq \&$ +.Ql $ is used to introduce parameter, command and arithmetic substitutions (see .Sx Substitution below); -.Sq \&` +.Ql ` introduces an old-style command substitution (see .Sx Substitution below); -.Sq \&~ +.Ql ~ begins a directory expansion (see .Sx Tilde expansion below); -.Sq \&{ +.Ql { and -.Sq \&} +.Ql } delimit .Xr csh 1 style alterations (see .Sx Brace expansion below); and finally, -.Sq \&* , -.Sq \&? , +.Ql * , +.Ql ? , and -.Sq \&[ +.Ql [ are used in file name generation (see .Sx File name patterns below). @@ -351,13 +351,13 @@ assignments is that of the last command substitution performed during the parameter assignment or 0 is there were no command substitutions. .Pp Commands can be chained together using the -.Sq \&| +.Ql | token to form pipelines, in which the standard output of each command but the last is piped (see .Xr pipe 2 ) to the standard input of the following command. The exit status of a pipeline is that of its last command. A pipeline may be prefixed by the -.Sq \&! +.Ql ! reversed word which causes the exit status of the pipeline to be logically complemented: if the original status was 0 the complemented status will be 1; if the original status was not 0, the complemented status will be 0. @@ -365,12 +365,12 @@ if the original status was not 0, the complemented status will be 0. .Em Lists of commands can be created by separating pipelines by any of the following tokens: -.Sq \&&\&& , -.Sq \&|\&| , -.Sq \&& , -.Sq \&|\&& , +.Ql && , +.Ql || , +.Ql & , +.Ql |& , and -.Sq \&; . +.Ql \&; . The first two are for conditional execution: .Dq Ar cmd1 No && Ar cmd2 executes @@ -378,22 +378,22 @@ executes only if the exit status of .Ar cmd1 is zero; -.Sq \&|\&| +.Ql || is the opposite -- .Ar cmd2 is executed only if the exit status of .Ar cmd1 is non-zero. -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || have equal precedence which is higher that that of -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& and -.Sq \&; , +.Ql \&; , which also have equal precedence. The -.Sq \&& +.Ql & token causes the preceding command to be executed asynchronously; that is, the shell starts the command but does not wait for it to complete (the shell does keep track of the status of asynchronous commands, see @@ -407,14 +407,14 @@ ignored and with input redirected from .Pa /dev/null (however, redirections specified in the asynchronous command have precedence). Note that a command must follow the -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || operators, while it need not follow -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& or -.Sq \&; . +.Ql \&; . The exit status of a list is that of the last command executed, with the exception of asynchronous lists, for which the exit status is 0. .Pp @@ -432,7 +432,8 @@ done fi in while { elif for time then } .TE .Pp -NOTE: Some shells (but not this one) execute control structure commands in a +.Sy Note: +Some shells (but not this one) execute control structure commands in a subshell when one or more of their file descriptors are redirected, so any environment changes inside them may fail. To be portable, the .Ic exec @@ -491,9 +492,9 @@ used in .Ic case statements are the same as those used for file name patterns except that the restrictions regarding -.Sq \&. +.Ql \&. and -.Sq \&/ +.Ql / are dropped. Note that any unquoted space before and after a pattern is stripped; any space with a pattern must be quoted. Both the word and the patterns are subject to parameter, command and arithmetic substitution as @@ -540,7 +541,7 @@ if is never executed, the exit status is zero. .Ar term is either a newline or a -.Sq \&; . +.Ql \&; . .It Xo Ic if Ar list Ic then .Ar list [ Ic elif Ar list Ic then .Ar list ] Ar ... [ Ic else @@ -611,42 +612,43 @@ below). .Ss Quoting Quoting is used to prevent the shell from treating characters or words specially. There are three methods of quoting. First, -.Sq \e +.Ql \e quotes the following character, unless it is at the end of a line, in which case both the -.Sq \e +.Ql \e and the newline are stripped. Second, a single quote .Pq Sq ' quotes everything up to the next single quote (this may span lines). Third, a double quote .Pq Sq \&" quotes all characters, except -.Sq \&$ , -.Sq \&` +.Ql $ , +.Ql ` and -.Sq \e , +.Ql \e , up to the next unquoted double quote. -.Sq $ +.Ql $ and -.Sq ` +.Ql ` inside double quotes have their usual meaning (i.e., parameter, command or arithmetic substitution) except no field splitting is carried out on the results of double-quoted substitutions. If a -.Sq \e +.Ql \e inside a double-quoted string is followed by -.Sq \e , -.Sq $ , -.Sq ` , +.Ql \e , +.Ql $ , +.Ql ` , or -.Sq \&" , +.Ql \&" , it is replaced by the second character; if it is followed by a newline, both the -.Sq \e +.Ql \e and the newline are stripped; otherwise, both the -.Sq \e +.Ql \e and the character following are unchanged. .Pp -NOTE: See +.Sy Note: +See .Sx POSIX mode below for a special rule regarding sequences of the form .Ic \&"...`...\e\&"...`..\&" . @@ -724,11 +726,15 @@ characters are called .Dq IFS whitespace . Sequences of one or more .Ev IFS -whitespace characters, in combination with zero or none non-IFS whitespace +whitespace characters, in combination with zero or no +.Pf non- Ev IFS +whitespace characters delimit a field. As a special case, leading and trailing .Ev IFS whitespace is stripped (i.e., no leading or trailing empty field is created by -it); leading or trailing non-IFS whitespace does create an empty field. +it); leading or trailing +.Pf non- Ev IFS +whitespace does create an empty field. .Pp Example: If .Ev IFS @@ -780,14 +786,14 @@ substitutions, normal quoting rules are used when is parsed, however, for the .Ic ` Ns Ar command Ns Ic ` form, a -.Sq \e +.Ql \e followed by any of -.Sq $ , -.Sq ` , +.Ql $ , +.Ql ` , or -.Sq \e +.Ql \e is stripped (a -.Sq \e +.Ql \e followed by any other character is unchanged). As a special case in command substitutions, a command of the form .Ic \&< Ar file @@ -799,7 +805,7 @@ has the same effect as .Ic $(cat foo) , but it is carried out more efficiently because no process is started). .Pp -NOTE: +.Sy Note: .Ic $( Ns Ar command Ns Ic \&) expressions are currently parsed by finding the matching parenthesis, regardless of quoting. This will hopefully be fixed soon. @@ -816,7 +822,7 @@ can be accessed using a parameter substitution. A parameter name is either one of the special single punctuation or digit character parameters described below, or a letter followed by zero or more letters or digits .Po -.Sq _ +.Ql _ counts as a letter .Pc . Parameter substitutions take the form @@ -854,7 +860,7 @@ can be followed by a simple-command, in which case the assignments are in effect only for the duration of the command (such assignments are also exported, see below for implications of this). Note that both the parameter name and the -.Sq = +.Ql = must be unquoted for the shell to recognize a parameter assignment. The fourth way of setting a parameter is with the .Ic export , @@ -946,7 +952,7 @@ is used instead. .El .Pp In the above modifiers, the -.Sq \&: +.Ql \&: can be omitted, in which case the conditions only depand on .Ar name being set (as opposed to set and not @@ -964,8 +970,8 @@ The following forms of parameter substitution can also be used: The number of positional parameters if .Ar name is -.Sq \&* , -.Sq \&@ , +.Ql * , +.Ql @ , not specified, or the length of the string value of parameter .Ar name . .It Xo Ic ${# Ns Ar name Ns @@ -984,7 +990,7 @@ If matches the beginning of the value of parameter .Ar name , the matched text is deleted from the result of substitution. A single -.Sq \&# +.Ql # results in the shortest match, two of them results in the longest match. .Sm off @@ -1068,7 +1074,7 @@ Search path for the built-in command. Works the same way as .Ev PATH for those directories not beginning with -.Sq \&/ +.Ql / in .Ic cd commands. Note that if @@ -1134,7 +1140,8 @@ and newline. See .Sx Substitution above for details. .Pp -NOTE: This parameter is not imported from the environment when the shell is +.Sy Note: +This parameter is not imported from the environment when the shell is started. .It Ev SH_VERSION The version of shell and the date the version was created (read-only). @@ -1206,13 +1213,13 @@ files are created in .Ss Tilde expansion Tilde expansion, which is done in parallel with parameter substitution, is done on words starting with an unquoted -.Sq ~ . +.Ql ~ . The characters following the tilde, up to the first -.Sq / , +.Ql / , if any, are assumed to be a login name. If the login name is empty, -.Sq \&+ +.Ql + or -.Sq \&- , +.Ql - , the value of the .Ev HOME , PWD or @@ -1241,9 +1248,9 @@ command may be used to list, change and add to this cache (e.g., .Ic alias -d fac=/usr/local/facilities; cd ~fac/bin ) . .Ss File name patterns A file name pattern is a word containing one or more unquoted -.Sq \&? +.Ql ? or -.Sq \&* +.Ql * characters or .Dq [..] sequences. Once brace expansion has been performed, the shell replaces file @@ -1258,19 +1265,19 @@ Matches any sequence of characters. .It Ic \&[ Ns No .. Ns Ic \&] Matches any of the characters inside the brackets. Ranges of characters can be specified by separating two characters by a -.Sq \&- +.Ql - (e.g., .Dq [a0-9] matches the letter .Dq a or any digit). In order to represent itself, a -.Sq \&- +.Ql - must either be quoted or the first or last character in the character list. Similarly, a -.Sq \&] +.Ql \&] must be quoted or the first character in the list if it is to represent itself instead of the end of the list. Also, a -.Sq \&! +.Ql ! appearing at the start of the list has special meaning (see below), so to represent itself it must be quoted or appear later in the list. .It Ic \&[\&! Ns No .. Ns Ic \&] @@ -1310,7 +1317,7 @@ If the .Ic markdirs option is set, any directories that result from file name generation are marked with a trailing -.Sq / . +.Ql / . .Pp The POSIX character classes (i.e., .Ic \&[\&: Ns Ar class-name Ns Ic \&:\&] @@ -1380,9 +1387,9 @@ parameter, command and arithmetic substitutions are performed, along with backslash .Pq Sq \e escapes for -.Sq \&$ , -.Sq ` , -.Sq \e , +.Ql $ , +.Ql ` , +.Ql \e , and .Dq \enewline . If multiple here documents are used on the same command line, they are saved in @@ -1397,10 +1404,10 @@ Standard input is duplicated from file descriptor .Ar fd can be a single digit, indicating the number of an existing file descriptor; the letter -.Sq p , +.Ql p , indicating the file descriptor associated with the output of the current co-process; or the character -.Sq \&- , +.Ql - , indicating standard input is to be closed. .It Ic \&>\&& Ar fd Same as @@ -1755,11 +1762,11 @@ non-POSIX mode, the exit status is that of the last foregrounded job. .It .Ic getopts . In POSIX mode, options must start with a -.Sq \&- ; +.Ql - ; in non-POSIX mode, options can start with either -.Sq \&- +.Ql - or -.Sq \&+ . +.Ql + . .It Brace expansion (also known as alternation). In POSIX mode, brace expansion is disabled; in non-POSIX mode, brace expansion is enabled. Note that @@ -1824,9 +1831,9 @@ in POSIX mode, in non-POSIX mode. .It Test. In POSIX mode, the expression -.Sq Fl t +.Ql Fl t (preceded by some number of -.Sq Ic \&! +.Ql Ic \&! arguments) is always true as it is a non-zero length string; in non-POSIX mode, it tests if file descriptor 1 is a tty (i.e., the .Ar fd @@ -1924,7 +1931,7 @@ as where .Ar value is quoted. If options were preceded with -.Sq \&+ , +.Ql + , or a lone \&+ is given on the command line, only .Ar name is printed. In addition, if the @@ -2009,7 +2016,7 @@ is missing, the home directory is used. If .Ar dir is -.Sq \&- , +.Ql - , the previous working directory is used (see .Ev OLDPWD parameter). If the @@ -2077,7 +2084,7 @@ defaults to 1. Prints its arguments (separated by spaces) followed by a newline, to the standard output. The newline is suppressed if any of the arguments contain the backslash sequence -.Sq \ec . +.Ql \ec . See the .Ic print command below for a list of other backslash sequences that are recognized. @@ -2170,11 +2177,11 @@ is invoked, it places the next option in the shell parameter and the index of the next argument to be processed in the shell parameter .Ev OPTIND . If the option was introduced with a -.Sq \&+ , +.Ql + , the option places in .Ar name is prefixed with a -.Sq \&+ . +.Ql + . When an option requires an argument, .Ic getopts places it in the shell parameter @@ -2193,9 +2200,9 @@ When the end of the options is encountered, .Ic getopts exits with a non-zero exit status. Options end at the first (non-option argument) argument that does not start with a -.Sq \&- , +.Ql - , or when a -.Sq \&-\&- +.Ql -- argument is encountered. .Pp Option parsing can be reset by setting @@ -2260,23 +2267,23 @@ terminated with a newline. The .Fl n option suppresses the newline. By default, certain C escapes are translated. These include -.Sq \eb , -.Sq \ef , -.Sq \en , -.Sq \er , -.Sq \et , -.Sq \ev , +.Ql \eb , +.Ql \ef , +.Ql \en , +.Ql \er , +.Ql \et , +.Ql \ev , and -.Sq \e0### +.Ql \e0### .Po -.Sq # +.Ql # is an octal digit, of which there may be 0 to 3 .Pc . -.Sq \ec +.Ql \ec is equivalent to using the .Fl n option. -.Sq \e +.Ql \e expansion may be inhibited with the .Fl r option. The @@ -2301,7 +2308,7 @@ option is used to emulate, to some degree, the .Bx .Xr echo command, which does not process -.Sq \e +.Ql \e sequences unless the .Fl e option is given. As above, the @@ -2503,10 +2510,10 @@ if is used). .It Fl u Ic nounset Referencing of an unset parameter is treated as an error, unless one of the -.Sq \&- , -.Sq \&+ +.Ql - , +.Ql + or -.Sq = +.Ql = modifiers is used. .It Fl v Ic verbose Write shell input to standard error as it is read. @@ -2516,7 +2523,7 @@ the value of .Ev PS4 . .It Fl X Ic markdirs Mark directories with a trailing -.Sq / +.Ql / during file name generation. .It Ic bgnice Background jobs are run with lower priority. @@ -2571,7 +2578,8 @@ Enable vi-like command line editing (interactive shells only). No effect. In the original Korn shell, unless .Ic viraw was set, the vi command line mode would let the tty driver do the work until -ESC (^[) was entered. +.Tn ESC +(^[) was entered. .Nm pdksh is always in viraw mode. .It Ic vi-esccomplete @@ -2597,11 +2605,11 @@ will print the long names of all options that are currently on. .Pp Remaining arguments, if any, are positional parameters and are assigned, in order, to the positional parameters (i.e., $1, $2, etc.). If options end with -.Sq \&-\&- +.Ql -- and there are no remaining arguments, all positional parameters are cleared. If no options or arguments are given, the values of all names are printed. For unknown historical reasons, a lone -.Sq \&- +.Ql - option is treated specially -- it clears both the .Fl x and @@ -2709,7 +2717,7 @@ is set (see .Ic set command above for a list of options). As a non-standard extension, if the option starts with a -.Sq \&! , +.Ql ! , the test is negated; the test always fails if .Ar option doesn't exist (thus @@ -2802,17 +2810,18 @@ arguments to or .Ic \&[ ... \&] is less than five; if leading -.Sq \&! +.Ql ! arguments can be stripped such that only one argument remains then a string length test is performed (again, even if the argument is a unary operator); if leading -.Sq \&! +.Ql ! arguments can be stripped such that three arguments remain and the second argument is a binary operator, then the binary operation is performed (even if the first argument is a unary operator, including an unstripped -.Sq \&! ) . +.Ql ! ) . .Pp -NOTE: A common mistake is to use +.Sy Note: +A common mistake is to use .Ic if \&[ $foo = bar \&] which fails if parameter .Ic foo @@ -2821,9 +2830,9 @@ is or unset, if it has embedded spaces (i.e., .Ev IFS characters), or if it is a unary operator like -.Sq Ic \&! +.Ql Ic \&! or -.Sq Fl n . +.Ql Fl n . Use tests like .Ic if \&[ \&"X$foo\&" = Xbar \&] instead. @@ -2894,10 +2903,10 @@ arguments, parameter attributes are displayed; if no options are used, the current attributes of all parameters are printed as .Ic typeset commands; if an option is given (or -.Sq \&- +.Ql - with no option letter), all parameters and their values with the specified attributes are printed; if options are introduced with -.Sq \&+ , +.Ql + , parameter values are not printed. .Pp If @@ -2919,7 +2928,7 @@ operates on the attributes of functions. As with parameters, if no .Ar name Ns s are given, functions are listed with their values (i.e., definitions) unless options are introduced with -.Sq \&+ , +.Ql + , in which case only the function names are reported. .Bl -tag -width 3n .It Fl L Ns Ar n @@ -3261,9 +3270,9 @@ where is the job number of the job. .It Ar flag is the -.Sq \&+ +.Ql + or -.Sq \&- +.Ql - character if the job is the .Ic %\&+ or .Ic %\&- diff --git a/bin/ksh/sh.1tbl b/bin/ksh/sh.1tbl index 97ae3b773c5..ec899910111 100644 --- a/bin/ksh/sh.1tbl +++ b/bin/ksh/sh.1tbl @@ -1,4 +1,4 @@ -.\" $OpenBSD: sh.1tbl,v 1.10 1999/05/28 12:23:06 aaron Exp $ +.\" $OpenBSD: sh.1tbl,v 1.11 1999/05/30 17:44:56 aaron Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -150,10 +150,10 @@ option of the built-in command can't be used. .It Redirections that create files can't be used (i.e., -.Sq > , -.Sq >| , -.Sq >> , -.Sq <> ) . +.Ql > , +.Ql >| , +.Ql >> , +.Ql <> ) . .El .Pp A shell is @@ -176,7 +176,7 @@ its effective user ID (group ID) to its real user ID (group ID). .Pp If the basename of the name the shell is called with (i.e., argv[0]) starts with -.Sq \&- +.Ql - or if the .Fl l option is used, @@ -216,42 +216,42 @@ The shells begins parsing its input by breaking it into Words, which are sequences of characters, are delimited by unquoted whitespace characters (space, tab, and newline) or meta-characters .Po -.Sq \&< , -.Sq \&> , -.Sq \&| , -.Sq \&; , -.Sq \&( , +.Ql < , +.Ql > , +.Ql | , +.Ql \&; , +.Ql ( , and -.Sq \&) +.Ql \&) .Pc . Aside from delimiting words, spaces and tabs are ignored, while newlines usually delimit commands. The meta-charcters are used in building the following tokens: -.Sq \&< , -.Sq \&<\&& , -.Sq \&<\&< , -.Sq \&> , -.Sq \&>\&& , -.Sq \&>\&> , +.Ql < , +.Ql <& , +.Ql << , +.Ql > , +.Ql >& , +.Ql >> , etc. are used to specify redirections (see .Sx Input/output redirection below); -.Sq \&| +.Ql | is used to create pipelines; -.Sq \&; +.Ql \&; is used to separate commands; -.Sq \&& +.Ql & is used to create asynchronous pipelines; -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || are used to specify conditional execution; -.Sq \&;\&; +.Ql \&;\&; is used in .Ic case statements; and lastly, -.Sq \&( .. \&) +.Ql \&( .. \&) is used to create subshells. .Pp Whitespace and meta-characters can be quoted individually using a backslash @@ -262,52 +262,52 @@ or single .Pq Sq \&' quotes. Note that the following characters are also treated specially by the shell and must be quoted if they are to represent themselves: -.Sq \e , -.Sq \&" , -.Sq \&' , -.Sq \&# , -.Sq \&$ , -.Sq \&` , -.Sq \&~ , -.Sq \&{ , -.Sq \&} , -.Sq \&* , -.Sq \&? , +.Ql \e , +.Ql \&" , +.Ql ' , +.Ql # , +.Ql $ , +.Ql ` , +.Ql ~ , +.Ql { , +.Ql } , +.Ql * , +.Ql ? , and -.Sq \&[ . +.Ql [ . The first three of these are the above mentioned quoting characters (see .Sx Quoting below); -.Sq \&# , +.Ql # , if used at the beginning of a word, introduces a comment -- everything after the -.Sq \&# +.Ql # up to the nearest newline is ignored; -.Sq \&$ +.Ql $ is used to introduce parameter, command and arithmetic substitutions (see .Sx Substitution below); -.Sq \&` +.Ql ` introduces an old-style command substitution (see .Sx Substitution below); -.Sq \&~ +.Ql ~ begins a directory expansion (see .Sx Tilde expansion below); -.Sq \&{ +.Ql { and -.Sq \&} +.Ql } delimit .Xr csh 1 style alterations (see .Sx Brace expansion below); and finally, -.Sq \&* , -.Sq \&? , +.Ql * , +.Ql ? , and -.Sq \&[ +.Ql [ are used in file name generation (see .Sx File name patterns below). @@ -351,13 +351,13 @@ assignments is that of the last command substitution performed during the parameter assignment or 0 is there were no command substitutions. .Pp Commands can be chained together using the -.Sq \&| +.Ql | token to form pipelines, in which the standard output of each command but the last is piped (see .Xr pipe 2 ) to the standard input of the following command. The exit status of a pipeline is that of its last command. A pipeline may be prefixed by the -.Sq \&! +.Ql ! reversed word which causes the exit status of the pipeline to be logically complemented: if the original status was 0 the complemented status will be 1; if the original status was not 0, the complemented status will be 0. @@ -365,12 +365,12 @@ if the original status was not 0, the complemented status will be 0. .Em Lists of commands can be created by separating pipelines by any of the following tokens: -.Sq \&&\&& , -.Sq \&|\&| , -.Sq \&& , -.Sq \&|\&& , +.Ql && , +.Ql || , +.Ql & , +.Ql |& , and -.Sq \&; . +.Ql \&; . The first two are for conditional execution: .Dq Ar cmd1 No && Ar cmd2 executes @@ -378,22 +378,22 @@ executes only if the exit status of .Ar cmd1 is zero; -.Sq \&|\&| +.Ql || is the opposite -- .Ar cmd2 is executed only if the exit status of .Ar cmd1 is non-zero. -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || have equal precedence which is higher that that of -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& and -.Sq \&; , +.Ql \&; , which also have equal precedence. The -.Sq \&& +.Ql & token causes the preceding command to be executed asynchronously; that is, the shell starts the command but does not wait for it to complete (the shell does keep track of the status of asynchronous commands, see @@ -407,14 +407,14 @@ ignored and with input redirected from .Pa /dev/null (however, redirections specified in the asynchronous command have precedence). Note that a command must follow the -.Sq \&&\&& +.Ql && and -.Sq \&|\&| +.Ql || operators, while it need not follow -.Sq \&& , -.Sq \&|\&& +.Ql & , +.Ql |& or -.Sq \&; . +.Ql \&; . The exit status of a list is that of the last command executed, with the exception of asynchronous lists, for which the exit status is 0. .Pp @@ -432,7 +432,8 @@ done fi in while { elif for time then } .TE .Pp -NOTE: Some shells (but not this one) execute control structure commands in a +.Sy Note: +Some shells (but not this one) execute control structure commands in a subshell when one or more of their file descriptors are redirected, so any environment changes inside them may fail. To be portable, the .Ic exec @@ -491,9 +492,9 @@ used in .Ic case statements are the same as those used for file name patterns except that the restrictions regarding -.Sq \&. +.Ql \&. and -.Sq \&/ +.Ql / are dropped. Note that any unquoted space before and after a pattern is stripped; any space with a pattern must be quoted. Both the word and the patterns are subject to parameter, command and arithmetic substitution as @@ -540,7 +541,7 @@ if is never executed, the exit status is zero. .Ar term is either a newline or a -.Sq \&; . +.Ql \&; . .It Xo Ic if Ar list Ic then .Ar list [ Ic elif Ar list Ic then .Ar list ] Ar ... [ Ic else @@ -611,42 +612,43 @@ below). .Ss Quoting Quoting is used to prevent the shell from treating characters or words specially. There are three methods of quoting. First, -.Sq \e +.Ql \e quotes the following character, unless it is at the end of a line, in which case both the -.Sq \e +.Ql \e and the newline are stripped. Second, a single quote .Pq Sq ' quotes everything up to the next single quote (this may span lines). Third, a double quote .Pq Sq \&" quotes all characters, except -.Sq \&$ , -.Sq \&` +.Ql $ , +.Ql ` and -.Sq \e , +.Ql \e , up to the next unquoted double quote. -.Sq $ +.Ql $ and -.Sq ` +.Ql ` inside double quotes have their usual meaning (i.e., parameter, command or arithmetic substitution) except no field splitting is carried out on the results of double-quoted substitutions. If a -.Sq \e +.Ql \e inside a double-quoted string is followed by -.Sq \e , -.Sq $ , -.Sq ` , +.Ql \e , +.Ql $ , +.Ql ` , or -.Sq \&" , +.Ql \&" , it is replaced by the second character; if it is followed by a newline, both the -.Sq \e +.Ql \e and the newline are stripped; otherwise, both the -.Sq \e +.Ql \e and the character following are unchanged. .Pp -NOTE: See +.Sy Note: +See .Sx POSIX mode below for a special rule regarding sequences of the form .Ic \&"...`...\e\&"...`..\&" . @@ -724,11 +726,15 @@ characters are called .Dq IFS whitespace . Sequences of one or more .Ev IFS -whitespace characters, in combination with zero or none non-IFS whitespace +whitespace characters, in combination with zero or no +.Pf non- Ev IFS +whitespace characters delimit a field. As a special case, leading and trailing .Ev IFS whitespace is stripped (i.e., no leading or trailing empty field is created by -it); leading or trailing non-IFS whitespace does create an empty field. +it); leading or trailing +.Pf non- Ev IFS +whitespace does create an empty field. .Pp Example: If .Ev IFS @@ -780,14 +786,14 @@ substitutions, normal quoting rules are used when is parsed, however, for the .Ic ` Ns Ar command Ns Ic ` form, a -.Sq \e +.Ql \e followed by any of -.Sq $ , -.Sq ` , +.Ql $ , +.Ql ` , or -.Sq \e +.Ql \e is stripped (a -.Sq \e +.Ql \e followed by any other character is unchanged). As a special case in command substitutions, a command of the form .Ic \&< Ar file @@ -799,7 +805,7 @@ has the same effect as .Ic $(cat foo) , but it is carried out more efficiently because no process is started). .Pp -NOTE: +.Sy Note: .Ic $( Ns Ar command Ns Ic \&) expressions are currently parsed by finding the matching parenthesis, regardless of quoting. This will hopefully be fixed soon. @@ -816,7 +822,7 @@ can be accessed using a parameter substitution. A parameter name is either one of the special single punctuation or digit character parameters described below, or a letter followed by zero or more letters or digits .Po -.Sq _ +.Ql _ counts as a letter .Pc . Parameter substitutions take the form @@ -854,7 +860,7 @@ can be followed by a simple-command, in which case the assignments are in effect only for the duration of the command (such assignments are also exported, see below for implications of this). Note that both the parameter name and the -.Sq = +.Ql = must be unquoted for the shell to recognize a parameter assignment. The fourth way of setting a parameter is with the .Ic export , @@ -946,7 +952,7 @@ is used instead. .El .Pp In the above modifiers, the -.Sq \&: +.Ql \&: can be omitted, in which case the conditions only depand on .Ar name being set (as opposed to set and not @@ -964,8 +970,8 @@ The following forms of parameter substitution can also be used: The number of positional parameters if .Ar name is -.Sq \&* , -.Sq \&@ , +.Ql * , +.Ql @ , not specified, or the length of the string value of parameter .Ar name . .It Xo Ic ${# Ns Ar name Ns @@ -984,7 +990,7 @@ If matches the beginning of the value of parameter .Ar name , the matched text is deleted from the result of substitution. A single -.Sq \&# +.Ql # results in the shortest match, two of them results in the longest match. .Sm off @@ -1068,7 +1074,7 @@ Search path for the built-in command. Works the same way as .Ev PATH for those directories not beginning with -.Sq \&/ +.Ql / in .Ic cd commands. Note that if @@ -1134,7 +1140,8 @@ and newline. See .Sx Substitution above for details. .Pp -NOTE: This parameter is not imported from the environment when the shell is +.Sy Note: +This parameter is not imported from the environment when the shell is started. .It Ev SH_VERSION The version of shell and the date the version was created (read-only). @@ -1206,13 +1213,13 @@ files are created in .Ss Tilde expansion Tilde expansion, which is done in parallel with parameter substitution, is done on words starting with an unquoted -.Sq ~ . +.Ql ~ . The characters following the tilde, up to the first -.Sq / , +.Ql / , if any, are assumed to be a login name. If the login name is empty, -.Sq \&+ +.Ql + or -.Sq \&- , +.Ql - , the value of the .Ev HOME , PWD or @@ -1241,9 +1248,9 @@ command may be used to list, change and add to this cache (e.g., .Ic alias -d fac=/usr/local/facilities; cd ~fac/bin ) . .Ss File name patterns A file name pattern is a word containing one or more unquoted -.Sq \&? +.Ql ? or -.Sq \&* +.Ql * characters or .Dq [..] sequences. Once brace expansion has been performed, the shell replaces file @@ -1258,19 +1265,19 @@ Matches any sequence of characters. .It Ic \&[ Ns No .. Ns Ic \&] Matches any of the characters inside the brackets. Ranges of characters can be specified by separating two characters by a -.Sq \&- +.Ql - (e.g., .Dq [a0-9] matches the letter .Dq a or any digit). In order to represent itself, a -.Sq \&- +.Ql - must either be quoted or the first or last character in the character list. Similarly, a -.Sq \&] +.Ql \&] must be quoted or the first character in the list if it is to represent itself instead of the end of the list. Also, a -.Sq \&! +.Ql ! appearing at the start of the list has special meaning (see below), so to represent itself it must be quoted or appear later in the list. .It Ic \&[\&! Ns No .. Ns Ic \&] @@ -1310,7 +1317,7 @@ If the .Ic markdirs option is set, any directories that result from file name generation are marked with a trailing -.Sq / . +.Ql / . .Pp The POSIX character classes (i.e., .Ic \&[\&: Ns Ar class-name Ns Ic \&:\&] @@ -1380,9 +1387,9 @@ parameter, command and arithmetic substitutions are performed, along with backslash .Pq Sq \e escapes for -.Sq \&$ , -.Sq ` , -.Sq \e , +.Ql $ , +.Ql ` , +.Ql \e , and .Dq \enewline . If multiple here documents are used on the same command line, they are saved in @@ -1397,10 +1404,10 @@ Standard input is duplicated from file descriptor .Ar fd can be a single digit, indicating the number of an existing file descriptor; the letter -.Sq p , +.Ql p , indicating the file descriptor associated with the output of the current co-process; or the character -.Sq \&- , +.Ql - , indicating standard input is to be closed. .It Ic \&>\&& Ar fd Same as @@ -1755,11 +1762,11 @@ non-POSIX mode, the exit status is that of the last foregrounded job. .It .Ic getopts . In POSIX mode, options must start with a -.Sq \&- ; +.Ql - ; in non-POSIX mode, options can start with either -.Sq \&- +.Ql - or -.Sq \&+ . +.Ql + . .It Brace expansion (also known as alternation). In POSIX mode, brace expansion is disabled; in non-POSIX mode, brace expansion is enabled. Note that @@ -1824,9 +1831,9 @@ in POSIX mode, in non-POSIX mode. .It Test. In POSIX mode, the expression -.Sq Fl t +.Ql Fl t (preceded by some number of -.Sq Ic \&! +.Ql Ic \&! arguments) is always true as it is a non-zero length string; in non-POSIX mode, it tests if file descriptor 1 is a tty (i.e., the .Ar fd @@ -1924,7 +1931,7 @@ as where .Ar value is quoted. If options were preceded with -.Sq \&+ , +.Ql + , or a lone \&+ is given on the command line, only .Ar name is printed. In addition, if the @@ -2009,7 +2016,7 @@ is missing, the home directory is used. If .Ar dir is -.Sq \&- , +.Ql - , the previous working directory is used (see .Ev OLDPWD parameter). If the @@ -2077,7 +2084,7 @@ defaults to 1. Prints its arguments (separated by spaces) followed by a newline, to the standard output. The newline is suppressed if any of the arguments contain the backslash sequence -.Sq \ec . +.Ql \ec . See the .Ic print command below for a list of other backslash sequences that are recognized. @@ -2170,11 +2177,11 @@ is invoked, it places the next option in the shell parameter and the index of the next argument to be processed in the shell parameter .Ev OPTIND . If the option was introduced with a -.Sq \&+ , +.Ql + , the option places in .Ar name is prefixed with a -.Sq \&+ . +.Ql + . When an option requires an argument, .Ic getopts places it in the shell parameter @@ -2193,9 +2200,9 @@ When the end of the options is encountered, .Ic getopts exits with a non-zero exit status. Options end at the first (non-option argument) argument that does not start with a -.Sq \&- , +.Ql - , or when a -.Sq \&-\&- +.Ql -- argument is encountered. .Pp Option parsing can be reset by setting @@ -2260,23 +2267,23 @@ terminated with a newline. The .Fl n option suppresses the newline. By default, certain C escapes are translated. These include -.Sq \eb , -.Sq \ef , -.Sq \en , -.Sq \er , -.Sq \et , -.Sq \ev , +.Ql \eb , +.Ql \ef , +.Ql \en , +.Ql \er , +.Ql \et , +.Ql \ev , and -.Sq \e0### +.Ql \e0### .Po -.Sq # +.Ql # is an octal digit, of which there may be 0 to 3 .Pc . -.Sq \ec +.Ql \ec is equivalent to using the .Fl n option. -.Sq \e +.Ql \e expansion may be inhibited with the .Fl r option. The @@ -2301,7 +2308,7 @@ option is used to emulate, to some degree, the .Bx .Xr echo command, which does not process -.Sq \e +.Ql \e sequences unless the .Fl e option is given. As above, the @@ -2503,10 +2510,10 @@ if is used). .It Fl u Ic nounset Referencing of an unset parameter is treated as an error, unless one of the -.Sq \&- , -.Sq \&+ +.Ql - , +.Ql + or -.Sq = +.Ql = modifiers is used. .It Fl v Ic verbose Write shell input to standard error as it is read. @@ -2516,7 +2523,7 @@ the value of .Ev PS4 . .It Fl X Ic markdirs Mark directories with a trailing -.Sq / +.Ql / during file name generation. .It Ic bgnice Background jobs are run with lower priority. @@ -2571,7 +2578,8 @@ Enable vi-like command line editing (interactive shells only). No effect. In the original Korn shell, unless .Ic viraw was set, the vi command line mode would let the tty driver do the work until -ESC (^[) was entered. +.Tn ESC +(^[) was entered. .Nm pdksh is always in viraw mode. .It Ic vi-esccomplete @@ -2597,11 +2605,11 @@ will print the long names of all options that are currently on. .Pp Remaining arguments, if any, are positional parameters and are assigned, in order, to the positional parameters (i.e., $1, $2, etc.). If options end with -.Sq \&-\&- +.Ql -- and there are no remaining arguments, all positional parameters are cleared. If no options or arguments are given, the values of all names are printed. For unknown historical reasons, a lone -.Sq \&- +.Ql - option is treated specially -- it clears both the .Fl x and @@ -2709,7 +2717,7 @@ is set (see .Ic set command above for a list of options). As a non-standard extension, if the option starts with a -.Sq \&! , +.Ql ! , the test is negated; the test always fails if .Ar option doesn't exist (thus @@ -2802,17 +2810,18 @@ arguments to or .Ic \&[ ... \&] is less than five; if leading -.Sq \&! +.Ql ! arguments can be stripped such that only one argument remains then a string length test is performed (again, even if the argument is a unary operator); if leading -.Sq \&! +.Ql ! arguments can be stripped such that three arguments remain and the second argument is a binary operator, then the binary operation is performed (even if the first argument is a unary operator, including an unstripped -.Sq \&! ) . +.Ql ! ) . .Pp -NOTE: A common mistake is to use +.Sy Note: +A common mistake is to use .Ic if \&[ $foo = bar \&] which fails if parameter .Ic foo @@ -2821,9 +2830,9 @@ is or unset, if it has embedded spaces (i.e., .Ev IFS characters), or if it is a unary operator like -.Sq Ic \&! +.Ql Ic \&! or -.Sq Fl n . +.Ql Fl n . Use tests like .Ic if \&[ \&"X$foo\&" = Xbar \&] instead. @@ -2894,10 +2903,10 @@ arguments, parameter attributes are displayed; if no options are used, the current attributes of all parameters are printed as .Ic typeset commands; if an option is given (or -.Sq \&- +.Ql - with no option letter), all parameters and their values with the specified attributes are printed; if options are introduced with -.Sq \&+ , +.Ql + , parameter values are not printed. .Pp If @@ -2919,7 +2928,7 @@ operates on the attributes of functions. As with parameters, if no .Ar name Ns s are given, functions are listed with their values (i.e., definitions) unless options are introduced with -.Sq \&+ , +.Ql + , in which case only the function names are reported. .Bl -tag -width 3n .It Fl L Ns Ar n @@ -3261,9 +3270,9 @@ where is the job number of the job. .It Ar flag is the -.Sq \&+ +.Ql + or -.Sq \&- +.Ql - character if the job is the .Ic %\&+ or .Ic %\&- |