This commit is contained in:
tg 2004-12-13 19:47:25 +00:00
parent 51053f03f5
commit 3d0671eced

252
sh.1tbl
View File

@ -1,7 +1,7 @@
.\" $MirBSD: src/bin/ksh/sh.1tbl,v 2.2 2004/12/13 18:24:34 tg Exp $
.\" _MirBSD: src/bin/ksh/ksh.1tbl,v 1.41 2004/11/10 17:18:29 tg Exp $
.\" $OpenBSD: ksh.1tbl,v 1.78 2004/11/08 23:42:02 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.52 2004/11/09 21:56:54 jmc Exp $
.\" $MirBSD: src/bin/ksh/sh.1tbl,v 2.3 2004/12/13 19:47:25 tg Exp $
.\" _MirBSD: src/bin/ksh/ksh.1tbl,v 2.5 2004/12/13 19:36:27 tg Exp $
.\" $OpenBSD: ksh.1tbl,v 1.79 2004/12/04 07:05:13 jaredy Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -37,26 +37,11 @@
.Dd November 10, 2004
.Dt SH 1
.Os MirOS
.\" define Mx macro for portable mksh, just in case...
.de Mx
.nr cF \\n(.f
.nr cZ \\n(.s
.ds aa \&\f\\n(cF\s\\n(cZ
.if \\n(aC==0 \{\
. if \\n(.$==0 \&MirOS\\*(aa
.\}
.if \\n(.$==1 \{\
. if "\\$1"6" \&MirOS #6\\*(aa
. if "\\$1"." \&MirOS\\$1\\*(aa
. if "\\$1"," \&MirOS\\$1\\*(aa
. if "\\$1"MirBSD" \&MirBSD\\*(aa
.\}
..
.Sh NAME
.Nm sh ,
.Nm ksh ,
.Nm mksh ,
.Nm sh
.Nd MirBSD Korn/Bourne shell
.Nm mksh
.Nd MirBSD Bourne shell
.Sh SYNOPSIS
.Nm
.Op Fl +abCefhiklmnprsuvxX
@ -109,7 +94,7 @@ If there are no non-option
arguments, the shell reads commands from the standard input.
The name of
the shell (i.e., the contents of
.Va $0 )
.Ic $0 )
is determined as follows: if the
.Fl c
option is used and there is a non-option argument, it is used as the name;
@ -122,8 +107,8 @@ A shell is
.Dq interactive
if the
.Fl i
option is used or if both standard input and standard error are attached
to a tty.
option is used or if both standard input and standard error are attached to a
.Xr tty 4 .
An interactive shell has job control enabled (if available), ignores the
.Dv SIGINT ,
.Dv SIGQUIT
@ -151,7 +136,7 @@ parameter match the pattern
.Dq \&*r\&*sh
(e.g.,
.Dq rsh ,
.Dq rksh ,
.Dq rmksh ,
.Dq rpdksh ,
etc.).
The following restrictions come into effect after the shell processes any
@ -234,8 +219,8 @@ If the
parameter is not set (and not
.Dv NULL )
and
.Nm pdksh
was compiled with the
.Nm
was compiled with the non-default
.Dv DEFAULT_ENV
macro defined, the file named in that macro is included (after the above
mentioned substitutions have been performed).
@ -316,7 +301,7 @@ The first three of these are the above mentioned quoting characters (see
.Sx Quoting
below);
.Ql # ,
if used at the beginning of a word, introduces a comment -- everything after
if used at the beginning of a word, introduces a comment \(em everything after
the
.Ql #
up to the nearest newline is ignored;
@ -419,7 +404,7 @@ only if the exit status of
.Ar cmd1
is zero;
.Ql ||
is the opposite --
is the opposite \(em
.Ar cmd2
is executed only if the exit status of
.Ar cmd1
@ -508,14 +493,14 @@ In the following compound command descriptions, command lists (denoted as
that are followed by reserved words must end with a semicolon, a newline, or
a (syntactically correct) reserved word.
For example,
.Bd -unfilled -offset -indent
.Bd -unfilled -offset indent
.Ic { echo foo; echo bar; }
.Ic { echo foo; echo bar<newline> }
.Ic { { echo foo; echo bar; } }
.Ed
.Pp
are all valid, but
.Bd -unfilled -offset -indent
.Bd -unfilled -offset indent
.Ic { echo foo; echo bar }
.Ed
.Pp
@ -593,7 +578,7 @@ If
.Ic in
is not used to specify a word list, the positional parameters
.Po
.Va $1 , $2 ,
.Ic $1 , $2 ,
etc.\&
.Pc
are used instead.
@ -819,8 +804,10 @@ 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
whitespace and trailing
.Ev IFS
non-whitespace are stripped (i.e., no leading or trailing
empty field is created by it); leading
.Pf non- Ev IFS
whitespace does create an empty field.
.Pp
@ -1115,7 +1102,7 @@ Process ID of the last background process started.
If no background processes have been started, the parameter is not set.
.It Ev \&#
The number of positional parameters (i.e.,
.Va $1 , $2 ,
.Ic $1 , $2 ,
etc.).
.It Ev \&$
The process ID of the shell, or the
@ -1159,7 +1146,7 @@ Further positional parameters may be accessed using
.Ic ${ Ns Ar number Ns Ic \&} .
.It Ev \&*
All positional parameters (except parameter 0); i.e.,
.Va $1 , $2 , $3 ,
.Ic $1 , $2 , $3 ,
\&...
If used
outside of double quotes, parameters are separate words (which are subjected
@ -1268,13 +1255,9 @@ above for details.
This parameter is not imported from the environment when the shell is
started.
.It Ev SH_VERSION
The version of the shell, consisting of the upstream
.Nm pdksh
version (and sometimes date), the string
.Dq MirOS
and the
.Xr rcs 1
revision number (read-only).
The version of
.Nm
(read-only).
.It Ev LINENO
The line number of the function or shell script that is currently being
executed.
@ -1511,7 +1494,7 @@ matches all strings (think about it).
.El
.Pp
Note that
.Nm pdksh
.Nm
currently never matches
.Dq \&.
and
@ -1523,11 +1506,6 @@ Bourne
and GNU
.Xr bash
do.
For
.Nm pdksh ,
this may have to change (too bad), but
.Nm mksh
will not adopt this behaviour.
.Pp
Note that none of the above pattern elements match either a period
.Pq Sq \&.
@ -1677,7 +1655,7 @@ any redirections must appear at the end.
Redirections are processed after
pipelines are created and in the order they are given, so
.Pp
.Ic cat /foo/bar 2\&>&1 \&> /dev/null \&| cat -n
.Dl Ic cat /foo/bar 2\*(Gt&1 \*(Gt /dev/null \&| cat -n
.Pp
will print an error with a line number prepended to it.
.Ss Arithmetic expressions
@ -1858,7 +1836,7 @@ in that they are executed in the current environment.
However, unlike
.Li .-scripts ,
shell arguments (i.e., positional parameters
.Va $1 , $2 ,
.Ic $1 , $2 ,
etc.) are never visible
inside them.
When the shell is determining the location of a command, functions
@ -1917,7 +1895,9 @@ assignments made inside functions are visible after the function completes.
If this is not the desired effect, the
.Ic typeset
command can be used inside a function to create a local parameter.
Note that special parameters (e.g., $$, $\&!) can't be scoped in this way.
Note that special parameters (e.g.
.Ic \&$$ , $\&! )
can't be scoped in this way.
.Pp
The exit status of a function is that of the last command executed in the
function.
@ -1933,8 +1913,11 @@ defined with the
notation:
.Bl -bullet
.It
The $0 parameter is set to the name of the function (Bourne-style functions
leave $0 untouched).
The
.Ic $0
parameter is set to the name of the function (Bourne-style functions leave
.Ic $0
untouched).
.It
Parameter assignments preceding function calls are not kept in the shell
environment (executing Bourne-style functions will keep assignments).
@ -2034,7 +2017,7 @@ 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
In the future, a new option
.Po Fl v
\ perhaps
.Pc
@ -2176,7 +2159,9 @@ mode, the expression
.Sq Ic \&!
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
mode, it tests if file descriptor 1 is a
.Xr tty 4
(i.e., the
.Ar fd
argument to the
.Fl t
@ -2220,7 +2205,9 @@ special commands
.Ic readonly , return , set , shift ,
.Ic trap , unset
.Pp
Additional ksh special commands
Additional
.Nm
special commands
.Pp
.Ic builtin , times , typeset
.Pp
@ -2237,12 +2224,16 @@ regular commands
.Ic jobs , kill , read , true ,
.Ic umask , unalias , wait
.Pp
Additional ksh regular commands
Additional
.Nm
regular commands
.Pp
.Ic \&[ , echo , let , print ,
.Ic pwd , test , ulimit , whence
.Pp
In the future, the additional ksh special and regular commands may be treated
In the future, the additional
.Nm
special and regular commands may be treated
differently from the
.Tn POSIX
special and regular commands.
@ -2273,8 +2264,7 @@ Exit status is set to zero.
.Op Ic +-
.Oo Ar name
.Op Ns = Ns Ar value
.Ar ...
.Oc
.Ar ... Oc
.Xc
Without arguments,
.Ic alias
@ -2485,7 +2475,7 @@ The shell exits with the specified exit status.
If
.Ar status
is not specified, the exit status is the current value of the
.Ic \&?
.Ic $\&?
parameter.
.It Xo Ic export Op Fl p
.Op Ar parameter Ns Op \&= Ns Ar value
@ -2628,10 +2618,10 @@ below for the format of
.Ar job
and the displayed job.
.It Xo Ic kill
.Oo Fl s Ar signame No \&|
.Fl signum No \&| Fl signame Oc {
.Ar job No \&|
.Ar pid No \&|
.Oo Fl s Ar signame \*(Ba
.Fl Ar signum | Fl Ar signame Oc {
.Ar job |
.Ar pid |
.Ar pgrp No } Ar ...
.Xc
Send the specified signal to the specified jobs, process IDs, or process
@ -2651,7 +2641,7 @@ specified
If no arguments are specified, a list of all the signals, their numbers and
a short description of them are printed.
.It Xo Ic print
.Oo Fl nprsu Ns Ar n No \&|
.Oo Fl nprsu Ns Ar n \*(Ba
.Fl R Op Fl en Oc
.Op Ar argument ...
.Xc
@ -2703,7 +2693,7 @@ The
.Fl R
option is used to emulate, to some degree, the
.Bx
.Xr echo
.Xr echo 1
command, which does not process
.Ql \e
sequences unless the
@ -2756,7 +2746,9 @@ exits with a non-zero status.
.Pp
The first parameter may have a question mark and a string appended to it, in
which case the string is used as a prompt (printed to standard error before
any input is read) if the input is a tty (e.g.,
any input is read) if the input is a
.Xr tty 4
(e.g.,
.Ic read nfoo?'number of foos: ' ) .
.Pp
The
@ -2802,7 +2794,7 @@ If used outside of a function or
script, it has the same effect as
.Ic exit .
Note that
.Nm pdksh
.Nm
treats both profile and
.Ev ENV
files as
@ -3000,10 +2992,12 @@ 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
was set, the vi command-line mode would let the
.Xr tty 4
driver do the work until
.Tn ESC
(^[) was entered.
.Nm pdksh
.Nm
is always in viraw mode.
.It Ic vi-esccomplete
In vi command-line editing, do command and file name completion when escape
@ -3029,7 +3023,7 @@ 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.
.Va $1 , $2 ,
.Ic $1 , $2 ,
etc.).
If options end with
.Ql --
@ -3037,7 +3031,7 @@ 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
.Ql -
option is treated specially -- it clears both the
option is treated specially \(em it clears both the
.Fl x
and
.Fl v
@ -3142,25 +3136,24 @@ doesn't exist (thus
returns true if and only if option
.Ar foo
exists).
.It Ar file Fl nt Ar file
first
.Ar file
is newer than second
.Ar file .
.It Ar file Fl ot Ar file
first
.Ar file
is older than second
.Ar file .
.It Ar file Fl ef Ar file
first
.Ar file
is the same file as second
.Ar file .
.It Ar file1 Fl nt Ar file2
.Ar file1
is newer than
.Ar file2 .
.It Ar file1 Fl ot Ar file2
.Ar file1
is older than
.Ar file2 .
.It Ar file1 Fl ef Ar file2
.Ar file1
is the same file as
.Ar file2 .
.It Fl t Op Ar fd
File descriptor
.Ar fd
is a tty device.
is a
.Xr tty 4
device.
If the
.Ic posix
option is not set,
@ -3171,7 +3164,21 @@ to the special
rules described below).
.It Ar string
.Ar string
is not empty.
is not empty (has non-zero length).
Note that there is the potential for problems if
.Ar string
turns out to be an operator (e.g.
.Fl r ) .
It is generally better to use a test like
.No ( Ns Nm sh )
.Bk -words
.Sm off
.Ic \&[\ X\&" Ar string Ic \&" Ic \ \&]
.Sm on
.Ek
instead (double quotes are used in case
.Ar string
contains spaces or globbing characters).
.It Fl z Ar string
.Ar string
is empty.
@ -3247,7 +3254,9 @@ if the first argument is a unary operator, including an unstripped
.Pp
.Sy Note:
A common mistake is to use
.Bk -words
.Ic if \&[ $foo = bar \&]
.Ek
which fails if parameter
.Ic foo
is
@ -3259,14 +3268,17 @@ characters), or if it is a unary operator like
or
.Sq Fl n .
Use tests like
.No ( Ns Nm sh )
.Bk -words
.Ic if \&[ \&"X$foo\&" = Xbar \&]
.Ek
instead.
.It Ic times
Print the accumulated user and system times used by the shell and by processes
which have exited that the shell started.
.It Ic trap Op Ar handler signal ...
Sets trap handler that is to be executed when any of the specified signals are
received.
Sets a trap handler that is to be executed when any of the
specified signals are received.
.Ar handler
is either a
.Dv NULL
@ -3438,7 +3450,7 @@ This is the default action (option exists for ksh93 compatibility).
.It Fl r
Read-only attribute.
Parameters with this attribute may not be assigned to or unset.
Once this attribute is set, it can not be turned off.
Once this attribute is set, it cannot be turned off.
.It Fl t
Tag attribute.
Has no meaning to the shell; provided for application use.
@ -3490,7 +3502,7 @@ limit is imposed.
Note that some systems may not allow limits to be increased
once they are set.
Also note that the types of limits available are system
dependent -- some systems have only the
dependent \(em some systems have only the
.Fl f
limit.
.Bl -tag -width 5n
@ -3706,8 +3718,9 @@ A job may be referred to in the
and
.Ic wait
commands either by the process ID of the last process in the command pipeline
(as stored in the $! parameter) or by prefixing the job number with a percent
sign
(as stored in the
.Ic $\&!
parameter) or by prefixing the job number with a percent sign
.Pq Sq % .
Other percent sequences can also be used to refer to jobs:
.Bl -tag -width 10n
@ -3736,8 +3749,9 @@ The job starting with string
.Pp
When a job changes state (e.g., a background job finishes or foreground job is
stopped), the shell prints the following status information:
.Pp
.Bd -unfilled -offset indent
.Ic \&[ Ar number Ic \&] Ar flag status command
.Ed
.Pp
where
.Bl -tag -width "status"
@ -3759,7 +3773,7 @@ indicates the current state of the job and can be:
The job has neither stopped nor exited (note that running does not necessarily
mean consuming
.Tn CPU
time -- the process could be blocked waiting for some
time \(em the process could be blocked waiting for some
event).
.It Cm Done Op Ar number
The job exited.
@ -3833,6 +3847,7 @@ signal and the shell exits.
.Xr srand 3 ,
.Xr srandom 3 ,
.Xr system 3 ,
.Xr tty 4 ,
.Xr environ 7
.Pp
.Pa http://docsrv.sco.com:507/en/man/html.C/sh.C.html
@ -3856,14 +3871,10 @@ signal and the shell exits.
.%D 1993
.%O "ISBN 1-55937-266-9"
.Re
.Sh VERSION
This page documents version @(#)PD KSH v5.2.14 99/07/13.2 of the public
domain Korn shell, as delivered with
.Mx .
.Sh NOTES
.Nm sh
is implemented as a run-time option of
.Nm pdksh ,
.Nm mksh ,
with only those
.Nm ksh
features whose syntax or semantics are incompatible with a traditional Bourne
@ -3877,7 +3888,7 @@ compliant shells is an issue.
.Pp
.Nm mksh
is the name for the portable version of
.Mx MirBSD
.Mx
.Nm ksh
installed as
.Pa /bin/mksh
@ -3887,26 +3898,9 @@ Visit
to obtain the latest version of
.Nm mksh .
.Sh AUTHORS
This shell is based on the public domain 7th edition Bourne shell clone by
Charles Forsyth and parts of the BRL shell by Doug A. Gwyn, Doug Kingston,
Ron Natalie, Arnold Robbins, Lou Salkind, and others.
The first release of
.Nm pdksh
was created by Eric Gisin, and it was subsequently maintained by
.An John R. MacMillan Aq change!john@sq.sq.com
and
.An Simon J. Gerraty Aq sjg@zen.void.oz.au .
The current maintainer is
.An Michael Rendell Aq michael@cs.mun.ca
for the upstream version of
.Nm pdksh
and
.An Thorsten Glaser Aq tg@66h.42h.de
for
.Mx .
The
.Pa CONTRIBUTORS
file in the source distribution contains a more complete list of people and
file in the source distribution contains an almost complete list of people and
their part in the shell's development.
.Sh BUGS
Send bug reports for
@ -3915,15 +3909,7 @@ to the
.Mx
development team at
.Aq miros\-discuss@66h.42h.de .
Please include the version of
.Nm
.Po
.Ic echo $KSH_VERSION
shows it
.Pc ,
the machine, operating system, and compiler you are using and how you built
.Nm .
Please test if the bug appears with the latest version of the full
Please test first if the bug appears with the latest version of the full
.Nm mksh
as well.
We do not extensively use nor support