2012-11-30 20:25:08 +01:00
|
|
|
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.301 2012/11/30 19:25:05 tg Exp $
|
2012-07-25 21:40:40 +02:00
|
|
|
|
.\" $OpenBSD: ksh.1,v 1.144 2012/07/08 08:13:20 guenther Exp $
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.\"-
|
2011-01-09 22:57:29 +01:00
|
|
|
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
2012-03-24 00:25:30 +01:00
|
|
|
|
.\" 2010, 2011, 2012
|
2009-05-16 18:59:42 +02:00
|
|
|
|
.\" Thorsten Glaser <tg@mirbsd.org>
|
|
|
|
|
.\"
|
|
|
|
|
.\" Provided that these terms and disclaimer and all copyright notices
|
|
|
|
|
.\" are retained or reproduced in an accompanying document, permission
|
|
|
|
|
.\" is granted to deal in this work without restriction, including un‐
|
|
|
|
|
.\" limited rights to use, publicly perform, distribute, sell, modify,
|
|
|
|
|
.\" merge, give away, or sublicence.
|
|
|
|
|
.\"
|
|
|
|
|
.\" This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
|
|
|
|
|
.\" the utmost extent permitted by applicable law, neither express nor
|
|
|
|
|
.\" implied; without malicious intent or gross negligence. In no event
|
|
|
|
|
.\" may a licensor, author or contributor be held liable for indirect,
|
|
|
|
|
.\" direct, other damage, loss, or other issues arising in any way out
|
|
|
|
|
.\" of dealing in the work, even if advised of the possibility of such
|
|
|
|
|
.\" damage or existence of a defect, except proven that it results out
|
|
|
|
|
.\" of said person’s immediate fault when using the work as intended.
|
|
|
|
|
.\"-
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.\" Try to make GNU groff and AT&T nroff more compatible
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.\" * ` generates ‘ in gnroff, so use \`
|
|
|
|
|
.\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq
|
|
|
|
|
.\" * - generates ‐ in gnroff, \- generates −, so .tr it to -
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.\" thus use - for hyphens and \- for minus signs and option dashes
|
|
|
|
|
.\" * ~ is size-reduced and placed atop in groff, so use \*(TI
|
|
|
|
|
.\" * ^ is size-reduced and placed atop in groff, so use \*(ha
|
|
|
|
|
.\" * \(en does not work in nroff, so use \*(en
|
2012-04-14 14:51:34 +02:00
|
|
|
|
.\" * <>| are problematic, so redefine and use \*(Lt\*(Gt\*(Ba
|
|
|
|
|
.\" Also make sure to use \& especially with two-letter words.
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.\" The section after the "doc" macropackage has been loaded contains
|
|
|
|
|
.\" additional code to convene between the UCB mdoc macropackage (and
|
|
|
|
|
.\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage.
|
|
|
|
|
.\"
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.ie \n(.g \{\
|
2009-11-17 22:49:42 +01:00
|
|
|
|
. if \*[.T]ascii .tr \-\N'45'
|
|
|
|
|
. if \*[.T]latin1 .tr \-\N'45'
|
|
|
|
|
. if \*[.T]utf8 .tr \-\N'45'
|
|
|
|
|
. ds <= \[<=]
|
|
|
|
|
. ds >= \[>=]
|
|
|
|
|
. ds Rq \[rq]
|
|
|
|
|
. ds Lq \[lq]
|
|
|
|
|
. ds sL \(aq
|
|
|
|
|
. ds sR \(aq
|
|
|
|
|
. if \*[.T]utf8 .ds sL `
|
|
|
|
|
. if \*[.T]ps .ds sL `
|
|
|
|
|
. if \*[.T]utf8 .ds sR '
|
|
|
|
|
. if \*[.T]ps .ds sR '
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
. ds aq \(aq
|
|
|
|
|
. ds TI \(ti
|
|
|
|
|
. ds ha \(ha
|
|
|
|
|
. ds en \(en
|
|
|
|
|
.\}
|
|
|
|
|
.el \{\
|
|
|
|
|
. ds aq '
|
|
|
|
|
. ds TI ~
|
|
|
|
|
. ds ha ^
|
|
|
|
|
. ds en \(em
|
|
|
|
|
.\}
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.\"
|
2008-02-29 12:03:55 +01:00
|
|
|
|
.\" Implement .Dd with the Mdocdate RCS keyword
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.\"
|
2008-02-29 12:03:55 +01:00
|
|
|
|
.rn Dd xD
|
|
|
|
|
.de Dd
|
2008-02-29 19:20:16 +01:00
|
|
|
|
.ie \\$1$Mdocdate: \{\
|
|
|
|
|
. xD \\$2 \\$3, \\$4
|
|
|
|
|
.\}
|
2008-02-29 12:03:55 +01:00
|
|
|
|
.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
|
|
|
|
|
..
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.\"
|
|
|
|
|
.\" .Dd must come before definition of .Mx, because when called
|
|
|
|
|
.\" with -mandoc, it might implement .Mx itself, but we want to
|
|
|
|
|
.\" use our own definition. And .Dd must come *first*, always.
|
|
|
|
|
.\"
|
2012-11-30 20:25:08 +01:00
|
|
|
|
.Dd $Mdocdate: November 30 2012 $
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.\"
|
2012-04-14 14:51:34 +02:00
|
|
|
|
.\" Check which macro package we use, and do other -mdoc setup.
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.\"
|
|
|
|
|
.ie \n(.g \{\
|
2012-04-14 14:51:34 +02:00
|
|
|
|
. if \*[.T]utf8 .tr \[la]\*(Lt
|
|
|
|
|
. if \*[.T]utf8 .tr \[ra]\*(Gt
|
2009-11-17 22:49:42 +01:00
|
|
|
|
. ie d volume-ds-1 .ds tT gnu
|
|
|
|
|
. el .ds tT bsd
|
|
|
|
|
.\}
|
|
|
|
|
.el .ds tT ucb
|
|
|
|
|
.\"
|
|
|
|
|
.\" Implement .Mx (MirBSD)
|
|
|
|
|
.\"
|
|
|
|
|
.ie "\*(tT"gnu" \{\
|
|
|
|
|
. eo
|
|
|
|
|
. de Mx
|
|
|
|
|
. nr curr-font \n[.f]
|
|
|
|
|
. nr curr-size \n[.ps]
|
|
|
|
|
. ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
|
|
|
|
|
. ds str-Mx1 \*[Tn-font-size]\%MirOS\*[str-Mx]
|
|
|
|
|
. if !\n[arg-limit] \
|
|
|
|
|
. if \n[.$] \{\
|
|
|
|
|
. ds macro-name Mx
|
|
|
|
|
. parse-args \$@
|
|
|
|
|
. \}
|
|
|
|
|
. if (\n[arg-limit] > \n[arg-ptr]) \{\
|
|
|
|
|
. nr arg-ptr +1
|
|
|
|
|
. ie (\n[type\n[arg-ptr]] == 2) \
|
|
|
|
|
. as str-Mx1 \~\*[arg\n[arg-ptr]]
|
|
|
|
|
. el \
|
|
|
|
|
. nr arg-ptr -1
|
|
|
|
|
. \}
|
|
|
|
|
. ds arg\n[arg-ptr] "\*[str-Mx1]
|
|
|
|
|
. nr type\n[arg-ptr] 2
|
|
|
|
|
. ds space\n[arg-ptr] "\*[space]
|
|
|
|
|
. nr num-args (\n[arg-limit] - \n[arg-ptr])
|
|
|
|
|
. nr arg-limit \n[arg-ptr]
|
|
|
|
|
. if \n[num-args] \
|
|
|
|
|
. parse-space-vector
|
|
|
|
|
. print-recursive
|
|
|
|
|
..
|
|
|
|
|
. ec
|
|
|
|
|
. ds sP \s0
|
|
|
|
|
. ds tN \*[Tn-font-size]
|
|
|
|
|
.\}
|
|
|
|
|
.el \{\
|
|
|
|
|
. de Mx
|
|
|
|
|
. nr cF \\n(.f
|
|
|
|
|
. nr cZ \\n(.s
|
|
|
|
|
. ds aa \&\f\\n(cF\s\\n(cZ
|
|
|
|
|
. if \\n(aC==0 \{\
|
|
|
|
|
. ie \\n(.$==0 \&MirOS\\*(aa
|
|
|
|
|
. el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
|
|
|
|
|
. \}
|
|
|
|
|
. if \\n(aC>\\n(aP \{\
|
|
|
|
|
. nr aP \\n(aP+1
|
|
|
|
|
. ie \\n(C\\n(aP==2 \{\
|
|
|
|
|
. as b1 \&MirOS\ #\&\\*(A\\n(aP\\*(aa
|
|
|
|
|
. ie \\n(aC>\\n(aP \{\
|
|
|
|
|
. nr aP \\n(aP+1
|
|
|
|
|
. nR
|
|
|
|
|
. \}
|
|
|
|
|
. el .aZ
|
|
|
|
|
. \}
|
|
|
|
|
. el \{\
|
|
|
|
|
. as b1 \&MirOS\\*(aa
|
|
|
|
|
. nR
|
|
|
|
|
. \}
|
|
|
|
|
. \}
|
|
|
|
|
..
|
|
|
|
|
.\}
|
2008-02-29 12:03:55 +01:00
|
|
|
|
.\"-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Dt MKSH 1
|
2006-01-27 11:59:30 +01:00
|
|
|
|
.Os MirBSD
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sh NAME
|
2006-07-21 23:47:43 +02:00
|
|
|
|
.Nm mksh ,
|
|
|
|
|
.Nm sh
|
2005-07-04 14:34:24 +02:00
|
|
|
|
.Nd MirBSD Korn shell
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
|
.Nm
|
|
|
|
|
.Bk -words
|
2006-11-05 18:01:47 +01:00
|
|
|
|
.Op Fl +abCefhiklmnprUuvXx
|
2012-04-14 14:51:34 +02:00
|
|
|
|
.Op Fl T Ar /dev/ttyCn \*(Ba \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Fl +o Ar option
|
2010-09-24 22:21:43 +02:00
|
|
|
|
.Oo
|
|
|
|
|
.Fl c Ar string \*(Ba
|
|
|
|
|
.Fl s \*(Ba
|
|
|
|
|
.Ar file
|
|
|
|
|
.Op Ar argument ...
|
|
|
|
|
.Oc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ek
|
• more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
bin/echo bin/kill bin/pwd bin/sleep (exact matches)
bin/test bin/[ (were scripts before)
bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 02:18:23 +01:00
|
|
|
|
.Nm builtin-name
|
|
|
|
|
.Op Ar argument ...
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
|
.Nm
|
|
|
|
|
is a command interpreter intended for both interactive and shell
|
|
|
|
|
script use.
|
|
|
|
|
Its command language is a superset of the
|
|
|
|
|
.Xr sh C
|
|
|
|
|
shell language and largely compatible to the original Korn shell.
|
2012-11-20 19:25:12 +01:00
|
|
|
|
.Ss I'm an Android user, so what's mksh?
|
|
|
|
|
.Nm mksh
|
|
|
|
|
is a
|
|
|
|
|
.Ux
|
|
|
|
|
shell / command interpreter, similar to
|
|
|
|
|
.Nm COMMAND.COM
|
|
|
|
|
or
|
|
|
|
|
.Nm CMD.EXE ,
|
|
|
|
|
which has been included with
|
|
|
|
|
.Tn Android Open Source Project
|
|
|
|
|
for a while now.
|
|
|
|
|
Basically, it's a program that runs in a terminal (console window),
|
|
|
|
|
takes user input and runs commands or scripts, which it can also
|
|
|
|
|
be asked to do by other programs, even in the background.
|
|
|
|
|
Any privilege pop-ups you might be encountering are thus not
|
|
|
|
|
.Nm mksh
|
|
|
|
|
issues but questions by some other program utilising it.
|
|
|
|
|
.Ss Invocation
|
• more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
bin/echo bin/kill bin/pwd bin/sleep (exact matches)
bin/test bin/[ (were scripts before)
bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 02:18:23 +01:00
|
|
|
|
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.
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The options are as follows:
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.Bl -tag -width XcXstring
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl c Ar string
|
|
|
|
|
.Nm
|
|
|
|
|
will execute the command(s) contained in
|
|
|
|
|
.Ar string .
|
|
|
|
|
.It Fl i
|
|
|
|
|
Interactive shell.
|
|
|
|
|
A shell is
|
|
|
|
|
.Dq interactive
|
|
|
|
|
if this
|
|
|
|
|
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, ignores the
|
|
|
|
|
.Dv SIGINT ,
|
|
|
|
|
.Dv SIGQUIT ,
|
|
|
|
|
and
|
|
|
|
|
.Dv SIGTERM
|
|
|
|
|
signals, and prints prompts before reading input (see the
|
|
|
|
|
.Ev PS1
|
|
|
|
|
and
|
|
|
|
|
.Ev PS2
|
|
|
|
|
parameters).
|
2007-10-14 15:43:17 +02:00
|
|
|
|
It also processes the
|
|
|
|
|
.Ev ENV
|
2011-07-16 19:08:21 +02:00
|
|
|
|
parameter or the
|
|
|
|
|
.Pa mkshrc
|
|
|
|
|
file (see below).
|
2005-05-23 05:06:10 +02:00
|
|
|
|
For non-interactive shells, the
|
|
|
|
|
.Ic trackall
|
|
|
|
|
option is on by default (see the
|
|
|
|
|
.Ic set
|
|
|
|
|
command below).
|
|
|
|
|
.It Fl l
|
|
|
|
|
Login shell.
|
|
|
|
|
If the basename the shell is called with (i.e. argv[0])
|
|
|
|
|
starts with
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or if this option is used,
|
2011-07-16 19:08:21 +02:00
|
|
|
|
the shell is assumed to be a login shell; see
|
|
|
|
|
.Sx Startup files
|
|
|
|
|
below.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl p
|
|
|
|
|
Privileged shell.
|
|
|
|
|
A shell is
|
|
|
|
|
.Dq privileged
|
|
|
|
|
if this option is used
|
|
|
|
|
or if the real user ID or group ID does not match the
|
|
|
|
|
effective user ID or group ID (see
|
|
|
|
|
.Xr getuid 2
|
|
|
|
|
and
|
|
|
|
|
.Xr getgid 2 ) .
|
|
|
|
|
Clearing the privileged option causes the shell to set
|
|
|
|
|
its effective user ID (group ID) to its real user ID (group ID).
|
2011-07-16 19:08:21 +02:00
|
|
|
|
For further implications, see
|
|
|
|
|
.Sx Startup files .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl r
|
|
|
|
|
Restricted shell.
|
|
|
|
|
A shell is
|
|
|
|
|
.Dq restricted
|
|
|
|
|
if this
|
2005-07-04 13:57:55 +02:00
|
|
|
|
option is used.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The following restrictions come into effect after the shell processes any
|
|
|
|
|
profile and
|
|
|
|
|
.Ev ENV
|
|
|
|
|
files:
|
|
|
|
|
.Pp
|
|
|
|
|
.Bl -bullet -compact
|
|
|
|
|
.It
|
|
|
|
|
The
|
|
|
|
|
.Ic cd
|
2009-08-30 23:02:01 +02:00
|
|
|
|
.Po and Ic chdir Pc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
command is disabled.
|
|
|
|
|
.It
|
|
|
|
|
The
|
|
|
|
|
.Ev SHELL ,
|
|
|
|
|
.Ev ENV ,
|
|
|
|
|
and
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameters cannot be changed.
|
|
|
|
|
.It
|
|
|
|
|
Command names can't be specified with absolute or relative paths.
|
|
|
|
|
.It
|
|
|
|
|
The
|
|
|
|
|
.Fl p
|
|
|
|
|
option of the built-in command
|
|
|
|
|
.Ic command
|
|
|
|
|
can't be used.
|
|
|
|
|
.It
|
|
|
|
|
Redirections that create files can't be used (i.e.\&
|
|
|
|
|
.Ql \*(Gt ,
|
|
|
|
|
.Ql \*(Gt\*(Ba ,
|
|
|
|
|
.Ql \*(Gt\*(Gt ,
|
|
|
|
|
.Ql \*(Lt\*(Gt ) .
|
|
|
|
|
.El
|
|
|
|
|
.It Fl s
|
|
|
|
|
The shell reads commands from standard input; all non-option arguments
|
|
|
|
|
are positional parameters.
|
|
|
|
|
.It Fl T Ar tty
|
|
|
|
|
Spawn
|
|
|
|
|
.Nm
|
|
|
|
|
on the
|
|
|
|
|
.Xr tty 4
|
|
|
|
|
device given.
|
|
|
|
|
Superuser only.
|
2008-03-23 23:09:59 +01:00
|
|
|
|
If
|
|
|
|
|
.Ar tty
|
|
|
|
|
is a dash, detach from controlling terminal (daemonise) instead.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
In addition to the above, the options described in the
|
|
|
|
|
.Ic set
|
|
|
|
|
built-in command can also be used on the command line:
|
|
|
|
|
both
|
|
|
|
|
.Op Fl +abCefhkmnuvXx
|
|
|
|
|
and
|
|
|
|
|
.Op Fl +o Ar option
|
|
|
|
|
can be used for single letter or long options, respectively.
|
|
|
|
|
.Pp
|
|
|
|
|
If neither the
|
|
|
|
|
.Fl c
|
|
|
|
|
nor the
|
|
|
|
|
.Fl s
|
|
|
|
|
option is specified, the first non-option argument specifies the name
|
|
|
|
|
of a file the shell reads commands from.
|
|
|
|
|
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 $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;
|
|
|
|
|
if commands are being read from a file, the file is used as the name;
|
|
|
|
|
otherwise, the basename the shell was called with (i.e. argv[0]) is used.
|
|
|
|
|
.Pp
|
|
|
|
|
The exit status of the shell is 127 if the command file specified on the
|
|
|
|
|
command line could not be opened, or non-zero if a fatal syntax error
|
|
|
|
|
occurred during the execution of a script.
|
|
|
|
|
In the absence of fatal errors,
|
|
|
|
|
the exit status is that of the last command executed, or zero, if no
|
|
|
|
|
command is executed.
|
2011-07-16 19:08:21 +02:00
|
|
|
|
.Ss Startup files
|
|
|
|
|
For the actual location of these files, see
|
|
|
|
|
.Sx FILES .
|
|
|
|
|
A login shell processes the system profile first.
|
|
|
|
|
A privileged shell then processes the suid profile.
|
|
|
|
|
A non-privileged login shell processes the user profile next.
|
|
|
|
|
A non-privileged interactive shell checks the value of the
|
|
|
|
|
.Ev ENV
|
|
|
|
|
parameter after subjecting it to parameter, command, arithmetic and tilde
|
|
|
|
|
.Pq Sq \*(TI
|
|
|
|
|
substitution; if unset or empty, the user mkshrc profile is processed;
|
|
|
|
|
otherwise, if a file whose name is the substitution result exists,
|
|
|
|
|
it is processed; non-existence is silently ignored.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ss Command syntax
|
2005-05-26 01:31:08 +02:00
|
|
|
|
The shell begins parsing its input by removing any backslash-newline
|
|
|
|
|
combinations, then breaking it into
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Em words .
|
2006-01-30 13:37:24 +01:00
|
|
|
|
Words (which are sequences of characters) are delimited by unquoted whitespace
|
2005-05-23 05:06:10 +02:00
|
|
|
|
characters (space, tab, and newline) or meta-characters
|
|
|
|
|
.Po
|
|
|
|
|
.Ql \*(Lt ,
|
|
|
|
|
.Ql \*(Gt ,
|
|
|
|
|
.Ql \*(Ba ,
|
|
|
|
|
.Ql \&; ,
|
2006-11-16 14:05:39 +01:00
|
|
|
|
.Ql \&( ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql \&) ,
|
|
|
|
|
and
|
|
|
|
|
.Ql &
|
|
|
|
|
.Pc .
|
|
|
|
|
Aside from delimiting words, spaces and tabs are ignored, while newlines
|
|
|
|
|
usually delimit commands.
|
|
|
|
|
The meta-characters are used in building the following
|
|
|
|
|
.Em tokens :
|
|
|
|
|
.Ql \*(Lt ,
|
|
|
|
|
.Ql \*(Lt& ,
|
|
|
|
|
.Ql \*(Lt\*(Lt ,
|
2008-02-26 21:43:11 +01:00
|
|
|
|
.Ql \*(Lt\*(Lt\*(Lt ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql \*(Gt ,
|
|
|
|
|
.Ql \*(Gt& ,
|
|
|
|
|
.Ql \*(Gt\*(Gt ,
|
2008-06-29 00:51:56 +02:00
|
|
|
|
.Ql &\*(Gt ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
etc. are used to specify redirections (see
|
|
|
|
|
.Sx Input/output redirection
|
|
|
|
|
below);
|
|
|
|
|
.Ql \*(Ba
|
|
|
|
|
is used to create pipelines;
|
|
|
|
|
.Ql \*(Ba&
|
|
|
|
|
is used to create co-processes (see
|
|
|
|
|
.Sx Co-processes
|
|
|
|
|
below);
|
|
|
|
|
.Ql \&;
|
|
|
|
|
is used to separate commands;
|
|
|
|
|
.Ql &
|
|
|
|
|
is used to create asynchronous pipelines;
|
|
|
|
|
.Ql &&
|
|
|
|
|
and
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba
|
2005-05-23 05:06:10 +02:00
|
|
|
|
are used to specify conditional execution;
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Ql ;; ,
|
|
|
|
|
.Ql ;&\&
|
|
|
|
|
and
|
|
|
|
|
.Ql ;\*(Ba\&
|
|
|
|
|
are used in
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic case
|
|
|
|
|
statements;
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Ql \&(( .. ))
|
2005-05-23 05:06:10 +02:00
|
|
|
|
is used in arithmetic expressions;
|
|
|
|
|
and lastly,
|
|
|
|
|
.Ql \&( .. )\&
|
|
|
|
|
is used to create subshells.
|
|
|
|
|
.Pp
|
|
|
|
|
Whitespace and meta-characters can be quoted individually using a backslash
|
|
|
|
|
.Pq Sq \e ,
|
|
|
|
|
or in groups using double
|
|
|
|
|
.Pq Sq \&"
|
|
|
|
|
or single
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Pq Sq \*(aq
|
2005-05-23 05:06:10 +02:00
|
|
|
|
quotes.
|
|
|
|
|
Note that the following characters are also treated specially by the
|
|
|
|
|
shell and must be quoted if they are to represent themselves:
|
|
|
|
|
.Ql \e ,
|
|
|
|
|
.Ql \&" ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \*(aq ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql # ,
|
|
|
|
|
.Ql $ ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \` ,
|
|
|
|
|
.Ql \*(TI ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql { ,
|
|
|
|
|
.Ql } ,
|
|
|
|
|
.Ql * ,
|
|
|
|
|
.Ql \&? ,
|
|
|
|
|
and
|
2006-11-16 14:05:39 +01:00
|
|
|
|
.Ql \&[ .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The first three of these are the above mentioned quoting characters (see
|
|
|
|
|
.Sx Quoting
|
|
|
|
|
below);
|
|
|
|
|
.Ql # ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
if used at the beginning of a word, introduces a comment \*(en everything after
|
2005-05-23 05:06:10 +02:00
|
|
|
|
the
|
|
|
|
|
.Ql #
|
|
|
|
|
up to the nearest newline is ignored;
|
|
|
|
|
.Ql $
|
|
|
|
|
is used to introduce parameter, command, and arithmetic substitutions (see
|
|
|
|
|
.Sx Substitution
|
|
|
|
|
below);
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \`
|
2005-05-23 05:06:10 +02:00
|
|
|
|
introduces an old-style command substitution (see
|
|
|
|
|
.Sx Substitution
|
|
|
|
|
below);
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \*(TI
|
2005-05-23 05:06:10 +02:00
|
|
|
|
begins a directory expansion (see
|
|
|
|
|
.Sx Tilde expansion
|
|
|
|
|
below);
|
|
|
|
|
.Ql {
|
|
|
|
|
and
|
|
|
|
|
.Ql }
|
|
|
|
|
delimit
|
|
|
|
|
.Xr csh 1 Ns -style
|
|
|
|
|
alterations (see
|
|
|
|
|
.Sx Brace expansion
|
|
|
|
|
below);
|
|
|
|
|
and finally,
|
|
|
|
|
.Ql * ,
|
|
|
|
|
.Ql \&? ,
|
|
|
|
|
and
|
2006-11-16 14:05:39 +01:00
|
|
|
|
.Ql \&[
|
2005-05-23 05:06:10 +02:00
|
|
|
|
are used in file name generation (see
|
|
|
|
|
.Sx File name patterns
|
|
|
|
|
below).
|
|
|
|
|
.Pp
|
|
|
|
|
As words and tokens are parsed, the shell builds commands, of which there
|
|
|
|
|
are two basic types:
|
|
|
|
|
.Em simple-commands ,
|
|
|
|
|
typically programmes that are executed, and
|
|
|
|
|
.Em compound-commands ,
|
|
|
|
|
such as
|
|
|
|
|
.Ic for
|
|
|
|
|
and
|
|
|
|
|
.Ic if
|
|
|
|
|
statements, grouping constructs, and function definitions.
|
|
|
|
|
.Pp
|
|
|
|
|
A simple-command consists of some combination of parameter assignments
|
|
|
|
|
(see
|
|
|
|
|
.Sx Parameters
|
|
|
|
|
below),
|
|
|
|
|
input/output redirections (see
|
|
|
|
|
.Sx Input/output redirections
|
|
|
|
|
below),
|
|
|
|
|
and command words; the only restriction is that parameter assignments come
|
|
|
|
|
before any command words.
|
|
|
|
|
The command words, if any, define the command
|
|
|
|
|
that is to be executed and its arguments.
|
|
|
|
|
The command may be a shell built-in command, a function,
|
|
|
|
|
or an external command
|
|
|
|
|
(i.e. a separate executable file that is located using the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameter; see
|
|
|
|
|
.Sx Command execution
|
|
|
|
|
below).
|
|
|
|
|
Note that all command constructs have an exit status: for external commands,
|
|
|
|
|
this is related to the status returned by
|
|
|
|
|
.Xr wait 2
|
|
|
|
|
(if the command could not be found, the exit status is 127; if it could not
|
|
|
|
|
be executed, the exit status is 126); the exit status of other command
|
|
|
|
|
constructs (built-in commands, functions, compound-commands, pipelines, lists,
|
|
|
|
|
etc.) are all well-defined and are described where the construct is
|
|
|
|
|
described.
|
|
|
|
|
The exit status of a command consisting only of parameter
|
|
|
|
|
assignments is that of the last command substitution performed during the
|
|
|
|
|
parameter assignment or 0 if there were no command substitutions.
|
|
|
|
|
.Pp
|
|
|
|
|
Commands can be chained together using the
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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.
|
2009-09-06 20:17:51 +02:00
|
|
|
|
All commands of a pipeline are executed in separate subshells;
|
|
|
|
|
this is allowed by POSIX but differs from both variants of
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh ,
|
|
|
|
|
where all but the last command were executed in subshells; see the
|
|
|
|
|
.Ic read
|
|
|
|
|
builtin's description for implications and workarounds.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
A pipeline may be prefixed by the
|
|
|
|
|
.Ql \&!
|
2006-01-30 13:37:24 +01:00
|
|
|
|
reserved word which causes the exit status of the pipeline to be logically
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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.
|
|
|
|
|
.Pp
|
|
|
|
|
.Em Lists
|
|
|
|
|
of commands can be created by separating pipelines by any of the following
|
|
|
|
|
tokens:
|
|
|
|
|
.Ql && ,
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql & ,
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba& ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and
|
|
|
|
|
.Ql \&; .
|
|
|
|
|
The first two are for conditional execution:
|
|
|
|
|
.Dq Ar cmd1 No && Ar cmd2
|
|
|
|
|
executes
|
|
|
|
|
.Ar cmd2
|
|
|
|
|
only if the exit status of
|
|
|
|
|
.Ar cmd1
|
|
|
|
|
is zero;
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
is the opposite \*(en
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ar cmd2
|
|
|
|
|
is executed only if the exit status of
|
|
|
|
|
.Ar cmd1
|
|
|
|
|
is non-zero.
|
|
|
|
|
.Ql &&
|
|
|
|
|
and
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba
|
2005-05-23 05:06:10 +02:00
|
|
|
|
have equal precedence which is higher than that of
|
|
|
|
|
.Ql & ,
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba& ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and
|
|
|
|
|
.Ql \&; ,
|
|
|
|
|
which also have equal precedence.
|
|
|
|
|
Note that the
|
|
|
|
|
.Ql &&
|
|
|
|
|
and
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba
|
2005-05-23 05:06:10 +02:00
|
|
|
|
operators are
|
|
|
|
|
.Qq left-associative .
|
|
|
|
|
For example, both of these commands will print only
|
|
|
|
|
.Qq bar :
|
|
|
|
|
.Bd -literal -offset indent
|
2006-01-27 11:58:36 +01:00
|
|
|
|
$ false && echo foo \*(Ba\*(Ba echo bar
|
|
|
|
|
$ true \*(Ba\*(Ba echo foo && echo bar
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.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 SIGINT
|
|
|
|
|
and
|
|
|
|
|
.Dv SIGQUIT
|
|
|
|
|
ignored and with input redirected from
|
|
|
|
|
.Pa /dev/null
|
|
|
|
|
(however, redirections specified in the asynchronous command have precedence).
|
|
|
|
|
The
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba&
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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
|
|
|
|
|
.Ql &&
|
|
|
|
|
and
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba
|
2005-05-23 05:06:10 +02:00
|
|
|
|
operators, while it need not follow
|
|
|
|
|
.Ql & ,
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba& ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
|
|
|
|
.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
|
|
|
|
|
Compound commands are created using the following reserved words.
|
|
|
|
|
These words
|
|
|
|
|
are only recognised if they are unquoted and if they are used as the first
|
|
|
|
|
word of a command (i.e. they can't be preceded by parameter assignments or
|
|
|
|
|
redirections):
|
|
|
|
|
.Bd -literal -offset indent
|
2010-07-13 15:12:32 +02:00
|
|
|
|
case else function then ! (
|
|
|
|
|
do esac if time [[ ((
|
2005-05-23 05:06:10 +02:00
|
|
|
|
done fi in until {
|
|
|
|
|
elif for select while }
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
In the following compound command descriptions, command lists (denoted as
|
|
|
|
|
.Em list )
|
|
|
|
|
that are followed by reserved words must end with a semicolon, a newline, or
|
|
|
|
|
a (syntactically correct) reserved word.
|
|
|
|
|
For example, the following are all valid:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
$ { echo foo; echo bar; }
|
2005-05-26 01:31:08 +02:00
|
|
|
|
$ { echo foo; echo bar\*(Ltnewline\*(Gt}
|
2005-05-23 05:06:10 +02:00
|
|
|
|
$ { { echo foo; echo bar; } }
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
This is not valid:
|
|
|
|
|
.Pp
|
|
|
|
|
.Dl $ { echo foo; echo bar }
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.Bl -tag -width 4n
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Pq Ar list
|
|
|
|
|
Execute
|
|
|
|
|
.Ar list
|
|
|
|
|
in a subshell.
|
|
|
|
|
There is no implicit way to pass environment changes from a
|
|
|
|
|
subshell back to its parent.
|
|
|
|
|
.It { Ar list ; No }
|
|
|
|
|
Compound construct;
|
|
|
|
|
.Ar list
|
|
|
|
|
is executed, but not in a subshell.
|
|
|
|
|
Note that
|
|
|
|
|
.Ql {
|
|
|
|
|
and
|
|
|
|
|
.Ql }
|
|
|
|
|
are reserved words, not meta-characters.
|
|
|
|
|
.It Xo case Ar word No in
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Oo Op \&(
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Ar pattern
|
|
|
|
|
.Op \*(Ba Ar pat
|
|
|
|
|
.No ... Ns )
|
|
|
|
|
.Ar list
|
|
|
|
|
.Op ;; \*(Ba ;&\& \*(Ba ;\*(Ba\ \&
|
|
|
|
|
.Oc ... esac
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
The
|
|
|
|
|
.Ic case
|
|
|
|
|
statement attempts to match
|
|
|
|
|
.Ar word
|
|
|
|
|
against a specified
|
|
|
|
|
.Ar pattern ;
|
|
|
|
|
the
|
|
|
|
|
.Ar list
|
|
|
|
|
associated with the first successfully matched pattern is executed.
|
|
|
|
|
Patterns used in
|
|
|
|
|
.Ic case
|
|
|
|
|
statements are the same as those used for file name patterns except that the
|
|
|
|
|
restrictions regarding
|
|
|
|
|
.Ql \&.
|
|
|
|
|
and
|
|
|
|
|
.Ql /
|
|
|
|
|
are dropped.
|
|
|
|
|
Note that any unquoted space before and after a pattern is
|
|
|
|
|
stripped; any space within a pattern must be quoted.
|
|
|
|
|
Both the word and the
|
|
|
|
|
patterns are subject to parameter, command, and arithmetic substitution, as
|
|
|
|
|
well as tilde substitution.
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
For historical reasons, open and close braces may be used instead of
|
|
|
|
|
.Ic in
|
|
|
|
|
and
|
|
|
|
|
.Ic esac
|
|
|
|
|
e.g.\&
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Ic case $foo { *) echo bar;; } .
|
|
|
|
|
.Pp
|
2011-07-16 19:08:04 +02:00
|
|
|
|
The list terminators are:
|
|
|
|
|
.Bl -tag -width 4n
|
|
|
|
|
.It Ql ;;
|
|
|
|
|
Terminate after the list.
|
|
|
|
|
.It Ql ;&\&
|
|
|
|
|
Fall through into the next list.
|
|
|
|
|
.It Ql ;\*(Ba\&
|
|
|
|
|
Evaluate the remaining pattern-list tuples.
|
|
|
|
|
.El
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The exit status of a
|
|
|
|
|
.Ic case
|
|
|
|
|
statement is that of the executed
|
|
|
|
|
.Ar list ;
|
|
|
|
|
if no
|
|
|
|
|
.Ar list
|
|
|
|
|
is executed, the exit status is zero.
|
|
|
|
|
.It Xo for Ar name
|
|
|
|
|
.Oo in Ar word No ... Oc ;
|
|
|
|
|
.No do Ar list ; No done
|
|
|
|
|
.Xc
|
|
|
|
|
For each
|
|
|
|
|
.Ar word
|
|
|
|
|
in the specified word list, the parameter
|
|
|
|
|
.Ar name
|
|
|
|
|
is set to the word and
|
|
|
|
|
.Ar list
|
|
|
|
|
is executed.
|
|
|
|
|
If
|
|
|
|
|
.Ic in
|
|
|
|
|
is not used to specify a word list, the positional parameters
|
|
|
|
|
($1, $2, etc.)\&
|
|
|
|
|
are used instead.
|
|
|
|
|
For historical reasons, open and close braces may be used instead of
|
|
|
|
|
.Ic do
|
|
|
|
|
and
|
|
|
|
|
.Ic done
|
|
|
|
|
e.g.\&
|
|
|
|
|
.Ic for i; { echo $i; } .
|
|
|
|
|
The exit status of a
|
|
|
|
|
.Ic for
|
|
|
|
|
statement is the last exit status of
|
|
|
|
|
.Ar list ;
|
|
|
|
|
if
|
|
|
|
|
.Ar list
|
|
|
|
|
is never executed, the exit status is zero.
|
|
|
|
|
.It Xo if Ar list ;
|
|
|
|
|
.No then Ar list ;
|
|
|
|
|
.Oo elif Ar list ;
|
|
|
|
|
.No then Ar list ; Oc
|
|
|
|
|
.No ...
|
|
|
|
|
.Oo else Ar list ; Oc
|
|
|
|
|
.No fi
|
|
|
|
|
.Xc
|
|
|
|
|
If the exit status of the first
|
|
|
|
|
.Ar list
|
|
|
|
|
is zero, the second
|
|
|
|
|
.Ar list
|
|
|
|
|
is executed; otherwise, the
|
|
|
|
|
.Ar list
|
|
|
|
|
following the
|
|
|
|
|
.Ic elif ,
|
|
|
|
|
if any, is executed with similar consequences.
|
|
|
|
|
If all the lists following the
|
|
|
|
|
.Ic if
|
|
|
|
|
and
|
|
|
|
|
.Ic elif Ns s
|
|
|
|
|
fail (i.e. exit with non-zero status), the
|
|
|
|
|
.Ar list
|
|
|
|
|
following the
|
|
|
|
|
.Ic else
|
|
|
|
|
is executed.
|
|
|
|
|
The exit status of an
|
|
|
|
|
.Ic if
|
|
|
|
|
statement is that of non-conditional
|
|
|
|
|
.Ar list
|
|
|
|
|
that is executed; if no non-conditional
|
|
|
|
|
.Ar list
|
|
|
|
|
is executed, the exit status is zero.
|
|
|
|
|
.It Xo select Ar name
|
|
|
|
|
.Oo in Ar word No ... Oc ;
|
|
|
|
|
.No do Ar list ; No done
|
|
|
|
|
.Xc
|
|
|
|
|
The
|
|
|
|
|
.Ic select
|
|
|
|
|
statement provides an automatic method of presenting the user with a menu and
|
|
|
|
|
selecting from it.
|
|
|
|
|
An enumerated list of the specified
|
|
|
|
|
.Ar word Ns (s)
|
|
|
|
|
is printed on standard error, followed by a prompt
|
|
|
|
|
.Po
|
|
|
|
|
.Ev PS3: normally
|
|
|
|
|
.Sq #?\ \&
|
|
|
|
|
.Pc .
|
|
|
|
|
A number corresponding to one of the enumerated words is then read from
|
|
|
|
|
standard input,
|
|
|
|
|
.Ar name
|
|
|
|
|
is set to the selected word (or unset if the selection is not valid),
|
|
|
|
|
.Ev REPLY
|
|
|
|
|
is set to what was read (leading/trailing space is stripped), and
|
|
|
|
|
.Ar list
|
|
|
|
|
is executed.
|
|
|
|
|
If a blank line (i.e. zero or more
|
|
|
|
|
.Ev IFS
|
2009-11-22 15:23:21 +01:00
|
|
|
|
octets) is entered, the menu is reprinted without executing
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ar list .
|
|
|
|
|
.Pp
|
|
|
|
|
When
|
|
|
|
|
.Ar list
|
|
|
|
|
completes, the enumerated list is printed if
|
|
|
|
|
.Ev REPLY
|
|
|
|
|
is
|
|
|
|
|
.Dv NULL ,
|
|
|
|
|
the prompt is printed, and so on.
|
|
|
|
|
This process continues until an end-of-file
|
|
|
|
|
is read, an interrupt is received, or a
|
|
|
|
|
.Ic break
|
|
|
|
|
statement is executed inside the loop.
|
|
|
|
|
If
|
|
|
|
|
.Dq in word ...
|
|
|
|
|
is omitted, the positional parameters are used
|
|
|
|
|
(i.e. $1, $2, etc.).
|
|
|
|
|
For historical reasons, open and close braces may be used instead of
|
|
|
|
|
.Ic do
|
|
|
|
|
and
|
|
|
|
|
.Ic done
|
|
|
|
|
e.g.\&
|
|
|
|
|
.Ic select i; { echo $i; } .
|
|
|
|
|
The exit status of a
|
|
|
|
|
.Ic select
|
|
|
|
|
statement is zero if a
|
|
|
|
|
.Ic break
|
|
|
|
|
statement is used to exit the loop, non-zero otherwise.
|
|
|
|
|
.It Xo until Ar list ;
|
|
|
|
|
.No do Ar list ;
|
|
|
|
|
.No done
|
|
|
|
|
.Xc
|
|
|
|
|
This works like
|
|
|
|
|
.Ic while ,
|
|
|
|
|
except that the body is executed only while the exit status of the first
|
|
|
|
|
.Ar list
|
|
|
|
|
is non-zero.
|
|
|
|
|
.It Xo while Ar list ;
|
|
|
|
|
.No do Ar list ;
|
|
|
|
|
.No done
|
|
|
|
|
.Xc
|
|
|
|
|
A
|
|
|
|
|
.Ic while
|
|
|
|
|
is a pre-checked loop.
|
|
|
|
|
Its body is executed as often as the exit status of the first
|
|
|
|
|
.Ar list
|
|
|
|
|
is zero.
|
|
|
|
|
The exit status of a
|
|
|
|
|
.Ic while
|
|
|
|
|
statement is the last exit status of the
|
|
|
|
|
.Ar list
|
|
|
|
|
in the body of the loop; if the body is not executed, the exit status is zero.
|
|
|
|
|
.It Xo function Ar name
|
|
|
|
|
.No { Ar list ; No }
|
|
|
|
|
.Xc
|
|
|
|
|
Defines the function
|
|
|
|
|
.Ar name
|
|
|
|
|
(see
|
|
|
|
|
.Sx Functions
|
|
|
|
|
below).
|
|
|
|
|
Note that redirections specified after a function definition are
|
|
|
|
|
performed whenever the function is executed, not when the function definition
|
|
|
|
|
is executed.
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.It Ar name Ns \&() Ar command
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Mostly the same as
|
|
|
|
|
.Ic function
|
|
|
|
|
(see
|
|
|
|
|
.Sx Functions
|
|
|
|
|
below).
|
2009-07-06 17:06:25 +02:00
|
|
|
|
Whitespace (space or tab) after
|
|
|
|
|
.Ar name
|
|
|
|
|
will be ignored most of the time.
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.It Xo function Ar name Ns \&()
|
2009-09-19 20:36:59 +02:00
|
|
|
|
.No { Ar list ; No }
|
|
|
|
|
.Xc
|
|
|
|
|
The same as
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Ar name Ns \&()
|
2009-09-19 20:36:59 +02:00
|
|
|
|
.Pq Nm bash Ns ism .
|
|
|
|
|
The
|
|
|
|
|
.Ic function
|
|
|
|
|
keyword is ignored.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Xo Ic time Op Fl p
|
|
|
|
|
.Op Ar pipeline
|
|
|
|
|
.Xc
|
|
|
|
|
The
|
|
|
|
|
.Sx Command execution
|
2011-07-16 19:08:04 +02:00
|
|
|
|
section describes the
|
|
|
|
|
.Ic time
|
|
|
|
|
reserved word.
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.It \&(( Ar expression No ))
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The arithmetic expression
|
|
|
|
|
.Ar expression
|
|
|
|
|
is evaluated; equivalent to
|
|
|
|
|
.Dq let expression
|
|
|
|
|
(see
|
|
|
|
|
.Sx Arithmetic expressions
|
|
|
|
|
and the
|
|
|
|
|
.Ic let
|
|
|
|
|
command, below).
|
|
|
|
|
.It Bq Bq Ar \ \&expression\ \&
|
|
|
|
|
Similar to the
|
|
|
|
|
.Ic test
|
|
|
|
|
and
|
|
|
|
|
.Ic \&[ ... \&]
|
|
|
|
|
commands (described later), with the following exceptions:
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.Bl -bullet
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It
|
|
|
|
|
Field splitting and file name generation are not performed on arguments.
|
|
|
|
|
.It
|
|
|
|
|
The
|
|
|
|
|
.Fl a
|
|
|
|
|
.Pq AND
|
|
|
|
|
and
|
|
|
|
|
.Fl o
|
|
|
|
|
.Pq OR
|
|
|
|
|
operators are replaced with
|
|
|
|
|
.Ql &&
|
|
|
|
|
and
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
respectively.
|
|
|
|
|
.It
|
|
|
|
|
Operators (e.g.\&
|
|
|
|
|
.Sq Fl f ,
|
|
|
|
|
.Sq = ,
|
|
|
|
|
.Sq \&! )
|
|
|
|
|
must be unquoted.
|
|
|
|
|
.It
|
|
|
|
|
Parameter, command, and arithmetic substitutions are performed as expressions
|
|
|
|
|
are evaluated and lazy expression evaluation is used for the
|
|
|
|
|
.Ql &&
|
|
|
|
|
and
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba\*(Ba
|
2005-05-23 05:06:10 +02:00
|
|
|
|
operators.
|
|
|
|
|
This means that in the following statement,
|
2007-03-10 22:14:07 +01:00
|
|
|
|
.Ic $(\*(Ltfoo)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
is evaluated if and only if the file
|
|
|
|
|
.Pa foo
|
|
|
|
|
exists and is readable:
|
|
|
|
|
.Bd -literal -offset indent
|
2008-03-03 23:38:41 +01:00
|
|
|
|
$ [[ \-r foo && $(\*(Ltfoo) = b*r ]]
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ed
|
2010-08-14 22:13:10 +02:00
|
|
|
|
.It
|
|
|
|
|
The second operand of the
|
|
|
|
|
.Sq !=
|
|
|
|
|
and
|
|
|
|
|
.Sq =
|
|
|
|
|
expressions are patterns (e.g. the comparison
|
|
|
|
|
.Ic \&[[ foobar = f*r ]]
|
|
|
|
|
succeeds).
|
|
|
|
|
This even works indirectly:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
$ bar=foobar; baz=\*(aqf*r\*(aq
|
|
|
|
|
$ [[ $bar = $baz ]]; echo $?
|
2011-11-11 23:10:52 +01:00
|
|
|
|
$ [[ $bar = \&"$baz" ]]; echo $?
|
2010-08-14 22:13:10 +02:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
2011-08-14 00:19:41 +02:00
|
|
|
|
Perhaps surprisingly, the first comparison succeeds,
|
2010-08-14 22:13:10 +02:00
|
|
|
|
whereas the second doesn't.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.El
|
|
|
|
|
.Ss Quoting
|
|
|
|
|
Quoting is used to prevent the shell from treating characters or words
|
|
|
|
|
specially.
|
|
|
|
|
There are three methods of quoting.
|
|
|
|
|
First,
|
|
|
|
|
.Ql \e
|
|
|
|
|
quotes the following character, unless it is at the end of a line, in which
|
|
|
|
|
case both the
|
|
|
|
|
.Ql \e
|
|
|
|
|
and the newline are stripped.
|
|
|
|
|
Second, a single quote
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Pq Sq \*(aq
|
2005-05-23 05:06:10 +02:00
|
|
|
|
quotes everything up to the next single quote (this may span lines).
|
|
|
|
|
Third, a double quote
|
|
|
|
|
.Pq Sq \&"
|
|
|
|
|
quotes all characters, except
|
|
|
|
|
.Ql $ ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \`
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and
|
|
|
|
|
.Ql \e ,
|
|
|
|
|
up to the next unquoted double quote.
|
|
|
|
|
.Ql $
|
|
|
|
|
and
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \`
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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
|
|
|
|
|
.Ql \e
|
|
|
|
|
inside a double-quoted string is followed by
|
|
|
|
|
.Ql \e ,
|
|
|
|
|
.Ql $ ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \` ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
|
|
|
|
.Ql \&" ,
|
|
|
|
|
it is replaced by the second character; if it is followed by a newline, both
|
|
|
|
|
the
|
|
|
|
|
.Ql \e
|
|
|
|
|
and the newline are stripped; otherwise, both the
|
|
|
|
|
.Ql \e
|
|
|
|
|
and the character following are unchanged.
|
2009-09-19 23:54:46 +02:00
|
|
|
|
.Pp
|
|
|
|
|
If a single-quoted string is preceded by an unquoted
|
|
|
|
|
.Ql $ ,
|
|
|
|
|
C style backslash expansion (see below) is applied (even single quote
|
|
|
|
|
characters inside can be escaped and do not terminate the string then);
|
|
|
|
|
the expanded result is treated as any other single-quoted string.
|
2010-12-19 21:00:56 +01:00
|
|
|
|
If a double-quoted string is preceded by an unquoted
|
|
|
|
|
.Ql $ ,
|
|
|
|
|
the latter is ignored.
|
2009-09-19 17:16:05 +02:00
|
|
|
|
.Ss Backslash expansion
|
|
|
|
|
In places where backslashes are expanded, certain C and
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh
|
|
|
|
|
or GNU
|
|
|
|
|
.Nm bash
|
|
|
|
|
style escapes are translated.
|
|
|
|
|
These include
|
|
|
|
|
.Ql \ea ,
|
|
|
|
|
.Ql \eb ,
|
|
|
|
|
.Ql \ef ,
|
|
|
|
|
.Ql \en ,
|
|
|
|
|
.Ql \er ,
|
|
|
|
|
.Ql \et ,
|
|
|
|
|
.Ql \eU######## ,
|
|
|
|
|
.Ql \eu#### ,
|
|
|
|
|
and
|
2009-09-19 23:54:46 +02:00
|
|
|
|
.Ql \ev .
|
|
|
|
|
For
|
|
|
|
|
.Ql \eU########
|
|
|
|
|
and
|
|
|
|
|
.Ql \eu#### ,
|
|
|
|
|
.Dq #
|
|
|
|
|
means a hexadecimal digit, of thich there may be none up to four or eight;
|
|
|
|
|
these escapes translate a Unicode codepoint to UTF-8.
|
|
|
|
|
Furthermore,
|
|
|
|
|
.Ql \eE
|
|
|
|
|
and
|
|
|
|
|
.Ql \ee
|
|
|
|
|
expand to the escape character.
|
|
|
|
|
.Pp
|
|
|
|
|
In the
|
|
|
|
|
.Ic print
|
|
|
|
|
builtin mode,
|
|
|
|
|
.Ql \e" ,
|
|
|
|
|
.Ql \e\*(aq ,
|
|
|
|
|
and
|
|
|
|
|
.Ql \e?
|
|
|
|
|
are explicitly excluded;
|
|
|
|
|
octal sequences must have the none up to three octal digits
|
|
|
|
|
.Dq #
|
|
|
|
|
prefixed with the digit zero
|
|
|
|
|
.Pq Ql \e0### ;
|
|
|
|
|
hexadecimal sequences
|
|
|
|
|
.Ql \ex##
|
|
|
|
|
are limited to none up to two hexadecimal digits
|
|
|
|
|
.Dq # ;
|
|
|
|
|
both octal and hexadecimal sequences convert to raw octets;
|
|
|
|
|
.Ql \e# ,
|
|
|
|
|
where # is none of the above, translates to \e# (backslashes are retained).
|
|
|
|
|
.Pp
|
|
|
|
|
Backslash expansion in the C style mode slightly differs: octal sequences
|
|
|
|
|
.Ql \e###
|
|
|
|
|
must have no digit zero prefixing the one up to three octal digits
|
|
|
|
|
.Dq #
|
|
|
|
|
and yield raw octets; hexadecimal sequences
|
|
|
|
|
.Ql \ex#*
|
|
|
|
|
greedily eat up as many hexadecimal digits
|
|
|
|
|
.Dq #
|
|
|
|
|
as they can and terminate with the first non-hexadecimal digit;
|
|
|
|
|
these translate a Unicode codepoint to UTF-8.
|
|
|
|
|
The sequence
|
|
|
|
|
.Ql \ec# ,
|
|
|
|
|
where
|
|
|
|
|
.Dq #
|
|
|
|
|
is any octet, translates to Ctrl-# (which basically means,
|
2010-10-08 19:30:05 +02:00
|
|
|
|
.Ql \ec?
|
2009-09-19 23:54:46 +02:00
|
|
|
|
becomes DEL, everything else is bitwise ANDed with 0x1F).
|
|
|
|
|
Finally,
|
|
|
|
|
.Ql \e# ,
|
|
|
|
|
where # is none of the above, translates to # (has the backslash trimmed),
|
|
|
|
|
even if it is a newline.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ss Aliases
|
|
|
|
|
There are two types of aliases: normal command aliases and tracked aliases.
|
|
|
|
|
Command aliases are normally used as a short hand for a long or often used
|
|
|
|
|
command.
|
|
|
|
|
The shell expands command aliases (i.e. substitutes the alias name
|
|
|
|
|
for its value) when it reads the first word of a command.
|
|
|
|
|
An expanded alias is re-processed to check for more aliases.
|
|
|
|
|
If a command alias ends in a
|
|
|
|
|
space or tab, the following word is also checked for alias expansion.
|
|
|
|
|
The alias expansion process stops when a word that is not an alias is found,
|
|
|
|
|
when a quoted word is found, or when an alias word that is currently being
|
|
|
|
|
expanded is found.
|
2012-06-28 22:05:11 +02:00
|
|
|
|
Aliases are specifically an interactive feature: while they do happen
|
|
|
|
|
to work in scripts and on the command line in some cases, aliases are
|
|
|
|
|
expanded during lexing, so their use must be in a separate command tree
|
|
|
|
|
from their definition; otherwise, the alias will not be found.
|
|
|
|
|
Noticeably, command lists (separated by semicolon, in command substitutions
|
|
|
|
|
also by newline) may be one same parse tree.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
2008-02-25 01:58:26 +01:00
|
|
|
|
The following command aliases are defined automatically by the shell:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Bd -literal -offset indent
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
autoload=\*(aqtypeset \-fu\*(aq
|
|
|
|
|
functions=\*(aqtypeset \-f\*(aq
|
|
|
|
|
hash=\*(aqalias \-t\*(aq
|
|
|
|
|
history=\*(aqfc \-l\*(aq
|
|
|
|
|
integer=\*(aqtypeset \-i\*(aq
|
|
|
|
|
local=\*(aqtypeset\*(aq
|
|
|
|
|
login=\*(aqexec login\*(aq
|
2009-11-23 13:49:55 +01:00
|
|
|
|
nameref=\*(aqtypeset \-n\*(aq
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
nohup=\*(aqnohup \*(aq
|
|
|
|
|
r=\*(aqfc \-e \-\*(aq
|
|
|
|
|
stop=\*(aqkill \-STOP\*(aq
|
|
|
|
|
suspend=\*(aqkill \-STOP $$\*(aq
|
|
|
|
|
type=\*(aqwhence \-v\*(aq
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
Tracked aliases allow the shell to remember where it found a particular
|
|
|
|
|
command.
|
|
|
|
|
The first time the shell does a path search for a command that is
|
|
|
|
|
marked as a tracked alias, it saves the full path of the command.
|
|
|
|
|
The next
|
|
|
|
|
time the command is executed, the shell checks the saved path to see that it
|
|
|
|
|
is still valid, and if so, avoids repeating the path search.
|
|
|
|
|
Tracked aliases can be listed and created using
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic alias \-t .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Note that changing the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameter clears the saved paths for all tracked aliases.
|
|
|
|
|
If the
|
|
|
|
|
.Ic trackall
|
|
|
|
|
option is set (i.e.\&
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-o Ic trackall
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-h ) ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
the shell tracks all commands.
|
|
|
|
|
This option is set automatically for non-interactive shells.
|
|
|
|
|
For interactive shells, only the following commands are
|
2008-09-17 21:27:16 +02:00
|
|
|
|
automatically tracked:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xr cat 1 ,
|
|
|
|
|
.Xr cc 1 ,
|
|
|
|
|
.Xr chmod 1 ,
|
|
|
|
|
.Xr cp 1 ,
|
|
|
|
|
.Xr date 1 ,
|
|
|
|
|
.Xr ed 1 ,
|
|
|
|
|
.Xr emacs 1 ,
|
|
|
|
|
.Xr grep 1 ,
|
|
|
|
|
.Xr ls 1 ,
|
|
|
|
|
.Xr make 1 ,
|
|
|
|
|
.Xr mv 1 ,
|
|
|
|
|
.Xr pr 1 ,
|
|
|
|
|
.Xr rm 1 ,
|
|
|
|
|
.Xr sed 1 ,
|
|
|
|
|
.Xr sh 1 ,
|
|
|
|
|
.Xr vi 1 ,
|
|
|
|
|
and
|
|
|
|
|
.Xr who 1 .
|
|
|
|
|
.Ss Substitution
|
|
|
|
|
The first step the shell takes in executing a simple-command is to perform
|
|
|
|
|
substitutions on the words of the command.
|
|
|
|
|
There are three kinds of
|
|
|
|
|
substitution: parameter, command, and arithmetic.
|
|
|
|
|
Parameter substitutions,
|
|
|
|
|
which are described in detail in the next section, take the form
|
|
|
|
|
.Pf $ Ns Ar name
|
|
|
|
|
or
|
|
|
|
|
.Pf ${ Ns Ar ... Ns } ;
|
|
|
|
|
command substitutions take the form
|
|
|
|
|
.Pf $( Ns Ar command Ns \&)
|
|
|
|
|
or (deprecated)
|
2012-07-30 23:37:17 +02:00
|
|
|
|
.Pf \` Ns Ar command Ns \`
|
2012-10-22 22:19:18 +02:00
|
|
|
|
or (executed in the current environment)
|
|
|
|
|
.Pf ${\ \& Ar command Ns \&;}
|
2012-07-30 23:37:17 +02:00
|
|
|
|
and strip trailing newlines;
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and arithmetic substitutions take the form
|
|
|
|
|
.Pf $(( Ns Ar expression Ns )) .
|
2012-10-22 22:19:18 +02:00
|
|
|
|
Parsing the current-environment command substitution requires a space,
|
|
|
|
|
tab or newline after the opening brace and that the closing brace be
|
|
|
|
|
recognised as a keyword (i.e. is preceded by a newline or semicolon).
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
If a substitution appears outside of double quotes, the results of the
|
|
|
|
|
substitution are generally subject to word or field splitting according to
|
|
|
|
|
the current value of the
|
|
|
|
|
.Ev IFS
|
|
|
|
|
parameter.
|
|
|
|
|
The
|
|
|
|
|
.Ev IFS
|
2009-11-22 15:23:21 +01:00
|
|
|
|
parameter specifies a list of octets which are used to break a string up
|
|
|
|
|
into several words; any octets from the set space, tab, and newline that
|
2005-05-23 05:06:10 +02:00
|
|
|
|
appear in the
|
|
|
|
|
.Ev IFS
|
2009-11-22 15:23:21 +01:00
|
|
|
|
octets are called
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Dq IFS whitespace .
|
|
|
|
|
Sequences of one or more
|
|
|
|
|
.Ev IFS
|
2009-11-22 15:23:21 +01:00
|
|
|
|
whitespace octets, in combination with zero or one
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pf non- Ev IFS
|
2009-11-22 15:23:21 +01:00
|
|
|
|
whitespace octets, delimit a field.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
As a special case, leading and trailing
|
|
|
|
|
.Ev IFS
|
|
|
|
|
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
|
|
|
|
|
Example: If
|
|
|
|
|
.Ev IFS
|
|
|
|
|
is set to
|
|
|
|
|
.Dq \*(Ltspace\*(Gt: ,
|
|
|
|
|
and VAR is set to
|
|
|
|
|
.Dq \*(Ltspace\*(GtA\*(Ltspace\*(Gt:\*(Ltspace\*(Gt\*(Ltspace\*(GtB::D ,
|
|
|
|
|
the substitution for $VAR results in four fields:
|
|
|
|
|
.Sq A ,
|
|
|
|
|
.Sq B ,
|
|
|
|
|
.Sq
|
|
|
|
|
(an empty field),
|
|
|
|
|
and
|
|
|
|
|
.Sq D .
|
|
|
|
|
Note that if the
|
|
|
|
|
.Ev IFS
|
|
|
|
|
parameter is set to the
|
|
|
|
|
.Dv NULL
|
|
|
|
|
string, no field splitting is done; if the parameter is unset, the default
|
|
|
|
|
value of space, tab, and newline is used.
|
|
|
|
|
.Pp
|
|
|
|
|
Also, note that the field splitting applies only to the immediate result of
|
|
|
|
|
the substitution.
|
|
|
|
|
Using the previous example, the substitution for $VAR:E
|
|
|
|
|
results in the fields:
|
|
|
|
|
.Sq A ,
|
|
|
|
|
.Sq B ,
|
|
|
|
|
.Sq ,
|
|
|
|
|
and
|
|
|
|
|
.Sq D:E ,
|
|
|
|
|
not
|
|
|
|
|
.Sq A ,
|
|
|
|
|
.Sq B ,
|
|
|
|
|
.Sq ,
|
2005-06-08 12:59:41 +02:00
|
|
|
|
.Sq D ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and
|
|
|
|
|
.Sq E .
|
|
|
|
|
This behavior is POSIX compliant, but incompatible with some other shell
|
|
|
|
|
implementations which do field splitting on the word which contained the
|
|
|
|
|
substitution or use
|
|
|
|
|
.Dv IFS
|
|
|
|
|
as a general whitespace delimiter.
|
|
|
|
|
.Pp
|
|
|
|
|
The results of substitution are, unless otherwise specified, also subject to
|
|
|
|
|
brace expansion and file name expansion (see the relevant sections below).
|
|
|
|
|
.Pp
|
|
|
|
|
A command substitution is replaced by the output generated by the specified
|
2006-01-30 13:37:24 +01:00
|
|
|
|
command which is run in a subshell.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
For
|
|
|
|
|
.Pf $( Ns Ar command Ns \&)
|
2012-10-22 22:19:18 +02:00
|
|
|
|
and
|
|
|
|
|
.Pf ${\ \& Ar command Ns \&;}
|
2005-05-23 05:06:10 +02:00
|
|
|
|
substitutions, normal quoting rules are used when
|
|
|
|
|
.Ar command
|
|
|
|
|
is parsed; however, for the deprecated
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Pf \` Ns Ar command Ns \`
|
2005-05-23 05:06:10 +02:00
|
|
|
|
form, a
|
|
|
|
|
.Ql \e
|
|
|
|
|
followed by any of
|
|
|
|
|
.Ql $ ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \` ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
|
|
|
|
.Ql \e
|
|
|
|
|
is stripped (a
|
|
|
|
|
.Ql \e
|
|
|
|
|
followed by any other character is unchanged).
|
|
|
|
|
As a special case in command substitutions, a command of the form
|
|
|
|
|
.Pf \*(Lt Ar file
|
|
|
|
|
is interpreted to mean substitute the contents of
|
|
|
|
|
.Ar file .
|
|
|
|
|
Note that
|
2007-03-10 22:14:07 +01:00
|
|
|
|
.Ic $(\*(Ltfoo)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
has the same effect as
|
2010-08-28 23:22:24 +02:00
|
|
|
|
.Ic $(cat foo) .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
2011-03-06 02:50:11 +01:00
|
|
|
|
Note that some shells do not use a recursive parser for command substitutions,
|
|
|
|
|
leading to failure for certain constructs; to be portable, use as workaround
|
|
|
|
|
.Ql x=$(cat) \*(Lt\*(Lt"EOF"
|
|
|
|
|
(or the newline-keeping
|
|
|
|
|
.Ql x=\*(Lt\*(Lt"EOF"
|
|
|
|
|
extension) instead to merely slurp the string.
|
|
|
|
|
.St -p1003.1
|
|
|
|
|
recommends to use case statements of the form
|
|
|
|
|
.Ql "x=$(case $foo in (bar) echo $bar ;; (*) echo $baz ;; esac)"
|
|
|
|
|
instead, which would work but not serve as example for this portability issue.
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
x=$(case $foo in bar) echo $bar ;; *) echo $baz ;; esac)
|
|
|
|
|
# above fails to parse on old shells; below is the workaround
|
|
|
|
|
x=$(eval $(cat)) \*(Lt\*(Lt"EOF"
|
|
|
|
|
case $foo in bar) echo $bar ;; *) echo $baz ;; esac
|
|
|
|
|
EOF
|
|
|
|
|
.Ed
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Arithmetic substitutions are replaced by the value of the specified expression.
|
|
|
|
|
For example, the command
|
|
|
|
|
.Ic print $((2+3*4))
|
|
|
|
|
displays 14.
|
|
|
|
|
See
|
|
|
|
|
.Sx Arithmetic expressions
|
|
|
|
|
for a description of an expression.
|
|
|
|
|
.Ss Parameters
|
|
|
|
|
Parameters are shell variables; they can be assigned values and their values
|
|
|
|
|
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
|
|
|
|
|
.Ql _
|
|
|
|
|
counts as a letter
|
|
|
|
|
.Pc .
|
|
|
|
|
The latter form can be treated as arrays by appending an array index of the
|
|
|
|
|
form
|
|
|
|
|
.Op Ar expr
|
|
|
|
|
where
|
|
|
|
|
.Ar expr
|
|
|
|
|
is an arithmetic expression.
|
2011-04-23 12:40:27 +02:00
|
|
|
|
Array indices in
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Nm
|
2011-04-23 12:40:27 +02:00
|
|
|
|
are limited to the range 0 through 4294967295, inclusive.
|
2008-10-24 23:27:20 +02:00
|
|
|
|
That is, they are a 32-bit unsigned integer.
|
2011-04-23 12:40:27 +02:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Parameter substitutions take the form
|
|
|
|
|
.Pf $ Ns Ar name ,
|
|
|
|
|
.Pf ${ Ns Ar name Ns } ,
|
|
|
|
|
or
|
|
|
|
|
.Sm off
|
|
|
|
|
.Pf ${ Ar name Oo Ar expr Oc }
|
|
|
|
|
.Sm on
|
|
|
|
|
where
|
|
|
|
|
.Ar name
|
|
|
|
|
is a parameter name.
|
2011-04-23 12:40:27 +02:00
|
|
|
|
Substitution of all array elements with
|
|
|
|
|
.Pf ${ Ns Ar name Ns \&[*]}
|
|
|
|
|
and
|
|
|
|
|
.Pf ${ Ns Ar name Ns \&[@]}
|
|
|
|
|
works equivalent to $* and $@ for positional parameters.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If substitution is performed on a parameter
|
|
|
|
|
(or an array parameter element)
|
|
|
|
|
that is not set, a null string is substituted unless the
|
|
|
|
|
.Ic nounset
|
|
|
|
|
option
|
|
|
|
|
.Po
|
|
|
|
|
.Ic set Fl o Ic nounset
|
|
|
|
|
or
|
|
|
|
|
.Ic set Fl u
|
|
|
|
|
.Pc
|
|
|
|
|
is set, in which case an error occurs.
|
|
|
|
|
.Pp
|
|
|
|
|
Parameters can be assigned values in a number of ways.
|
|
|
|
|
First, the shell implicitly sets some parameters like
|
|
|
|
|
.Ql # ,
|
|
|
|
|
.Ql PWD ,
|
|
|
|
|
and
|
|
|
|
|
.Ql $ ;
|
|
|
|
|
this is the only way the special single character parameters are set.
|
|
|
|
|
Second, parameters are imported from the shell's environment at startup.
|
|
|
|
|
Third, parameters can be assigned values on the command line: for example,
|
|
|
|
|
.Ic FOO=bar
|
|
|
|
|
sets the parameter
|
|
|
|
|
.Dq FOO
|
|
|
|
|
to
|
|
|
|
|
.Dq bar ;
|
|
|
|
|
multiple parameter assignments can be given on a single command line and they
|
|
|
|
|
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 the implications of this).
|
|
|
|
|
Note that both the parameter name and the
|
|
|
|
|
.Ql =
|
|
|
|
|
must be unquoted for the shell to recognise a parameter assignment.
|
2011-05-05 01:16:05 +02:00
|
|
|
|
The construct
|
|
|
|
|
.Ic FOO+=baz
|
|
|
|
|
is also recognised; the old and new values are immediately concatenated.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The fourth way of setting a parameter is with the
|
|
|
|
|
.Ic export ,
|
2011-07-05 22:19:18 +02:00
|
|
|
|
.Ic global ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic readonly ,
|
|
|
|
|
and
|
|
|
|
|
.Ic typeset
|
|
|
|
|
commands; see their descriptions in the
|
|
|
|
|
.Sx Command execution
|
|
|
|
|
section.
|
|
|
|
|
Fifth,
|
|
|
|
|
.Ic for
|
|
|
|
|
and
|
|
|
|
|
.Ic select
|
|
|
|
|
loops set parameters as well as the
|
|
|
|
|
.Ic getopts ,
|
|
|
|
|
.Ic read ,
|
|
|
|
|
and
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-A
|
2005-05-23 05:06:10 +02:00
|
|
|
|
commands.
|
|
|
|
|
Lastly, parameters can be assigned values using assignment operators
|
|
|
|
|
inside arithmetic expressions (see
|
|
|
|
|
.Sx Arithmetic expressions
|
|
|
|
|
below) or using the
|
|
|
|
|
.Sm off
|
|
|
|
|
.Pf ${ Ar name No = Ar value No }
|
|
|
|
|
.Sm on
|
|
|
|
|
form of the parameter substitution (see below).
|
|
|
|
|
.Pp
|
|
|
|
|
Parameters with the export attribute (set using the
|
|
|
|
|
.Ic export
|
|
|
|
|
or
|
|
|
|
|
.Ic typeset Fl x
|
|
|
|
|
commands, or by parameter assignments followed by simple commands) are put in
|
|
|
|
|
the environment (see
|
|
|
|
|
.Xr environ 7 )
|
|
|
|
|
of commands run by the shell as
|
|
|
|
|
.Ar name Ns = Ns Ar value
|
|
|
|
|
pairs.
|
|
|
|
|
The order in which parameters appear in the environment of a command is
|
|
|
|
|
unspecified.
|
|
|
|
|
When the shell starts up, it extracts parameters and their values
|
|
|
|
|
from its environment and automatically sets the export attribute for those
|
|
|
|
|
parameters.
|
|
|
|
|
.Pp
|
|
|
|
|
Modifiers can be applied to the
|
|
|
|
|
.Pf ${ Ns Ar name Ns }
|
|
|
|
|
form of parameter substitution:
|
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
|
.Sm off
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It ${ Ar name No :\- Ar word No }
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sm on
|
|
|
|
|
If
|
|
|
|
|
.Ar name
|
|
|
|
|
is set and not
|
|
|
|
|
.Dv NULL ,
|
|
|
|
|
it is substituted; otherwise,
|
|
|
|
|
.Ar word
|
|
|
|
|
is substituted.
|
|
|
|
|
.Sm off
|
|
|
|
|
.It ${ Ar name No :+ Ar word No }
|
|
|
|
|
.Sm on
|
|
|
|
|
If
|
|
|
|
|
.Ar name
|
|
|
|
|
is set and not
|
|
|
|
|
.Dv NULL ,
|
|
|
|
|
.Ar word
|
|
|
|
|
is substituted; otherwise, nothing is substituted.
|
|
|
|
|
.Sm off
|
|
|
|
|
.It ${ Ar name No := Ar word No }
|
|
|
|
|
.Sm on
|
|
|
|
|
If
|
|
|
|
|
.Ar name
|
|
|
|
|
is set and not
|
|
|
|
|
.Dv NULL ,
|
|
|
|
|
it is substituted; otherwise, it is assigned
|
|
|
|
|
.Ar word
|
|
|
|
|
and the resulting value of
|
|
|
|
|
.Ar name
|
|
|
|
|
is substituted.
|
|
|
|
|
.Sm off
|
|
|
|
|
.It ${ Ar name No :? Ar word No }
|
|
|
|
|
.Sm on
|
|
|
|
|
If
|
|
|
|
|
.Ar name
|
|
|
|
|
is set and not
|
|
|
|
|
.Dv NULL ,
|
|
|
|
|
it is substituted; otherwise,
|
|
|
|
|
.Ar word
|
|
|
|
|
is printed on standard error (preceded by
|
|
|
|
|
.Ar name : )
|
|
|
|
|
and an error occurs (normally causing termination of a shell script, function,
|
|
|
|
|
or script sourced using the
|
|
|
|
|
.Sq \&.
|
|
|
|
|
built-in).
|
|
|
|
|
If
|
|
|
|
|
.Ar word
|
|
|
|
|
is omitted, the string
|
|
|
|
|
.Dq parameter null or not set
|
|
|
|
|
is used instead.
|
2005-05-26 01:31:08 +02:00
|
|
|
|
Currently a bug, if
|
|
|
|
|
.Ar word
|
|
|
|
|
is a variable which expands to the null string, the
|
|
|
|
|
error message is also printed.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2010-02-25 21:18:19 +01:00
|
|
|
|
Note that, for all of the above,
|
|
|
|
|
.Ar word
|
|
|
|
|
is actually considered quoted, and special parsing rules apply.
|
2010-04-08 15:21:08 +02:00
|
|
|
|
The parsing rules also differ on whether the expression is double-quoted:
|
|
|
|
|
.Ar word
|
|
|
|
|
then uses double-quoting rules, except for the double quote itself
|
|
|
|
|
.Pq Sq \&"
|
|
|
|
|
and the closing brace, which, if backslash escaped, gets quote removal applied.
|
2010-02-25 21:18:19 +01:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
In the above modifiers, the
|
|
|
|
|
.Ql \&:
|
|
|
|
|
can be omitted, in which case the conditions only depend on
|
|
|
|
|
.Ar name
|
|
|
|
|
being set (as opposed to set and not
|
|
|
|
|
.Dv NULL ) .
|
|
|
|
|
If
|
|
|
|
|
.Ar word
|
|
|
|
|
is needed, parameter, command, arithmetic, and tilde substitution are performed
|
|
|
|
|
on it; if
|
|
|
|
|
.Ar word
|
|
|
|
|
is not needed, it is not evaluated.
|
|
|
|
|
.Pp
|
2011-05-05 02:05:01 +02:00
|
|
|
|
The following forms of parameter substitution can also be used (if
|
|
|
|
|
.Ar name
|
|
|
|
|
is an array, its element #0 will be substituted in a scalar context):
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.Bl -tag -width Ds -compact
|
|
|
|
|
.It Pf ${# Ns Ar name Ns \&}
|
|
|
|
|
The number of positional parameters if
|
|
|
|
|
.Ar name
|
|
|
|
|
is
|
|
|
|
|
.Ql * ,
|
|
|
|
|
.Ql @ ,
|
2009-05-16 17:53:02 +02:00
|
|
|
|
or not specified; otherwise the length
|
|
|
|
|
.Pq in characters
|
|
|
|
|
of the string value of parameter
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ar name .
|
|
|
|
|
.Pp
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.It Pf ${# Ns Ar name Ns \&[*]}
|
|
|
|
|
.It Pf ${# Ns Ar name Ns \&[@]}
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The number of elements in the array
|
|
|
|
|
.Ar name .
|
|
|
|
|
.Pp
|
2009-11-22 00:23:20 +01:00
|
|
|
|
.It Pf ${% Ns Ar name Ns \&}
|
|
|
|
|
The width
|
|
|
|
|
.Pq in screen columns
|
|
|
|
|
of the string value of parameter
|
2010-01-01 18:44:10 +01:00
|
|
|
|
.Ar name ,
|
2010-02-28 15:06:56 +01:00
|
|
|
|
or \-1 if
|
2010-01-01 18:44:10 +01:00
|
|
|
|
.Pf ${ Ns Ar name Ns }
|
|
|
|
|
contains a control character.
|
2009-11-22 00:23:20 +01:00
|
|
|
|
.Pp
|
2009-09-06 19:42:15 +02:00
|
|
|
|
.It Pf ${! Ns Ar name Ns }
|
|
|
|
|
The name of the variable referred to by
|
|
|
|
|
.Ar name .
|
|
|
|
|
This will be
|
|
|
|
|
.Ar name
|
|
|
|
|
except when
|
|
|
|
|
.Ar name
|
|
|
|
|
is a name reference (bound variable), created by the
|
|
|
|
|
.Ic nameref
|
|
|
|
|
command (which is an alias for
|
|
|
|
|
.Ic typeset Fl n ) .
|
|
|
|
|
.Pp
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.It Pf ${! Ns Ar name Ns \&[*]}
|
|
|
|
|
.It Pf ${! Ns Ar name Ns \&[@]}
|
2009-08-29 00:46:21 +02:00
|
|
|
|
The names of indices (keys) in the array
|
|
|
|
|
.Ar name .
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sm off
|
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name
|
|
|
|
|
.Pf # Ar pattern No }
|
|
|
|
|
.Xc
|
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name
|
|
|
|
|
.Pf ## Ar pattern No }
|
|
|
|
|
.Xc
|
|
|
|
|
.Sm on
|
|
|
|
|
If
|
|
|
|
|
.Ar pattern
|
|
|
|
|
matches the beginning of the value of parameter
|
|
|
|
|
.Ar name ,
|
|
|
|
|
the matched text is deleted from the result of substitution.
|
|
|
|
|
A single
|
|
|
|
|
.Ql #
|
|
|
|
|
results in the shortest match, and two
|
|
|
|
|
of them result in the longest match.
|
2011-05-05 02:05:01 +02:00
|
|
|
|
Cannot be applied to a vector
|
|
|
|
|
.Pq ${*} or ${@} or ${array[*]} or ${array[@]} .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.Sm off
|
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name
|
|
|
|
|
.Pf % Ar pattern No }
|
|
|
|
|
.Xc
|
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name
|
|
|
|
|
.Pf %% Ar pattern No }
|
|
|
|
|
.Xc
|
|
|
|
|
.Sm on
|
|
|
|
|
Like ${..#..} substitution, but it deletes from the end of the value.
|
2011-05-05 02:05:01 +02:00
|
|
|
|
Cannot be applied to a vector.
|
2008-02-27 12:24:12 +01:00
|
|
|
|
.Pp
|
|
|
|
|
.Sm off
|
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name
|
|
|
|
|
.Pf / Ar pattern / Ar string No }
|
|
|
|
|
.Xc
|
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name
|
|
|
|
|
.Pf // Ar pattern / Ar string No }
|
|
|
|
|
.Xc
|
|
|
|
|
.Sm on
|
|
|
|
|
Like ${..#..} substitution, but it replaces the longest match of
|
|
|
|
|
.Ar pattern ,
|
|
|
|
|
anchored anywhere in the value, with
|
|
|
|
|
.Ar string .
|
|
|
|
|
If
|
|
|
|
|
.Ar pattern
|
|
|
|
|
begins with
|
|
|
|
|
.Ql # ,
|
|
|
|
|
it is anchored at the beginning of the value; if it begins with
|
|
|
|
|
.Ql % ,
|
|
|
|
|
it is anchored at the end.
|
|
|
|
|
A single
|
|
|
|
|
.Ql /
|
|
|
|
|
replaces the first occurence of the search
|
|
|
|
|
.Ar pattern ,
|
|
|
|
|
and two of them replace all occurences.
|
|
|
|
|
If
|
|
|
|
|
.Pf / Ar string
|
|
|
|
|
is omitted, the
|
|
|
|
|
.Ar pattern
|
|
|
|
|
is replaced by the empty string, i.e. deleted.
|
2011-05-05 02:05:01 +02:00
|
|
|
|
Cannot be applied to a vector.
|
|
|
|
|
Inefficiently implemented.
|
2008-02-27 12:24:12 +01:00
|
|
|
|
.Pp
|
|
|
|
|
.Sm off
|
2007-06-28 01:12:59 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name : Ns Ar pos
|
|
|
|
|
.Pf : Ns Ar len Ns }
|
|
|
|
|
.Xc
|
2008-12-17 20:25:54 +01:00
|
|
|
|
.Sm on
|
2007-06-28 01:12:59 +02:00
|
|
|
|
The first
|
|
|
|
|
.Ar len
|
2009-05-16 17:53:02 +02:00
|
|
|
|
characters of
|
2007-06-28 01:12:59 +02:00
|
|
|
|
.Ar name ,
|
|
|
|
|
starting at position
|
|
|
|
|
.Ar pos ,
|
|
|
|
|
are substituted.
|
|
|
|
|
Both
|
|
|
|
|
.Ar pos
|
|
|
|
|
and
|
|
|
|
|
.Pf : Ns Ar len
|
|
|
|
|
are optional.
|
|
|
|
|
If
|
|
|
|
|
.Ar pos
|
2007-07-06 04:22:57 +02:00
|
|
|
|
is negative, counting starts at the end of the string; if it
|
2007-06-28 01:12:59 +02:00
|
|
|
|
is omitted, it defaults to 0.
|
|
|
|
|
If
|
|
|
|
|
.Ar len
|
|
|
|
|
is omitted or greater than the length of the remaining string,
|
|
|
|
|
all of it is substituted.
|
2007-07-06 04:22:57 +02:00
|
|
|
|
Both
|
|
|
|
|
.Ar pos
|
|
|
|
|
and
|
|
|
|
|
.Ar len
|
|
|
|
|
are evaluated as arithmetic expressions.
|
2007-07-26 15:32:16 +02:00
|
|
|
|
Currently,
|
|
|
|
|
.Ar pos
|
|
|
|
|
must start with a space, opening parenthesis or digit to be recognised.
|
2011-05-05 02:05:01 +02:00
|
|
|
|
Cannot be applied to a vector.
|
|
|
|
|
.Pp
|
2012-03-24 00:25:30 +01:00
|
|
|
|
.It Xo
|
|
|
|
|
.Pf ${ Ar name
|
|
|
|
|
.Pf @# Ns Oo Ar seed Oc Ns }
|
|
|
|
|
.Xc
|
2011-01-21 23:25:34 +01:00
|
|
|
|
The internal hash of the expansion of
|
2012-03-24 00:25:30 +01:00
|
|
|
|
.Ar name ,
|
|
|
|
|
with an optional (defaulting to zero)
|
|
|
|
|
.Ar seed .
|
2012-04-22 23:50:35 +02:00
|
|
|
|
At the moment, this is NZAAT (a 32-bit hash based on
|
2011-07-07 00:22:02 +02:00
|
|
|
|
Bob Jenkins' one-at-a-time hash), but this is not set.
|
2011-01-21 23:25:34 +01:00
|
|
|
|
This is the hash the shell uses internally for its associative arrays.
|
2012-07-21 01:22:13 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.It Pf ${ Ns Ar name Ns @Q}
|
|
|
|
|
A quoted expression safe for re-entry, whose value is the value of the
|
|
|
|
|
.Ar name
|
|
|
|
|
parameter, is substituted.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2009-07-06 11:37:03 +02:00
|
|
|
|
Note that
|
|
|
|
|
.Ar pattern
|
2011-05-05 02:05:01 +02:00
|
|
|
|
may need extended globbing pattern
|
2009-07-06 11:37:03 +02:00
|
|
|
|
.Pq @(...) ,
|
2011-05-05 02:05:01 +02:00
|
|
|
|
single
|
2009-09-19 23:54:46 +02:00
|
|
|
|
.Pq \&\*(aq...\&\*(aq
|
2011-05-05 02:05:01 +02:00
|
|
|
|
or double
|
|
|
|
|
.Pq \&"...\&"
|
|
|
|
|
quote escaping unless
|
|
|
|
|
.Fl o Ic sh
|
|
|
|
|
is set.
|
2009-07-06 11:37:03 +02:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The following special parameters are implicitly set by the shell and cannot be
|
|
|
|
|
set directly using assignments:
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.Bl -tag -width "1 .. 9"
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev \&!
|
|
|
|
|
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 ($1, $2, etc.).
|
|
|
|
|
.It Ev \&$
|
|
|
|
|
The PID of the shell, or the PID of the original shell if it is a subshell.
|
|
|
|
|
Do
|
|
|
|
|
.Em NOT
|
|
|
|
|
use this mechanism for generating temporary file names; see
|
|
|
|
|
.Xr mktemp 1
|
|
|
|
|
instead.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Ev \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The concatenation of the current single letter options (see the
|
|
|
|
|
.Ic set
|
|
|
|
|
command below for a list of options).
|
|
|
|
|
.It Ev \&?
|
|
|
|
|
The exit status of the last non-asynchronous command executed.
|
|
|
|
|
If the last command was killed by a signal,
|
|
|
|
|
.Ic $?\&
|
|
|
|
|
is set to 128 plus the signal number.
|
|
|
|
|
.It Ev 0
|
|
|
|
|
The name of the shell, determined as follows:
|
|
|
|
|
the first argument to
|
|
|
|
|
.Nm
|
|
|
|
|
if it was invoked with the
|
|
|
|
|
.Fl c
|
|
|
|
|
option and arguments were given; otherwise the
|
|
|
|
|
.Ar file
|
|
|
|
|
argument, if it was supplied;
|
|
|
|
|
or else the basename the shell was invoked with (i.e.\&
|
|
|
|
|
.Li argv[0] ) .
|
|
|
|
|
.Ev $0
|
|
|
|
|
is also set to the name of the current script or
|
|
|
|
|
the name of the current function, if it was defined with the
|
|
|
|
|
.Ic function
|
|
|
|
|
keyword (i.e. a Korn shell style function).
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Ev 1 No .. Ev 9
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The first nine positional parameters that were supplied to the shell, function,
|
|
|
|
|
or script sourced using the
|
|
|
|
|
.Sq \&.
|
|
|
|
|
built-in.
|
|
|
|
|
Further positional parameters may be accessed using
|
|
|
|
|
.Pf ${ Ar number Ns } .
|
|
|
|
|
.It Ev *
|
2011-07-16 19:08:04 +02:00
|
|
|
|
All positional parameters (except 0), i.e. $1, $2, $3, ...
|
|
|
|
|
.br
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If used
|
|
|
|
|
outside of double quotes, parameters are separate words (which are subjected
|
|
|
|
|
to word splitting); if used within double quotes, parameters are separated
|
|
|
|
|
by the first character of the
|
|
|
|
|
.Ev IFS
|
|
|
|
|
parameter (or the empty string if
|
|
|
|
|
.Ev IFS
|
|
|
|
|
is
|
|
|
|
|
.Dv NULL ) .
|
|
|
|
|
.It Ev @
|
|
|
|
|
Same as
|
|
|
|
|
.Ic $* ,
|
|
|
|
|
unless it is used inside double quotes, in which case a separate word is
|
|
|
|
|
generated for each positional parameter.
|
|
|
|
|
If there are no positional parameters, no word is generated.
|
|
|
|
|
.Ic $@
|
|
|
|
|
can be used to access arguments, verbatim, without losing
|
|
|
|
|
.Dv NULL
|
|
|
|
|
arguments or splitting arguments with spaces.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
The following parameters are set and/or used by the shell:
|
2011-05-05 02:05:01 +02:00
|
|
|
|
.Bl -tag -width "KSH_VERSION"
|
|
|
|
|
.It Ev _
|
|
|
|
|
.Pq underscore
|
2005-05-23 05:06:10 +02:00
|
|
|
|
When an external command is executed by the shell, this parameter is set in the
|
|
|
|
|
environment of the new process to the path of the executed command.
|
|
|
|
|
In interactive use, this parameter is also set in the parent shell to the last
|
|
|
|
|
word of the previous command.
|
2012-11-20 18:42:32 +01:00
|
|
|
|
.It Ev BASHPID
|
|
|
|
|
The PID of the shell or subshell.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev CDPATH
|
|
|
|
|
Search path for the
|
|
|
|
|
.Ic cd
|
|
|
|
|
built-in command.
|
|
|
|
|
It works the same way as
|
|
|
|
|
.Ev PATH
|
|
|
|
|
for those directories not beginning with
|
|
|
|
|
.Ql /
|
|
|
|
|
in
|
|
|
|
|
.Ic cd
|
|
|
|
|
commands.
|
|
|
|
|
Note that if
|
|
|
|
|
.Ev CDPATH
|
|
|
|
|
is set and does not contain
|
|
|
|
|
.Sq \&.
|
|
|
|
|
or contains an empty path, the current directory is not searched.
|
|
|
|
|
Also, the
|
|
|
|
|
.Ic cd
|
|
|
|
|
built-in command will display the resulting directory when a match is found
|
|
|
|
|
in any search path other than the empty path.
|
|
|
|
|
.It Ev COLUMNS
|
|
|
|
|
Set to the number of columns on the terminal or window.
|
2008-12-29 22:34:22 +01:00
|
|
|
|
Always set, defaults to 80, unless the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
value as reported by
|
|
|
|
|
.Xr stty 1
|
2012-11-30 20:25:08 +01:00
|
|
|
|
is non-zero and sane enough (minimum is 12x3); similar for
|
2008-12-29 22:34:22 +01:00
|
|
|
|
.Ev LINES .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
This parameter is used by the interactive line editing modes, and by the
|
|
|
|
|
.Ic select ,
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-o ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic kill \-l
|
2005-05-23 05:06:10 +02:00
|
|
|
|
commands to format information columns.
|
2012-11-30 20:25:08 +01:00
|
|
|
|
Importing from the environment or unsetting this parameter removes the
|
|
|
|
|
binding to the actual terminal size in favour of the provided value.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev ENV
|
|
|
|
|
If this parameter is found to be set after any profile files are executed, the
|
|
|
|
|
expanded value is used as a shell startup file.
|
|
|
|
|
It typically contains function and alias definitions.
|
|
|
|
|
.It Ev ERRNO
|
|
|
|
|
Integer value of the shell's
|
|
|
|
|
.Va errno
|
|
|
|
|
variable.
|
|
|
|
|
It indicates the reason the last system call failed.
|
|
|
|
|
Not yet implemented.
|
|
|
|
|
.It Ev EXECSHELL
|
|
|
|
|
If set, this parameter is assumed to contain the shell that is to be used to
|
|
|
|
|
execute commands that
|
|
|
|
|
.Xr execve 2
|
|
|
|
|
fails to execute and which do not start with a
|
|
|
|
|
.Dq #! Ns Ar shell
|
|
|
|
|
sequence.
|
|
|
|
|
.It Ev FCEDIT
|
|
|
|
|
The editor used by the
|
|
|
|
|
.Ic fc
|
|
|
|
|
command (see below).
|
|
|
|
|
.It Ev FPATH
|
|
|
|
|
Like
|
|
|
|
|
.Ev PATH ,
|
|
|
|
|
but used when an undefined function is executed to locate the file defining the
|
|
|
|
|
function.
|
|
|
|
|
It is also searched when a command can't be found using
|
|
|
|
|
.Ev PATH .
|
|
|
|
|
See
|
|
|
|
|
.Sx Functions
|
|
|
|
|
below for more information.
|
|
|
|
|
.It Ev HISTFILE
|
|
|
|
|
The name of the file used to store command history.
|
|
|
|
|
When assigned to, history is loaded from the specified file.
|
2010-01-25 17:12:57 +01:00
|
|
|
|
Also, several invocations of the shell will share history if their
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ev HISTFILE
|
|
|
|
|
parameters all point to the same file.
|
|
|
|
|
.Pp
|
|
|
|
|
.Sy Note :
|
|
|
|
|
If
|
|
|
|
|
.Ev HISTFILE
|
|
|
|
|
isn't set, no history file is used.
|
2007-03-10 22:14:07 +01:00
|
|
|
|
This is different from
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev HISTSIZE
|
|
|
|
|
The number of commands normally stored for history.
|
2012-10-14 16:04:05 +02:00
|
|
|
|
The default is 2047.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev HOME
|
|
|
|
|
The default directory for the
|
|
|
|
|
.Ic cd
|
|
|
|
|
command and the value substituted for an unqualified
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ic \*(TI
|
2005-05-23 05:06:10 +02:00
|
|
|
|
(see
|
|
|
|
|
.Sx Tilde expansion
|
|
|
|
|
below).
|
|
|
|
|
.It Ev IFS
|
|
|
|
|
Internal field separator, used during substitution and by the
|
|
|
|
|
.Ic read
|
|
|
|
|
command, to split values into distinct arguments; normally set to space, tab,
|
|
|
|
|
and newline.
|
|
|
|
|
See
|
|
|
|
|
.Sx Substitution
|
|
|
|
|
above for details.
|
|
|
|
|
.Pp
|
|
|
|
|
.Sy Note :
|
|
|
|
|
This parameter is not imported from the environment when the shell is
|
|
|
|
|
started.
|
2011-01-21 22:04:48 +01:00
|
|
|
|
.It Ev KSHEGID
|
|
|
|
|
The effective group id of the shell.
|
|
|
|
|
.It Ev KSHGID
|
|
|
|
|
The real group id of the shell.
|
|
|
|
|
.It Ev KSHUID
|
|
|
|
|
The real user id of the shell.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev KSH_VERSION
|
|
|
|
|
The name and version of the shell (read-only).
|
2006-08-01 14:44:17 +02:00
|
|
|
|
See also the version commands in
|
|
|
|
|
.Sx Emacs editing mode
|
|
|
|
|
and
|
|
|
|
|
.Sx Vi editing mode
|
|
|
|
|
sections, below.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev LINENO
|
|
|
|
|
The line number of the function or shell script that is currently being
|
|
|
|
|
executed.
|
|
|
|
|
.It Ev LINES
|
|
|
|
|
Set to the number of lines on the terminal or window.
|
2008-12-29 22:34:22 +01:00
|
|
|
|
Always set, defaults to 24.
|
2012-11-30 20:25:08 +01:00
|
|
|
|
See
|
|
|
|
|
.Ev COLUMNS .
|
2012-11-26 23:49:51 +01:00
|
|
|
|
.It Ev EPOCHREALTIME
|
2012-11-20 19:07:45 +01:00
|
|
|
|
Time since the epoch, as returned by
|
|
|
|
|
.Xr gettimeofday 2 ,
|
|
|
|
|
formatted as decimal
|
|
|
|
|
.Va tv_sec
|
|
|
|
|
followed by a dot
|
|
|
|
|
.Pq Sq .\&
|
|
|
|
|
and
|
|
|
|
|
.Va tv_usec
|
|
|
|
|
padded to exactly six decimal digits.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev OLDPWD
|
|
|
|
|
The previous working directory.
|
|
|
|
|
Unset if
|
|
|
|
|
.Ic cd
|
|
|
|
|
has not successfully changed directories since the shell started, or if the
|
|
|
|
|
shell doesn't know where it is.
|
|
|
|
|
.It Ev OPTARG
|
|
|
|
|
When using
|
|
|
|
|
.Ic getopts ,
|
|
|
|
|
it contains the argument for a parsed option, if it requires one.
|
|
|
|
|
.It Ev OPTIND
|
2008-10-20 21:52:07 +02:00
|
|
|
|
The index of the next argument to be processed when using
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic getopts .
|
|
|
|
|
Assigning 1 to this parameter causes
|
|
|
|
|
.Ic getopts
|
|
|
|
|
to process arguments from the beginning the next time it is invoked.
|
|
|
|
|
.It Ev PATH
|
|
|
|
|
A colon separated list of directories that are searched when looking for
|
|
|
|
|
commands and files sourced using the
|
|
|
|
|
.Sq \&.
|
|
|
|
|
command (see below).
|
|
|
|
|
An empty string resulting from a leading or trailing
|
|
|
|
|
colon, or two adjacent colons, is treated as a
|
|
|
|
|
.Sq \&.
|
|
|
|
|
(the current directory).
|
2008-05-15 17:24:11 +02:00
|
|
|
|
.It Ev PGRP
|
|
|
|
|
The process ID of the shell's process group leader.
|
2011-02-18 23:26:13 +01:00
|
|
|
|
.It Ev PIPESTATUS
|
|
|
|
|
An array containing the errorlevel (exit status) codes,
|
|
|
|
|
one by one, of the last pipeline run in the foreground.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev PPID
|
2008-05-15 17:24:11 +02:00
|
|
|
|
The process ID of the shell's parent.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev PS1
|
|
|
|
|
The primary prompt for interactive shells.
|
|
|
|
|
Parameter, command, and arithmetic
|
|
|
|
|
substitutions are performed, and
|
|
|
|
|
.Ql \&!
|
|
|
|
|
is replaced with the current command number (see the
|
|
|
|
|
.Ic fc
|
|
|
|
|
command below).
|
|
|
|
|
A literal
|
|
|
|
|
.Ql \&!
|
|
|
|
|
can be put in the prompt by placing
|
|
|
|
|
.Ql !!
|
|
|
|
|
in
|
|
|
|
|
.Ev PS1 .
|
2006-08-02 15:34:03 +02:00
|
|
|
|
.Pp
|
2006-08-02 13:50:30 +02:00
|
|
|
|
The default prompt is
|
|
|
|
|
.Sq $\ \&
|
|
|
|
|
for non-root users,
|
|
|
|
|
.Sq #\ \&
|
|
|
|
|
for root.
|
|
|
|
|
If
|
|
|
|
|
.Nm
|
|
|
|
|
is invoked by root and
|
|
|
|
|
.Ev PS1
|
|
|
|
|
does not contain a
|
|
|
|
|
.Sq #
|
|
|
|
|
character, the default value will be used even if
|
|
|
|
|
.Ev PS1
|
|
|
|
|
already exists in the environment.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
2006-08-02 13:50:30 +02:00
|
|
|
|
The
|
|
|
|
|
.Nm
|
|
|
|
|
distribution comes with a sample
|
|
|
|
|
.Pa dot.mkshrc
|
|
|
|
|
containing a sophisticated example, but you might like the following one
|
2011-07-16 19:08:04 +02:00
|
|
|
|
(note that ${HOSTNAME:=$(hostname)} and the
|
2006-05-08 14:12:36 +02:00
|
|
|
|
root-vs-user distinguishing clause are (in this example) executed at
|
|
|
|
|
.Ev PS1
|
|
|
|
|
assignment time, while the $USER and $PWD are escaped
|
|
|
|
|
and thus will be evaluated each time a prompt is displayed):
|
2006-08-02 13:50:30 +02:00
|
|
|
|
.Bd -literal
|
2011-07-16 19:08:04 +02:00
|
|
|
|
PS1=\*(aq${USER:=$(id \-un)}\*(aq"@${HOSTNAME:=$(hostname)}:\e$PWD $(
|
2008-08-14 19:39:30 +02:00
|
|
|
|
if (( USER_ID )); then print \e$; else print \e#; fi) "
|
2006-05-08 14:12:36 +02:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Note that since the command-line editors try to figure out how long the prompt
|
|
|
|
|
is (so they know how far it is to the edge of the screen), escape codes in
|
|
|
|
|
the prompt tend to mess things up.
|
|
|
|
|
You can tell the shell not to count certain
|
2006-08-02 12:41:03 +02:00
|
|
|
|
sequences (such as escape codes) by prefixing your prompt with a
|
2009-09-19 23:54:46 +02:00
|
|
|
|
character (such as Ctrl-A) followed by a carriage return and then delimiting
|
2006-08-02 12:41:03 +02:00
|
|
|
|
the escape codes with this character.
|
|
|
|
|
Any occurences of that character in the prompt are not printed.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
By the way, don't blame me for
|
2006-08-02 12:41:03 +02:00
|
|
|
|
this hack; it's derived from the original
|
|
|
|
|
.Xr ksh88 1 ,
|
|
|
|
|
which did print the delimiter character so you were out of luck
|
|
|
|
|
if you did not have any non-printing characters.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Since Backslashes and other special characters may be
|
|
|
|
|
interpreted by the shell, to set
|
|
|
|
|
.Ev PS1
|
|
|
|
|
either escape the backslash itself,
|
|
|
|
|
or use double quotes.
|
|
|
|
|
The latter is more practical.
|
|
|
|
|
This is a more complex example,
|
|
|
|
|
avoiding to directly enter special characters (for example with
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ic \*(haV
|
2005-05-23 05:06:10 +02:00
|
|
|
|
in the emacs editing mode),
|
|
|
|
|
which embeds the current working directory,
|
2009-08-14 11:00:30 +02:00
|
|
|
|
in reverse video
|
|
|
|
|
.Pq colour would work, too ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
in the prompt string:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
x=$(print \e\e001)
|
2006-08-02 13:50:30 +02:00
|
|
|
|
PS1="$x$(print \e\er)$x$(tput smso)$x\e$PWD$x$(tput rmso)$x\*(Gt "
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ed
|
2010-05-13 20:47:50 +02:00
|
|
|
|
.Pp
|
2012-07-30 23:37:17 +02:00
|
|
|
|
Due to a strong suggestion from David G. Korn,
|
2010-05-13 20:47:50 +02:00
|
|
|
|
.Nm
|
|
|
|
|
now also supports the following form:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
PS1=$'\e1\er\e1\ee[7m\e1$PWD\e1\ee[0m\e1\*(Gt '
|
|
|
|
|
.Ed
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev PS2
|
|
|
|
|
Secondary prompt string, by default
|
|
|
|
|
.Sq \*(Gt\ \& ,
|
|
|
|
|
used when more input is needed to complete a command.
|
|
|
|
|
.It Ev PS3
|
|
|
|
|
Prompt used by the
|
|
|
|
|
.Ic select
|
|
|
|
|
statement when reading a menu selection.
|
|
|
|
|
The default is
|
|
|
|
|
.Sq #?\ \& .
|
|
|
|
|
.It Ev PS4
|
|
|
|
|
Used to prefix commands that are printed during execution tracing (see the
|
|
|
|
|
.Ic set Fl x
|
|
|
|
|
command below).
|
|
|
|
|
Parameter, command, and arithmetic substitutions are performed
|
|
|
|
|
before it is printed.
|
|
|
|
|
The default is
|
|
|
|
|
.Sq +\ \& .
|
|
|
|
|
.It Ev PWD
|
|
|
|
|
The current working directory.
|
|
|
|
|
May be unset or
|
|
|
|
|
.Dv NULL
|
|
|
|
|
if the shell doesn't know where it is.
|
|
|
|
|
.It Ev RANDOM
|
2010-07-11 13:17:33 +02:00
|
|
|
|
Each time
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ev RANDOM
|
2010-07-11 13:17:33 +02:00
|
|
|
|
is referenced, it is assigned a number between 0 and 32767 from
|
|
|
|
|
a Linear Congruential PRNG first.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ev REPLY
|
|
|
|
|
Default parameter for the
|
|
|
|
|
.Ic read
|
|
|
|
|
command if no names are given.
|
|
|
|
|
Also used in
|
|
|
|
|
.Ic select
|
|
|
|
|
loops to store the value that is read from standard input.
|
|
|
|
|
.It Ev SECONDS
|
|
|
|
|
The number of seconds since the shell started or, if the parameter has been
|
|
|
|
|
assigned an integer value, the number of seconds since the assignment plus the
|
|
|
|
|
value that was assigned.
|
|
|
|
|
.It Ev TMOUT
|
|
|
|
|
If set to a positive integer in an interactive shell, it specifies the maximum
|
|
|
|
|
number of seconds the shell will wait for input after printing the primary
|
|
|
|
|
prompt
|
|
|
|
|
.Pq Ev PS1 .
|
|
|
|
|
If the time is exceeded, the shell exits.
|
|
|
|
|
.It Ev TMPDIR
|
|
|
|
|
The directory temporary shell files are created in.
|
|
|
|
|
If this parameter is not
|
|
|
|
|
set, or does not contain the absolute path of a writable directory, temporary
|
|
|
|
|
files are created in
|
|
|
|
|
.Pa /tmp .
|
2008-05-15 17:24:11 +02:00
|
|
|
|
.It Ev USER_ID
|
|
|
|
|
The effective user id of the shell.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Ss Tilde expansion
|
2006-01-30 13:37:24 +01:00
|
|
|
|
Tilde expansion which is done in parallel with parameter substitution, is done
|
2005-05-23 05:06:10 +02:00
|
|
|
|
on words starting with an unquoted
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \*(TI .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The characters following the tilde, up to the first
|
|
|
|
|
.Ql / ,
|
|
|
|
|
if any, are assumed to be a login name.
|
|
|
|
|
If the login name is empty,
|
|
|
|
|
.Ql + ,
|
|
|
|
|
or
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \- ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
the value of the
|
|
|
|
|
.Ev HOME ,
|
|
|
|
|
.Ev PWD ,
|
|
|
|
|
or
|
|
|
|
|
.Ev OLDPWD
|
|
|
|
|
parameter is substituted, respectively.
|
|
|
|
|
Otherwise, the password file is
|
|
|
|
|
searched for the login name, and the tilde expression is substituted with the
|
|
|
|
|
user's home directory.
|
|
|
|
|
If the login name is not found in the password file or
|
|
|
|
|
if any quoting or parameter substitution occurs in the login name, no
|
|
|
|
|
substitution is performed.
|
|
|
|
|
.Pp
|
|
|
|
|
In parameter assignments
|
|
|
|
|
(such as those preceding a simple-command or those occurring
|
|
|
|
|
in the arguments of
|
|
|
|
|
.Ic alias ,
|
|
|
|
|
.Ic export ,
|
2011-07-05 22:19:18 +02:00
|
|
|
|
.Ic global ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic readonly ,
|
|
|
|
|
and
|
|
|
|
|
.Ic typeset ) ,
|
|
|
|
|
tilde expansion is done after any assignment
|
|
|
|
|
(i.e. after the equals sign)
|
|
|
|
|
or after an unquoted colon
|
|
|
|
|
.Pq Sq \&: ;
|
|
|
|
|
login names are also delimited by colons.
|
|
|
|
|
.Pp
|
|
|
|
|
The home directory of previously expanded login names are cached and re-used.
|
|
|
|
|
The
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic alias \-d
|
2005-05-23 05:06:10 +02:00
|
|
|
|
command may be used to list, change, and add to this cache (e.g.\&
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ic alias \-d fac=/usr/local/facilities; cd \*(TIfac/bin ) .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ss Brace expansion (alteration)
|
|
|
|
|
Brace expressions take the following form:
|
|
|
|
|
.Bd -unfilled -offset indent
|
|
|
|
|
.Sm off
|
|
|
|
|
.Xo
|
|
|
|
|
.Ar prefix No { Ar str1 No ,...,
|
|
|
|
|
.Ar strN No } Ar suffix
|
|
|
|
|
.Xc
|
|
|
|
|
.Sm on
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
The expressions are expanded to
|
|
|
|
|
.Ar N
|
|
|
|
|
words, each of which is the concatenation of
|
|
|
|
|
.Ar prefix ,
|
|
|
|
|
.Ar str Ns i ,
|
|
|
|
|
and
|
|
|
|
|
.Ar suffix
|
|
|
|
|
(e.g.\&
|
|
|
|
|
.Dq a{c,b{X,Y},d}e
|
|
|
|
|
expands to four words:
|
|
|
|
|
.Dq ace ,
|
|
|
|
|
.Dq abXe ,
|
|
|
|
|
.Dq abYe ,
|
|
|
|
|
and
|
|
|
|
|
.Dq ade ) .
|
|
|
|
|
As noted in the example, brace expressions can be nested and the resulting
|
|
|
|
|
words are not sorted.
|
|
|
|
|
Brace expressions must contain an unquoted comma
|
|
|
|
|
.Pq Sq \&,
|
|
|
|
|
for expansion to occur (e.g.\&
|
|
|
|
|
.Ic {}
|
|
|
|
|
and
|
|
|
|
|
.Ic {foo}
|
|
|
|
|
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
|
|
|
|
|
.Ql \&? ,
|
|
|
|
|
.Ql * ,
|
|
|
|
|
.Ql + ,
|
|
|
|
|
.Ql @ ,
|
|
|
|
|
or
|
|
|
|
|
.Ql \&!
|
|
|
|
|
characters or
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Dq \&[..]
|
2005-05-23 05:06:10 +02:00
|
|
|
|
sequences.
|
|
|
|
|
Once brace expansion has been performed, the shell replaces file
|
|
|
|
|
name patterns with the sorted names of all the files that match the pattern
|
|
|
|
|
(if no files match, the word is left unchanged).
|
|
|
|
|
The pattern elements have the following meaning:
|
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
|
.It \&?
|
|
|
|
|
Matches any single character.
|
|
|
|
|
.It \&*
|
2009-11-22 00:21:23 +01:00
|
|
|
|
Matches any sequence of octets.
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.It \&[..]
|
2009-11-22 00:21:23 +01:00
|
|
|
|
Matches any of the octets inside the brackets.
|
|
|
|
|
Ranges of octets can be specified by separating two octets by a
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
(e.g.\&
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Dq \&[a0\-9]
|
2005-05-23 05:06:10 +02:00
|
|
|
|
matches the letter
|
|
|
|
|
.Sq a
|
|
|
|
|
or any digit).
|
|
|
|
|
In order to represent itself, a
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-
|
2009-11-22 00:21:23 +01:00
|
|
|
|
must either be quoted or the first or last octet in the octet list.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Similarly, a
|
|
|
|
|
.Ql \&]
|
2009-11-22 00:21:23 +01:00
|
|
|
|
must be quoted or the first octet in the list if it is to represent itself
|
2005-05-23 05:06:10 +02:00
|
|
|
|
instead of the end of the list.
|
|
|
|
|
Also, a
|
|
|
|
|
.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.
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.It \&[!..]
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Like [..],
|
2009-11-22 00:21:23 +01:00
|
|
|
|
except it matches any octet not inside the brackets.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sm off
|
|
|
|
|
.It *( Ar pattern\*(Ba No ...\*(Ba Ar pattern )
|
|
|
|
|
.Sm on
|
2009-11-22 00:21:23 +01:00
|
|
|
|
Matches any string of octets that matches zero or more occurrences of the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
specified patterns.
|
|
|
|
|
Example: The pattern
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ic *(foo\*(Babar)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
matches the strings
|
|
|
|
|
.Dq ,
|
|
|
|
|
.Dq foo ,
|
|
|
|
|
.Dq bar ,
|
|
|
|
|
.Dq foobarfoo ,
|
|
|
|
|
etc.
|
|
|
|
|
.Sm off
|
|
|
|
|
.It +( Ar pattern\*(Ba No ...\*(Ba Ar pattern )
|
|
|
|
|
.Sm on
|
2009-11-22 00:21:23 +01:00
|
|
|
|
Matches any string of octets that matches one or more occurrences of the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
specified patterns.
|
|
|
|
|
Example: The pattern
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ic +(foo\*(Babar)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
matches the strings
|
|
|
|
|
.Dq foo ,
|
|
|
|
|
.Dq bar ,
|
|
|
|
|
.Dq foobar ,
|
|
|
|
|
etc.
|
|
|
|
|
.Sm off
|
|
|
|
|
.It ?( Ar pattern\*(Ba No ...\*(Ba Ar pattern )
|
|
|
|
|
.Sm on
|
|
|
|
|
Matches the empty string or a string that matches one of the specified
|
|
|
|
|
patterns.
|
|
|
|
|
Example: The pattern
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ic ?(foo\*(Babar)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
only matches the strings
|
|
|
|
|
.Dq ,
|
|
|
|
|
.Dq foo ,
|
|
|
|
|
and
|
|
|
|
|
.Dq bar .
|
|
|
|
|
.Sm off
|
|
|
|
|
.It @( Ar pattern\*(Ba No ...\*(Ba Ar pattern )
|
|
|
|
|
.Sm on
|
|
|
|
|
Matches a string that matches one of the specified patterns.
|
|
|
|
|
Example: The pattern
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ic @(foo\*(Babar)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
only matches the strings
|
|
|
|
|
.Dq foo
|
|
|
|
|
and
|
|
|
|
|
.Dq bar .
|
|
|
|
|
.Sm off
|
|
|
|
|
.It !( Ar pattern\*(Ba No ...\*(Ba Ar pattern )
|
|
|
|
|
.Sm on
|
|
|
|
|
Matches any string that does not match one of the specified patterns.
|
|
|
|
|
Examples: The pattern
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ic !(foo\*(Babar)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
matches all strings except
|
|
|
|
|
.Dq foo
|
|
|
|
|
and
|
|
|
|
|
.Dq bar ;
|
|
|
|
|
the pattern
|
|
|
|
|
.Ic !(*)
|
|
|
|
|
matches no strings; the pattern
|
|
|
|
|
.Ic !(?)*\&
|
|
|
|
|
matches all strings (think about it).
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
Note that
|
|
|
|
|
.Nm mksh
|
2006-08-28 05:31:01 +02:00
|
|
|
|
.Po and Nm pdksh Pc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
never matches
|
|
|
|
|
.Sq \&.
|
|
|
|
|
and
|
|
|
|
|
.Sq .. ,
|
2006-08-28 05:31:01 +02:00
|
|
|
|
but
|
|
|
|
|
.At
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Nm ksh ,
|
|
|
|
|
Bourne
|
|
|
|
|
.Nm sh ,
|
|
|
|
|
and GNU
|
|
|
|
|
.Nm bash
|
|
|
|
|
do.
|
|
|
|
|
.Pp
|
|
|
|
|
Note that none of the above pattern elements match either a period
|
|
|
|
|
.Pq Sq \&.
|
|
|
|
|
at the start of a file name or a slash
|
|
|
|
|
.Pq Sq / ,
|
|
|
|
|
even if they are explicitly used in a [..] sequence; also, the names
|
|
|
|
|
.Sq \&.
|
|
|
|
|
and
|
|
|
|
|
.Sq ..
|
|
|
|
|
are never matched, even by the pattern
|
|
|
|
|
.Sq .* .
|
|
|
|
|
.Pp
|
|
|
|
|
If the
|
|
|
|
|
.Ic markdirs
|
|
|
|
|
option is set, any directories that result from file name generation are marked
|
|
|
|
|
with a trailing
|
|
|
|
|
.Ql / .
|
|
|
|
|
.Ss Input/output redirection
|
|
|
|
|
When a command is executed, its standard input, standard output, and standard
|
|
|
|
|
error (file descriptors 0, 1, and 2, respectively) are normally inherited from
|
|
|
|
|
the shell.
|
|
|
|
|
Three exceptions to this are commands in pipelines, for which
|
|
|
|
|
standard input and/or standard output are those set up by the pipeline,
|
|
|
|
|
asynchronous commands created when job control is disabled, for which standard
|
|
|
|
|
input is initially set to be from
|
|
|
|
|
.Pa /dev/null ,
|
|
|
|
|
and commands for which any of the following redirections have been specified:
|
2011-05-05 02:05:01 +02:00
|
|
|
|
.Bl -tag -width XXxxmarker
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It \*(Gt Ar file
|
|
|
|
|
Standard output is redirected to
|
|
|
|
|
.Ar file .
|
|
|
|
|
If
|
|
|
|
|
.Ar file
|
|
|
|
|
does not exist, it is created; if it does exist, is a regular file, and the
|
|
|
|
|
.Ic noclobber
|
|
|
|
|
option is set, an error occurs; otherwise, the file is truncated.
|
|
|
|
|
Note that this means the command
|
2009-09-06 20:17:51 +02:00
|
|
|
|
.Ic cmd \*(Ltfoo \*(Gtfoo
|
2005-05-23 05:06:10 +02:00
|
|
|
|
will open
|
|
|
|
|
.Ar foo
|
|
|
|
|
for reading and then truncate it when it opens it for writing, before
|
|
|
|
|
.Ar cmd
|
|
|
|
|
gets a chance to actually read
|
|
|
|
|
.Ar foo .
|
|
|
|
|
.It \*(Gt\*(Ba Ar file
|
|
|
|
|
Same as
|
|
|
|
|
.Ic \*(Gt ,
|
|
|
|
|
except the file is truncated, even if the
|
|
|
|
|
.Ic noclobber
|
|
|
|
|
option is set.
|
|
|
|
|
.It \*(Gt\*(Gt Ar file
|
|
|
|
|
Same as
|
|
|
|
|
.Ic \*(Gt ,
|
|
|
|
|
except if
|
|
|
|
|
.Ar file
|
|
|
|
|
exists it is appended to instead of being truncated.
|
|
|
|
|
Also, the file is opened
|
|
|
|
|
in append mode, so writes always go to the end of the file (see
|
|
|
|
|
.Xr open 2 ) .
|
|
|
|
|
.It \*(Lt Ar file
|
|
|
|
|
Standard input is redirected from
|
|
|
|
|
.Ar file ,
|
|
|
|
|
which is opened for reading.
|
|
|
|
|
.It \*(Lt\*(Gt Ar file
|
|
|
|
|
Same as
|
|
|
|
|
.Ic \*(Lt ,
|
|
|
|
|
except the file is opened for reading and writing.
|
|
|
|
|
.It \*(Lt\*(Lt Ar marker
|
|
|
|
|
After reading the command line containing this kind of redirection (called a
|
|
|
|
|
.Dq here document ) ,
|
|
|
|
|
the shell copies lines from the command source into a temporary file until a
|
|
|
|
|
line matching
|
|
|
|
|
.Ar marker
|
|
|
|
|
is read.
|
|
|
|
|
When the command is executed, standard input is redirected from the
|
|
|
|
|
temporary file.
|
|
|
|
|
If
|
|
|
|
|
.Ar marker
|
|
|
|
|
contains no quoted characters, the contents of the temporary file are processed
|
|
|
|
|
as if enclosed in double quotes each time the command is executed, so
|
|
|
|
|
parameter, command, and arithmetic substitutions are performed, along with
|
|
|
|
|
backslash
|
|
|
|
|
.Pq Sq \e
|
|
|
|
|
escapes for
|
|
|
|
|
.Ql $ ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \` ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql \e ,
|
|
|
|
|
and
|
2006-02-16 12:48:32 +01:00
|
|
|
|
.Ql \enewline ,
|
|
|
|
|
but not for
|
|
|
|
|
.Ql \&" .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If multiple here documents are used on the same command line, they are saved in
|
|
|
|
|
order.
|
2011-05-05 02:05:01 +02:00
|
|
|
|
.Pp
|
|
|
|
|
If no
|
|
|
|
|
.Ar marker
|
|
|
|
|
is given, the here document ends at the next
|
|
|
|
|
.Ic \*(Lt\*(Lt
|
|
|
|
|
and substitution will be performed.
|
|
|
|
|
If
|
|
|
|
|
.Ar marker
|
|
|
|
|
is only a set of either single
|
|
|
|
|
.Dq \*(aq\*(aq
|
|
|
|
|
or double
|
|
|
|
|
.Sq \&""
|
|
|
|
|
quotes with nothing in between, the here document ends at the next empty line
|
|
|
|
|
and substitution will not be performed.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It \*(Lt\*(Lt\- Ar marker
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Same as
|
|
|
|
|
.Ic \*(Lt\*(Lt ,
|
|
|
|
|
except leading tabs are stripped from lines in the here document.
|
2008-02-26 21:43:11 +01:00
|
|
|
|
.It \*(Lt\*(Lt\*(Lt Ar word
|
|
|
|
|
Same as
|
|
|
|
|
.Ic \*(Lt\*(Lt ,
|
|
|
|
|
except that
|
|
|
|
|
.Ar word
|
|
|
|
|
.Em is
|
|
|
|
|
the here document.
|
|
|
|
|
This is called a here string.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It \*(Lt& Ar fd
|
|
|
|
|
Standard input is duplicated from file descriptor
|
|
|
|
|
.Ar fd .
|
|
|
|
|
.Ar fd
|
2008-07-09 23:32:45 +02:00
|
|
|
|
can be a number, indicating the number of an existing file descriptor;
|
2005-05-23 05:06:10 +02:00
|
|
|
|
the letter
|
|
|
|
|
.Ql p ,
|
|
|
|
|
indicating the file descriptor associated with the output of the current
|
|
|
|
|
co-process; or the character
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \- ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
indicating standard input is to be closed.
|
2008-07-09 23:32:45 +02:00
|
|
|
|
Note that
|
|
|
|
|
.Ar fd
|
|
|
|
|
is limited to a single digit in most shell implementations.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It \*(Gt& Ar fd
|
|
|
|
|
Same as
|
|
|
|
|
.Ic \*(Lt& ,
|
|
|
|
|
except the operation is done on standard output.
|
2008-06-29 00:51:56 +02:00
|
|
|
|
.It &\*(Gt Ar file
|
|
|
|
|
Same as
|
|
|
|
|
.Ic \*(Gt Ar file 2\*(Gt&1 .
|
|
|
|
|
This is a GNU
|
|
|
|
|
.Nm bash
|
|
|
|
|
extension supported by
|
|
|
|
|
.Nm
|
2008-07-09 23:32:45 +02:00
|
|
|
|
which also supports the preceding explicit fd number, for example,
|
2008-06-29 00:51:56 +02:00
|
|
|
|
.Ic 3&\*(Gt Ar file
|
|
|
|
|
is the same as
|
|
|
|
|
.Ic 3\*(Gt Ar file 2\*(Gt&3
|
|
|
|
|
in
|
|
|
|
|
.Nm
|
|
|
|
|
but a syntax error in GNU
|
|
|
|
|
.Nm bash .
|
|
|
|
|
.It Xo
|
2009-11-22 19:23:38 +01:00
|
|
|
|
.No &\*(Gt\*(Ba Ar file ,
|
2008-06-29 00:51:56 +02:00
|
|
|
|
.No &\*(Gt\*(Gt Ar file ,
|
|
|
|
|
.No &\*(Gt& Ar fd
|
|
|
|
|
.Xc
|
|
|
|
|
Same as
|
2009-11-22 19:23:38 +01:00
|
|
|
|
.Ic \*(Gt\*(Ba Ar file ,
|
2008-06-29 00:51:56 +02:00
|
|
|
|
.Ic \*(Gt\*(Gt Ar file ,
|
|
|
|
|
or
|
|
|
|
|
.Ic \*(Gt& Ar fd ,
|
|
|
|
|
followed by
|
|
|
|
|
.Ic 2\*(Gt&1 ,
|
|
|
|
|
as above.
|
|
|
|
|
These are
|
|
|
|
|
.Nm
|
|
|
|
|
extensions.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
In any of the above redirections, the file descriptor that is redirected
|
|
|
|
|
(i.e. standard input or standard output)
|
|
|
|
|
can be explicitly given by preceding the
|
2008-07-09 23:32:45 +02:00
|
|
|
|
redirection with a number (portably, only a single digit).
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Parameter, command, and arithmetic
|
|
|
|
|
substitutions, tilde substitutions, and (if the shell is interactive)
|
|
|
|
|
file name generation are all performed on the
|
|
|
|
|
.Ar file ,
|
|
|
|
|
.Ar marker ,
|
|
|
|
|
and
|
|
|
|
|
.Ar fd
|
|
|
|
|
arguments of redirections.
|
|
|
|
|
Note, however, that the results of any file name
|
|
|
|
|
generation are only used if a single file is matched; if multiple files match,
|
|
|
|
|
the word with the expanded file name generation characters is used.
|
|
|
|
|
Note
|
|
|
|
|
that in restricted shells, redirections which can create files cannot be used.
|
|
|
|
|
.Pp
|
|
|
|
|
For simple-commands, redirections may appear anywhere in the command; for
|
|
|
|
|
compound-commands
|
|
|
|
|
.Po
|
|
|
|
|
.Ic if
|
|
|
|
|
statements, etc.
|
|
|
|
|
.Pc ,
|
|
|
|
|
any redirections must appear at the end.
|
|
|
|
|
Redirections are processed after
|
|
|
|
|
pipelines are created and in the order they are given, so the following
|
2011-05-05 02:05:01 +02:00
|
|
|
|
will print an error with a line number prepended to it:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
2011-05-05 02:05:01 +02:00
|
|
|
|
.D1 $ cat /foo/bar 2\*(Gt&1 \*(Gt/dev/null \*(Ba pr \-n \-t
|
2008-09-17 21:31:30 +02:00
|
|
|
|
.Pp
|
|
|
|
|
File descriptors created by input/output redirections are private to the
|
|
|
|
|
Korn shell, but passed to sub-processes if
|
2010-01-28 16:18:51 +01:00
|
|
|
|
.Fl o Ic posix
|
|
|
|
|
or
|
2009-10-02 20:08:37 +02:00
|
|
|
|
.Fl o Ic sh
|
2008-09-17 21:31:30 +02:00
|
|
|
|
is set.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ss Arithmetic expressions
|
|
|
|
|
Integer arithmetic expressions can be used with the
|
|
|
|
|
.Ic let
|
|
|
|
|
command, inside $((..)) expressions, inside array references (e.g.\&
|
|
|
|
|
.Ar name Ns Bq Ar expr ) ,
|
|
|
|
|
as numeric arguments to the
|
|
|
|
|
.Ic test
|
|
|
|
|
command, and as the value of an assignment to an integer parameter.
|
|
|
|
|
.Pp
|
2008-12-17 20:39:23 +01:00
|
|
|
|
Expressions are calculated using signed arithmetic and the
|
2009-03-14 19:12:55 +01:00
|
|
|
|
.Vt mksh_ari_t
|
|
|
|
|
type (a 32-bit signed integer), unless they begin with a sole
|
2008-12-17 20:39:23 +01:00
|
|
|
|
.Sq #
|
|
|
|
|
character, in which case they use
|
2009-03-14 19:12:55 +01:00
|
|
|
|
.Vt mksh_uari_t
|
|
|
|
|
.Po a 32-bit unsigned integer Pc .
|
2008-12-17 20:39:23 +01:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Expressions may contain alpha-numeric parameter identifiers, array references,
|
|
|
|
|
and integer constants and may be combined with the following C operators
|
|
|
|
|
(listed and grouped in increasing order of precedence):
|
|
|
|
|
.Pp
|
|
|
|
|
Unary operators:
|
|
|
|
|
.Bd -literal -offset indent
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
+ \- ! \*(TI ++ \-\-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
Binary operators:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
= *= /= %= += \-= \*(Lt\*(Lt= \*(Gt\*(Gt= &= \*(ha= \*(Ba=
|
2005-05-23 05:06:10 +02:00
|
|
|
|
\*(Ba\*(Ba
|
|
|
|
|
&&
|
|
|
|
|
\*(Ba
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
\*(ha
|
2005-05-23 05:06:10 +02:00
|
|
|
|
&
|
|
|
|
|
== !=
|
|
|
|
|
\*(Lt \*(Lt= \*(Gt= \*(Gt
|
|
|
|
|
\*(Lt\*(Lt \*(Gt\*(Gt
|
2008-03-03 23:38:41 +01:00
|
|
|
|
+ \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
* / %
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
Ternary operators:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
?: (precedence is immediately higher than assignment)
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
Grouping operators:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
( )
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
• finally, the code and manual page text to deprecate, and code to not
handle any more, octal 010 style constants, as promised
• overhaul the manpage re. arithmetic expressions, make the guarantees
mksh code has explicitly, precisely, clear
• to reduce burden of the compiler, getint() now operates on mksh_uari_t
internally; it already applied the sign after operation, anyway (C99
guarantees wraparound on unsigned types, but for signed types we need
specific compiler support; apparently, this comes from hardware limits)
• use const and shuffle order of locals around while here
2011-12-10 14:34:19 +01:00
|
|
|
|
Integer constants and expressions are calculated using an exactly 32-bit
|
|
|
|
|
wide, signed or unsigned, type with silent wraparound on integer overflow.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Integer constants may be specified with arbitrary bases using the notation
|
|
|
|
|
.Ar base Ns # Ns Ar number ,
|
|
|
|
|
where
|
|
|
|
|
.Ar base
|
|
|
|
|
is a decimal integer specifying the base, and
|
|
|
|
|
.Ar number
|
|
|
|
|
is a number in the specified base.
|
• finally, the code and manual page text to deprecate, and code to not
handle any more, octal 010 style constants, as promised
• overhaul the manpage re. arithmetic expressions, make the guarantees
mksh code has explicitly, precisely, clear
• to reduce burden of the compiler, getint() now operates on mksh_uari_t
internally; it already applied the sign after operation, anyway (C99
guarantees wraparound on unsigned types, but for signed types we need
specific compiler support; apparently, this comes from hardware limits)
• use const and shuffle order of locals around while here
2011-12-10 14:34:19 +01:00
|
|
|
|
Additionally, base-16 integers may be specified by prefixing them with
|
2012-04-07 13:19:53 +02:00
|
|
|
|
.Sq 0x
|
|
|
|
|
.Pq case-insensitive
|
• finally, the code and manual page text to deprecate, and code to not
handle any more, octal 010 style constants, as promised
• overhaul the manpage re. arithmetic expressions, make the guarantees
mksh code has explicitly, precisely, clear
• to reduce burden of the compiler, getint() now operates on mksh_uari_t
internally; it already applied the sign after operation, anyway (C99
guarantees wraparound on unsigned types, but for signed types we need
specific compiler support; apparently, this comes from hardware limits)
• use const and shuffle order of locals around while here
2011-12-10 14:34:19 +01:00
|
|
|
|
in all forms of arithmetic expressions, except as numeric arguments to the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic test
|
• finally, the code and manual page text to deprecate, and code to not
handle any more, octal 010 style constants, as promised
• overhaul the manpage re. arithmetic expressions, make the guarantees
mksh code has explicitly, precisely, clear
• to reduce burden of the compiler, getint() now operates on mksh_uari_t
internally; it already applied the sign after operation, anyway (C99
guarantees wraparound on unsigned types, but for signed types we need
specific compiler support; apparently, this comes from hardware limits)
• use const and shuffle order of locals around while here
2011-12-10 14:34:19 +01:00
|
|
|
|
built-in command.
|
2012-04-07 13:19:53 +02:00
|
|
|
|
It is discouraged to prefix numbers with a sole zero
|
|
|
|
|
.Pq Sq 0 ,
|
|
|
|
|
because some shells may interpret them as base-8 integers.
|
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-20 00:15:06 +02:00
|
|
|
|
As a special
|
|
|
|
|
.Nm mksh
|
|
|
|
|
extension, numbers to the base of one are treated as either (8-bit
|
|
|
|
|
transparent) ASCII or Unicode codepoints, depending on the shell's
|
2008-12-04 19:11:08 +01:00
|
|
|
|
.Ic utf8\-mode
|
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-20 00:15:06 +02:00
|
|
|
|
flag (current setting).
|
2009-09-06 19:55:55 +02:00
|
|
|
|
The
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh93
|
|
|
|
|
syntax of
|
|
|
|
|
.Dq \*(aqx\*(aq
|
|
|
|
|
instead of
|
|
|
|
|
.Dq 1#x
|
|
|
|
|
is also supported.
|
2008-05-10 20:10:02 +02:00
|
|
|
|
Note that NUL bytes (integral value of zero) cannot be used.
|
2012-06-25 18:22:59 +02:00
|
|
|
|
An unset or empty parameter evaluates to 0 in integer context.
|
2008-08-02 02:57:28 +02:00
|
|
|
|
In Unicode mode, raw octets are mapped into the range EF80..EFFF as in
|
|
|
|
|
OPTU-8, which is in the PUA and has been assigned by CSUR for this use.
|
2008-04-20 03:12:52 +02:00
|
|
|
|
If more than one octet in ASCII mode, or a sequence of more than one
|
|
|
|
|
octet not forming a valid and minimal CESU-8 sequence is passed, the
|
|
|
|
|
behaviour is undefined (usually, the shell aborts with a parse error,
|
|
|
|
|
but rarely, it succeeds, e.g. on the sequence C2 20).
|
|
|
|
|
That's why you should always use ASCII mode unless you know that the
|
2008-04-20 03:47:59 +02:00
|
|
|
|
input is well-formed UTF-8 in the range of 0000..FFFD.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
The operators are evaluated as follows:
|
|
|
|
|
.Bl -tag -width Ds -offset indent
|
|
|
|
|
.It unary +
|
|
|
|
|
Result is the argument (included for completeness).
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It unary \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Negation.
|
|
|
|
|
.It \&!
|
|
|
|
|
Logical NOT;
|
|
|
|
|
the result is 1 if argument is zero, 0 if not.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(TI
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Arithmetic (bit-wise) NOT.
|
|
|
|
|
.It ++
|
|
|
|
|
Increment; must be applied to a parameter (not a literal or other expression).
|
|
|
|
|
The parameter is incremented by 1.
|
|
|
|
|
When used as a prefix operator, the result
|
|
|
|
|
is the incremented value of the parameter; when used as a postfix operator, the
|
|
|
|
|
result is the original value of the parameter.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It \-\-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Similar to
|
|
|
|
|
.Ic ++ ,
|
|
|
|
|
except the parameter is decremented by 1.
|
|
|
|
|
.It \&,
|
|
|
|
|
Separates two arithmetic expressions; the left-hand side is evaluated first,
|
|
|
|
|
then the right.
|
|
|
|
|
The result is the value of the expression on the right-hand side.
|
|
|
|
|
.It =
|
|
|
|
|
Assignment; the variable on the left is set to the value on the right.
|
|
|
|
|
.It Xo
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.No *= /= += \-= \*(Lt\*(Lt=
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(Gt\*(Gt= &= \*(ha= \*(Ba=
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Assignment operators.
|
|
|
|
|
.Sm off
|
2010-02-25 22:05:00 +01:00
|
|
|
|
.Ao Ar var Ac Xo
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Aq Ar op
|
|
|
|
|
.No = Aq Ar expr
|
|
|
|
|
.Xc
|
|
|
|
|
.Sm on
|
|
|
|
|
is the same as
|
|
|
|
|
.Sm off
|
2010-02-25 22:05:00 +01:00
|
|
|
|
.Ao Ar var Ac Xo
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.No = Aq Ar var
|
|
|
|
|
.Aq Ar op
|
|
|
|
|
.Aq Ar expr ,
|
|
|
|
|
.Xc
|
|
|
|
|
.Sm on
|
|
|
|
|
with any operator precedence in
|
|
|
|
|
.Aq Ar expr
|
|
|
|
|
preserved.
|
|
|
|
|
For example,
|
|
|
|
|
.Dq var1 *= 5 + 3
|
|
|
|
|
is the same as specifying
|
|
|
|
|
.Dq var1 = var1 * (5 + 3) .
|
|
|
|
|
.It \*(Ba\*(Ba
|
|
|
|
|
Logical OR;
|
|
|
|
|
the result is 1 if either argument is non-zero, 0 if not.
|
|
|
|
|
The right argument is evaluated only if the left argument is zero.
|
|
|
|
|
.It &&
|
|
|
|
|
Logical AND;
|
|
|
|
|
the result is 1 if both arguments are non-zero, 0 if not.
|
|
|
|
|
The right argument is evaluated only if the left argument is non-zero.
|
|
|
|
|
.It \*(Ba
|
|
|
|
|
Arithmetic (bit-wise) OR.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(ha
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Arithmetic (bit-wise) XOR
|
|
|
|
|
(exclusive-OR).
|
|
|
|
|
.It &
|
|
|
|
|
Arithmetic (bit-wise) AND.
|
|
|
|
|
.It ==
|
|
|
|
|
Equal; the result is 1 if both arguments are equal, 0 if not.
|
|
|
|
|
.It !=
|
|
|
|
|
Not equal; the result is 0 if both arguments are equal, 1 if not.
|
|
|
|
|
.It \*(Lt
|
|
|
|
|
Less than; the result is 1 if the left argument is less than the right, 0 if
|
|
|
|
|
not.
|
|
|
|
|
.It \*(Lt= \*(Gt= \*(Gt
|
|
|
|
|
Less than or equal, greater than or equal, greater than.
|
|
|
|
|
See
|
|
|
|
|
.Ic \*(Lt .
|
|
|
|
|
.It \*(Lt\*(Lt \*(Gt\*(Gt
|
|
|
|
|
Shift left (right); the result is the left argument with its bits shifted left
|
|
|
|
|
(right) by the amount given in the right argument.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It + \- * /
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Addition, subtraction, multiplication, and division.
|
|
|
|
|
.It %
|
|
|
|
|
Remainder; the result is the remainder of the division of the left argument by
|
|
|
|
|
the right.
|
|
|
|
|
The sign of the result is unspecified if either argument is negative.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Sm off
|
|
|
|
|
.Aq Ar arg1 ?
|
|
|
|
|
.Aq Ar arg2 :
|
|
|
|
|
.Aq Ar arg3
|
|
|
|
|
.Sm on
|
|
|
|
|
.Xc
|
|
|
|
|
If
|
|
|
|
|
.Aq Ar arg1
|
|
|
|
|
is non-zero, the result is
|
|
|
|
|
.Aq Ar arg2 ;
|
|
|
|
|
otherwise the result is
|
|
|
|
|
.Aq Ar arg3 .
|
|
|
|
|
.El
|
|
|
|
|
.Ss Co-processes
|
2006-01-30 13:37:24 +01:00
|
|
|
|
A co-process (which is a pipeline created with the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sq \*(Ba&
|
2006-01-30 13:37:24 +01:00
|
|
|
|
operator) is an asynchronous process that the shell can both write to (using
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic print \-p )
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and read from (using
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic read \-p ) .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The input and output of the co-process can also be manipulated using
|
|
|
|
|
.Ic \*(Gt&p
|
|
|
|
|
and
|
|
|
|
|
.Ic \*(Lt&p
|
|
|
|
|
redirections, respectively.
|
|
|
|
|
Once a co-process has been started, another can't
|
|
|
|
|
be started until the co-process exits, or until the co-process's input has been
|
|
|
|
|
redirected using an
|
|
|
|
|
.Ic exec Ar n Ns Ic \*(Gt&p
|
|
|
|
|
redirection.
|
|
|
|
|
If a co-process's input is redirected in this way, the next
|
|
|
|
|
co-process to be started will share the output with the first co-process,
|
|
|
|
|
unless the output of the initial co-process has been redirected using an
|
|
|
|
|
.Ic exec Ar n Ns Ic \*(Lt&p
|
|
|
|
|
redirection.
|
|
|
|
|
.Pp
|
|
|
|
|
Some notes concerning co-processes:
|
|
|
|
|
.Bl -bullet
|
|
|
|
|
.It
|
|
|
|
|
The only way to close the co-process's input (so the co-process reads an
|
|
|
|
|
end-of-file) is to redirect the input to a numbered file descriptor and then
|
2005-05-26 01:31:08 +02:00
|
|
|
|
close that file descriptor:
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic exec 3\*(Gt&p; exec 3\*(Gt&\-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It
|
|
|
|
|
In order for co-processes to share a common output, the shell must keep the
|
|
|
|
|
write portion of the output pipe open.
|
|
|
|
|
This means that end-of-file will not be
|
|
|
|
|
detected until all co-processes sharing the co-process's output have exited
|
|
|
|
|
(when they all exit, the shell closes its copy of the pipe).
|
|
|
|
|
This can be
|
|
|
|
|
avoided by redirecting the output to a numbered file descriptor (as this also
|
|
|
|
|
causes the shell to close its copy).
|
|
|
|
|
Note that this behaviour is slightly
|
|
|
|
|
different from the original Korn shell which closes its copy of the write
|
|
|
|
|
portion of the co-process output when the most recently started co-process
|
|
|
|
|
(instead of when all sharing co-processes) exits.
|
|
|
|
|
.It
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic print \-p
|
2005-05-23 05:06:10 +02:00
|
|
|
|
will ignore
|
|
|
|
|
.Dv SIGPIPE
|
|
|
|
|
signals during writes if the signal is not being trapped or ignored; the same
|
|
|
|
|
is true if the co-process input has been duplicated to another file descriptor
|
|
|
|
|
and
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic print \-u Ns Ar n
|
2005-05-23 05:06:10 +02:00
|
|
|
|
is used.
|
|
|
|
|
.El
|
|
|
|
|
.Ss Functions
|
|
|
|
|
Functions are defined using either Korn shell
|
|
|
|
|
.Ic function Ar function-name
|
|
|
|
|
syntax or the Bourne/POSIX shell
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Ar function-name Ns \&()
|
2005-05-23 05:06:10 +02:00
|
|
|
|
syntax (see below for the difference between the two forms).
|
|
|
|
|
Functions are like
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Li .\(hyscripts
|
2005-05-23 05:06:10 +02:00
|
|
|
|
(i.e. scripts sourced using the
|
|
|
|
|
.Sq \&.
|
|
|
|
|
built-in)
|
|
|
|
|
in that they are executed in the current environment.
|
|
|
|
|
However, unlike
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Li .\(hyscripts ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
shell arguments (i.e. positional parameters $1, $2, etc.)\&
|
|
|
|
|
are never visible inside them.
|
|
|
|
|
When the shell is determining the location of a command, functions
|
|
|
|
|
are searched after special built-in commands, before regular and
|
|
|
|
|
non-regular built-ins, and before the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
is searched.
|
|
|
|
|
.Pp
|
|
|
|
|
An existing function may be deleted using
|
|
|
|
|
.Ic unset Fl f Ar function-name .
|
|
|
|
|
A list of functions can be obtained using
|
|
|
|
|
.Ic typeset +f
|
|
|
|
|
and the function definitions can be listed using
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic typeset \-f .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The
|
|
|
|
|
.Ic autoload
|
|
|
|
|
command (which is an alias for
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic typeset \-fu )
|
2005-05-23 05:06:10 +02:00
|
|
|
|
may be used to create undefined functions: when an undefined function is
|
|
|
|
|
executed, the shell searches the path specified in the
|
|
|
|
|
.Ev FPATH
|
2006-01-30 13:37:24 +01:00
|
|
|
|
parameter for a file with the same name as the function which, if found, is
|
2005-05-23 05:06:10 +02:00
|
|
|
|
read and executed.
|
|
|
|
|
If after executing the file the named function is found to
|
|
|
|
|
be defined, the function is executed; otherwise, the normal command search is
|
|
|
|
|
continued (i.e. the shell searches the regular built-in command table and
|
|
|
|
|
.Ev PATH ) .
|
|
|
|
|
Note that if a command is not found using
|
|
|
|
|
.Ev PATH ,
|
|
|
|
|
an attempt is made to autoload a function using
|
|
|
|
|
.Ev FPATH
|
|
|
|
|
(this is an undocumented feature of the original Korn shell).
|
|
|
|
|
.Pp
|
|
|
|
|
Functions can have two attributes,
|
|
|
|
|
.Dq trace
|
|
|
|
|
and
|
|
|
|
|
.Dq export ,
|
|
|
|
|
which can be set with
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic typeset \-ft
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic typeset \-fx ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
respectively.
|
|
|
|
|
When a traced function is executed, the shell's
|
|
|
|
|
.Ic xtrace
|
2011-04-17 17:43:12 +02:00
|
|
|
|
option is turned on for the function's duration.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The
|
|
|
|
|
.Dq export
|
|
|
|
|
attribute of functions is currently not used.
|
|
|
|
|
In the original Korn shell,
|
|
|
|
|
exported functions are visible to shell scripts that are executed.
|
|
|
|
|
.Pp
|
|
|
|
|
Since functions are executed in the current shell environment, parameter
|
|
|
|
|
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.
|
2009-09-05 19:12:49 +02:00
|
|
|
|
Note that
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh93
|
2012-11-20 19:25:12 +01:00
|
|
|
|
uses static scoping (one global scope, one local scope per function)
|
|
|
|
|
and allows local variables only on Korn style functions, whereas
|
2009-09-05 19:12:49 +02:00
|
|
|
|
.Nm mksh
|
|
|
|
|
uses dynamic scoping (nested scopes of varying locality).
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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.
|
|
|
|
|
A function can be made to finish immediately using the
|
|
|
|
|
.Ic return
|
|
|
|
|
command; this may also be used to explicitly specify the exit status.
|
|
|
|
|
.Pp
|
|
|
|
|
Functions defined with the
|
|
|
|
|
.Ic function
|
|
|
|
|
reserved word are treated differently in the following ways from functions
|
|
|
|
|
defined with the
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Ic \&()
|
2005-05-23 05:06:10 +02:00
|
|
|
|
notation:
|
|
|
|
|
.Bl -bullet
|
|
|
|
|
.It
|
|
|
|
|
The $0 parameter is set to the name of the function
|
|
|
|
|
(Bourne-style functions leave $0 untouched).
|
|
|
|
|
.It
|
|
|
|
|
Parameter assignments preceding function calls are not kept in the shell
|
|
|
|
|
environment (executing Bourne-style functions will keep assignments).
|
|
|
|
|
.It
|
|
|
|
|
.Ev OPTIND
|
|
|
|
|
is saved/reset and restored on entry and exit from the function so
|
|
|
|
|
.Ic getopts
|
|
|
|
|
can be used properly both inside and outside the function (Bourne-style
|
|
|
|
|
functions leave
|
|
|
|
|
.Ev OPTIND
|
|
|
|
|
untouched, so using
|
|
|
|
|
.Ic getopts
|
|
|
|
|
inside a function interferes with using
|
|
|
|
|
.Ic getopts
|
|
|
|
|
outside the function).
|
2009-07-06 17:06:25 +02:00
|
|
|
|
.It
|
|
|
|
|
Bourne-style function definitions take precedence over alias dereferences
|
|
|
|
|
and remove alias definitions upon encounter, while aliases take precedence
|
|
|
|
|
over Korn-style functions.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2012-11-20 19:25:12 +01:00
|
|
|
|
In the future, the following differences may also be added:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Bl -bullet
|
|
|
|
|
.It
|
|
|
|
|
A separate trap/signal environment will be used during the execution of
|
|
|
|
|
functions.
|
|
|
|
|
This will mean that traps set inside a function will not affect the
|
|
|
|
|
shell's traps and signals that are not ignored in the shell (but may be
|
|
|
|
|
trapped) will have their default effect in a function.
|
|
|
|
|
.It
|
|
|
|
|
The EXIT trap, if set in a function, will be executed after the function
|
|
|
|
|
returns.
|
|
|
|
|
.El
|
|
|
|
|
.Ss Command execution
|
|
|
|
|
After evaluation of command-line arguments, redirections, and parameter
|
|
|
|
|
assignments, the type of command is determined: a special built-in, a
|
|
|
|
|
function, a regular built-in, or the name of a file to execute found using the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameter.
|
|
|
|
|
The checks are made in the above order.
|
|
|
|
|
Special built-in commands differ from other commands in that the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameter is not used to find them, an error during their execution can
|
|
|
|
|
cause a non-interactive shell to exit, and parameter assignments that are
|
|
|
|
|
specified before the command are kept after the command completes.
|
|
|
|
|
Regular built-in commands are different only in that the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameter is not used to find them.
|
|
|
|
|
.Pp
|
|
|
|
|
The original
|
|
|
|
|
.Nm ksh
|
|
|
|
|
and POSIX differ somewhat in which commands are considered
|
|
|
|
|
special or regular:
|
|
|
|
|
.Pp
|
|
|
|
|
POSIX special commands
|
|
|
|
|
.Pp
|
|
|
|
|
.Ic \&. , \&: , break , continue ,
|
|
|
|
|
.Ic eval , exec , exit , export ,
|
|
|
|
|
.Ic readonly , return , set , shift ,
|
2009-07-08 12:37:24 +02:00
|
|
|
|
.Ic trap , unset , wait
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Additional
|
|
|
|
|
.Nm
|
|
|
|
|
special commands
|
|
|
|
|
.Pp
|
2011-07-05 22:19:18 +02:00
|
|
|
|
.Ic builtin , global , times , typeset
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Very special commands
|
|
|
|
|
.Pq non-POSIX
|
|
|
|
|
.Pp
|
|
|
|
|
.Ic alias , readonly , set , typeset
|
|
|
|
|
.Pp
|
|
|
|
|
POSIX regular commands
|
|
|
|
|
.Pp
|
|
|
|
|
.Ic alias , bg , cd , command ,
|
|
|
|
|
.Ic false , fc , fg , getopts ,
|
|
|
|
|
.Ic jobs , kill , read , true ,
|
2009-07-08 12:37:24 +02:00
|
|
|
|
.Ic umask , unalias
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Additional
|
|
|
|
|
.Nm
|
|
|
|
|
regular commands
|
|
|
|
|
.Pp
|
2010-08-28 19:21:46 +02:00
|
|
|
|
.Ic \&[ , chdir , bind , cat ,
|
|
|
|
|
.Ic echo , let , mknod , print ,
|
2012-08-03 20:34:31 +02:00
|
|
|
|
.Ic pwd , realpath , rename , sleep ,
|
|
|
|
|
.Ic test , ulimit , whence
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
In the future, the additional
|
|
|
|
|
.Nm
|
|
|
|
|
special and regular commands may be treated
|
|
|
|
|
differently from the POSIX special and regular commands.
|
|
|
|
|
.Pp
|
|
|
|
|
Once the type of command has been determined, any command-line parameter
|
|
|
|
|
assignments are performed and exported for the duration of the command.
|
|
|
|
|
.Pp
|
|
|
|
|
The following describes the special and regular built-in commands:
|
|
|
|
|
.Pp
|
2009-10-10 23:17:31 +02:00
|
|
|
|
.Bl -tag -width false -compact
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ic \&. Ar file Op Ar arg ...
|
2007-08-13 21:39:21 +02:00
|
|
|
|
This is called the
|
|
|
|
|
.Dq dot
|
|
|
|
|
command.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Execute the commands in
|
|
|
|
|
.Ar file
|
|
|
|
|
in the current environment.
|
|
|
|
|
The file is searched for in the directories of
|
|
|
|
|
.Ev PATH .
|
|
|
|
|
If arguments are given, the positional parameters may be used to access them
|
|
|
|
|
while
|
|
|
|
|
.Ar file
|
|
|
|
|
is being executed.
|
|
|
|
|
If no arguments are given, the positional parameters are
|
|
|
|
|
those of the environment the command is used in.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic \&: Op Ar ...
|
|
|
|
|
The null command.
|
|
|
|
|
Exit status is set to zero.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo Ic alias
|
|
|
|
|
.Oo Fl d \*(Ba t Oo Fl r Oc \*(Ba
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Cm +\-x Oc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Fl p
|
|
|
|
|
.Op Cm +
|
|
|
|
|
.Oo Ar name
|
|
|
|
|
.Op Ns = Ns Ar value
|
|
|
|
|
.Ar ... Oc
|
|
|
|
|
.Xc
|
|
|
|
|
Without arguments,
|
|
|
|
|
.Ic alias
|
|
|
|
|
lists all aliases.
|
|
|
|
|
For any name without a value, the existing alias is listed.
|
|
|
|
|
Any name with a value defines an alias (see
|
|
|
|
|
.Sx Aliases
|
|
|
|
|
above).
|
|
|
|
|
.Pp
|
|
|
|
|
When listing aliases, one of two formats is used.
|
|
|
|
|
Normally, aliases are listed as
|
|
|
|
|
.Ar name Ns = Ns Ar value ,
|
|
|
|
|
where
|
|
|
|
|
.Ar value
|
|
|
|
|
is quoted.
|
|
|
|
|
If options were preceded with
|
|
|
|
|
.Ql + ,
|
|
|
|
|
or a lone
|
|
|
|
|
.Ql +
|
|
|
|
|
is given on the command line, only
|
|
|
|
|
.Ar name
|
|
|
|
|
is printed.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fl d
|
2006-01-30 13:37:24 +01:00
|
|
|
|
option causes directory aliases which are used in tilde expansion to be
|
2005-05-23 05:06:10 +02:00
|
|
|
|
listed or set (see
|
|
|
|
|
.Sx Tilde expansion
|
|
|
|
|
above).
|
|
|
|
|
.Pp
|
|
|
|
|
If the
|
|
|
|
|
.Fl p
|
|
|
|
|
option is used, each alias is prefixed with the string
|
|
|
|
|
.Dq alias\ \& .
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fl t
|
|
|
|
|
option indicates that tracked aliases are to be listed/set (values specified on
|
|
|
|
|
the command line are ignored for tracked aliases).
|
|
|
|
|
The
|
|
|
|
|
.Fl r
|
|
|
|
|
option indicates that all tracked aliases are to be reset.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fl x
|
|
|
|
|
option sets
|
|
|
|
|
.Pq Ic +x No clears
|
|
|
|
|
the export attribute of an alias, or, if no names are given, lists the aliases
|
|
|
|
|
with the export attribute (exporting an alias has no effect).
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic bg Op Ar job ...
|
|
|
|
|
Resume the specified stopped job(s) in the background.
|
|
|
|
|
If no jobs are specified,
|
|
|
|
|
.Ic %+
|
|
|
|
|
is assumed.
|
|
|
|
|
See
|
|
|
|
|
.Sx Job control
|
|
|
|
|
below for more information.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic bind Op Fl l
|
|
|
|
|
The current bindings are listed.
|
|
|
|
|
If the
|
|
|
|
|
.Fl l
|
|
|
|
|
flag is given,
|
|
|
|
|
.Ic bind
|
|
|
|
|
instead lists the names of the functions to which keys may be bound.
|
|
|
|
|
See
|
|
|
|
|
.Sx Emacs editing mode
|
|
|
|
|
for more information.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo Ic bind Op Fl m
|
|
|
|
|
.Ar string Ns = Ns Op Ar substitute
|
|
|
|
|
.Ar ...
|
|
|
|
|
.Xc
|
|
|
|
|
.It Xo Ic bind
|
|
|
|
|
.Ar string Ns = Ns Op Ar editing-command
|
|
|
|
|
.Ar ...
|
|
|
|
|
.Xc
|
|
|
|
|
The specified editing command is bound to the given
|
|
|
|
|
.Ar string ,
|
|
|
|
|
which should consist of a control character
|
2006-08-02 15:32:18 +02:00
|
|
|
|
optionally preceded by one of the two prefix characters
|
|
|
|
|
and optionally succeded by a tilde character.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Future input of the
|
|
|
|
|
.Ar string
|
|
|
|
|
will cause the editing command to be immediately invoked.
|
|
|
|
|
If the
|
|
|
|
|
.Fl m
|
|
|
|
|
flag is given, the specified input
|
|
|
|
|
.Ar string
|
|
|
|
|
will afterwards be immediately replaced by the given
|
|
|
|
|
.Ar substitute
|
2009-04-05 14:45:25 +02:00
|
|
|
|
string which may contain editing commands but not other macros.
|
2006-08-02 15:32:18 +02:00
|
|
|
|
If a tilde postfix is given, a tilde trailing the one or
|
|
|
|
|
two prefices and the control character is ignored, any
|
|
|
|
|
other trailing character will be processed afterwards.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Control characters may be written using caret notation
|
2009-09-19 23:54:46 +02:00
|
|
|
|
i.e. \*(haX represents Ctrl-X.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
Note that although only two prefix characters (usually ESC and \*(haX)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
are supported, some multi-character sequences can be supported.
|
|
|
|
|
.Pp
|
2006-08-02 16:00:19 +02:00
|
|
|
|
The following default bindings show how the arrow keys, the home, end and
|
2009-09-19 23:54:46 +02:00
|
|
|
|
delete key on a BSD wsvt25, xterm\-xfree86 or GNU screen terminal are bound
|
2005-05-23 05:06:10 +02:00
|
|
|
|
(of course some escape sequences won't work out quite this nicely):
|
|
|
|
|
.Bd -literal -offset indent
|
2009-04-05 14:45:25 +02:00
|
|
|
|
bind \*(aq\*(haX\*(aq=prefix\-2
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
bind \*(aq\*(ha[[\*(aq=prefix\-2
|
|
|
|
|
bind \*(aq\*(haXA\*(aq=up\-history
|
|
|
|
|
bind \*(aq\*(haXB\*(aq=down\-history
|
|
|
|
|
bind \*(aq\*(haXC\*(aq=forward\-char
|
|
|
|
|
bind \*(aq\*(haXD\*(aq=backward\-char
|
|
|
|
|
bind \*(aq\*(haX1\*(TI\*(aq=beginning\-of\-line
|
|
|
|
|
bind \*(aq\*(haX7\*(TI\*(aq=beginning\-of\-line
|
|
|
|
|
bind \*(aq\*(haXH\*(aq=beginning\-of\-line
|
|
|
|
|
bind \*(aq\*(haX4\*(TI\*(aq=end\-of\-line
|
|
|
|
|
bind \*(aq\*(haX8\*(TI\*(aq=end\-of\-line
|
|
|
|
|
bind \*(aq\*(haXF\*(aq=end\-of\-line
|
|
|
|
|
bind \*(aq\*(haX3\*(TI\*(aq=delete\-char\-forward
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic break Op Ar level
|
|
|
|
|
Exit the
|
|
|
|
|
.Ar level Ns th
|
|
|
|
|
inner-most
|
|
|
|
|
.Ic for ,
|
|
|
|
|
.Ic select ,
|
|
|
|
|
.Ic until ,
|
|
|
|
|
or
|
|
|
|
|
.Ic while
|
|
|
|
|
loop.
|
|
|
|
|
.Ar level
|
|
|
|
|
defaults to 1.
|
|
|
|
|
.Pp
|
2010-09-05 21:51:35 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic builtin
|
|
|
|
|
.Op Fl \-
|
|
|
|
|
.Ar command Op Ar arg ...
|
|
|
|
|
.Xc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Execute the built-in command
|
|
|
|
|
.Ar command .
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
2010-08-28 19:21:46 +02:00
|
|
|
|
.Ic cat
|
2011-02-18 23:26:13 +01:00
|
|
|
|
.Op Fl u
|
2010-08-28 19:21:46 +02:00
|
|
|
|
.Op Ar
|
|
|
|
|
.Xc
|
|
|
|
|
Read files sequentially, in command line order, and write them to
|
|
|
|
|
standard output.
|
2011-02-18 23:26:13 +01:00
|
|
|
|
If a
|
2010-08-28 19:21:46 +02:00
|
|
|
|
.Ar file
|
|
|
|
|
is a single dash
|
|
|
|
|
.Pq Sq -
|
|
|
|
|
or absent, read from standard input.
|
2011-07-07 23:24:53 +02:00
|
|
|
|
Unless compiled with
|
|
|
|
|
.Dv MKSH_NO_EXTERNAL_CAT ,
|
|
|
|
|
if any options are given, an external
|
2010-08-28 19:21:46 +02:00
|
|
|
|
.Xr cat 1
|
2011-02-18 23:26:13 +01:00
|
|
|
|
utility is invoked instead if called from the shell.
|
|
|
|
|
For direct builtin calls, the
|
|
|
|
|
.Tn POSIX
|
|
|
|
|
.Fl u
|
|
|
|
|
option is supported as a no-op.
|
2010-08-28 19:21:46 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic cd
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Op Fl L
|
|
|
|
|
.Op Ar dir
|
|
|
|
|
.Xc
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic cd
|
|
|
|
|
.Fl P Op Fl e
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar dir
|
|
|
|
|
.Xc
|
2009-08-30 23:02:01 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic chdir
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Op Fl eLP
|
2009-08-30 23:02:01 +02:00
|
|
|
|
.Op Ar dir
|
|
|
|
|
.Xc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Set the working directory to
|
|
|
|
|
.Ar dir .
|
|
|
|
|
If the parameter
|
|
|
|
|
.Ev CDPATH
|
|
|
|
|
is set, it lists the search path for the directory containing
|
|
|
|
|
.Ar dir .
|
|
|
|
|
A
|
|
|
|
|
.Dv NULL
|
|
|
|
|
path means the current directory.
|
|
|
|
|
If
|
|
|
|
|
.Ar dir
|
|
|
|
|
is found in any component of the
|
|
|
|
|
.Ev CDPATH
|
|
|
|
|
search path other than the
|
|
|
|
|
.Dv NULL
|
|
|
|
|
path, the name of the new working directory will be written to standard output.
|
|
|
|
|
If
|
|
|
|
|
.Ar dir
|
|
|
|
|
is missing, the home directory
|
|
|
|
|
.Ev HOME
|
|
|
|
|
is used.
|
|
|
|
|
If
|
|
|
|
|
.Ar dir
|
|
|
|
|
is
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \- ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
the previous working directory is used (see the
|
|
|
|
|
.Ev OLDPWD
|
|
|
|
|
parameter).
|
|
|
|
|
.Pp
|
|
|
|
|
If the
|
|
|
|
|
.Fl L
|
|
|
|
|
option (logical path) is used or if the
|
|
|
|
|
.Ic physical
|
|
|
|
|
option isn't set (see the
|
|
|
|
|
.Ic set
|
|
|
|
|
command below), references to
|
|
|
|
|
.Sq ..
|
|
|
|
|
in
|
|
|
|
|
.Ar dir
|
|
|
|
|
are relative to the path used to get to the directory.
|
|
|
|
|
If the
|
|
|
|
|
.Fl P
|
|
|
|
|
option (physical path) is used or if the
|
|
|
|
|
.Ic physical
|
|
|
|
|
option is set,
|
|
|
|
|
.Sq ..
|
|
|
|
|
is relative to the filesystem directory tree.
|
|
|
|
|
The
|
|
|
|
|
.Ev PWD
|
|
|
|
|
and
|
|
|
|
|
.Ev OLDPWD
|
|
|
|
|
parameters are updated to reflect the current and old working directory,
|
|
|
|
|
respectively.
|
2011-05-29 04:18:57 +02:00
|
|
|
|
If the
|
|
|
|
|
.Fl e
|
|
|
|
|
option is set for physical filesystem traversal, and
|
|
|
|
|
.Ev PWD
|
|
|
|
|
could not be set, the exit code is 1; greater than 1 if an
|
|
|
|
|
error occurred, 0 otherwise.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic cd
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Op Fl eLP
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ar old new
|
|
|
|
|
.Xc
|
2009-08-30 23:02:01 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic chdir
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Op Fl eLP
|
2009-08-30 23:02:01 +02:00
|
|
|
|
.Ar old new
|
|
|
|
|
.Xc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The string
|
|
|
|
|
.Ar new
|
|
|
|
|
is substituted for
|
|
|
|
|
.Ar old
|
|
|
|
|
in the current directory, and the shell attempts to change to the new
|
|
|
|
|
directory.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic command
|
|
|
|
|
.Op Fl pVv
|
|
|
|
|
.Ar cmd
|
|
|
|
|
.Op Ar arg ...
|
|
|
|
|
.Xc
|
|
|
|
|
If neither the
|
|
|
|
|
.Fl v
|
|
|
|
|
nor
|
|
|
|
|
.Fl V
|
|
|
|
|
option is given,
|
|
|
|
|
.Ar cmd
|
|
|
|
|
is executed exactly as if
|
|
|
|
|
.Ic command
|
|
|
|
|
had not been specified, with two exceptions:
|
|
|
|
|
firstly,
|
|
|
|
|
.Ar cmd
|
|
|
|
|
cannot be a shell function;
|
|
|
|
|
and secondly, special built-in commands lose their specialness
|
|
|
|
|
(i.e. redirection and utility errors do not cause the shell to
|
|
|
|
|
exit, and command assignments are not permanent).
|
|
|
|
|
.Pp
|
|
|
|
|
If the
|
|
|
|
|
.Fl p
|
|
|
|
|
option is given, a default search path is used instead of the current value of
|
2006-11-09 23:11:08 +01:00
|
|
|
|
.Ev PATH ,
|
|
|
|
|
the actual value of which is system dependent.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
If the
|
|
|
|
|
.Fl v
|
|
|
|
|
option is given, instead of executing
|
|
|
|
|
.Ar cmd ,
|
|
|
|
|
information about what would be executed is given (and the same is done for
|
|
|
|
|
.Ar arg ... ) .
|
|
|
|
|
For special and regular built-in commands and functions, their names are simply
|
|
|
|
|
printed; for aliases, a command that defines them is printed; and for commands
|
|
|
|
|
found by searching the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameter, the full path of the command is printed.
|
|
|
|
|
If no command is found
|
|
|
|
|
(i.e. the path search fails), nothing is printed and
|
|
|
|
|
.Ic command
|
|
|
|
|
exits with a non-zero status.
|
|
|
|
|
The
|
|
|
|
|
.Fl V
|
|
|
|
|
option is like the
|
|
|
|
|
.Fl v
|
|
|
|
|
option, except it is more verbose.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic continue Op Ar level
|
|
|
|
|
Jumps to the beginning of the
|
|
|
|
|
.Ar level Ns th
|
|
|
|
|
inner-most
|
|
|
|
|
.Ic for ,
|
|
|
|
|
.Ic select ,
|
|
|
|
|
.Ic until ,
|
|
|
|
|
or
|
|
|
|
|
.Ic while
|
|
|
|
|
loop.
|
|
|
|
|
.Ar level
|
|
|
|
|
defaults to 1.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic echo
|
|
|
|
|
.Op Fl Een
|
|
|
|
|
.Op Ar arg ...
|
|
|
|
|
.Xc
|
2011-07-16 19:07:48 +02:00
|
|
|
|
.Em Warning:
|
|
|
|
|
this utility is not portable; use the Korn shell builtin
|
|
|
|
|
.Ic print
|
|
|
|
|
instead.
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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
|
|
|
|
|
.Ql \ec .
|
|
|
|
|
See the
|
|
|
|
|
.Ic print
|
|
|
|
|
command below for a list of other backslash sequences that are recognised.
|
|
|
|
|
.Pp
|
|
|
|
|
The options are provided for compatibility with
|
|
|
|
|
.Bx
|
|
|
|
|
shell scripts.
|
|
|
|
|
The
|
|
|
|
|
.Fl n
|
|
|
|
|
option suppresses the trailing newline,
|
|
|
|
|
.Fl e
|
|
|
|
|
enables backslash interpretation (a no-op, since this is normally done), and
|
|
|
|
|
.Fl E
|
|
|
|
|
suppresses backslash interpretation.
|
|
|
|
|
.Pp
|
2009-03-22 19:09:17 +01:00
|
|
|
|
If the
|
2010-01-28 16:18:51 +01:00
|
|
|
|
.Ic posix
|
|
|
|
|
or
|
2009-10-02 20:08:37 +02:00
|
|
|
|
.Ic sh
|
• more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
bin/echo bin/kill bin/pwd bin/sleep (exact matches)
bin/test bin/[ (were scripts before)
bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 02:18:23 +01:00
|
|
|
|
option is set or this is a direct builtin call, only the first argument
|
|
|
|
|
is treated as an option, and only if it is exactly
|
2009-03-22 19:09:17 +01:00
|
|
|
|
.Dq Fl n .
|
2009-10-10 23:17:31 +02:00
|
|
|
|
Backslash interpretation is disabled.
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ic eval Ar command ...
|
|
|
|
|
The arguments are concatenated (with spaces between them) to form a single
|
|
|
|
|
string which the shell then parses and executes in the current environment.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic exec
|
|
|
|
|
.Op Ar command Op Ar arg ...
|
|
|
|
|
.Xc
|
|
|
|
|
The command is executed without forking, replacing the shell process.
|
|
|
|
|
.Pp
|
|
|
|
|
If no command is given except for I/O redirection, the I/O redirection is
|
|
|
|
|
permanent and the shell is
|
|
|
|
|
not replaced.
|
|
|
|
|
Any file descriptors greater than 2 which are opened or
|
|
|
|
|
.Xr dup 2 Ns 'd
|
|
|
|
|
in this way are not made available to other executed commands (i.e. commands
|
|
|
|
|
that are not built-in to the shell).
|
|
|
|
|
Note that the Bourne shell differs here;
|
|
|
|
|
it does pass these file descriptors on.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic exit Op Ar status
|
|
|
|
|
The shell exits with the specified exit status.
|
|
|
|
|
If
|
|
|
|
|
.Ar status
|
|
|
|
|
is not specified, the exit status is the current value of the
|
|
|
|
|
.Ic $?\&
|
|
|
|
|
parameter.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic export
|
|
|
|
|
.Op Fl p
|
|
|
|
|
.Op Ar parameter Ns Op = Ns Ar value
|
|
|
|
|
.Xc
|
|
|
|
|
Sets the export attribute of the named parameters.
|
|
|
|
|
Exported parameters are passed in the environment to executed commands.
|
|
|
|
|
If values are specified, the named parameters are also assigned.
|
|
|
|
|
.Pp
|
2011-10-24 21:41:13 +02:00
|
|
|
|
If no parameters are specified, all parameters with the export attribute
|
|
|
|
|
set are printed one per line; either their names, or, if a
|
|
|
|
|
.Ql \-
|
|
|
|
|
with no option letter is specified, name=value pairs, or, with
|
|
|
|
|
.Fl p ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic export
|
2011-10-24 21:41:13 +02:00
|
|
|
|
commands suitable for re-entry.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.It Ic false
|
|
|
|
|
A command that exits with a non-zero status.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic fc
|
|
|
|
|
.Oo Fl e Ar editor \*(Ba
|
|
|
|
|
.Fl l Op Fl n Oc
|
|
|
|
|
.Op Fl r
|
|
|
|
|
.Op Ar first Op Ar last
|
|
|
|
|
.Xc
|
|
|
|
|
.Ar first
|
|
|
|
|
and
|
|
|
|
|
.Ar last
|
|
|
|
|
select commands from the history.
|
|
|
|
|
Commands can be selected by history number
|
|
|
|
|
or a string specifying the most recent command starting with that string.
|
|
|
|
|
The
|
|
|
|
|
.Fl l
|
|
|
|
|
option lists the command on standard output, and
|
|
|
|
|
.Fl n
|
|
|
|
|
inhibits the default command numbers.
|
|
|
|
|
The
|
|
|
|
|
.Fl r
|
|
|
|
|
option reverses the order of the list.
|
|
|
|
|
Without
|
|
|
|
|
.Fl l ,
|
|
|
|
|
the selected commands are edited by the editor specified with the
|
|
|
|
|
.Fl e
|
|
|
|
|
option, or if no
|
|
|
|
|
.Fl e
|
|
|
|
|
is specified, the editor specified by the
|
|
|
|
|
.Ev FCEDIT
|
|
|
|
|
parameter (if this parameter is not set,
|
|
|
|
|
.Pa /bin/ed
|
|
|
|
|
is used), and then executed by the shell.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic fc
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Cm \-e \- \*(Ba Fl s
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Fl g
|
|
|
|
|
.Op Ar old Ns = Ns Ar new
|
|
|
|
|
.Op Ar prefix
|
|
|
|
|
.Xc
|
|
|
|
|
Re-execute the selected command (the previous command by default) after
|
|
|
|
|
performing the optional substitution of
|
|
|
|
|
.Ar old
|
|
|
|
|
with
|
|
|
|
|
.Ar new .
|
|
|
|
|
If
|
|
|
|
|
.Fl g
|
|
|
|
|
is specified, all occurrences of
|
|
|
|
|
.Ar old
|
|
|
|
|
are replaced with
|
|
|
|
|
.Ar new .
|
|
|
|
|
The meaning of
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Cm \-e \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and
|
|
|
|
|
.Fl s
|
|
|
|
|
is identical: re-execute the selected command without invoking an editor.
|
2012-04-07 13:19:53 +02:00
|
|
|
|
This command is usually accessed with the predefined:
|
2009-05-27 21:52:38 +02:00
|
|
|
|
.Ic alias r=\*(aqfc \-e \-\*(aq
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.It Ic fg Op Ar job ...
|
|
|
|
|
Resume the specified job(s) in the foreground.
|
|
|
|
|
If no jobs are specified,
|
|
|
|
|
.Ic %+
|
|
|
|
|
is assumed.
|
|
|
|
|
See
|
|
|
|
|
.Sx Job control
|
|
|
|
|
below for more information.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic getopts
|
|
|
|
|
.Ar optstring name
|
|
|
|
|
.Op Ar arg ...
|
|
|
|
|
.Xc
|
|
|
|
|
Used by shell procedures to parse the specified arguments (or positional
|
|
|
|
|
parameters, if no arguments are given) and to check for legal options.
|
|
|
|
|
.Ar optstring
|
|
|
|
|
contains the option letters that
|
|
|
|
|
.Ic getopts
|
|
|
|
|
is to recognise.
|
|
|
|
|
If a letter is followed by a colon, the option is expected to
|
|
|
|
|
have an argument.
|
|
|
|
|
Options that do not take arguments may be grouped in a single argument.
|
|
|
|
|
If an option takes an argument and the option character is not the
|
|
|
|
|
last character of the argument it is found in, the remainder of the argument is
|
|
|
|
|
taken to be the option's argument; otherwise, the next argument is the option's
|
|
|
|
|
argument.
|
|
|
|
|
.Pp
|
|
|
|
|
Each time
|
|
|
|
|
.Ic getopts
|
|
|
|
|
is invoked, it places the next option in the shell parameter
|
|
|
|
|
.Ar name
|
2006-08-01 16:09:20 +02:00
|
|
|
|
and the index of the argument to be processed by the next call to
|
|
|
|
|
.Ic getopts
|
|
|
|
|
in the shell parameter
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ev OPTIND .
|
|
|
|
|
If the option was introduced with a
|
|
|
|
|
.Ql + ,
|
|
|
|
|
the option placed in
|
|
|
|
|
.Ar name
|
|
|
|
|
is prefixed with a
|
|
|
|
|
.Ql + .
|
|
|
|
|
When an option requires an argument,
|
|
|
|
|
.Ic getopts
|
|
|
|
|
places it in the shell parameter
|
|
|
|
|
.Ev OPTARG .
|
|
|
|
|
.Pp
|
|
|
|
|
When an illegal option or a missing option argument is encountered, a question
|
|
|
|
|
mark or a colon is placed in
|
|
|
|
|
.Ar name
|
|
|
|
|
(indicating an illegal option or missing argument, respectively) and
|
|
|
|
|
.Ev OPTARG
|
|
|
|
|
is set to the option character that caused the problem.
|
|
|
|
|
Furthermore, if
|
|
|
|
|
.Ar optstring
|
|
|
|
|
does not begin with a colon, a question mark is placed in
|
|
|
|
|
.Ar name ,
|
|
|
|
|
.Ev OPTARG
|
|
|
|
|
is unset, and an error message is printed to standard error.
|
|
|
|
|
.Pp
|
|
|
|
|
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
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \- ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or when a
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-\-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
argument is encountered.
|
|
|
|
|
.Pp
|
|
|
|
|
Option parsing can be reset by setting
|
|
|
|
|
.Ev OPTIND
|
|
|
|
|
to 1 (this is done automatically whenever the shell or a shell procedure is
|
|
|
|
|
invoked).
|
|
|
|
|
.Pp
|
|
|
|
|
Warning: Changing the value of the shell parameter
|
|
|
|
|
.Ev OPTIND
|
|
|
|
|
to a value other than 1, or parsing different sets of arguments without
|
|
|
|
|
resetting
|
|
|
|
|
.Ev OPTIND ,
|
|
|
|
|
may lead to unexpected results.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic hash
|
|
|
|
|
.Op Fl r
|
|
|
|
|
.Op Ar name ...
|
|
|
|
|
.Xc
|
|
|
|
|
Without arguments, any hashed executable command pathnames are listed.
|
|
|
|
|
The
|
|
|
|
|
.Fl r
|
|
|
|
|
option causes all hashed commands to be removed from the hash table.
|
|
|
|
|
Each
|
|
|
|
|
.Ar name
|
|
|
|
|
is searched as if it were a command name and added to the hash table if it is
|
|
|
|
|
an executable command.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic jobs
|
|
|
|
|
.Op Fl lnp
|
|
|
|
|
.Op Ar job ...
|
|
|
|
|
.Xc
|
|
|
|
|
Display information about the specified job(s); if no jobs are specified, all
|
|
|
|
|
jobs are displayed.
|
|
|
|
|
The
|
|
|
|
|
.Fl n
|
|
|
|
|
option causes information to be displayed only for jobs that have changed
|
|
|
|
|
state since the last notification.
|
|
|
|
|
If the
|
|
|
|
|
.Fl l
|
|
|
|
|
option is used, the process ID of each process in a job is also listed.
|
|
|
|
|
The
|
|
|
|
|
.Fl p
|
|
|
|
|
option causes only the process group of each job to be printed.
|
|
|
|
|
See
|
|
|
|
|
.Sx Job control
|
|
|
|
|
below for the format of
|
|
|
|
|
.Ar job
|
|
|
|
|
and the displayed job.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic kill
|
|
|
|
|
.Oo Fl s Ar signame \*(Ba
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.No \- Ns Ar signum \*(Ba
|
|
|
|
|
.No \- Ns Ar signame Oc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.No { Ar job \*(Ba pid \*(Ba pgrp No }
|
|
|
|
|
.Ar ...
|
|
|
|
|
.Xc
|
|
|
|
|
Send the specified signal to the specified jobs, process IDs, or process
|
|
|
|
|
groups.
|
|
|
|
|
If no signal is specified, the
|
|
|
|
|
.Dv TERM
|
|
|
|
|
signal is sent.
|
|
|
|
|
If a job is specified, the signal is sent to the job's process group.
|
|
|
|
|
See
|
|
|
|
|
.Sx Job control
|
|
|
|
|
below for the format of
|
|
|
|
|
.Ar job .
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic kill
|
|
|
|
|
.Fl l
|
|
|
|
|
.Op Ar exit-status ...
|
|
|
|
|
.Xc
|
|
|
|
|
Print the signal name corresponding to
|
|
|
|
|
.Ar exit-status .
|
|
|
|
|
If no arguments are specified, a list of all the signals, their numbers, and
|
|
|
|
|
a short description of them are printed.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic let Op Ar expression ...
|
|
|
|
|
Each expression is evaluated (see
|
|
|
|
|
.Sx Arithmetic expressions
|
|
|
|
|
above).
|
|
|
|
|
If all expressions are successfully evaluated, the exit status is 0 (1)
|
|
|
|
|
if the last expression evaluated to non-zero (zero).
|
|
|
|
|
If an error occurs during
|
|
|
|
|
the parsing or evaluation of an expression, the exit status is greater than 1.
|
|
|
|
|
Since expressions may need to be quoted,
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.No \&(( Ar expr No ))
|
2005-05-23 05:06:10 +02:00
|
|
|
|
is syntactic sugar for
|
|
|
|
|
.No let \&" Ns Ar expr Ns \&" .
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
2005-10-21 14:41:56 +02:00
|
|
|
|
.Ic mknod
|
|
|
|
|
.Op Fl m Ar mode
|
|
|
|
|
.Ar name
|
2010-04-09 20:59:30 +02:00
|
|
|
|
.Cm b\*(Bac
|
2005-10-21 14:41:56 +02:00
|
|
|
|
.Ar major minor
|
|
|
|
|
.Xc
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic mknod
|
|
|
|
|
.Op Fl m Ar mode
|
|
|
|
|
.Ar name
|
|
|
|
|
.Cm p
|
|
|
|
|
.Xc
|
|
|
|
|
Create a device special file.
|
|
|
|
|
The file type may be
|
|
|
|
|
.Cm b
|
|
|
|
|
(block type device),
|
|
|
|
|
.Cm c
|
|
|
|
|
(character type device),
|
|
|
|
|
or
|
|
|
|
|
.Cm p
|
2011-11-30 22:34:15 +01:00
|
|
|
|
.Pq named pipe , Tn FIFO .
|
2005-10-21 14:41:56 +02:00
|
|
|
|
The file created may be modified according to its
|
|
|
|
|
.Ar mode
|
|
|
|
|
(via the
|
|
|
|
|
.Fl m
|
|
|
|
|
option),
|
|
|
|
|
.Ar major
|
|
|
|
|
(major device number),
|
|
|
|
|
and
|
|
|
|
|
.Ar minor
|
|
|
|
|
(minor device number).
|
|
|
|
|
.Pp
|
|
|
|
|
See
|
|
|
|
|
.Xr mknod 8
|
|
|
|
|
for further information.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic print
|
|
|
|
|
.Oo Fl nprsu Ns Oo Ar n Oc \*(Ba
|
|
|
|
|
.Fl R Op Fl en Oc
|
|
|
|
|
.Op Ar argument ...
|
|
|
|
|
.Xc
|
|
|
|
|
.Ic print
|
|
|
|
|
prints its arguments on the standard output, separated by spaces and
|
|
|
|
|
terminated with a newline.
|
|
|
|
|
The
|
|
|
|
|
.Fl n
|
|
|
|
|
option suppresses the newline.
|
|
|
|
|
By default, certain C escapes are translated.
|
2009-09-19 23:54:46 +02:00
|
|
|
|
These include these mentioned in
|
2009-09-19 17:16:05 +02:00
|
|
|
|
.Sx Backslash expansion
|
|
|
|
|
above, as well as
|
|
|
|
|
.Ql \ec ,
|
|
|
|
|
which is equivalent to using the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Fl n
|
|
|
|
|
option.
|
2009-09-19 23:54:46 +02:00
|
|
|
|
Backslash expansion may be inhibited with the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Fl r
|
|
|
|
|
option.
|
|
|
|
|
The
|
|
|
|
|
.Fl s
|
|
|
|
|
option prints to the history file instead of standard output; the
|
|
|
|
|
.Fl u
|
|
|
|
|
option prints to file descriptor
|
|
|
|
|
.Ar n
|
|
|
|
|
.Po
|
|
|
|
|
.Ar n
|
|
|
|
|
defaults to 1 if omitted
|
|
|
|
|
.Pc ;
|
|
|
|
|
and the
|
|
|
|
|
.Fl p
|
|
|
|
|
option prints to the co-process (see
|
|
|
|
|
.Sx Co-processes
|
|
|
|
|
above).
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fl R
|
|
|
|
|
option is used to emulate, to some degree, the
|
|
|
|
|
.Bx
|
|
|
|
|
.Xr echo 1
|
2006-01-30 13:37:24 +01:00
|
|
|
|
command which does not process
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql \e
|
|
|
|
|
sequences unless the
|
|
|
|
|
.Fl e
|
|
|
|
|
option is given.
|
|
|
|
|
As above, the
|
|
|
|
|
.Fl n
|
|
|
|
|
option suppresses the trailing newline.
|
|
|
|
|
.Pp
|
2009-08-30 13:38:44 +02:00
|
|
|
|
.It Ic printf Ar format Op Ar arguments ...
|
|
|
|
|
Formatted output.
|
2012-08-03 20:34:31 +02:00
|
|
|
|
Approximately the same as the
|
|
|
|
|
.Xr printf 1 ,
|
|
|
|
|
utility, except it uses the same
|
2009-09-20 14:12:00 +02:00
|
|
|
|
.Sx Backslash expansion
|
2012-11-30 20:25:08 +01:00
|
|
|
|
and I/O code and does hot handle floating point as the rest of
|
2009-09-20 14:12:00 +02:00
|
|
|
|
.Nm mksh .
|
2009-08-30 13:38:44 +02:00
|
|
|
|
This is not normally part of
|
2010-07-18 00:09:40 +02:00
|
|
|
|
.Nm mksh ;
|
2009-08-30 13:38:44 +02:00
|
|
|
|
however, distributors may have added this as builtin as a speed hack.
|
2012-08-03 20:34:31 +02:00
|
|
|
|
Do not use in new code.
|
2009-08-30 13:38:44 +02:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ic pwd Op Fl LP
|
|
|
|
|
Print the present working directory.
|
|
|
|
|
If the
|
|
|
|
|
.Fl L
|
|
|
|
|
option is used or if the
|
|
|
|
|
.Ic physical
|
|
|
|
|
option isn't set (see the
|
|
|
|
|
.Ic set
|
|
|
|
|
command below), the logical path is printed (i.e. the path used to
|
|
|
|
|
.Ic cd
|
|
|
|
|
to the current directory).
|
|
|
|
|
If the
|
|
|
|
|
.Fl P
|
|
|
|
|
option (physical path) is used or if the
|
|
|
|
|
.Ic physical
|
|
|
|
|
option is set, the path determined from the filesystem (by following
|
|
|
|
|
.Sq ..
|
|
|
|
|
directories to the root directory) is printed.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic read
|
2012-04-14 14:51:34 +02:00
|
|
|
|
.Op Fl A \*(Ba Fl a
|
2011-05-29 04:18:57 +02:00
|
|
|
|
.Op Fl d Ar x
|
|
|
|
|
.Oo Fl N Ar z \*(Ba
|
|
|
|
|
.Fl n Ar z Oc
|
|
|
|
|
.Oo Fl p \*(Ba
|
|
|
|
|
.Fl u Ns Op Ar n
|
|
|
|
|
.Oc Op Fl t Ar n
|
|
|
|
|
.Op Fl rs
|
|
|
|
|
.Op Ar p ...
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
2011-05-29 04:18:57 +02:00
|
|
|
|
Reads a line of input, separates the input into fields using the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ev IFS
|
|
|
|
|
parameter (see
|
|
|
|
|
.Sx Substitution
|
2011-05-29 04:18:57 +02:00
|
|
|
|
above), and assigns each field to the specified parameters
|
|
|
|
|
.Ar p .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If no parameters are specified, the
|
|
|
|
|
.Ev REPLY
|
2011-05-29 04:18:57 +02:00
|
|
|
|
parameter is used to store the result.
|
|
|
|
|
With the
|
|
|
|
|
.Fl A
|
|
|
|
|
and
|
|
|
|
|
.Fl a
|
|
|
|
|
options, only no or one parameter is accepted.
|
|
|
|
|
If there are more parameters than fields, the extra parameters are set to
|
|
|
|
|
the empty string or 0; if there are more fields than parameters, the last
|
|
|
|
|
parameter is assigned the remaining fields (including the word separators).
|
|
|
|
|
.Pp
|
|
|
|
|
The options are as follows:
|
|
|
|
|
.Bl -tag -width XuXnX
|
|
|
|
|
.It Fl A
|
|
|
|
|
Store the result into the parameter
|
|
|
|
|
.Ar p
|
|
|
|
|
(or
|
|
|
|
|
.Ev REPLY )
|
|
|
|
|
as array of words.
|
|
|
|
|
.It Fl a
|
|
|
|
|
Store the result without word splitting into the parameter
|
|
|
|
|
.Ar p
|
|
|
|
|
(or
|
|
|
|
|
.Ev REPLY )
|
|
|
|
|
as array of characters (wide characters if the
|
|
|
|
|
.Ic utf8\-mode
|
|
|
|
|
option is enacted, octets otherwise).
|
|
|
|
|
.It Fl d Ar x
|
|
|
|
|
Use the first byte of
|
|
|
|
|
.Ar x ,
|
|
|
|
|
.Dv NUL
|
|
|
|
|
if empty, instead of the ASCII newline character as input line delimiter.
|
|
|
|
|
.It Fl N Ar z
|
|
|
|
|
Instead of reading till end-of-line, read exactly
|
|
|
|
|
.Ar z
|
|
|
|
|
bytes; less if EOF or a timeout occurs.
|
|
|
|
|
.It Fl n Ar z
|
|
|
|
|
Instead of reading till end-of-line, read up to
|
|
|
|
|
.Ar z
|
|
|
|
|
bytes but return as soon as any bytes are read, e.g.\& from a
|
|
|
|
|
slow terminal device, or if EOF or a timeout occurs.
|
|
|
|
|
.It Fl p
|
|
|
|
|
Read from the currently active co-process, see
|
|
|
|
|
.Sx Co-processes
|
|
|
|
|
above for details on this.
|
|
|
|
|
.It Fl u Ns Op Ar n
|
|
|
|
|
Read from the file descriptor
|
|
|
|
|
.Ar n
|
|
|
|
|
(defaults to 0, i.e.\& standard input).
|
|
|
|
|
The argument must immediately follow the option character.
|
|
|
|
|
.It Fl t Ar n
|
|
|
|
|
Interrupt reading after
|
|
|
|
|
.Ar n
|
|
|
|
|
seconds (specified as positive decimal value with an optional fractional part).
|
|
|
|
|
.It Fl r
|
|
|
|
|
Normally, the ASCII backslash character escapes the special
|
|
|
|
|
meaning of the following character and is stripped from the input;
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic read
|
2011-05-29 04:18:57 +02:00
|
|
|
|
does not stop when encountering a backslash-newline sequence and
|
|
|
|
|
does not store that newline in the result.
|
|
|
|
|
This option enables raw mode, in which backslashes are not processed.
|
|
|
|
|
.It Fl s
|
|
|
|
|
The input line is saved to the history.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
If the input is a terminal, both the
|
|
|
|
|
.Fl N
|
|
|
|
|
and
|
|
|
|
|
.Fl n
|
|
|
|
|
options set it into raw mode;
|
|
|
|
|
they read an entire file if \-1 is passed as
|
|
|
|
|
.Ar z
|
|
|
|
|
argument.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.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
|
|
|
|
|
.Xr tty 4
|
|
|
|
|
(e.g.\&
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ic read nfoo?\*(aqnumber of foos: \*(aq ) .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
2011-05-29 04:18:57 +02:00
|
|
|
|
If no input is read or a timeout occurred,
|
|
|
|
|
.Ic read
|
|
|
|
|
exits with a non-zero status.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
2006-01-27 11:58:36 +01:00
|
|
|
|
Another handy set of tricks:
|
|
|
|
|
If
|
|
|
|
|
.Ic read
|
|
|
|
|
is run in a loop such as
|
|
|
|
|
.Ic while read foo; do ...; done
|
2009-11-22 15:23:21 +01:00
|
|
|
|
then leading whitespace will be removed (IFS) and backslashes processed.
|
2006-01-27 11:58:36 +01:00
|
|
|
|
You might want to use
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic while IFS= read \-r foo; do ...; done
|
2009-11-22 15:23:21 +01:00
|
|
|
|
for pristine I/O.
|
2011-05-29 04:18:57 +02:00
|
|
|
|
Similarily, when using the
|
|
|
|
|
.Fl a
|
|
|
|
|
option, use of the
|
|
|
|
|
.Fl r
|
|
|
|
|
option might be prudent; the same applies for:
|
|
|
|
|
.Bd -literal -offset indent
|
2011-05-29 19:01:26 +02:00
|
|
|
|
find . \-type f \-print0 \*(Ba \e
|
2011-05-29 04:18:57 +02:00
|
|
|
|
while IFS= read \-d \*(aq\*(aq \-r filename; do
|
2012-04-14 14:51:34 +02:00
|
|
|
|
print \-r \-\- "found \*(Lt${filename#./}\*(Gt"
|
2011-05-29 04:18:57 +02:00
|
|
|
|
done
|
|
|
|
|
.Ed
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Pp
|
|
|
|
|
The inner loop will be executed in a subshell and variable changes
|
|
|
|
|
cannot be propagated if executed in a pipeline:
|
|
|
|
|
.Bd -literal -offset indent
|
2010-01-28 16:33:11 +01:00
|
|
|
|
bar \*(Ba baz \*(Ba while read foo; do ...; done
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
Use co-processes instead:
|
|
|
|
|
.Bd -literal -offset indent
|
2010-01-28 16:33:11 +01:00
|
|
|
|
bar \*(Ba baz \*(Ba&
|
2008-03-03 23:38:41 +01:00
|
|
|
|
while read \-p foo; do ...; done
|
|
|
|
|
exec 3\*(Gt&p; exec 3\*(Gt&\-
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic readonly
|
|
|
|
|
.Op Fl p
|
|
|
|
|
.Oo Ar parameter
|
|
|
|
|
.Op Ns = Ns Ar value
|
|
|
|
|
.Ar ... Oc
|
|
|
|
|
.Xc
|
|
|
|
|
Sets the read-only attribute of the named parameters.
|
|
|
|
|
If values are given,
|
|
|
|
|
parameters are set to them before setting the attribute.
|
|
|
|
|
Once a parameter is
|
|
|
|
|
made read-only, it cannot be unset and its value cannot be changed.
|
|
|
|
|
.Pp
|
|
|
|
|
If no parameters are specified, the names of all parameters with the read-only
|
|
|
|
|
attribute are printed one per line, unless the
|
|
|
|
|
.Fl p
|
|
|
|
|
option is used, in which case
|
|
|
|
|
.Ic readonly
|
|
|
|
|
commands defining all read-only parameters, including their values, are
|
|
|
|
|
printed.
|
|
|
|
|
.Pp
|
2008-05-17 20:27:57 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic realpath
|
|
|
|
|
.Op Fl \-
|
|
|
|
|
.Ar name
|
|
|
|
|
.Xc
|
|
|
|
|
Prints the resolved absolute pathname corresponding to
|
|
|
|
|
.Ar name .
|
2010-08-24 16:42:04 +02:00
|
|
|
|
If
|
|
|
|
|
.Ar name
|
|
|
|
|
ends with a slash
|
|
|
|
|
.Pq Sq / ,
|
|
|
|
|
it's also checked for existence and whether it is a directory; otherwise,
|
|
|
|
|
.Ic realpath
|
|
|
|
|
returns 0 if the pathname either exists or can be created immediately,
|
|
|
|
|
i.e. all but the last component exist and are directories.
|
2008-05-17 20:27:57 +02:00
|
|
|
|
.Pp
|
2010-09-05 21:51:35 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic rename
|
|
|
|
|
.Op Fl \-
|
|
|
|
|
.Ar from to
|
|
|
|
|
.Xc
|
2007-08-20 00:06:27 +02:00
|
|
|
|
Renames the file
|
|
|
|
|
.Ar from
|
|
|
|
|
to
|
|
|
|
|
.Ar to .
|
|
|
|
|
Both must be complete pathnames and on the same device.
|
|
|
|
|
This builtin is intended for emergency situations where
|
|
|
|
|
.Pa /bin/mv
|
|
|
|
|
becomes unusable, and directly calls
|
|
|
|
|
.Xr rename 2 .
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ic return Op Ar status
|
|
|
|
|
Returns from a function or
|
|
|
|
|
.Ic .\&
|
|
|
|
|
script, with exit status
|
|
|
|
|
.Ar status .
|
|
|
|
|
If no
|
|
|
|
|
.Ar status
|
|
|
|
|
is given, the exit status of the last executed command is used.
|
|
|
|
|
If used outside of a function or
|
|
|
|
|
.Ic .\&
|
|
|
|
|
script, it has the same effect as
|
|
|
|
|
.Ic exit .
|
|
|
|
|
Note that
|
|
|
|
|
.Nm
|
|
|
|
|
treats both profile and
|
|
|
|
|
.Ev ENV
|
|
|
|
|
files as
|
|
|
|
|
.Ic .\&
|
|
|
|
|
scripts, while the original Korn shell only treats profiles as
|
|
|
|
|
.Ic .\&
|
|
|
|
|
scripts.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
2009-09-20 18:40:58 +02:00
|
|
|
|
.Ic set Op Ic +\-abCefhiklmnprsUuvXx
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Op Ic +\-o Ar option
|
|
|
|
|
.Op Ic +\-A Ar name
|
|
|
|
|
.Op Fl \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar arg ...
|
|
|
|
|
.Xc
|
|
|
|
|
The
|
|
|
|
|
.Ic set
|
|
|
|
|
command can be used to set
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Pq Ic \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or clear
|
|
|
|
|
.Pq Ic +
|
|
|
|
|
shell options, set the positional parameters, or set an array parameter.
|
|
|
|
|
Options can be changed using the
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Cm +\-o Ar option
|
2005-05-23 05:06:10 +02:00
|
|
|
|
syntax, where
|
|
|
|
|
.Ar option
|
|
|
|
|
is the long name of an option, or using the
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Cm +\- Ns Ar letter
|
2005-05-23 05:06:10 +02:00
|
|
|
|
syntax, where
|
|
|
|
|
.Ar letter
|
|
|
|
|
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
|
|
|
|
|
along with a description of what the option does:
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.Bl -tag -width 3n
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl A Ar name
|
|
|
|
|
Sets the elements of the array parameter
|
|
|
|
|
.Ar name
|
|
|
|
|
to
|
|
|
|
|
.Ar arg ...
|
|
|
|
|
If
|
|
|
|
|
.Fl A
|
|
|
|
|
is used, the array is reset (i.e. emptied) first; if
|
|
|
|
|
.Ic +A
|
|
|
|
|
is used, the first N elements are set (where N is the number of arguments);
|
|
|
|
|
the rest are left untouched.
|
2007-06-23 01:34:42 +02:00
|
|
|
|
.Pp
|
|
|
|
|
An alternative syntax for the command
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-A foo \-\- a b c
|
2007-06-23 01:34:42 +02:00
|
|
|
|
which is compatible to
|
|
|
|
|
.Tn GNU
|
|
|
|
|
.Nm bash
|
|
|
|
|
and also supported by
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh93
|
|
|
|
|
is:
|
2011-05-05 01:16:05 +02:00
|
|
|
|
.Ic foo=(a b c); foo+=(d e)
|
2009-08-29 00:46:21 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Another
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh93
|
|
|
|
|
and
|
|
|
|
|
.Tn GNU
|
|
|
|
|
.Nm bash
|
|
|
|
|
extension allows specifying the indices used for
|
|
|
|
|
.Ar arg ...
|
|
|
|
|
.Pq from the above example, Ic a b c
|
|
|
|
|
like this:
|
|
|
|
|
.Ic set \-A foo \-\- [0]=a [1]=b [2]=c
|
|
|
|
|
or
|
|
|
|
|
.Ic foo=([0]=a [1]=b [2]=c)
|
2009-12-01 20:15:35 +01:00
|
|
|
|
which can also be written
|
|
|
|
|
.Ic foo=([0]=a b c)
|
|
|
|
|
because indices are incremented automatically.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl a \*(Ba Fl o Ic allexport
|
2005-05-23 05:06:10 +02:00
|
|
|
|
All new parameters are created with the export attribute.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl b \*(Ba Fl o Ic notify
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Print job notification messages asynchronously, instead of just before the
|
|
|
|
|
prompt.
|
|
|
|
|
Only used if job control is enabled
|
|
|
|
|
.Pq Fl m .
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl C \*(Ba Fl o Ic noclobber
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Prevent \*(Gt redirection from overwriting existing files.
|
|
|
|
|
Instead, \*(Gt\*(Ba must be used to force an overwrite.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl e \*(Ba Fl o Ic errexit
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Exit (after executing the
|
|
|
|
|
.Dv ERR
|
|
|
|
|
trap) as soon as an error occurs or a command fails (i.e. exits with a
|
|
|
|
|
non-zero status).
|
|
|
|
|
This does not apply to commands whose exit status is
|
|
|
|
|
explicitly tested by a shell construct such as
|
|
|
|
|
.Ic if ,
|
|
|
|
|
.Ic until ,
|
|
|
|
|
.Ic while ,
|
|
|
|
|
.Ic && ,
|
2009-03-22 19:09:17 +01:00
|
|
|
|
.Ic \*(Ba\*(Ba ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
2009-03-22 19:09:17 +01:00
|
|
|
|
.Ic !\&
|
2005-05-23 05:06:10 +02:00
|
|
|
|
statements.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl f \*(Ba Fl o Ic noglob
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Do not expand file name patterns.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl h \*(Ba Fl o Ic trackall
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Create tracked aliases for all executed commands (see
|
|
|
|
|
.Sx Aliases
|
|
|
|
|
above).
|
|
|
|
|
Enabled by default for non-interactive shells.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl i \*(Ba Fl o Ic interactive
|
2009-09-20 18:40:58 +02:00
|
|
|
|
The shell is an interactive shell.
|
|
|
|
|
This option can only be used when the shell is invoked.
|
|
|
|
|
See above for a description of what this means.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl k \*(Ba Fl o Ic keyword
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Parameter assignments are recognised anywhere in a command.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl l \*(Ba Fl o Ic login
|
2009-09-20 18:40:58 +02:00
|
|
|
|
The shell is a login shell.
|
|
|
|
|
This option can only be used when the shell is invoked.
|
|
|
|
|
See above for a description of what this means.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl m \*(Ba Fl o Ic monitor
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Enable job control (default for interactive shells).
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl n \*(Ba Fl o Ic noexec
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Do not execute any commands.
|
|
|
|
|
Useful for checking the syntax of scripts
|
|
|
|
|
(ignored if interactive).
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl p \*(Ba Fl o Ic privileged
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The shell is a privileged shell.
|
|
|
|
|
It is set automatically if, when the shell starts,
|
|
|
|
|
the real UID or GID does not match
|
|
|
|
|
the effective UID (EUID) or GID (EGID), respectively.
|
|
|
|
|
See above for a description of what this means.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl r \*(Ba Fl o Ic restricted
|
2009-09-20 18:40:58 +02:00
|
|
|
|
The shell is a restricted shell.
|
|
|
|
|
This option can only be used when the shell is invoked.
|
|
|
|
|
See above for a description of what this means.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl s \*(Ba Fl o Ic stdin
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If used when the shell is invoked, commands are read from standard input.
|
|
|
|
|
Set automatically if the shell is invoked with no arguments.
|
|
|
|
|
.Pp
|
|
|
|
|
When
|
|
|
|
|
.Fl s
|
|
|
|
|
is used with the
|
|
|
|
|
.Ic set
|
|
|
|
|
command it causes the specified arguments to be sorted before assigning them to
|
|
|
|
|
the positional parameters (or to array
|
|
|
|
|
.Ar name ,
|
|
|
|
|
if
|
|
|
|
|
.Fl A
|
|
|
|
|
is used).
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl U \*(Ba Fl o Ic utf8\-mode
|
2007-03-10 22:14:07 +01:00
|
|
|
|
Enable UTF-8 support in the
|
2008-05-04 03:51:31 +02:00
|
|
|
|
.Sx Emacs editing mode
|
|
|
|
|
and internal string handling functions.
|
• more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
bin/echo bin/kill bin/pwd bin/sleep (exact matches)
bin/test bin/[ (were scripts before)
bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 02:18:23 +01:00
|
|
|
|
This flag is disabled by default, but can be enabled by setting it on the
|
|
|
|
|
shell command line; is enabled automatically for interactive shells if
|
|
|
|
|
requested at compile time, your system supports
|
2006-11-05 18:01:47 +01:00
|
|
|
|
.Fn setlocale LC_CTYPE \&""
|
2006-11-09 00:49:01 +01:00
|
|
|
|
and optionally
|
|
|
|
|
.Fn nl_langinfo CODESET ,
|
2008-05-04 03:58:15 +02:00
|
|
|
|
or the
|
|
|
|
|
.Ev LC_ALL ,
|
|
|
|
|
.Ev LC_CTYPE ,
|
|
|
|
|
or
|
|
|
|
|
.Ev LANG
|
|
|
|
|
environment variables,
|
2006-11-09 00:49:01 +01:00
|
|
|
|
and at least one of these returns something that matches
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Dq UTF\-8
|
2006-11-05 18:01:47 +01:00
|
|
|
|
or
|
• more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
bin/echo bin/kill bin/pwd bin/sleep (exact matches)
bin/test bin/[ (were scripts before)
bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 02:18:23 +01:00
|
|
|
|
.Dq utf8
|
|
|
|
|
case-insensitively; for direct builtin calls depending on the
|
|
|
|
|
aforementioned environment variables; or for stdin or scripts,
|
|
|
|
|
if the input begins with a UTF-8 Byte Order Mark.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl u \*(Ba Fl o Ic nounset
|
2009-07-16 17:06:45 +02:00
|
|
|
|
Referencing of an unset parameter, other than
|
|
|
|
|
.Dq $@
|
|
|
|
|
or
|
|
|
|
|
.Dq $* ,
|
|
|
|
|
is treated as an error, unless one of the
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \- ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql + ,
|
|
|
|
|
or
|
|
|
|
|
.Ql =
|
|
|
|
|
modifiers is used.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl v \*(Ba Fl o Ic verbose
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Write shell input to standard error as it is read.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl X \*(Ba Fl o Ic markdirs
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Mark directories with a trailing
|
|
|
|
|
.Ql /
|
|
|
|
|
during file name generation.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl x \*(Ba Fl o Ic xtrace
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Print commands and parameter assignments when they are executed, preceded by
|
|
|
|
|
the value of
|
|
|
|
|
.Ev PS4 .
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic bgnice
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Background jobs are run with lower priority.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic braceexpand
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Enable brace expansion (a.k.a. alternation).
|
2005-07-04 14:27:28 +02:00
|
|
|
|
This is enabled by default.
|
|
|
|
|
If disabled, tilde expansion after an equals sign is disabled as a side effect.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic emacs
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Enable BRL emacs-like command-line editing (interactive shells only); see
|
|
|
|
|
.Sx Emacs editing mode .
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic gmacs
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Enable gmacs-like command-line editing (interactive shells only).
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
Currently identical to emacs editing except that transpose\-chars (\*(haT) acts
|
2006-08-08 22:07:53 +02:00
|
|
|
|
slightly differently.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic ignoreeof
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The shell will not (easily) exit when end-of-file is read;
|
|
|
|
|
.Ic exit
|
|
|
|
|
must be used.
|
|
|
|
|
To avoid infinite loops, the shell will exit if
|
|
|
|
|
.Dv EOF
|
|
|
|
|
is read 13 times in a row.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic nohup
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Do not kill running jobs with a
|
|
|
|
|
.Dv SIGHUP
|
|
|
|
|
signal when a login shell exits.
|
2009-09-20 18:40:58 +02:00
|
|
|
|
Currently set by default, but this may
|
2007-03-10 22:14:07 +01:00
|
|
|
|
change in the future to be compatible with
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh ,
|
|
|
|
|
which
|
2005-05-23 05:06:10 +02:00
|
|
|
|
doesn't have this option, but does send the
|
|
|
|
|
.Dv SIGHUP
|
2007-03-10 22:14:07 +01:00
|
|
|
|
signal.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic nolog
|
2005-05-23 05:06:10 +02:00
|
|
|
|
No effect.
|
|
|
|
|
In the original Korn shell, this prevents function definitions from
|
|
|
|
|
being stored in the history file.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic physical
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Causes the
|
|
|
|
|
.Ic cd
|
|
|
|
|
and
|
|
|
|
|
.Ic pwd
|
|
|
|
|
commands to use
|
|
|
|
|
.Dq physical
|
|
|
|
|
(i.e. the filesystem's)
|
|
|
|
|
.Sq ..
|
|
|
|
|
directories instead of
|
|
|
|
|
.Dq logical
|
|
|
|
|
directories (i.e. the shell handles
|
|
|
|
|
.Sq .. ,
|
|
|
|
|
which allows the user to be oblivious of symbolic links to directories).
|
|
|
|
|
Clear by default.
|
|
|
|
|
Note that setting this option does not affect the current value of the
|
|
|
|
|
.Ev PWD
|
|
|
|
|
parameter; only the
|
|
|
|
|
.Ic cd
|
|
|
|
|
command changes
|
|
|
|
|
.Ev PWD .
|
|
|
|
|
See the
|
|
|
|
|
.Ic cd
|
|
|
|
|
and
|
|
|
|
|
.Ic pwd
|
|
|
|
|
commands above for more details.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic posix
|
2010-01-28 16:18:51 +01:00
|
|
|
|
Enable a somewhat more
|
|
|
|
|
.Px
|
2010-01-28 16:23:03 +01:00
|
|
|
|
ish mode.
|
2010-01-28 16:18:51 +01:00
|
|
|
|
As a side effect, setting this flag turns off
|
|
|
|
|
.Ic braceexpand
|
2010-01-28 16:33:11 +01:00
|
|
|
|
mode, which can be turned back on manually, and
|
|
|
|
|
.Ic sh
|
|
|
|
|
mode.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic sh
|
2009-10-02 20:08:37 +02:00
|
|
|
|
Enable
|
|
|
|
|
.Pa /bin/sh
|
2010-01-28 16:18:51 +01:00
|
|
|
|
.Pq kludge
|
2009-10-02 20:08:37 +02:00
|
|
|
|
mode.
|
2008-09-17 21:31:30 +02:00
|
|
|
|
Automatically enabled if the basename of the shell invocation begins with
|
2008-10-20 21:29:25 +02:00
|
|
|
|
.Dq sh
|
2010-01-28 16:33:11 +01:00
|
|
|
|
and this autodetection feature is compiled in
|
2010-01-01 19:02:01 +01:00
|
|
|
|
.Pq not in MirBSD .
|
2008-09-17 21:31:30 +02:00
|
|
|
|
As a side effect, setting this flag turns off
|
2006-08-09 22:44:16 +02:00
|
|
|
|
.Ic braceexpand
|
2010-01-28 16:33:11 +01:00
|
|
|
|
mode, which can be turned back on manually, and
|
|
|
|
|
.Ic posix
|
|
|
|
|
mode.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic vi
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Enable
|
|
|
|
|
.Xr vi 1 Ns -like
|
|
|
|
|
command-line editing (interactive shells only).
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic vi\-esccomplete
|
2005-05-23 05:06:10 +02:00
|
|
|
|
In vi command-line editing, do command and file name completion when escape
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
(\*(ha[) is entered in command mode.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic vi\-tabcomplete
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
In vi command-line editing, do command and file name completion when tab (\*(haI)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
is entered in insert mode.
|
|
|
|
|
This is the default.
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.It Fl o Ic viraw
|
2005-05-23 05:06:10 +02:00
|
|
|
|
No effect.
|
|
|
|
|
In the original Korn shell, unless
|
|
|
|
|
.Ic viraw
|
|
|
|
|
was set, the vi command-line mode would let the
|
|
|
|
|
.Xr tty 4
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
driver do the work until ESC (\*(ha[) was entered.
|
2005-05-25 16:15:40 +02:00
|
|
|
|
.Nm
|
2005-05-23 05:06:10 +02:00
|
|
|
|
is always in viraw mode.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
These options can also be used upon invocation of the shell.
|
|
|
|
|
The current set of
|
|
|
|
|
options (with single letter names) can be found in the parameter
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Sq $\- .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic set Fl o
|
|
|
|
|
with no option name will list all the options and whether each is on or off;
|
|
|
|
|
.Ic set +o
|
|
|
|
|
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
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-\-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
option is treated specially \*(en it clears both the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Fl v
|
2009-09-20 18:40:58 +02:00
|
|
|
|
and
|
|
|
|
|
.Fl x
|
2005-05-23 05:06:10 +02:00
|
|
|
|
options.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic shift Op Ar number
|
|
|
|
|
The positional parameters
|
|
|
|
|
.Ar number Ns +1 ,
|
|
|
|
|
.Ar number Ns +2 ,
|
|
|
|
|
etc. are renamed to
|
|
|
|
|
.Sq 1 ,
|
|
|
|
|
.Sq 2 ,
|
|
|
|
|
etc.
|
|
|
|
|
.Ar number
|
|
|
|
|
defaults to 1.
|
|
|
|
|
.Pp
|
2011-02-11 01:41:38 +01:00
|
|
|
|
.It Ic sleep Ar seconds
|
|
|
|
|
Suspends execution for a minimum of the
|
|
|
|
|
.Ar seconds
|
|
|
|
|
specified as positive decimal value with an optional fractional part.
|
|
|
|
|
Signal delivery may continue execution earlier.
|
• more comment and int→bool cleanup, add and improve some comments
• in interactive mode, always look up {LC_{ALL,CTYPE},LANG} environment
variables if setlocale/nl_langinfo(CODESET) doesn’t suffice
• add the ability to call any builtin (some don't make sense or wouldn't
work) directly by analysing argv[0]
• for direct builtin calls, the {LC_{ALL,CTYPE},LANG} environment
variables determine utf8-mode, even if MKSH_ASSUME_UTF8 was set
• when called as builtin, echo behaves POSIXish
• add domainname as alias for true on MirBSD only, to be able to link it
• sync mksh Makefiles with Build.sh output
• adjust manpage wrt release plans
• link some things to mksh now that we have callable builtins:
bin/echo bin/kill bin/pwd bin/sleep (exact matches)
bin/test bin/[ (were scripts before)
bin/domainname=usr/bin/true usr/bin/false (move to /bin/ now)
• drop linked utilities and, except for echo and kill, their manpages
• adjust instbin and link a few more there as well
2011-02-11 02:18:23 +01:00
|
|
|
|
.Pp
|
2007-08-13 21:39:21 +02:00
|
|
|
|
.It Ic source Ar file Op Ar arg ...
|
|
|
|
|
Like
|
|
|
|
|
.Ic \&. Po Do dot Dc Pc ,
|
|
|
|
|
except that the current working directory is appended to the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
in GNU
|
|
|
|
|
.Nm bash
|
|
|
|
|
and
|
|
|
|
|
.Nm mksh .
|
|
|
|
|
In
|
|
|
|
|
.Nm ksh93
|
|
|
|
|
and
|
|
|
|
|
.Nm mksh ,
|
|
|
|
|
this is implemented as a shell alias instead of a builtin.
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ic test Ar expression
|
|
|
|
|
.It Ic \&[ Ar expression Ic \&]
|
|
|
|
|
.Ic test
|
|
|
|
|
evaluates the
|
|
|
|
|
.Ar expression
|
|
|
|
|
and returns zero status if true, 1 if false, or greater than 1 if there
|
|
|
|
|
was an error.
|
|
|
|
|
It is normally used as the condition command of
|
|
|
|
|
.Ic if
|
|
|
|
|
and
|
|
|
|
|
.Ic while
|
|
|
|
|
statements.
|
|
|
|
|
Symbolic links are followed for all
|
|
|
|
|
.Ar file
|
|
|
|
|
expressions except
|
|
|
|
|
.Fl h
|
|
|
|
|
and
|
|
|
|
|
.Fl L .
|
|
|
|
|
.Pp
|
|
|
|
|
The following basic expressions are available:
|
|
|
|
|
.Bl -tag -width 17n
|
|
|
|
|
.It Fl a Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
exists.
|
|
|
|
|
.It Fl b Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a block special device.
|
|
|
|
|
.It Fl c Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a character special device.
|
|
|
|
|
.It Fl d Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a directory.
|
|
|
|
|
.It Fl e Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
exists.
|
|
|
|
|
.It Fl f Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a regular file.
|
|
|
|
|
.It Fl G Ar file
|
|
|
|
|
.Ar file Ns 's
|
|
|
|
|
group is the shell's effective group ID.
|
|
|
|
|
.It Fl g Ar file
|
|
|
|
|
.Ar file Ns 's
|
|
|
|
|
mode has the setgid bit set.
|
2011-03-26 22:46:06 +01:00
|
|
|
|
.It Fl H Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a context dependent directory (only useful on HP-UX).
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl h Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a symbolic link.
|
|
|
|
|
.It Fl k Ar file
|
|
|
|
|
.Ar file Ns 's
|
|
|
|
|
mode has the
|
|
|
|
|
.Xr sticky 8
|
|
|
|
|
bit set.
|
|
|
|
|
.It Fl L Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a symbolic link.
|
|
|
|
|
.It Fl O Ar file
|
|
|
|
|
.Ar file Ns 's
|
|
|
|
|
owner is the shell's effective user ID.
|
|
|
|
|
.It Fl o Ar option
|
|
|
|
|
Shell
|
|
|
|
|
.Ar option
|
|
|
|
|
is set (see the
|
|
|
|
|
.Ic set
|
|
|
|
|
command above for a list of options).
|
|
|
|
|
As a non-standard extension, if the option starts with a
|
|
|
|
|
.Ql \&! ,
|
|
|
|
|
the test is negated; the test always fails if
|
|
|
|
|
.Ar option
|
2008-03-03 23:38:41 +01:00
|
|
|
|
doesn't exist (so [ \-o foo \-o \-o !foo ] returns true if and only if option
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ar foo
|
|
|
|
|
exists).
|
2009-09-07 19:24:49 +02:00
|
|
|
|
The same can be achieved with [ \-o ?foo ] like in
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh93 .
|
2010-01-01 19:02:01 +01:00
|
|
|
|
.Ar option
|
|
|
|
|
can also be the short flag led by either
|
|
|
|
|
.Ql \-
|
|
|
|
|
or
|
|
|
|
|
.Ql +
|
|
|
|
|
.Pq no logical negation ,
|
|
|
|
|
for example
|
|
|
|
|
.Ql \-x
|
|
|
|
|
or
|
|
|
|
|
.Ql +x
|
|
|
|
|
instead of
|
|
|
|
|
.Ql xtrace .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl p Ar file
|
|
|
|
|
.Ar file
|
2011-11-30 22:34:15 +01:00
|
|
|
|
is a named pipe
|
|
|
|
|
.Pq Tn FIFO .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl r Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
exists and is readable.
|
|
|
|
|
.It Fl S Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is a
|
|
|
|
|
.Xr unix 4 Ns -domain
|
|
|
|
|
socket.
|
|
|
|
|
.It Fl s Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
is not empty.
|
2011-05-06 17:41:25 +02:00
|
|
|
|
.It Fl t Ar fd
|
2005-05-23 05:06:10 +02:00
|
|
|
|
File descriptor
|
|
|
|
|
.Ar fd
|
|
|
|
|
is a
|
|
|
|
|
.Xr tty 4
|
|
|
|
|
device.
|
|
|
|
|
.It Fl u Ar file
|
|
|
|
|
.Ar file Ns 's
|
|
|
|
|
mode has the setuid bit set.
|
|
|
|
|
.It Fl w Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
exists and is writable.
|
|
|
|
|
.It Fl x Ar file
|
|
|
|
|
.Ar file
|
|
|
|
|
exists and is executable.
|
|
|
|
|
.It Ar file1 Fl nt Ar file2
|
|
|
|
|
.Ar file1
|
|
|
|
|
is newer than
|
|
|
|
|
.Ar file2
|
|
|
|
|
or
|
|
|
|
|
.Ar file1
|
|
|
|
|
exists and
|
|
|
|
|
.Ar file2
|
|
|
|
|
does not.
|
|
|
|
|
.It Ar file1 Fl ot Ar file2
|
|
|
|
|
.Ar file1
|
|
|
|
|
is older than
|
|
|
|
|
.Ar file2
|
|
|
|
|
or
|
|
|
|
|
.Ar file2
|
|
|
|
|
exists and
|
|
|
|
|
.Ar file1
|
|
|
|
|
does not.
|
|
|
|
|
.It Ar file1 Fl ef Ar file2
|
|
|
|
|
.Ar file1
|
|
|
|
|
is the same file as
|
|
|
|
|
.Ar file2 .
|
|
|
|
|
.It Ar string
|
|
|
|
|
.Ar string
|
|
|
|
|
has non-zero length.
|
|
|
|
|
.It Fl n Ar string
|
|
|
|
|
.Ar string
|
|
|
|
|
is not empty.
|
|
|
|
|
.It Fl z Ar string
|
|
|
|
|
.Ar string
|
|
|
|
|
is empty.
|
|
|
|
|
.It Ar string No = Ar string
|
|
|
|
|
Strings are equal.
|
|
|
|
|
.It Ar string No == Ar string
|
|
|
|
|
Strings are equal.
|
2005-10-08 21:31:00 +02:00
|
|
|
|
.It Ar string No \*(Gt Ar string
|
|
|
|
|
First string operand is greater than second string operand.
|
|
|
|
|
.It Ar string No \*(Lt Ar string
|
|
|
|
|
First string operand is less than second string operand.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ar string No != Ar string
|
|
|
|
|
Strings are not equal.
|
|
|
|
|
.It Ar number Fl eq Ar number
|
|
|
|
|
Numbers compare equal.
|
|
|
|
|
.It Ar number Fl ne Ar number
|
|
|
|
|
Numbers compare not equal.
|
|
|
|
|
.It Ar number Fl ge Ar number
|
|
|
|
|
Numbers compare greater than or equal.
|
|
|
|
|
.It Ar number Fl gt Ar number
|
|
|
|
|
Numbers compare greater than.
|
|
|
|
|
.It Ar number Fl le Ar number
|
|
|
|
|
Numbers compare less than or equal.
|
|
|
|
|
.It Ar number Fl \< Ar number
|
|
|
|
|
Numbers compare less than.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
The above basic expressions, in which unary operators have precedence over
|
|
|
|
|
binary operators, may be combined with the following operators (listed in
|
|
|
|
|
increasing order of precedence):
|
|
|
|
|
.Bd -literal -offset indent
|
2008-03-03 23:38:41 +01:00
|
|
|
|
expr \-o expr Logical OR.
|
|
|
|
|
expr \-a expr Logical AND.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
! expr Logical NOT.
|
|
|
|
|
( expr ) Grouping.
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
2009-03-23 13:15:33 +01:00
|
|
|
|
Note that a number actually may be an arithmetic expression, such as
|
2009-03-23 13:16:58 +01:00
|
|
|
|
a mathematical term or the name of an integer variable:
|
|
|
|
|
.Bd -literal -offset indent
|
2009-03-23 13:21:02 +01:00
|
|
|
|
x=1; [ "x" \-eq 1 ] evaluates to true
|
2009-03-23 13:16:58 +01:00
|
|
|
|
.Ed
|
2009-03-23 13:15:33 +01:00
|
|
|
|
.Pp
|
2011-11-30 22:34:15 +01:00
|
|
|
|
Note that some special rules are applied (courtesy of
|
|
|
|
|
.Px
|
|
|
|
|
) if the number of arguments to
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic test
|
2011-11-30 22:34:15 +01:00
|
|
|
|
or inside the brackets
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic \&[ ... \&]
|
|
|
|
|
is less than five: if leading
|
|
|
|
|
.Ql \&!
|
2011-11-30 22:34:15 +01:00
|
|
|
|
arguments can be stripped such that only one to three arguments remain,
|
|
|
|
|
then the lowered comparison is executed; (thanks to XSI) parentheses
|
|
|
|
|
.Ic \e( ... \e)
|
|
|
|
|
lower four- and three-argument forms to two- and one-argument forms,
|
|
|
|
|
respectively; three-argument forms ultimately prefer binary operations,
|
|
|
|
|
followed by negation and parenthesis lowering; two- and four-argument forms
|
|
|
|
|
prefer negation followed by parenthesis; the one-argument form always implies
|
|
|
|
|
.Fl n .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.Sy Note :
|
|
|
|
|
A common mistake is to use
|
|
|
|
|
.Dq if \&[ $foo = bar \&]
|
|
|
|
|
which fails if parameter
|
|
|
|
|
.Dq foo
|
|
|
|
|
is
|
|
|
|
|
.Dv NULL
|
|
|
|
|
or unset, if it has embedded spaces (i.e.\&
|
|
|
|
|
.Ev IFS
|
2009-11-22 15:23:21 +01:00
|
|
|
|
octets), or if it is a unary operator like
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sq \&!
|
|
|
|
|
or
|
|
|
|
|
.Sq Fl n .
|
|
|
|
|
Use tests like
|
2005-05-26 01:31:08 +02:00
|
|
|
|
.Dq if \&[ x\&"$foo\&" = x"bar" \&]
|
2010-08-14 22:13:10 +02:00
|
|
|
|
instead, or the double-bracket operator
|
2005-10-08 21:31:00 +02:00
|
|
|
|
.Dq if \&[[ $foo = bar \&]]
|
2010-08-14 22:13:10 +02:00
|
|
|
|
or, to avoid pattern matching (see
|
|
|
|
|
.Ic \&[[
|
|
|
|
|
above):
|
2011-11-11 23:10:52 +01:00
|
|
|
|
.Dq if \&[[ $foo = \&"$bar" \&]]
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic time
|
|
|
|
|
.Op Fl p
|
|
|
|
|
.Op Ar pipeline
|
|
|
|
|
.Xc
|
|
|
|
|
If a
|
|
|
|
|
.Ar pipeline
|
|
|
|
|
is given, the times used to execute the pipeline are reported.
|
|
|
|
|
If no pipeline
|
|
|
|
|
is given, then the user and system time used by the shell itself, and all the
|
|
|
|
|
commands it has run since it was started, are reported.
|
|
|
|
|
The times reported are the real time (elapsed time from start to finish),
|
|
|
|
|
the user CPU time (time spent running in user mode), and the system CPU time
|
|
|
|
|
(time spent running in kernel mode).
|
|
|
|
|
Times are reported to standard error; the format of the output is:
|
|
|
|
|
.Pp
|
|
|
|
|
.Dl "0m0.00s real 0m0.00s user 0m0.00s system"
|
|
|
|
|
.Pp
|
|
|
|
|
If the
|
|
|
|
|
.Fl p
|
|
|
|
|
option is given the output is slightly longer:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
real 0.00
|
|
|
|
|
user 0.00
|
|
|
|
|
sys 0.00
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
It is an error to specify the
|
|
|
|
|
.Fl p
|
|
|
|
|
option unless
|
|
|
|
|
.Ar pipeline
|
|
|
|
|
is a simple command.
|
|
|
|
|
.Pp
|
|
|
|
|
Simple redirections of standard error do not affect the output of the
|
|
|
|
|
.Ic time
|
|
|
|
|
command:
|
|
|
|
|
.Pp
|
2009-09-06 20:17:51 +02:00
|
|
|
|
.Dl $ time sleep 1 2\*(Gtafile
|
|
|
|
|
.Dl $ { time sleep 1; } 2\*(Gtafile
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Times for the first command do not go to
|
|
|
|
|
.Dq afile ,
|
|
|
|
|
but those of the second command do.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic times
|
|
|
|
|
Print the accumulated user and system times used both by the shell
|
|
|
|
|
and by processes that the shell started which have exited.
|
|
|
|
|
The format of the output is:
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
0m0.00s 0m0.00s
|
|
|
|
|
0m0.00s 0m0.00s
|
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic trap Op Ar handler signal ...
|
|
|
|
|
Sets a trap handler that is to be executed when any of the specified signals are
|
|
|
|
|
received.
|
|
|
|
|
.Ar handler
|
|
|
|
|
is either a
|
|
|
|
|
.Dv NULL
|
|
|
|
|
string, indicating the signals are to be ignored, a minus sign
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Pq Sq \- ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
indicating that the default action is to be taken for the signals (see
|
|
|
|
|
.Xr signal 3 ) ,
|
|
|
|
|
or a string containing shell commands to be evaluated and executed at the first
|
|
|
|
|
opportunity (i.e. when the current command completes, or before printing the
|
|
|
|
|
next
|
|
|
|
|
.Ev PS1
|
|
|
|
|
prompt) after receipt of one of the signals.
|
|
|
|
|
.Ar signal
|
|
|
|
|
is the name of a signal (e.g.\&
|
|
|
|
|
.Dv PIPE
|
|
|
|
|
or
|
|
|
|
|
.Dv ALRM )
|
|
|
|
|
or the number of the signal (see the
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic kill \-l
|
2005-05-23 05:06:10 +02:00
|
|
|
|
command above).
|
|
|
|
|
.Pp
|
|
|
|
|
There are two special signals:
|
|
|
|
|
.Dv EXIT
|
2006-01-30 13:37:24 +01:00
|
|
|
|
(also known as 0) which is executed when the shell is about to exit, and
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Dv ERR ,
|
|
|
|
|
which is executed after an error occurs (an error is something that would cause
|
|
|
|
|
the shell to exit if the
|
|
|
|
|
.Fl e
|
|
|
|
|
or
|
|
|
|
|
.Ic errexit
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
option were set \*(en see the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ic set
|
|
|
|
|
command above).
|
|
|
|
|
.Dv EXIT
|
|
|
|
|
handlers are executed in the environment of the last executed command.
|
|
|
|
|
Note
|
|
|
|
|
that for non-interactive shells, the trap handler cannot be changed for signals
|
|
|
|
|
that were ignored when the shell started.
|
|
|
|
|
.Pp
|
|
|
|
|
With no arguments,
|
|
|
|
|
.Ic trap
|
|
|
|
|
lists, as a series of
|
|
|
|
|
.Ic trap
|
|
|
|
|
commands, the current state of the traps that have been set since the shell
|
|
|
|
|
started.
|
|
|
|
|
Note that the output of
|
|
|
|
|
.Ic trap
|
|
|
|
|
cannot be usefully piped to another process (an artifact of the fact that
|
|
|
|
|
traps are cleared when subprocesses are created).
|
|
|
|
|
.Pp
|
|
|
|
|
The original Korn shell's
|
|
|
|
|
.Dv DEBUG
|
|
|
|
|
trap and the handling of
|
|
|
|
|
.Dv ERR
|
|
|
|
|
and
|
|
|
|
|
.Dv EXIT
|
|
|
|
|
traps in functions are not yet implemented.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Ic true
|
|
|
|
|
A command that exits with a zero value.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
2011-07-02 19:57:24 +02:00
|
|
|
|
.Ic global
|
2009-09-06 19:42:15 +02:00
|
|
|
|
.Oo Op Ic +\-alpnrtUux
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Fl L Ns Op Ar n
|
|
|
|
|
.Op Fl R Ns Op Ar n
|
|
|
|
|
.Op Fl Z Ns Op Ar n
|
|
|
|
|
.Op Fl i Ns Op Ar n
|
|
|
|
|
.No \*(Ba Fl f Op Fl tux Oc
|
|
|
|
|
.Oo Ar name
|
|
|
|
|
.Op Ns = Ns Ar value
|
|
|
|
|
.Ar ... Oc
|
|
|
|
|
.Xc
|
2011-07-02 19:57:24 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic typeset
|
|
|
|
|
.Oo Op Ic +\-alpnrtUux
|
|
|
|
|
.Op Fl LRZ Ns Op Ar n
|
|
|
|
|
.Op Fl i Ns Op Ar n
|
|
|
|
|
.No \*(Ba Fl f Op Fl tux Oc
|
|
|
|
|
.Oo Ar name
|
|
|
|
|
.Op Ns = Ns Ar value
|
|
|
|
|
.Ar ... Oc
|
|
|
|
|
.Xc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Display or set parameter attributes.
|
|
|
|
|
With no
|
|
|
|
|
.Ar name
|
|
|
|
|
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
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
with no option letter), all parameters and their values with the specified
|
|
|
|
|
attributes are printed; if options are introduced with
|
|
|
|
|
.Ql + ,
|
|
|
|
|
parameter values are not printed.
|
|
|
|
|
.Pp
|
|
|
|
|
If
|
|
|
|
|
.Ar name
|
|
|
|
|
arguments are given, the attributes of the named parameters are set
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Pq Ic \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or cleared
|
|
|
|
|
.Pq Ic + .
|
|
|
|
|
Values for parameters may optionally be specified.
|
2010-01-25 15:25:16 +01:00
|
|
|
|
For
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Ar name Ns \&[*] ,
|
2010-01-25 15:25:16 +01:00
|
|
|
|
the change affects the entire array, and no value may be specified.
|
2011-07-02 19:57:24 +02:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If
|
|
|
|
|
.Ic typeset
|
2011-07-02 19:57:24 +02:00
|
|
|
|
is used inside a function, any parameters specified are localised.
|
|
|
|
|
This is not done by the otherwise identical
|
|
|
|
|
.Ic global .
|
2011-12-03 01:09:15 +01:00
|
|
|
|
.Em Note :
|
|
|
|
|
This means that
|
|
|
|
|
.Nm No 's Ic global
|
|
|
|
|
command is
|
|
|
|
|
.Em not
|
|
|
|
|
equivalent to other programming languages' as it does not allow a
|
|
|
|
|
function called from another function to access a parameter at truly
|
|
|
|
|
global scope, but only prevents putting an accessed one into local scope.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
When
|
|
|
|
|
.Fl f
|
|
|
|
|
is used,
|
|
|
|
|
.Ic typeset
|
|
|
|
|
operates on the attributes of functions.
|
|
|
|
|
As with parameters, if no
|
|
|
|
|
.Ar name
|
|
|
|
|
arguments are given,
|
|
|
|
|
functions are listed with their values (i.e. definitions) unless
|
|
|
|
|
options are introduced with
|
|
|
|
|
.Ql + ,
|
|
|
|
|
in which case only the function names are reported.
|
|
|
|
|
.Bl -tag -width Ds
|
2009-08-28 23:51:52 +02:00
|
|
|
|
.It Fl a
|
|
|
|
|
Indexed array attribute.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl f
|
|
|
|
|
Function mode.
|
|
|
|
|
Display or set functions and their attributes, instead of parameters.
|
|
|
|
|
.It Fl i Ns Op Ar n
|
|
|
|
|
Integer attribute.
|
|
|
|
|
.Ar n
|
|
|
|
|
specifies the base to use when displaying the integer (if not specified, the
|
|
|
|
|
base given in the first assignment is used).
|
|
|
|
|
Parameters with this attribute may
|
|
|
|
|
be assigned values containing arithmetic expressions.
|
|
|
|
|
.It Fl L Ns Op Ar n
|
|
|
|
|
Left justify attribute.
|
|
|
|
|
.Ar n
|
|
|
|
|
specifies the field width.
|
|
|
|
|
If
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified, the current width of a parameter (or the width of its first
|
|
|
|
|
assigned value) is used.
|
|
|
|
|
Leading whitespace (and zeros, if used with the
|
|
|
|
|
.Fl Z
|
|
|
|
|
option) is stripped.
|
|
|
|
|
If necessary, values are either truncated or space padded
|
|
|
|
|
to fit the field width.
|
|
|
|
|
.It Fl l
|
|
|
|
|
Lower case attribute.
|
|
|
|
|
All upper case characters in values are converted to lower case.
|
|
|
|
|
(In the original Korn shell, this parameter meant
|
|
|
|
|
.Dq long integer
|
|
|
|
|
when used with the
|
|
|
|
|
.Fl i
|
|
|
|
|
option.)
|
2009-09-06 19:42:15 +02:00
|
|
|
|
.It Fl n
|
|
|
|
|
Create a bound variable (name reference): any access to the variable
|
|
|
|
|
.Ar name
|
|
|
|
|
will access the variable
|
|
|
|
|
.Ar value
|
|
|
|
|
in the current scope (this is different from
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh93 ! )
|
|
|
|
|
instead.
|
2010-01-06 19:29:01 +01:00
|
|
|
|
Also different from
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh93
|
|
|
|
|
is that
|
|
|
|
|
.Ar value
|
|
|
|
|
is lazily evaluated at the time
|
|
|
|
|
.Ar name
|
|
|
|
|
is accessed.
|
2009-09-06 19:42:15 +02:00
|
|
|
|
This can be used by functions to access variables whose names are
|
|
|
|
|
passed as parametres, instead of using
|
|
|
|
|
.Ic eval .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl p
|
|
|
|
|
Print complete
|
|
|
|
|
.Ic typeset
|
2008-04-01 23:07:20 +02:00
|
|
|
|
commands that can be used to re-create the attributes and values of
|
2005-05-23 05:06:10 +02:00
|
|
|
|
parameters.
|
|
|
|
|
.It Fl R Ns Op Ar n
|
|
|
|
|
Right justify attribute.
|
|
|
|
|
.Ar n
|
|
|
|
|
specifies the field width.
|
|
|
|
|
If
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified, the current width of a parameter (or the width of its first
|
|
|
|
|
assigned value) is used.
|
|
|
|
|
Trailing whitespace is stripped.
|
|
|
|
|
If necessary, values are either stripped of leading characters or space
|
|
|
|
|
padded to make them fit the field width.
|
|
|
|
|
.It Fl r
|
|
|
|
|
Read-only attribute.
|
|
|
|
|
Parameters with this attribute may not be assigned to or unset.
|
|
|
|
|
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.
|
|
|
|
|
.Pp
|
|
|
|
|
For functions,
|
|
|
|
|
.Fl t
|
|
|
|
|
is the trace attribute.
|
|
|
|
|
When functions with the trace attribute are executed, the
|
|
|
|
|
.Ic xtrace
|
|
|
|
|
.Pq Fl x
|
|
|
|
|
shell option is temporarily turned on.
|
|
|
|
|
.It Fl U
|
|
|
|
|
Unsigned integer attribute.
|
2006-11-19 18:00:32 +01:00
|
|
|
|
Integers are printed as unsigned values (combine with the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Fl i
|
|
|
|
|
option).
|
|
|
|
|
This option is not in the original Korn shell.
|
|
|
|
|
.It Fl u
|
|
|
|
|
Upper case attribute.
|
|
|
|
|
All lower case characters in values are converted to upper case.
|
|
|
|
|
(In the original Korn shell, this parameter meant
|
|
|
|
|
.Dq unsigned integer
|
|
|
|
|
when used with the
|
|
|
|
|
.Fl i
|
2006-01-30 13:37:24 +01:00
|
|
|
|
option which meant upper case letters would never be used for bases greater
|
2005-05-23 05:06:10 +02:00
|
|
|
|
than 10.
|
|
|
|
|
See the
|
|
|
|
|
.Fl U
|
|
|
|
|
option.)
|
|
|
|
|
.Pp
|
|
|
|
|
For functions,
|
|
|
|
|
.Fl u
|
|
|
|
|
is the undefined attribute.
|
|
|
|
|
See
|
|
|
|
|
.Sx Functions
|
|
|
|
|
above for the implications of this.
|
|
|
|
|
.It Fl x
|
|
|
|
|
Export attribute.
|
|
|
|
|
Parameters (or functions) are placed in the environment of
|
|
|
|
|
any executed commands.
|
|
|
|
|
Exported functions are not yet implemented.
|
|
|
|
|
.It Fl Z Ns Op Ar n
|
|
|
|
|
Zero fill attribute.
|
|
|
|
|
If not combined with
|
|
|
|
|
.Fl L ,
|
|
|
|
|
this is the same as
|
|
|
|
|
.Fl R ,
|
|
|
|
|
except zero padding is used instead of space padding.
|
2008-04-19 23:18:52 +02:00
|
|
|
|
For integers, the number instead of the base is padded.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
2006-11-19 18:00:32 +01:00
|
|
|
|
If any of the
|
|
|
|
|
.\" long integer ,
|
|
|
|
|
.Fl i ,
|
|
|
|
|
.Fl L ,
|
|
|
|
|
.Fl l ,
|
|
|
|
|
.Fl R ,
|
|
|
|
|
.Fl U ,
|
|
|
|
|
.Fl u ,
|
|
|
|
|
or
|
|
|
|
|
.Fl Z
|
|
|
|
|
options are changed, all others from this set are cleared,
|
2007-06-23 21:07:14 +02:00
|
|
|
|
unless they are also given on the same command line.
|
2006-11-19 18:00:32 +01:00
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Ic ulimit
|
2010-03-27 17:51:39 +01:00
|
|
|
|
.Op Fl aBCcdefHiLlMmnOPpqrSsTtVvw
|
2008-04-20 23:30:29 +02:00
|
|
|
|
.Op Ar value
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Display or set process limits.
|
|
|
|
|
If no options are used, the file size limit
|
|
|
|
|
.Pq Fl f
|
|
|
|
|
is assumed.
|
|
|
|
|
.Ar value ,
|
2008-04-20 23:30:29 +02:00
|
|
|
|
if specified, may be either an arithmetic expression or the word
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Dq unlimited .
|
|
|
|
|
The limits affect the shell and any processes created by the shell after a
|
|
|
|
|
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
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
dependent \*(en some systems have only the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Fl f
|
|
|
|
|
limit.
|
|
|
|
|
.Bl -tag -width 5n
|
|
|
|
|
.It Fl a
|
|
|
|
|
Display all limits; unless
|
|
|
|
|
.Fl H
|
|
|
|
|
is used, soft limits are displayed.
|
2010-03-27 17:51:39 +01:00
|
|
|
|
.It Fl B Ar n
|
|
|
|
|
Set the socket buffer size to
|
|
|
|
|
.Ar n
|
|
|
|
|
kibibytes.
|
|
|
|
|
.It Fl C Ar n
|
|
|
|
|
Set the number of cached threads to
|
|
|
|
|
.Ar n .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl c Ar n
|
|
|
|
|
Impose a size limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
blocks on the size of core dumps.
|
|
|
|
|
.It Fl d Ar n
|
|
|
|
|
Impose a size limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
kibibytes on the size of the data area.
|
2010-03-27 17:51:39 +01:00
|
|
|
|
.It Fl e Ar n
|
|
|
|
|
Set the maximum niceness to
|
|
|
|
|
.Ar n .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl f Ar n
|
|
|
|
|
Impose a size limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
blocks on files written by the shell and its child processes (files of any
|
|
|
|
|
size may be read).
|
|
|
|
|
.It Fl H
|
|
|
|
|
Set the hard limit only (the default is to set both hard and soft limits).
|
2010-03-27 17:51:39 +01:00
|
|
|
|
.It Fl i Ar n
|
|
|
|
|
Set the number of pending signals to
|
|
|
|
|
.Ar n .
|
2005-05-26 01:31:08 +02:00
|
|
|
|
.It Fl L Ar n
|
|
|
|
|
Control flocks; documentation is missing.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl l Ar n
|
|
|
|
|
Impose a limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
kibibytes on the amount of locked (wired) physical memory.
|
2010-03-27 17:51:39 +01:00
|
|
|
|
.It Fl M Ar n
|
|
|
|
|
Set the AIO locked memory to
|
|
|
|
|
.Ar n
|
|
|
|
|
kibibytes.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl m Ar n
|
|
|
|
|
Impose a limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
kibibytes on the amount of physical memory used.
|
|
|
|
|
.It Fl n Ar n
|
|
|
|
|
Impose a limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
file descriptors that can be open at once.
|
2010-03-27 17:51:39 +01:00
|
|
|
|
.It Fl O Ar n
|
|
|
|
|
Set the number of AIO operations to
|
|
|
|
|
.Ar n .
|
|
|
|
|
.It Fl P Ar n
|
|
|
|
|
Limit the number of threads per process to
|
|
|
|
|
.Ar n .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl p Ar n
|
|
|
|
|
Impose a limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
processes that can be run by the user at any one time.
|
2010-03-27 17:51:39 +01:00
|
|
|
|
.It Fl q Ar n
|
|
|
|
|
Limit the size of
|
2011-02-18 23:26:13 +01:00
|
|
|
|
.Tn POSIX
|
2010-03-27 17:51:39 +01:00
|
|
|
|
message queues to
|
|
|
|
|
.Ar n
|
|
|
|
|
bytes.
|
|
|
|
|
.It Fl r Ar n
|
|
|
|
|
Set the maximum real-time priority to
|
|
|
|
|
.Ar n .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl S
|
|
|
|
|
Set the soft limit only (the default is to set both hard and soft limits).
|
|
|
|
|
.It Fl s Ar n
|
|
|
|
|
Impose a size limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
kibibytes on the size of the stack area.
|
|
|
|
|
.It Fl T Ar n
|
|
|
|
|
Impose a time limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
real seconds to be used by each process.
|
|
|
|
|
.It Fl t Ar n
|
|
|
|
|
Impose a time limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
CPU seconds spent in user mode to be used by each process.
|
2010-03-15 19:14:40 +01:00
|
|
|
|
.It Fl V Ar n
|
|
|
|
|
Set the number of vnode monitors on Haiku to
|
|
|
|
|
.Ar n .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Fl v Ar n
|
|
|
|
|
Impose a limit of
|
|
|
|
|
.Ar n
|
2007-01-06 19:48:27 +01:00
|
|
|
|
kibibytes on the amount of virtual memory (address space) used.
|
2005-05-26 01:31:08 +02:00
|
|
|
|
.It Fl w Ar n
|
|
|
|
|
Impose a limit of
|
|
|
|
|
.Ar n
|
|
|
|
|
kibibytes on the amount of swap space used.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
As far as
|
|
|
|
|
.Ic ulimit
|
|
|
|
|
is concerned, a block is 512 bytes.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic umask
|
|
|
|
|
.Op Fl S
|
|
|
|
|
.Op Ar mask
|
|
|
|
|
.Xc
|
|
|
|
|
Display or set the file permission creation mask, or umask (see
|
|
|
|
|
.Xr umask 2 ) .
|
|
|
|
|
If the
|
|
|
|
|
.Fl S
|
|
|
|
|
option is used, the mask displayed or set is symbolic; otherwise, it is an
|
|
|
|
|
octal number.
|
|
|
|
|
.Pp
|
|
|
|
|
Symbolic masks are like those used by
|
|
|
|
|
.Xr chmod 1 .
|
|
|
|
|
When used, they describe what permissions may be made available (as opposed to
|
|
|
|
|
octal masks in which a set bit means the corresponding bit is to be cleared).
|
|
|
|
|
For example,
|
|
|
|
|
.Dq ug=rwx,o=
|
|
|
|
|
sets the mask so files will not be readable, writable, or executable by
|
|
|
|
|
.Dq others ,
|
|
|
|
|
and is equivalent (on most systems) to the octal mask
|
|
|
|
|
.Dq 007 .
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic unalias
|
|
|
|
|
.Op Fl adt
|
|
|
|
|
.Op Ar name ...
|
|
|
|
|
.Xc
|
|
|
|
|
The aliases for the given names are removed.
|
|
|
|
|
If the
|
|
|
|
|
.Fl a
|
|
|
|
|
option is used, all aliases are removed.
|
|
|
|
|
If the
|
|
|
|
|
.Fl t
|
|
|
|
|
or
|
|
|
|
|
.Fl d
|
|
|
|
|
options are used, the indicated operations are carried out on tracked or
|
|
|
|
|
directory aliases, respectively.
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic unset
|
|
|
|
|
.Op Fl fv
|
|
|
|
|
.Ar parameter ...
|
|
|
|
|
.Xc
|
|
|
|
|
Unset the named parameters
|
|
|
|
|
.Po
|
|
|
|
|
.Fl v ,
|
|
|
|
|
the default
|
|
|
|
|
.Pc
|
|
|
|
|
or functions
|
|
|
|
|
.Pq Fl f .
|
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 15:11:29 +01:00
|
|
|
|
With
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Ar parameter Ns \&[*] ,
|
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 15:11:29 +01:00
|
|
|
|
attributes are kept, only values are unset.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
2010-05-13 20:44:10 +02:00
|
|
|
|
The exit status is non-zero if any of the parameters have the read-only
|
|
|
|
|
attribute set, zero otherwise.
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Ic wait Op Ar job ...
|
|
|
|
|
Wait for the specified job(s) to finish.
|
|
|
|
|
The exit status of
|
|
|
|
|
.Ic wait
|
|
|
|
|
is that of the last specified job; if the last job is killed by a signal, the
|
|
|
|
|
exit status is 128 + the number of the signal (see
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic kill \-l Ar exit-status
|
2005-05-23 05:06:10 +02:00
|
|
|
|
above); if the last specified job can't be found (because it never existed, or
|
|
|
|
|
had already finished), the exit status of
|
|
|
|
|
.Ic wait
|
|
|
|
|
is 127.
|
|
|
|
|
See
|
|
|
|
|
.Sx Job control
|
|
|
|
|
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 SIGHUP ,
|
|
|
|
|
.Dv SIGINT ,
|
|
|
|
|
or
|
|
|
|
|
.Dv SIGQUIT
|
|
|
|
|
signal is received.
|
|
|
|
|
.Pp
|
|
|
|
|
If no jobs are specified,
|
|
|
|
|
.Ic wait
|
|
|
|
|
waits for all currently running jobs (if any) to finish and exits with a zero
|
|
|
|
|
status.
|
|
|
|
|
If job monitoring is enabled, the completion status of jobs is printed
|
|
|
|
|
(this is not the case when jobs are explicitly specified).
|
|
|
|
|
.Pp
|
|
|
|
|
.It Xo
|
|
|
|
|
.Ic whence
|
|
|
|
|
.Op Fl pv
|
|
|
|
|
.Op Ar name ...
|
|
|
|
|
.Xc
|
|
|
|
|
For each
|
|
|
|
|
.Ar name ,
|
|
|
|
|
the type of command is listed (reserved word, built-in, alias,
|
|
|
|
|
function, tracked alias, or executable).
|
|
|
|
|
If the
|
|
|
|
|
.Fl p
|
|
|
|
|
option is used, a path search is performed even if
|
|
|
|
|
.Ar name
|
|
|
|
|
is a reserved word, alias, etc.
|
|
|
|
|
Without the
|
|
|
|
|
.Fl v
|
|
|
|
|
option,
|
|
|
|
|
.Ic whence
|
|
|
|
|
is similar to
|
|
|
|
|
.Ic command Fl v
|
|
|
|
|
except that
|
|
|
|
|
.Ic whence
|
|
|
|
|
will find reserved words and won't print aliases as alias commands.
|
|
|
|
|
With the
|
|
|
|
|
.Fl v
|
|
|
|
|
option,
|
|
|
|
|
.Ic whence
|
|
|
|
|
is the same as
|
|
|
|
|
.Ic command Fl V .
|
|
|
|
|
Note that for
|
|
|
|
|
.Ic whence ,
|
|
|
|
|
the
|
|
|
|
|
.Fl p
|
|
|
|
|
option does not affect the search path used, as it does for
|
|
|
|
|
.Ic command .
|
|
|
|
|
If the type of one or more of the names could not be determined, the exit
|
|
|
|
|
status is non-zero.
|
|
|
|
|
.El
|
|
|
|
|
.Ss Job control
|
2006-01-30 13:37:24 +01:00
|
|
|
|
Job control refers to the shell's ability to monitor and control jobs which
|
2005-05-23 05:06:10 +02:00
|
|
|
|
are processes or groups of processes created for commands or pipelines.
|
|
|
|
|
At a minimum, the shell keeps track of the status of the background (i.e.\&
|
|
|
|
|
asynchronous) jobs that currently exist; this information can be displayed
|
|
|
|
|
using the
|
|
|
|
|
.Ic jobs
|
|
|
|
|
commands.
|
|
|
|
|
If job control is fully enabled (using
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-m
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-o monitor ) ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
as it is for interactive shells, the processes of a job are placed in their
|
|
|
|
|
own process group.
|
|
|
|
|
Foreground jobs can be stopped by typing the suspend
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
character from the terminal (normally \*(haZ), jobs can be restarted in either the
|
2005-05-23 05:06:10 +02:00
|
|
|
|
foreground or background using the
|
|
|
|
|
.Ic fg
|
|
|
|
|
and
|
|
|
|
|
.Ic bg
|
|
|
|
|
commands, and the state of the terminal is saved or restored when a foreground
|
|
|
|
|
job is stopped or restarted, respectively.
|
|
|
|
|
.Pp
|
|
|
|
|
Note that only commands that create processes (e.g. asynchronous commands,
|
|
|
|
|
subshell commands, and non-built-in, non-function commands) can be stopped;
|
|
|
|
|
commands like
|
|
|
|
|
.Ic read
|
|
|
|
|
cannot be.
|
|
|
|
|
.Pp
|
|
|
|
|
When a job is created, it is assigned a job number.
|
|
|
|
|
For interactive shells, this number is printed inside
|
2010-07-17 22:21:18 +02:00
|
|
|
|
.Dq \&[..] ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
followed by the process IDs of the processes in the job when an asynchronous
|
|
|
|
|
command is run.
|
|
|
|
|
A job may be referred to in the
|
|
|
|
|
.Ic bg ,
|
|
|
|
|
.Ic fg ,
|
|
|
|
|
.Ic jobs ,
|
|
|
|
|
.Ic kill ,
|
|
|
|
|
and
|
|
|
|
|
.Ic wait
|
|
|
|
|
commands either by the process ID of the last process in the command pipeline
|
|
|
|
|
(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:
|
2009-11-22 19:23:38 +01:00
|
|
|
|
.Bl -tag -width "%+ x %% x %XX"
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It %+ \*(Ba %% \*(Ba %
|
|
|
|
|
The most recently stopped job, or, if there are no stopped jobs, the oldest
|
|
|
|
|
running job.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It %\-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The job that would be the
|
|
|
|
|
.Ic %+
|
|
|
|
|
job if the latter did not exist.
|
|
|
|
|
.It % Ns Ar n
|
|
|
|
|
The job with job number
|
|
|
|
|
.Ar n .
|
|
|
|
|
.It %? Ns Ar string
|
|
|
|
|
The job with its command containing the string
|
|
|
|
|
.Ar string
|
|
|
|
|
(an error occurs if multiple jobs are matched).
|
|
|
|
|
.It % Ns Ar string
|
|
|
|
|
The job with its command starting with the string
|
|
|
|
|
.Ar string
|
|
|
|
|
(an error occurs if multiple jobs are matched).
|
|
|
|
|
.El
|
|
|
|
|
.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
|
|
|
|
|
.D1 [ Ns Ar number ] Ar flag status command
|
|
|
|
|
.Pp
|
|
|
|
|
where...
|
|
|
|
|
.Bl -tag -width "command"
|
|
|
|
|
.It Ar number
|
|
|
|
|
is the job number of the job;
|
|
|
|
|
.It Ar flag
|
|
|
|
|
is the
|
|
|
|
|
.Ql +
|
|
|
|
|
or
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ql \-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
character if the job is the
|
|
|
|
|
.Ic %+
|
|
|
|
|
or
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic %\-
|
2005-05-23 05:06:10 +02:00
|
|
|
|
job, respectively, or space if it is neither;
|
|
|
|
|
.It Ar status
|
|
|
|
|
indicates the current state of the job and can be:
|
|
|
|
|
.Bl -tag -width "RunningXX"
|
|
|
|
|
.It Done Op Ar number
|
|
|
|
|
The job exited.
|
|
|
|
|
.Ar number
|
2006-01-30 13:37:24 +01:00
|
|
|
|
is the exit status of the job which is omitted if the status is zero.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Running
|
|
|
|
|
The job has neither stopped nor exited (note that running does not necessarily
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
mean consuming CPU time \*(en
|
2005-05-23 05:06:10 +02:00
|
|
|
|
the process could be blocked waiting for some event).
|
|
|
|
|
.It Stopped Op Ar signal
|
|
|
|
|
The job was stopped by the indicated
|
|
|
|
|
.Ar signal
|
|
|
|
|
(if no signal is given, the job was stopped by
|
|
|
|
|
.Dv SIGTSTP ) .
|
|
|
|
|
.It Ar signal-description Op Dq core dumped
|
|
|
|
|
The job was killed by a signal (e.g. memory fault, hangup); use
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic kill \-l
|
2005-05-23 05:06:10 +02:00
|
|
|
|
for a list of signal descriptions.
|
|
|
|
|
The
|
|
|
|
|
.Dq core dumped
|
|
|
|
|
message indicates the process created a core file.
|
|
|
|
|
.El
|
|
|
|
|
.It Ar command
|
|
|
|
|
is the command that created the process.
|
|
|
|
|
If there are multiple processes in
|
|
|
|
|
the job, each process will have a line showing its
|
|
|
|
|
.Ar command
|
|
|
|
|
and possibly its
|
|
|
|
|
.Ar status ,
|
|
|
|
|
if it is different from the status of the previous process.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
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 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 SIGHUP
|
|
|
|
|
signal and the shell exits.
|
|
|
|
|
.Ss Interactive input line editing
|
|
|
|
|
The shell supports three modes of reading command lines from a
|
|
|
|
|
.Xr tty 4
|
|
|
|
|
in an interactive session, controlled by the
|
|
|
|
|
.Ic emacs ,
|
|
|
|
|
.Ic gmacs ,
|
|
|
|
|
and
|
|
|
|
|
.Ic vi
|
|
|
|
|
options (at most one of these can be set at once).
|
|
|
|
|
The default is
|
|
|
|
|
.Ic emacs .
|
|
|
|
|
Editing modes can be set explicitly using the
|
|
|
|
|
.Ic set
|
2005-07-04 14:07:41 +02:00
|
|
|
|
built-in.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If none of these options are enabled,
|
|
|
|
|
the shell simply reads lines using the normal
|
|
|
|
|
.Xr tty 4
|
|
|
|
|
driver.
|
|
|
|
|
If the
|
|
|
|
|
.Ic emacs
|
|
|
|
|
or
|
|
|
|
|
.Ic gmacs
|
|
|
|
|
option is set, the shell allows emacs-like editing of the command; similarly,
|
|
|
|
|
if the
|
|
|
|
|
.Ic vi
|
|
|
|
|
option is set, the shell allows vi-like editing of the command.
|
|
|
|
|
These modes are described in detail in the following sections.
|
|
|
|
|
.Pp
|
|
|
|
|
In these editing modes, if a line is longer than the screen width (see the
|
|
|
|
|
.Ev COLUMNS
|
|
|
|
|
parameter),
|
|
|
|
|
a
|
|
|
|
|
.Ql \*(Gt ,
|
|
|
|
|
.Ql + ,
|
|
|
|
|
or
|
|
|
|
|
.Ql \*(Lt
|
|
|
|
|
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.
|
2008-09-30 20:43:07 +02:00
|
|
|
|
.Pp
|
2008-09-30 20:48:01 +02:00
|
|
|
|
Completed lines are pushed into the history, unless they begin with an
|
2009-11-22 15:23:21 +01:00
|
|
|
|
IFS octet or IFS white space, or are the same as the previous line.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ss Emacs editing mode
|
|
|
|
|
When the
|
|
|
|
|
.Ic emacs
|
|
|
|
|
option is set, interactive input line editing is enabled.
|
|
|
|
|
Warning: This mode is
|
|
|
|
|
slightly different from the emacs mode in the original Korn shell.
|
|
|
|
|
In this mode, various editing commands
|
|
|
|
|
(typically bound to one or more control characters) cause immediate actions
|
|
|
|
|
without waiting for a newline.
|
|
|
|
|
Several editing commands are bound to particular
|
|
|
|
|
control characters when the shell is invoked; these bindings can be changed
|
|
|
|
|
using the
|
|
|
|
|
.Ic bind
|
|
|
|
|
command.
|
|
|
|
|
.Pp
|
|
|
|
|
The following is a list of available editing commands.
|
|
|
|
|
Each description starts with the name of the command,
|
|
|
|
|
suffixed with a colon;
|
|
|
|
|
an
|
|
|
|
|
.Op 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
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
e.g. the ASCII ESC character is written as \*(ha[.
|
2005-05-26 01:31:08 +02:00
|
|
|
|
These control sequences are not case sensitive.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
A count prefix for a command is entered using the sequence
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Pf \*(ha[ Ns Ar n ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
where
|
|
|
|
|
.Ar n
|
|
|
|
|
is a sequence of 1 or more digits.
|
|
|
|
|
Unless otherwise specified, if a count is
|
|
|
|
|
omitted, it defaults to 1.
|
|
|
|
|
.Pp
|
|
|
|
|
Note that editing command names are used only with the
|
|
|
|
|
.Ic bind
|
|
|
|
|
command.
|
|
|
|
|
Furthermore, many editing commands are useful only on terminals with
|
|
|
|
|
a visible cursor.
|
|
|
|
|
The default bindings were chosen to resemble corresponding
|
|
|
|
|
Emacs key bindings.
|
|
|
|
|
The user's
|
|
|
|
|
.Xr tty 4
|
|
|
|
|
characters (e.g.\&
|
|
|
|
|
.Dv ERASE )
|
|
|
|
|
are bound to
|
|
|
|
|
reasonable substitutes and override the default bindings.
|
|
|
|
|
.Bl -tag -width Ds
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It abort: \*(haC, \*(haG
|
2006-08-08 22:19:14 +02:00
|
|
|
|
Abort the current command, empty the line buffer and
|
|
|
|
|
set the exit state to interrupted.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It auto\-insert: Op Ar n
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Simply causes the character to appear as literal input.
|
|
|
|
|
Most ordinary characters are bound to this.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo backward\-char:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
2009-05-16 16:44:37 +02:00
|
|
|
|
.No \*(haB , \*(haXD , ANSI-CurLeft
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Moves the cursor backward
|
|
|
|
|
.Ar n
|
|
|
|
|
characters.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo backward\-word:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
2010-01-08 23:21:06 +01:00
|
|
|
|
.No \*(ha[b , ANSI-Ctrl-CurLeft , ANSI-Alt-CurLeft
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Moves the cursor backward to the beginning of the word; words consist of
|
|
|
|
|
alphanumerics, underscore
|
|
|
|
|
.Pq Sq _ ,
|
|
|
|
|
and dollar sign
|
|
|
|
|
.Pq Sq $
|
|
|
|
|
characters.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It beginning\-of\-history: \*(ha[\*(Lt
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Moves to the beginning of the history.
|
2009-05-16 16:44:37 +02:00
|
|
|
|
.It beginning\-of\-line: \*(haA, ANSI-Home
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Moves the cursor to the beginning of the edited input line.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo capitalise\-word:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha[C , \*(ha[c
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Uppercase the first character in the next
|
|
|
|
|
.Ar n
|
|
|
|
|
words, leaving the cursor past the end of the last word.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It clear\-screen: \*(ha[\*(haL
|
2007-07-31 17:29:40 +02:00
|
|
|
|
Prints a compile-time configurable sequence to clear the screen and home
|
|
|
|
|
the cursor, redraws the entire prompt and the currently edited input line.
|
|
|
|
|
The default sequence works for almost all standard terminals.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It comment: \*(ha[#
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If the current line does not begin with a comment character, one is added at
|
|
|
|
|
the beginning of the line and the line is entered (as if return had been
|
|
|
|
|
pressed); otherwise, the existing comment characters are removed and the cursor
|
|
|
|
|
is placed at the beginning of the line.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It complete: \*(ha[\*(ha[
|
2005-05-23 05:06:10 +02:00
|
|
|
|
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
|
|
|
|
|
.Ql /
|
|
|
|
|
is appended.
|
|
|
|
|
If there is no command or file name with the current partial word
|
|
|
|
|
as its prefix, a bell character is output (usually causing a beep to be
|
|
|
|
|
sounded).
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It complete\-command: \*(haX\*(ha[
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Automatically completes as much as is unique of the command name having the
|
|
|
|
|
partial word up to the cursor as its prefix, as in the
|
|
|
|
|
.Ic complete
|
|
|
|
|
command above.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It complete\-file: \*(ha[\*(haX
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Automatically completes as much as is unique of the file name having the
|
|
|
|
|
partial word up to the cursor as its prefix, as in the
|
|
|
|
|
.Ic complete
|
|
|
|
|
command described above.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It complete\-list: \*(haI, \*(ha[=
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Complete as much as is possible of the current word,
|
|
|
|
|
and list the possible completions for it.
|
|
|
|
|
If only one completion is possible,
|
|
|
|
|
match as in the
|
|
|
|
|
.Ic complete
|
|
|
|
|
command above.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
Note that \*(haI is usually generated by the TAB (tabulator) key.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo delete\-char\-backward:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No ERASE , \*(ha? , \*(haH
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Deletes
|
|
|
|
|
.Ar n
|
|
|
|
|
characters before the cursor.
|
2009-05-16 16:44:37 +02:00
|
|
|
|
.It Xo delete\-char\-forward:
|
|
|
|
|
.Op Ar n
|
|
|
|
|
.No ANSI-Del
|
|
|
|
|
.Xc
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Deletes
|
|
|
|
|
.Ar n
|
|
|
|
|
characters after the cursor.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo delete\-word\-backward:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
2009-05-16 16:34:58 +02:00
|
|
|
|
.No WERASE , \*(ha[\*(ha? , \*(ha[\*(haH , \*(ha[h
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Deletes
|
|
|
|
|
.Ar n
|
|
|
|
|
words before the cursor.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo delete\-word\-forward:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha[d
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Deletes characters after the cursor up to the end of
|
|
|
|
|
.Ar n
|
|
|
|
|
words.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo down\-history:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
2009-05-16 16:44:37 +02:00
|
|
|
|
.No \*(haN , \*(haXB , ANSI-CurDown
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Scrolls the history buffer forward
|
|
|
|
|
.Ar n
|
|
|
|
|
lines (later).
|
|
|
|
|
Each input line originally starts just after the last entry
|
|
|
|
|
in the history buffer, so
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic down\-history
|
2005-05-23 05:06:10 +02:00
|
|
|
|
is not useful until either
|
2009-05-16 16:19:23 +02:00
|
|
|
|
.Ic search\-history ,
|
|
|
|
|
.Ic search\-history\-up
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic up\-history
|
2005-05-23 05:06:10 +02:00
|
|
|
|
has been performed.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo downcase\-word:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha[L , \*(ha[l
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Lowercases the next
|
|
|
|
|
.Ar n
|
|
|
|
|
words.
|
2008-09-30 20:43:07 +02:00
|
|
|
|
.It Xo edit\-line:
|
2009-03-22 19:09:17 +01:00
|
|
|
|
.Op Ar n
|
2008-09-30 20:43:07 +02:00
|
|
|
|
.No \*(haXe
|
|
|
|
|
.Xc
|
|
|
|
|
Edit line
|
|
|
|
|
.Ar n
|
|
|
|
|
or the current line, if not specified, interactively.
|
|
|
|
|
The actual command executed is
|
|
|
|
|
.Ic fc \-e ${VISUAL:\-${EDITOR:\-vi}} Ar n .
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It end\-of\-history: \*(ha[\*(Gt
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Moves to the end of the history.
|
2009-05-16 16:44:37 +02:00
|
|
|
|
.It end\-of\-line: \*(haE, ANSI-End
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Moves the cursor to the end of the input line.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It eot: \*(ha_
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Acts as an end-of-file; this is useful because edit-mode input disables
|
|
|
|
|
normal terminal input canonicalization.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo eot\-or\-delete:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(haD
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Acts as
|
|
|
|
|
.Ic eot
|
|
|
|
|
if alone on a line; otherwise acts as
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic delete\-char\-forward .
|
2007-07-31 17:29:40 +02:00
|
|
|
|
.It error: (not bound)
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Error (ring the bell).
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It exchange\-point\-and\-mark: \*(haX\*(haX
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Places the cursor where the mark is and sets the mark to where the cursor was.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It expand\-file: \*(ha[*
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Appends a
|
|
|
|
|
.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.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo forward\-char:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
2009-05-16 16:44:37 +02:00
|
|
|
|
.No \*(haF , \*(haXC , ANSI-CurRight
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Moves the cursor forward
|
|
|
|
|
.Ar n
|
|
|
|
|
characters.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo forward\-word:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
2010-01-08 23:21:06 +01:00
|
|
|
|
.No \*(ha[f , ANSI-Ctrl-CurRight , ANSI-Alt-CurRight
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Moves the cursor forward to the end of the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
word.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo goto\-history:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha[g
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Goes to history number
|
|
|
|
|
.Ar n .
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It kill\-line: KILL
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Deletes the entire input line.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It kill\-region: \*(haW
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Deletes the input between the cursor and the mark.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo kill\-to\-eol:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(haK
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Deletes the input from the cursor to the end of the line if
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified; otherwise deletes characters between the cursor and column
|
|
|
|
|
.Ar n .
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It list: \*(ha[?
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Prints a sorted, columnated list of command names or file names (if any) that
|
|
|
|
|
can complete the partial word containing the cursor.
|
|
|
|
|
Directory names have
|
|
|
|
|
.Ql /
|
|
|
|
|
appended to them.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It list\-command: \*(haX?
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Prints a sorted, columnated list of command names (if any) that can complete
|
|
|
|
|
the partial word containing the cursor.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It list\-file: \*(haX\*(haY
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Prints a sorted, columnated list of file names (if any) that can complete the
|
|
|
|
|
partial word containing the cursor.
|
|
|
|
|
File type indicators are appended as described under
|
|
|
|
|
.Ic list
|
|
|
|
|
above.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It newline: \*(haJ , \*(haM
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Causes the current input line to be processed by the shell.
|
|
|
|
|
The current cursor position may be anywhere on the line.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It newline\-and\-next: \*(haO
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Causes the current input line to be processed by the shell, and the next line
|
|
|
|
|
from history becomes the current line.
|
|
|
|
|
This is only useful after an
|
2009-05-16 16:19:23 +02:00
|
|
|
|
.Ic up\-history ,
|
|
|
|
|
.Ic search\-history
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
2009-05-16 16:19:23 +02:00
|
|
|
|
.Ic search\-history\-up .
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It no\-op: QUIT
|
2005-05-23 05:06:10 +02:00
|
|
|
|
This does nothing.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It prefix\-1: \*(ha[
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Introduces a 2-character command sequence.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It prefix\-2: \*(haX , \*(ha[[ , \*(ha[O
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Introduces a 2-character command sequence.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo prev\-hist\-word:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha[. , \*(ha[_
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
2011-02-09 14:08:18 +01:00
|
|
|
|
The last word, or, if given, the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
word (zero-based) of the previous (on repeated execution, second-last,
|
|
|
|
|
third-last, etc.) command is inserted at the cursor.
|
2008-10-05 01:08:04 +02:00
|
|
|
|
Use of this editing command trashes the mark.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It quote: \*(ha\*(ha , \*(haV
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The following character is taken literally rather than as an editing command.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It redraw: \*(haL
|
2007-04-30 21:16:30 +02:00
|
|
|
|
Reprints the last line of the prompt string and the current input line
|
|
|
|
|
on a new line.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo search\-character\-backward:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha[\*(ha]
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Search backward in the current line for the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
occurrence of the next character typed.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo search\-character\-forward:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha]
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Search forward in the current line for the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
occurrence of the next character typed.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It search\-history: \*(haR
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Enter incremental search mode.
|
|
|
|
|
The internal history list is searched
|
|
|
|
|
backwards for commands matching the input.
|
|
|
|
|
An initial
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \*(ha
|
2005-05-23 05:06:10 +02:00
|
|
|
|
in the search string anchors the search.
|
2006-08-08 22:19:14 +02:00
|
|
|
|
The escape key will leave search mode.
|
2008-09-30 20:48:01 +02:00
|
|
|
|
Other commands, including sequences of escape as
|
|
|
|
|
.Ic prefix\-1
|
|
|
|
|
followed by a
|
|
|
|
|
.Ic prefix\-1
|
|
|
|
|
or
|
|
|
|
|
.Ic prefix\-2
|
|
|
|
|
key will be executed after leaving search mode.
|
2008-10-19 22:15:45 +02:00
|
|
|
|
The
|
|
|
|
|
.Ic abort Pq \*(haG
|
|
|
|
|
command will restore the input line before search started.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Successive
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic search\-history
|
2005-05-23 05:06:10 +02:00
|
|
|
|
commands continue searching backward to the next previous occurrence of the
|
|
|
|
|
pattern.
|
|
|
|
|
The history buffer retains only a finite number of lines; the oldest
|
|
|
|
|
are discarded as necessary.
|
2009-05-16 16:45:40 +02:00
|
|
|
|
.It search\-history\-up: ANSI-PgUp
|
2009-05-16 16:19:23 +02:00
|
|
|
|
Search backwards through the history buffer for commands whose beginning match
|
|
|
|
|
the portion of the input line before the cursor.
|
|
|
|
|
When used on an empty line, this has the same effect as
|
|
|
|
|
.Ic up\-history .
|
2009-05-16 16:45:40 +02:00
|
|
|
|
.It search\-history\-down: ANSI-PgDn
|
2009-05-16 16:19:23 +02:00
|
|
|
|
Search forwards through the history buffer for commands whose beginning match
|
|
|
|
|
the portion of the input line before the cursor.
|
|
|
|
|
When used on an empty line, this has the same effect as
|
|
|
|
|
.Ic down\-history .
|
|
|
|
|
This is only useful after an
|
|
|
|
|
.Ic up\-history ,
|
|
|
|
|
.Ic search\-history
|
|
|
|
|
or
|
|
|
|
|
.Ic search\-history\-up .
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It set\-mark\-command: \*(ha[ Ns Aq space
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Set the mark at the cursor position.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It transpose\-chars: \*(haT
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If at the end of line, or if the
|
|
|
|
|
.Ic gmacs
|
|
|
|
|
option is set, this exchanges the two previous characters; otherwise, it
|
2007-06-23 21:07:14 +02:00
|
|
|
|
exchanges the previous and current characters and moves the cursor one
|
|
|
|
|
character to the right.
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo up\-history:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
2009-05-16 16:44:37 +02:00
|
|
|
|
.No \*(haP , \*(haXA , ANSI-CurUp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Scrolls the history buffer backward
|
|
|
|
|
.Ar n
|
|
|
|
|
lines (earlier).
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.It Xo upcase\-word:
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Op Ar n
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.No \*(ha[U , \*(ha[u
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Uppercase the next
|
|
|
|
|
.Ar n
|
|
|
|
|
words.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It version: \*(ha[\*(haV
|
2006-08-01 14:44:17 +02:00
|
|
|
|
Display the version of
|
2007-01-18 01:00:27 +01:00
|
|
|
|
.Nm mksh .
|
2006-08-01 14:44:17 +02:00
|
|
|
|
The current edit buffer is restored as soon as a key is pressed.
|
|
|
|
|
The restoring keypress is processed, unless it is a space.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It yank: \*(haY
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Inserts the most recently killed text string at the current cursor position.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It yank\-pop: \*(ha[y
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Immediately after a
|
|
|
|
|
.Ic yank ,
|
|
|
|
|
replaces the inserted text string with the next previously killed text string.
|
|
|
|
|
.El
|
|
|
|
|
.Ss Vi editing mode
|
2008-09-14 22:56:06 +02:00
|
|
|
|
.Em Note:
|
|
|
|
|
The vi command-line editing mode is orphaned, yet still functional.
|
|
|
|
|
.Pp
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The vi command-line editor in
|
|
|
|
|
.Nm
|
|
|
|
|
has basically the same commands as the
|
|
|
|
|
.Xr vi 1
|
|
|
|
|
editor with the following exceptions:
|
|
|
|
|
.Bl -bullet
|
|
|
|
|
.It
|
|
|
|
|
You start out in insert mode.
|
|
|
|
|
.It
|
2007-06-23 21:07:14 +02:00
|
|
|
|
There are file name and command completion commands:
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
=, \e, *, \*(haX, \*(haE, \*(haF, and, optionally,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Aq tab
|
|
|
|
|
and
|
|
|
|
|
.Aq esc .
|
|
|
|
|
.It
|
|
|
|
|
The
|
|
|
|
|
.Ic _
|
2007-06-23 21:07:14 +02:00
|
|
|
|
command is different (in
|
|
|
|
|
.Nm mksh ,
|
|
|
|
|
it is the last argument command; in
|
|
|
|
|
.Xr vi 1
|
|
|
|
|
it goes to the start of the current line).
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It
|
|
|
|
|
The
|
|
|
|
|
.Ic /
|
|
|
|
|
and
|
|
|
|
|
.Ic G
|
|
|
|
|
commands move in the opposite direction to the
|
|
|
|
|
.Ic j
|
|
|
|
|
command.
|
|
|
|
|
.It
|
|
|
|
|
Commands which don't make sense in a single line editor are not available
|
|
|
|
|
(e.g. screen movement commands and
|
|
|
|
|
.Xr ex 1 Ns -style
|
|
|
|
|
colon
|
|
|
|
|
.Pq Ic \&:
|
|
|
|
|
commands).
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
Like
|
|
|
|
|
.Xr vi 1 ,
|
|
|
|
|
there are two modes:
|
|
|
|
|
.Dq insert
|
|
|
|
|
mode and
|
|
|
|
|
.Dq command
|
|
|
|
|
mode.
|
|
|
|
|
In insert mode, most characters are simply put in the buffer at the
|
|
|
|
|
current cursor position as they are typed; however, some characters are
|
|
|
|
|
treated specially.
|
|
|
|
|
In particular, the following characters are taken from current
|
|
|
|
|
.Xr tty 4
|
|
|
|
|
settings
|
|
|
|
|
(see
|
|
|
|
|
.Xr stty 1 )
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
and have their usual meaning (normal values are in parentheses): kill (\*(haU),
|
|
|
|
|
erase (\*(ha?), werase (\*(haW), eof (\*(haD), intr (\*(haC), and quit (\*(ha\e).
|
2005-05-23 05:06:10 +02:00
|
|
|
|
In addition to
|
|
|
|
|
the above, the following characters are also treated specially in insert mode:
|
2011-07-16 19:08:04 +02:00
|
|
|
|
.Bl -tag -width XJXXXXM
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haE
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Command and file name enumeration (see below).
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haF
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Command and file name completion (see below).
|
|
|
|
|
If used twice in a row, the
|
|
|
|
|
list of possible completions is displayed; if used a third time, the completion
|
|
|
|
|
is undone.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haH
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Erases previous character.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haJ \*(Ba \*(haM
|
2005-05-23 05:06:10 +02:00
|
|
|
|
End of line.
|
|
|
|
|
The current line is read, parsed, and executed by the shell.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haV
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Literal next.
|
|
|
|
|
The next character typed is not treated specially (can be used
|
|
|
|
|
to insert the characters being described here).
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haX
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Command and file name expansion (see below).
|
|
|
|
|
.It Aq esc
|
|
|
|
|
Puts the editor in command mode (see below).
|
|
|
|
|
.It Aq tab
|
2007-06-23 21:07:14 +02:00
|
|
|
|
Optional file name and command completion (see
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ic \*(haF
|
2007-06-23 21:07:14 +02:00
|
|
|
|
above), enabled with
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-o vi\-tabcomplete .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
In command mode, each character is interpreted as a command.
|
|
|
|
|
Characters that
|
|
|
|
|
don't correspond to commands, are illegal combinations of commands, or are
|
|
|
|
|
commands that can't be carried out, all cause beeps.
|
|
|
|
|
In the following command descriptions, an
|
|
|
|
|
.Op Ar n
|
|
|
|
|
indicates the command may be prefixed by a number (e.g.\&
|
|
|
|
|
.Ic 10l
|
|
|
|
|
moves right 10 characters); if no number prefix is used,
|
|
|
|
|
.Ar n
|
|
|
|
|
is assumed to be 1 unless otherwise specified.
|
|
|
|
|
The term
|
|
|
|
|
.Dq current position
|
|
|
|
|
refers to the position between the cursor and the character preceding the
|
|
|
|
|
cursor.
|
|
|
|
|
A
|
|
|
|
|
.Dq word
|
|
|
|
|
is a sequence of letters, digits, and underscore characters or a sequence of
|
|
|
|
|
non-letter, non-digit, non-underscore, and non-whitespace characters (e.g.\&
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Dq ab2*&\*(ha
|
2005-05-23 05:06:10 +02:00
|
|
|
|
contains two words) and a
|
|
|
|
|
.Dq big-word
|
|
|
|
|
is a sequence of non-whitespace characters.
|
|
|
|
|
.Pp
|
2007-06-23 21:07:14 +02:00
|
|
|
|
Special
|
|
|
|
|
.Nm
|
|
|
|
|
vi commands:
|
|
|
|
|
.Pp
|
|
|
|
|
The following commands are not in, or are different from, the normal vi file
|
2005-05-23 05:06:10 +02:00
|
|
|
|
editor:
|
|
|
|
|
.Bl -tag -width 10n
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns _
|
|
|
|
|
.Xc
|
|
|
|
|
Insert a space followed by the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
big-word from the last command in the history at the current position and enter
|
|
|
|
|
insert mode; if
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified, the last word is inserted.
|
|
|
|
|
.It #
|
|
|
|
|
Insert the comment character
|
|
|
|
|
.Pq Sq #
|
|
|
|
|
at the start of the current line and return the line to the shell (equivalent
|
|
|
|
|
to
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ic I#\*(haJ ) .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns g
|
|
|
|
|
.Xc
|
|
|
|
|
Like
|
|
|
|
|
.Ic G ,
|
|
|
|
|
except if
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified, it goes to the most recent remembered line.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns v
|
|
|
|
|
.Xc
|
|
|
|
|
Edit line
|
|
|
|
|
.Ar n
|
|
|
|
|
using the
|
|
|
|
|
.Xr vi 1
|
|
|
|
|
editor; if
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified, the current line is edited.
|
|
|
|
|
The actual command executed is
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic fc \-e ${VISUAL:\-${EDITOR:\-vi}} Ar n .
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It * and \*(haX
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Command or file name expansion is applied to the current big-word (with an
|
|
|
|
|
appended
|
|
|
|
|
.Ql *
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
if the word contains no file globbing characters) \*(en the big-word is replaced
|
2005-05-23 05:06:10 +02:00
|
|
|
|
with the resulting words.
|
2009-05-31 19:41:09 +02:00
|
|
|
|
If the current big-word is the first on the line
|
|
|
|
|
or follows one of the characters
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql \&; ,
|
2006-01-27 11:58:36 +01:00
|
|
|
|
.Ql \*(Ba ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Ql & ,
|
2006-11-16 14:05:39 +01:00
|
|
|
|
.Ql \&( ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
or
|
2009-05-31 19:41:09 +02:00
|
|
|
|
.Ql \&) ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
and does not contain a slash
|
2009-05-31 19:41:09 +02:00
|
|
|
|
.Pq Sq / ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
then command expansion is done; otherwise file name expansion is done.
|
|
|
|
|
Command expansion will match the big-word against all aliases, functions, and
|
|
|
|
|
built-in commands as well as any executable files found by searching the
|
|
|
|
|
directories in the
|
|
|
|
|
.Ev PATH
|
|
|
|
|
parameter.
|
|
|
|
|
File name expansion matches the big-word against the files in the
|
|
|
|
|
current directory.
|
|
|
|
|
After expansion, the cursor is placed just past the last
|
|
|
|
|
word and the editor is in insert mode.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns \e ,
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Oo Ar n Oc Ns \*(haF ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Oo Ar n Oc Ns Aq tab ,
|
|
|
|
|
.No and
|
|
|
|
|
.Oo Ar n Oc Ns Aq esc
|
|
|
|
|
.Xc
|
|
|
|
|
Command/file name completion.
|
|
|
|
|
Replace the current big-word with the
|
|
|
|
|
longest unique match obtained after performing command and file name expansion.
|
|
|
|
|
.Aq tab
|
|
|
|
|
is only recognised if the
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic vi\-tabcomplete
|
2005-05-23 05:06:10 +02:00
|
|
|
|
option is set, while
|
|
|
|
|
.Aq esc
|
|
|
|
|
is only recognised if the
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic vi\-esccomplete
|
2005-05-23 05:06:10 +02:00
|
|
|
|
option is set (see
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Ic set \-o ) .
|
2005-05-23 05:06:10 +02:00
|
|
|
|
If
|
|
|
|
|
.Ar n
|
|
|
|
|
is specified, the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
possible completion is selected (as reported by the command/file name
|
|
|
|
|
enumeration command).
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It = and \*(haE
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Command/file name enumeration.
|
|
|
|
|
List all the commands or files that match the current big-word.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haV
|
2006-08-01 14:44:17 +02:00
|
|
|
|
Display the version of
|
2007-01-18 01:00:27 +01:00
|
|
|
|
.Nm mksh .
|
2006-08-01 14:44:17 +02:00
|
|
|
|
The current edit buffer is restored as soon as a key is pressed.
|
|
|
|
|
The restoring keypress is ignored.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It @ Ns Ar c
|
|
|
|
|
Macro expansion.
|
|
|
|
|
Execute the commands found in the alias
|
|
|
|
|
.Ar c .
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
Intra-line movement commands:
|
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns h and
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Oo Ar n Oc Ns \*(haH
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Move left
|
|
|
|
|
.Ar n
|
|
|
|
|
characters.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns l and
|
|
|
|
|
.Oo Ar n Oc Ns Aq space
|
|
|
|
|
.Xc
|
|
|
|
|
Move right
|
|
|
|
|
.Ar n
|
|
|
|
|
characters.
|
|
|
|
|
.It 0
|
|
|
|
|
Move to column 0.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(ha
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Move to the first non-whitespace character.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns \*(Ba
|
|
|
|
|
.Xc
|
|
|
|
|
Move to column
|
|
|
|
|
.Ar n .
|
|
|
|
|
.It $
|
|
|
|
|
Move to the last character.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns b
|
|
|
|
|
.Xc
|
|
|
|
|
Move back
|
|
|
|
|
.Ar n
|
|
|
|
|
words.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns B
|
|
|
|
|
.Xc
|
|
|
|
|
Move back
|
|
|
|
|
.Ar n
|
|
|
|
|
big-words.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns e
|
|
|
|
|
.Xc
|
|
|
|
|
Move forward to the end of the word,
|
|
|
|
|
.Ar n
|
|
|
|
|
times.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns E
|
|
|
|
|
.Xc
|
|
|
|
|
Move forward to the end of the big-word,
|
|
|
|
|
.Ar n
|
|
|
|
|
times.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns w
|
|
|
|
|
.Xc
|
|
|
|
|
Move forward
|
|
|
|
|
.Ar n
|
|
|
|
|
words.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns W
|
|
|
|
|
.Xc
|
|
|
|
|
Move forward
|
|
|
|
|
.Ar n
|
|
|
|
|
big-words.
|
|
|
|
|
.It %
|
|
|
|
|
Find match.
|
|
|
|
|
The editor looks forward for the nearest parenthesis, bracket, or
|
|
|
|
|
brace and then moves the cursor to the matching parenthesis, bracket, or brace.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns f Ns Ar c
|
|
|
|
|
.Xc
|
|
|
|
|
Move forward to the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
occurrence of the character
|
|
|
|
|
.Ar c .
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns F Ns Ar c
|
|
|
|
|
.Xc
|
|
|
|
|
Move backward to the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
occurrence of the character
|
|
|
|
|
.Ar c .
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns t Ns Ar c
|
|
|
|
|
.Xc
|
|
|
|
|
Move forward to just before the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
occurrence of the character
|
|
|
|
|
.Ar c .
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns T Ns Ar c
|
|
|
|
|
.Xc
|
|
|
|
|
Move backward to just before the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
occurrence of the character
|
|
|
|
|
.Ar c .
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns \&;
|
|
|
|
|
.Xc
|
|
|
|
|
Repeats the last
|
|
|
|
|
.Ic f , F , t ,
|
|
|
|
|
or
|
|
|
|
|
.Ic T
|
|
|
|
|
command.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns \&,
|
|
|
|
|
.Xc
|
|
|
|
|
Repeats the last
|
|
|
|
|
.Ic f , F , t ,
|
|
|
|
|
or
|
|
|
|
|
.Ic T
|
|
|
|
|
command, but moves in the opposite direction.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
Inter-line movement commands:
|
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns j ,
|
|
|
|
|
.Oo Ar n Oc Ns + ,
|
|
|
|
|
.No and
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Oo Ar n Oc Ns \*(haN
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Move to the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
next line in the history.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns k ,
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Oo Ar n Oc Ns \- ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.No and
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Oo Ar n Oc Ns \*(haP
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Move to the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
previous line in the history.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns G
|
|
|
|
|
.Xc
|
|
|
|
|
Move to line
|
|
|
|
|
.Ar n
|
|
|
|
|
in the history; if
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified, the number of the first remembered line is used.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns g
|
|
|
|
|
.Xc
|
|
|
|
|
Like
|
|
|
|
|
.Ic G ,
|
|
|
|
|
except if
|
|
|
|
|
.Ar n
|
|
|
|
|
is not specified, it goes to the most recent remembered line.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns / Ns Ar string
|
|
|
|
|
.Xc
|
|
|
|
|
Search backward through the history for the
|
|
|
|
|
.Ar n Ns th
|
|
|
|
|
line containing
|
|
|
|
|
.Ar string ;
|
|
|
|
|
if
|
|
|
|
|
.Ar string
|
|
|
|
|
starts with
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Ql \*(ha ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
the remainder of the string must appear at the start of the history line for
|
|
|
|
|
it to match.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns \&? Ns Ar string
|
|
|
|
|
.Xc
|
|
|
|
|
Same as
|
|
|
|
|
.Ic / ,
|
|
|
|
|
except it searches forward through the history.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns n
|
|
|
|
|
.Xc
|
|
|
|
|
Search for the
|
|
|
|
|
.Ar n Ns th
|
2006-12-06 14:46:28 +01:00
|
|
|
|
occurrence of the last search string;
|
|
|
|
|
the direction of the search is the same as the last search.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns N
|
|
|
|
|
.Xc
|
|
|
|
|
Search for the
|
|
|
|
|
.Ar n Ns th
|
2006-12-06 14:46:28 +01:00
|
|
|
|
occurrence of the last search string;
|
|
|
|
|
the direction of the search is the opposite of the last search.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
Edit commands
|
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns a
|
|
|
|
|
.Xc
|
|
|
|
|
Append text
|
|
|
|
|
.Ar n
|
|
|
|
|
times; goes into insert mode just after the current position.
|
|
|
|
|
The append is
|
|
|
|
|
only replicated if command mode is re-entered i.e.\&
|
|
|
|
|
.Aq esc
|
|
|
|
|
is used.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns A
|
|
|
|
|
.Xc
|
|
|
|
|
Same as
|
|
|
|
|
.Ic a ,
|
|
|
|
|
except it appends at the end of the line.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns i
|
|
|
|
|
.Xc
|
|
|
|
|
Insert text
|
|
|
|
|
.Ar n
|
|
|
|
|
times; goes into insert mode at the current position.
|
|
|
|
|
The insertion is only
|
|
|
|
|
replicated if command mode is re-entered i.e.\&
|
|
|
|
|
.Aq esc
|
|
|
|
|
is used.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns I
|
|
|
|
|
.Xc
|
|
|
|
|
Same as
|
|
|
|
|
.Ic i ,
|
|
|
|
|
except the insertion is done just before the first non-blank character.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns s
|
|
|
|
|
.Xc
|
|
|
|
|
Substitute the next
|
|
|
|
|
.Ar n
|
|
|
|
|
characters (i.e. delete the characters and go into insert mode).
|
|
|
|
|
.It S
|
|
|
|
|
Substitute whole line.
|
|
|
|
|
All characters from the first non-blank character to the
|
|
|
|
|
end of the line are deleted and insert mode is entered.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns c Ns Ar move-cmd
|
|
|
|
|
.Xc
|
|
|
|
|
Change from the current position to the position resulting from
|
|
|
|
|
.Ar n move-cmd Ns s
|
|
|
|
|
(i.e. delete the indicated region and go into insert mode); if
|
|
|
|
|
.Ar move-cmd
|
|
|
|
|
is
|
|
|
|
|
.Ic c ,
|
|
|
|
|
the line starting from the first non-blank character is changed.
|
|
|
|
|
.It C
|
|
|
|
|
Change from the current position to the end of the line (i.e. delete to the
|
|
|
|
|
end of the line and go into insert mode).
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns x
|
|
|
|
|
.Xc
|
|
|
|
|
Delete the next
|
|
|
|
|
.Ar n
|
|
|
|
|
characters.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns X
|
|
|
|
|
.Xc
|
|
|
|
|
Delete the previous
|
|
|
|
|
.Ar n
|
|
|
|
|
characters.
|
|
|
|
|
.It D
|
|
|
|
|
Delete to the end of the line.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns d Ns Ar move-cmd
|
|
|
|
|
.Xc
|
|
|
|
|
Delete from the current position to the position resulting from
|
|
|
|
|
.Ar n move-cmd Ns s ;
|
|
|
|
|
.Ar move-cmd
|
|
|
|
|
is a movement command (see above) or
|
|
|
|
|
.Ic d ,
|
|
|
|
|
in which case the current line is deleted.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns r Ns Ar c
|
|
|
|
|
.Xc
|
|
|
|
|
Replace the next
|
|
|
|
|
.Ar n
|
|
|
|
|
characters with the character
|
|
|
|
|
.Ar c .
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns R
|
|
|
|
|
.Xc
|
|
|
|
|
Replace.
|
|
|
|
|
Enter insert mode but overwrite existing characters instead of
|
|
|
|
|
inserting before existing characters.
|
|
|
|
|
The replacement is repeated
|
|
|
|
|
.Ar n
|
|
|
|
|
times.
|
|
|
|
|
.It Xo
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.Oo Ar n Oc Ns \*(TI
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xc
|
|
|
|
|
Change the case of the next
|
|
|
|
|
.Ar n
|
|
|
|
|
characters.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns y Ns Ar move-cmd
|
|
|
|
|
.Xc
|
|
|
|
|
Yank from the current position to the position resulting from
|
|
|
|
|
.Ar n move-cmd Ns s
|
|
|
|
|
into the yank buffer; if
|
|
|
|
|
.Ar move-cmd
|
|
|
|
|
is
|
|
|
|
|
.Ic y ,
|
|
|
|
|
the whole line is yanked.
|
|
|
|
|
.It Y
|
|
|
|
|
Yank from the current position to the end of the line.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns p
|
|
|
|
|
.Xc
|
|
|
|
|
Paste the contents of the yank buffer just after the current position,
|
|
|
|
|
.Ar n
|
|
|
|
|
times.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns P
|
|
|
|
|
.Xc
|
|
|
|
|
Same as
|
|
|
|
|
.Ic p ,
|
|
|
|
|
except the buffer is pasted at the current position.
|
|
|
|
|
.El
|
|
|
|
|
.Pp
|
|
|
|
|
Miscellaneous vi commands
|
|
|
|
|
.Bl -tag -width Ds
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haJ and \*(haM
|
2005-05-23 05:06:10 +02:00
|
|
|
|
The current line is read, parsed, and executed by the shell.
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It \*(haL and \*(haR
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Redraw the current line.
|
|
|
|
|
.It Xo
|
|
|
|
|
.Oo Ar n Oc Ns \&.
|
|
|
|
|
.Xc
|
|
|
|
|
Redo the last edit command
|
|
|
|
|
.Ar n
|
|
|
|
|
times.
|
|
|
|
|
.It u
|
|
|
|
|
Undo the last edit command.
|
|
|
|
|
.It U
|
|
|
|
|
Undo all changes that have been made to the current line.
|
|
|
|
|
.It Ar intr No and Ar quit
|
|
|
|
|
The interrupt and quit terminal characters cause the current line to be
|
|
|
|
|
deleted and a new prompt to be printed.
|
|
|
|
|
.El
|
|
|
|
|
.Sh FILES
|
2011-07-16 19:08:21 +02:00
|
|
|
|
.Bl -tag -width XetcXsuid_profile -compact
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It Pa \*(TI/.mkshrc
|
2011-07-16 19:08:21 +02:00
|
|
|
|
User mkshrc profile (non-privileged interactive shells); see
|
|
|
|
|
.Sx Startup files.
|
|
|
|
|
The location can be changed at compile time (for embedded systems);
|
|
|
|
|
AOSP Android builds use
|
|
|
|
|
.Pa /system/etc/mkshrc .
|
according to groff_char(7) and my own hard experiences, there is more wrong
with GNU groff – add some special handling to the BSD mdoc macros for it so
that the manual pages look good in both utf8 and ps (PDF) mode; also fix in
mksh wrong display of ` (groff: ‘), ' (groff: ’), \' (groff: ´), \- (groff:
U+2212 −), the en dash (nroff doesn’t have it, use the em dash there ONLY),
and ~ and ^ (groff: placed atop and size-reduced, for use as diacritics, in
manual pages bad since these are control characters there)
→ PDF manpage now has ‘’ “” and good-looking hyphens and mini and ~ and ^
→ utf8 manpage now has ‘’ “”, good-looking hyphens, cut’n’pasteable mini
→ nroff manpage still has '' "" instead of ugly `' ``'' or even `´
→ Debian lintian won’t complain any longer
2008-03-04 01:09:34 +01:00
|
|
|
|
.It Pa \*(TI/.profile
|
2011-07-16 19:08:21 +02:00
|
|
|
|
User profile (non-privileged login shells); see
|
|
|
|
|
.Sx Startup files
|
|
|
|
|
near the top of this manual.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Pa /etc/profile
|
2011-07-16 19:08:21 +02:00
|
|
|
|
System profile (login shells); see
|
|
|
|
|
.Sx Startup files.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.It Pa /etc/shells
|
|
|
|
|
Shell database.
|
2005-11-22 19:09:18 +01:00
|
|
|
|
.It Pa /etc/suid_profile
|
2011-07-16 19:08:21 +02:00
|
|
|
|
Suid profile (privileged shells); see
|
|
|
|
|
.Sx Startup files.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.El
|
2011-07-16 19:08:21 +02:00
|
|
|
|
.Pp
|
|
|
|
|
Note: On Android,
|
|
|
|
|
.Pa /system/etc/
|
|
|
|
|
contains the system and suid profile.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sh SEE ALSO
|
|
|
|
|
.Xr awk 1 ,
|
2010-08-28 19:21:46 +02:00
|
|
|
|
.Xr cat 1 ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xr ed 1 ,
|
|
|
|
|
.Xr getopt 1 ,
|
|
|
|
|
.Xr sed 1 ,
|
|
|
|
|
.Xr sh 1 ,
|
|
|
|
|
.Xr stty 1 ,
|
|
|
|
|
.Xr dup 2 ,
|
|
|
|
|
.Xr execve 2 ,
|
|
|
|
|
.Xr getgid 2 ,
|
|
|
|
|
.Xr getuid 2 ,
|
2005-10-21 14:41:56 +02:00
|
|
|
|
.Xr mknod 2 ,
|
|
|
|
|
.Xr mkfifo 2 ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xr open 2 ,
|
|
|
|
|
.Xr pipe 2 ,
|
2007-08-20 00:06:27 +02:00
|
|
|
|
.Xr rename 2 ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xr wait 2 ,
|
|
|
|
|
.Xr getopt 3 ,
|
2006-11-09 00:49:01 +01:00
|
|
|
|
.Xr nl_langinfo 3 ,
|
|
|
|
|
.Xr setlocale 3 ,
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Xr signal 3 ,
|
|
|
|
|
.Xr system 3 ,
|
|
|
|
|
.Xr tty 4 ,
|
|
|
|
|
.Xr shells 5 ,
|
|
|
|
|
.Xr environ 7 ,
|
2005-10-21 14:41:56 +02:00
|
|
|
|
.Xr script 7 ,
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.Xr utf\-8 7 ,
|
2005-10-21 14:41:56 +02:00
|
|
|
|
.Xr mknod 8
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Pp
|
|
|
|
|
.Pa http://docsrv.sco.com:507/en/man/html.C/sh.C.html
|
2012-11-20 19:25:12 +01:00
|
|
|
|
.Pp
|
|
|
|
|
.Pa https://www.mirbsd.org/ksh\-chan.htm
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Rs
|
|
|
|
|
.%A Morris Bolsky
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%B "The KornShell Command and Programming Language"
|
|
|
|
|
.%D 1989
|
|
|
|
|
.%I "Prentice Hall PTR"
|
|
|
|
|
.%P "xvi\ +\ 356 pages"
|
|
|
|
|
.%O "ISBN 978\-0\-13\-516972\-8 (0\-13\-516972\-0)"
|
|
|
|
|
.Re
|
|
|
|
|
.Rs
|
|
|
|
|
.%A Morris I. Bolsky
|
|
|
|
|
.%A David G. Korn
|
|
|
|
|
.%B "The New KornShell Command and Programming Language (2nd Edition)"
|
|
|
|
|
.%D 1995
|
|
|
|
|
.%I "Prentice Hall PTR"
|
|
|
|
|
.%P "xvi\ +\ 400 pages"
|
|
|
|
|
.%O "ISBN 978\-0\-13\-182700\-4 (0\-13\-182700\-6)"
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Re
|
|
|
|
|
.Rs
|
|
|
|
|
.%A Stephen G. Kochan
|
|
|
|
|
.%A Patrick H. Wood
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.%B "\\*(tNUNIX\\*(sP Shell Programming"
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%V "Revised Edition"
|
|
|
|
|
.%D 1990
|
|
|
|
|
.%I "Hayden"
|
|
|
|
|
.%P "xi\ +\ 490 pages"
|
|
|
|
|
.%O "ISBN 978\-0\-672\-48448\-3 (0\-672\-48448\-X)"
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Re
|
|
|
|
|
.Rs
|
|
|
|
|
.%A "IEEE Inc."
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.%B "\\*(tNIEEE\\*(sP Standard for Information Technology \*(en Portable Operating System Interface (POSIX)"
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%V "Part 2: Shell and Utilities"
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.%D 1993
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%I "IEEE Press"
|
|
|
|
|
.%P "xvii\ +\ 1195 pages"
|
|
|
|
|
.%O "ISBN 978\-1\-55937\-255\-8 (1\-55937\-255\-9)"
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Re
|
2006-05-10 21:30:33 +02:00
|
|
|
|
.Rs
|
|
|
|
|
.%A Bill Rosenblatt
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%B "Learning the Korn Shell"
|
2006-05-10 21:30:33 +02:00
|
|
|
|
.%D 1993
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%I "O'Reilly"
|
|
|
|
|
.%P "360 pages"
|
|
|
|
|
.%O "ISBN 978\-1\-56592\-054\-5 (1\-56592\-054\-6)"
|
2006-05-10 21:30:33 +02:00
|
|
|
|
.Re
|
|
|
|
|
.Rs
|
|
|
|
|
.%A Bill Rosenblatt
|
|
|
|
|
.%A Arnold Robbins
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%B "Learning the Korn Shell, Second Edition"
|
2006-05-10 21:30:33 +02:00
|
|
|
|
.%D 2002
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%I "O'Reilly"
|
|
|
|
|
.%P "432 pages"
|
|
|
|
|
.%O "ISBN 978\-0\-596\-00195\-7 (0\-596\-00195\-9)"
|
|
|
|
|
.Re
|
|
|
|
|
.Rs
|
|
|
|
|
.%A Barry Rosenberg
|
|
|
|
|
.%B "KornShell Programming Tutorial"
|
|
|
|
|
.%D 1991
|
2008-03-03 23:38:41 +01:00
|
|
|
|
.%I "Addison-Wesley Professional"
|
2006-07-27 16:45:30 +02:00
|
|
|
|
.%P "xxi\ +\ 324 pages"
|
|
|
|
|
.%O "ISBN 978\-0\-201\-56324\-5 (0\-201\-56324\-X)"
|
2006-05-10 21:30:33 +02:00
|
|
|
|
.Re
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sh AUTHORS
|
2009-05-16 16:17:39 +02:00
|
|
|
|
.Nm "The MirBSD Korn Shell"
|
|
|
|
|
is developed by
|
|
|
|
|
.An Thorsten Glaser Aq tg@mirbsd.org
|
|
|
|
|
and currently maintained as part of The MirOS Project.
|
2007-01-18 17:23:52 +01:00
|
|
|
|
This shell is based upon the Public Domain Korn SHell.
|
2009-05-16 16:17:39 +02:00
|
|
|
|
The developer of mksh recognises the efforts of the pdksh authors,
|
|
|
|
|
who had dedicated their work into Public Domain, our users, and
|
|
|
|
|
all contributors, such as the Debian and OpenBSD projects.
|
2011-09-13 20:46:46 +02:00
|
|
|
|
.\"
|
|
|
|
|
.\" Charles Forsyth, author of the (Public Domain) Bourne Shell clone,
|
|
|
|
|
.\" which mksh is derived from, agreed to the following:
|
|
|
|
|
.\"
|
|
|
|
|
.\" In countries where the Public Domain status of the work may not be
|
|
|
|
|
.\" valid, its primary author hereby grants a copyright licence to the
|
|
|
|
|
.\" general public to deal in the work without restriction and permis-
|
|
|
|
|
.\" sion to sublicence derivates under the terms of any (OSI approved)
|
|
|
|
|
.\" Open Source licence.
|
|
|
|
|
.\"
|
2009-05-16 16:17:39 +02:00
|
|
|
|
See the documentation, CVS, and web site for details.
|
2009-09-19 23:54:46 +02:00
|
|
|
|
.Sh CAVEATS
|
|
|
|
|
.Nm
|
|
|
|
|
only supports the Unicode BMP (Basic Multilingual Plane).
|
|
|
|
|
It has a different scope model from
|
|
|
|
|
.At
|
|
|
|
|
.Nm ksh ,
|
|
|
|
|
which leads to subtile differences in semantics for identical builtins.
|
2010-09-05 21:12:24 +02:00
|
|
|
|
.Pp
|
|
|
|
|
The parts of a pipeline, like below, are executed in subshells.
|
|
|
|
|
Thus, variable assignments inside them fail.
|
|
|
|
|
Use co-processes instead.
|
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
|
foo \*(Ba bar \*(Ba read baz # will not change $baz
|
2010-09-05 22:43:37 +02:00
|
|
|
|
foo \*(Ba bar \*(Ba& read \-p baz # will, however, do so
|
2010-09-05 21:12:24 +02:00
|
|
|
|
.Ed
|
2005-05-23 05:06:10 +02:00
|
|
|
|
.Sh BUGS
|
2010-01-27 19:36:19 +01:00
|
|
|
|
Suspending (using \*(haZ) pipelines like the one below will only suspend
|
|
|
|
|
the currently running part of the pipeline; in this example,
|
|
|
|
|
.Dq fubar
|
2010-09-05 21:12:24 +02:00
|
|
|
|
is immediately printed on suspension (but not later after an
|
|
|
|
|
.Ic fg ) .
|
2010-01-27 19:16:14 +01:00
|
|
|
|
.Bd -literal -offset indent
|
2011-03-06 02:50:11 +01:00
|
|
|
|
$ /bin/sleep 666 && echo fubar
|
2010-01-28 16:33:11 +01:00
|
|
|
|
.Ed
|
|
|
|
|
.Pp
|
2006-05-10 21:30:33 +02:00
|
|
|
|
This document attempts to describe
|
2012-11-20 19:25:12 +01:00
|
|
|
|
.Nm mksh\ R41
|
2007-04-30 21:16:30 +02:00
|
|
|
|
and up,
|
2007-06-23 21:07:14 +02:00
|
|
|
|
compiled without any options impacting functionality, such as
|
|
|
|
|
.Dv MKSH_SMALL ,
|
|
|
|
|
for an operating environment supporting all of its advanced needs.
|
2005-05-23 05:06:10 +02:00
|
|
|
|
Please report bugs in
|
|
|
|
|
.Nm
|
2006-08-23 00:49:38 +02:00
|
|
|
|
to the
|
2009-11-17 22:49:42 +01:00
|
|
|
|
.Mx
|
|
|
|
|
mailing list at
|
2012-10-21 19:42:51 +02:00
|
|
|
|
.Aq miros\-mksh@mirbsd.org
|
2009-11-17 22:49:42 +01:00
|
|
|
|
or in the
|
• remove strcasestr.c, use home-grown implementation¹, call it stricmp,
and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version
¹) side effect from creating API-correct cstrchr, cstrstr, etc.
uses goto so it must be better ☻
tested on mirbsd-current via both Makefile and Build.sh
2007-03-04 04:04:28 +01:00
|
|
|
|
.Li \&#\&!/bin/mksh
|
2007-06-23 21:07:14 +02:00
|
|
|
|
.Pq or Li \&#ksh
|
2006-08-23 00:49:38 +02:00
|
|
|
|
IRC channel at
|
2012-06-29 10:11:45 +02:00
|
|
|
|
.Pa irc.freenode.net
|
|
|
|
|
.Pq Port 6697 SSL, 6667 unencrypted .
|