‣ merge from mksh R40-stable

first part of long-overdue manpage improvements
This commit is contained in:
tg 2011-07-16 17:08:04 +00:00
parent d6445aa007
commit b0ee967d00

111
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.270 2011/07/16 17:07:48 tg Exp $ .\" $MirOS: src/bin/mksh/mksh.1,v 1.271 2011/07/16 17:08:04 tg Exp $
.\" $OpenBSD: ksh.1,v 1.140 2011/04/23 10:14:59 sobrado Exp $ .\" $OpenBSD: ksh.1,v 1.140 2011/04/23 10:14:59 sobrado Exp $
.\"- .\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@ -176,7 +176,7 @@ Most builtins can be called directly, for example if a link points from its
name to the shell; not all make sense, have been tested or work at all though. name to the shell; not all make sense, have been tested or work at all though.
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width Ds .Bl -tag -width XcXstring
.It Fl c Ar string .It Fl c Ar string
.Nm .Nm
will execute the command(s) contained in will execute the command(s) contained in
@ -627,7 +627,7 @@ $ { { echo foo; echo bar; } }
This is not valid: This is not valid:
.Pp .Pp
.Dl $ { echo foo; echo bar } .Dl $ { echo foo; echo bar }
.Bl -tag -width Ds .Bl -tag -width 4n
.It Pq Ar list .It Pq Ar list
Execute Execute
.Ar list .Ar list
@ -682,13 +682,15 @@ and
e.g.\& e.g.\&
.Ic case $foo { *) echo bar;; } . .Ic case $foo { *) echo bar;; } .
.Pp .Pp
The list terminators are The list terminators are:
.Ql ;; .Bl -tag -width 4n
(terminate after the list), .It Ql ;;
.Ql ;&\& Terminate after the list.
(fall through into the next list) and .It Ql ;&\&
.Ql ;\*(Ba\& Fall through into the next list.
(evaluate the remaining pattern-list tuples). .It Ql ;\*(Ba\&
Evaluate the remaining pattern-list tuples.
.El
.Pp .Pp
The exit status of a The exit status of a
.Ic case .Ic case
@ -870,10 +872,10 @@ keyword is ignored.
.Op Ar pipeline .Op Ar pipeline
.Xc .Xc
The The
.Ic time
reserved word is described in the
.Sx Command execution .Sx Command execution
section. section describes the
.Ic time
reserved word.
.It \&(( Ar expression No )) .It \&(( Ar expression No ))
The arithmetic expression The arithmetic expression
.Ar expression .Ar expression
@ -890,7 +892,7 @@ Similar to the
and and
.Ic \&[ ... \&] .Ic \&[ ... \&]
commands (described later), with the following exceptions: commands (described later), with the following exceptions:
.Bl -bullet -offset indent .Bl -bullet
.It .It
Field splitting and file name generation are not performed on arguments. Field splitting and file name generation are not performed on arguments.
.It .It
@ -1651,7 +1653,7 @@ is set.
.Pp .Pp
The following special parameters are implicitly set by the shell and cannot be The following special parameters are implicitly set by the shell and cannot be
set directly using assignments: set directly using assignments:
.Bl -tag -width "1 ... 9" .Bl -tag -width "1 .. 9"
.It Ev \&! .It Ev \&!
Process ID of the last background process started. Process ID of the last background process started.
If no background processes have been started, the parameter is not set. If no background processes have been started, the parameter is not set.
@ -1689,7 +1691,7 @@ is also set to the name of the current script or
the name of the current function, if it was defined with the the name of the current function, if it was defined with the
.Ic function .Ic function
keyword (i.e. a Korn shell style function). keyword (i.e. a Korn shell style function).
.It Ev 1 No ... Ev 9 .It Ev 1 No .. Ev 9
The first nine positional parameters that were supplied to the shell, function, The first nine positional parameters that were supplied to the shell, function,
or script sourced using the or script sourced using the
.Sq \&. .Sq \&.
@ -1697,7 +1699,8 @@ built-in.
Further positional parameters may be accessed using Further positional parameters may be accessed using
.Pf ${ Ar number Ns } . .Pf ${ Ar number Ns } .
.It Ev * .It Ev *
All positional parameters (except parameter 0) i.e. $1, $2, $3, ... All positional parameters (except 0), i.e. $1, $2, $3, ...
.br
If used If used
outside of double quotes, parameters are separate words (which are subjected outside of double quotes, parameters are separate words (which are subjected
to word splitting); if used within double quotes, parameters are separated to word splitting); if used within double quotes, parameters are separated
@ -1914,13 +1917,13 @@ The
distribution comes with a sample distribution comes with a sample
.Pa dot.mkshrc .Pa dot.mkshrc
containing a sophisticated example, but you might like the following one containing a sophisticated example, but you might like the following one
(note that ${HOSTNAME:=$(hostname \-s)} and the (note that ${HOSTNAME:=$(hostname)} and the
root-vs-user distinguishing clause are (in this example) executed at root-vs-user distinguishing clause are (in this example) executed at
.Ev PS1 .Ev PS1
assignment time, while the $USER and $PWD are escaped assignment time, while the $USER and $PWD are escaped
and thus will be evaluated each time a prompt is displayed): and thus will be evaluated each time a prompt is displayed):
.Bd -literal .Bd -literal
PS1=\*(aq${USER:=$(id \-un)}\*(aq"@${HOSTNAME:=$(hostname \-s)}:\e$PWD $( PS1=\*(aq${USER:=$(id \-un)}\*(aq"@${HOSTNAME:=$(hostname)}:\e$PWD $(
if (( USER_ID )); then print \e$; else print \e#; fi) " if (( USER_ID )); then print \e$; else print \e#; fi) "
.Ed .Ed
.Pp .Pp
@ -3899,7 +3902,7 @@ syntax, where
is the option's single letter name (not all options have a single letter name). is the option's single letter name (not all options have a single letter name).
The following table lists both option letters (if they exist) and long names The following table lists both option letters (if they exist) and long names
along with a description of what the option does: along with a description of what the option does:
.Bl -tag -width 15n .Bl -tag -width 3n
.It Fl A Ar name .It Fl A Ar name
Sets the elements of the array parameter Sets the elements of the array parameter
.Ar name .Ar name
@ -3939,17 +3942,17 @@ or
which can also be written which can also be written
.Ic foo=([0]=a b c) .Ic foo=([0]=a b c)
because indices are incremented automatically. because indices are incremented automatically.
.It Fl a \*(Ba Ic allexport .It Fl a \*(Ba Fl o Ic allexport
All new parameters are created with the export attribute. All new parameters are created with the export attribute.
.It Fl b \*(Ba Ic notify .It Fl b \*(Ba Fl o Ic notify
Print job notification messages asynchronously, instead of just before the Print job notification messages asynchronously, instead of just before the
prompt. prompt.
Only used if job control is enabled Only used if job control is enabled
.Pq Fl m . .Pq Fl m .
.It Fl C \*(Ba Ic noclobber .It Fl C \*(Ba Fl o Ic noclobber
Prevent \*(Gt redirection from overwriting existing files. Prevent \*(Gt redirection from overwriting existing files.
Instead, \*(Gt\*(Ba must be used to force an overwrite. Instead, \*(Gt\*(Ba must be used to force an overwrite.
.It Fl e \*(Ba Ic errexit .It Fl e \*(Ba Fl o Ic errexit
Exit (after executing the Exit (after executing the
.Dv ERR .Dv ERR
trap) as soon as an error occurs or a command fails (i.e. exits with a trap) as soon as an error occurs or a command fails (i.e. exits with a
@ -3964,40 +3967,40 @@ explicitly tested by a shell construct such as
or or
.Ic !\& .Ic !\&
statements. statements.
.It Fl f \*(Ba Ic noglob .It Fl f \*(Ba Fl o Ic noglob
Do not expand file name patterns. Do not expand file name patterns.
.It Fl h \*(Ba Ic trackall .It Fl h \*(Ba Fl o Ic trackall
Create tracked aliases for all executed commands (see Create tracked aliases for all executed commands (see
.Sx Aliases .Sx Aliases
above). above).
Enabled by default for non-interactive shells. Enabled by default for non-interactive shells.
.It Fl i \*(Ba Ic interactive .It Fl i \*(Ba Fl o Ic interactive
The shell is an interactive shell. The shell is an interactive shell.
This option can only be used when the shell is invoked. This option can only be used when the shell is invoked.
See above for a description of what this means. See above for a description of what this means.
.It Fl k \*(Ba Ic keyword .It Fl k \*(Ba Fl o Ic keyword
Parameter assignments are recognised anywhere in a command. Parameter assignments are recognised anywhere in a command.
.It Fl l \*(Ba Ic login .It Fl l \*(Ba Fl o Ic login
The shell is a login shell. The shell is a login shell.
This option can only be used when the shell is invoked. This option can only be used when the shell is invoked.
See above for a description of what this means. See above for a description of what this means.
.It Fl m \*(Ba Ic monitor .It Fl m \*(Ba Fl o Ic monitor
Enable job control (default for interactive shells). Enable job control (default for interactive shells).
.It Fl n \*(Ba Ic noexec .It Fl n \*(Ba Fl o Ic noexec
Do not execute any commands. Do not execute any commands.
Useful for checking the syntax of scripts Useful for checking the syntax of scripts
(ignored if interactive). (ignored if interactive).
.It Fl p \*(Ba Ic privileged .It Fl p \*(Ba Fl o Ic privileged
The shell is a privileged shell. The shell is a privileged shell.
It is set automatically if, when the shell starts, It is set automatically if, when the shell starts,
the real UID or GID does not match the real UID or GID does not match
the effective UID (EUID) or GID (EGID), respectively. the effective UID (EUID) or GID (EGID), respectively.
See above for a description of what this means. See above for a description of what this means.
.It Fl r \*(Ba Ic restricted .It Fl r \*(Ba Fl o Ic restricted
The shell is a restricted shell. The shell is a restricted shell.
This option can only be used when the shell is invoked. This option can only be used when the shell is invoked.
See above for a description of what this means. See above for a description of what this means.
.It Fl s \*(Ba Ic stdin .It Fl s \*(Ba Fl o Ic stdin
If used when the shell is invoked, commands are read from standard input. If used when the shell is invoked, commands are read from standard input.
Set automatically if the shell is invoked with no arguments. Set automatically if the shell is invoked with no arguments.
.Pp .Pp
@ -4011,7 +4014,7 @@ the positional parameters (or to array
if if
.Fl A .Fl A
is used). is used).
.It Fl U \*(Ba Ic utf8\-mode .It Fl U \*(Ba Fl o Ic utf8\-mode
Enable UTF-8 support in the Enable UTF-8 support in the
.Sx Emacs editing mode .Sx Emacs editing mode
and internal string handling functions. and internal string handling functions.
@ -4034,7 +4037,7 @@ or
case-insensitively; for direct builtin calls depending on the case-insensitively; for direct builtin calls depending on the
aforementioned environment variables; or for stdin or scripts, aforementioned environment variables; or for stdin or scripts,
if the input begins with a UTF-8 Byte Order Mark. if the input begins with a UTF-8 Byte Order Mark.
.It Fl u \*(Ba Ic nounset .It Fl u \*(Ba Fl o Ic nounset
Referencing of an unset parameter, other than Referencing of an unset parameter, other than
.Dq $@ .Dq $@
or or
@ -4045,37 +4048,37 @@ is treated as an error, unless one of the
or or
.Ql = .Ql =
modifiers is used. modifiers is used.
.It Fl v \*(Ba Ic verbose .It Fl v \*(Ba Fl o Ic verbose
Write shell input to standard error as it is read. Write shell input to standard error as it is read.
.It Fl X \*(Ba Ic markdirs .It Fl X \*(Ba Fl o Ic markdirs
Mark directories with a trailing Mark directories with a trailing
.Ql / .Ql /
during file name generation. during file name generation.
.It Fl x \*(Ba Ic xtrace .It Fl x \*(Ba Fl o Ic xtrace
Print commands and parameter assignments when they are executed, preceded by Print commands and parameter assignments when they are executed, preceded by
the value of the value of
.Ev PS4 . .Ev PS4 .
.It Ic bgnice .It Fl o Ic bgnice
Background jobs are run with lower priority. Background jobs are run with lower priority.
.It Ic braceexpand .It Fl o Ic braceexpand
Enable brace expansion (a.k.a. alternation). Enable brace expansion (a.k.a. alternation).
This is enabled by default. This is enabled by default.
If disabled, tilde expansion after an equals sign is disabled as a side effect. If disabled, tilde expansion after an equals sign is disabled as a side effect.
.It Ic emacs .It Fl o Ic emacs
Enable BRL emacs-like command-line editing (interactive shells only); see Enable BRL emacs-like command-line editing (interactive shells only); see
.Sx Emacs editing mode . .Sx Emacs editing mode .
.It Ic gmacs .It Fl o Ic gmacs
Enable gmacs-like command-line editing (interactive shells only). Enable gmacs-like command-line editing (interactive shells only).
Currently identical to emacs editing except that transpose\-chars (\*(haT) acts Currently identical to emacs editing except that transpose\-chars (\*(haT) acts
slightly differently. slightly differently.
.It Ic ignoreeof .It Fl o Ic ignoreeof
The shell will not (easily) exit when end-of-file is read; The shell will not (easily) exit when end-of-file is read;
.Ic exit .Ic exit
must be used. must be used.
To avoid infinite loops, the shell will exit if To avoid infinite loops, the shell will exit if
.Dv EOF .Dv EOF
is read 13 times in a row. is read 13 times in a row.
.It Ic nohup .It Fl o Ic nohup
Do not kill running jobs with a Do not kill running jobs with a
.Dv SIGHUP .Dv SIGHUP
signal when a login shell exits. signal when a login shell exits.
@ -4087,11 +4090,11 @@ which
doesn't have this option, but does send the doesn't have this option, but does send the
.Dv SIGHUP .Dv SIGHUP
signal. signal.
.It Ic nolog .It Fl o Ic nolog
No effect. No effect.
In the original Korn shell, this prevents function definitions from In the original Korn shell, this prevents function definitions from
being stored in the history file. being stored in the history file.
.It Ic physical .It Fl o Ic physical
Causes the Causes the
.Ic cd .Ic cd
and and
@ -4117,7 +4120,7 @@ See the
and and
.Ic pwd .Ic pwd
commands above for more details. commands above for more details.
.It Ic posix .It Fl o Ic posix
Enable a somewhat more Enable a somewhat more
.Px .Px
ish mode. ish mode.
@ -4126,7 +4129,7 @@ As a side effect, setting this flag turns off
mode, which can be turned back on manually, and mode, which can be turned back on manually, and
.Ic sh .Ic sh
mode. mode.
.It Ic sh .It Fl o Ic sh
Enable Enable
.Pa /bin/sh .Pa /bin/sh
.Pq kludge .Pq kludge
@ -4140,18 +4143,18 @@ As a side effect, setting this flag turns off
mode, which can be turned back on manually, and mode, which can be turned back on manually, and
.Ic posix .Ic posix
mode. mode.
.It Ic vi .It Fl o Ic vi
Enable Enable
.Xr vi 1 Ns -like .Xr vi 1 Ns -like
command-line editing (interactive shells only). command-line editing (interactive shells only).
.It Ic vi\-esccomplete .It Fl o Ic vi\-esccomplete
In vi command-line editing, do command and file name completion when escape In vi command-line editing, do command and file name completion when escape
(\*(ha[) is entered in command mode. (\*(ha[) is entered in command mode.
.It Ic vi\-tabcomplete .It Fl o Ic vi\-tabcomplete
In vi command-line editing, do command and file name completion when tab (\*(haI) In vi command-line editing, do command and file name completion when tab (\*(haI)
is entered in insert mode. is entered in insert mode.
This is the default. This is the default.
.It Ic viraw .It Fl o Ic viraw
No effect. No effect.
In the original Korn shell, unless In the original Korn shell, unless
.Ic viraw .Ic viraw
@ -5621,7 +5624,7 @@ and have their usual meaning (normal values are in parentheses): kill (\*(haU),
erase (\*(ha?), werase (\*(haW), eof (\*(haD), intr (\*(haC), and quit (\*(ha\e). erase (\*(ha?), werase (\*(haW), eof (\*(haD), intr (\*(haC), and quit (\*(ha\e).
In addition to In addition to
the above, the following characters are also treated specially in insert mode: the above, the following characters are also treated specially in insert mode:
.Bl -tag -width 10n .Bl -tag -width XJXXXXM
.It \*(haE .It \*(haE
Command and file name enumeration (see below). Command and file name enumeration (see below).
.It \*(haF .It \*(haF