History log of /openbsd-current/bin/ksh/ksh.1
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.220 20-Oct-2023 schwarze

Improve markup in some cases where .Li was abused.
Triggered by a smaller diff from jan@.
OK jmc@ jan@


Revision tags: OPENBSD_7_4_BASE
# 1.219 10-Jun-2023 op

ksh: remove broken special handling of test -t

Drop the vestiges of the pre-POSIX support of `test -t' defaulting to fd
1. It doesn't work and it always succeed since "-t" is treated as a
string by default when no argument (fd) is specified.

diff by Lucas (lucas [at] sexy [dot] is) with minor change by me.
ok millert@


Revision tags: OPENBSD_7_3_BASE
# 1.218 26-Dec-2022 jmc

reformat some multiline markup, which had been causing an unwanted
space (specifically in the "alias", "readonly" and "typeset"
commands);

from josiah frentsos


Revision tags: OPENBSD_7_2_BASE
# 1.217 13-Sep-2022 kn

== in [[ does pattern matching as well

OK millert


Revision tags: OPENBSD_7_1_BASE
# 1.216 31-Mar-2022 naddy

man pages: add missing commas between subordinate and main clauses

jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@


Revision tags: OPENBSD_7_0_BASE
# 1.215 04-May-2021 naddy

shell scripts should use getopts instead of getopt

Add a prominent deprecation notice to getopt.1.
Add examples of the getopts idiom to sh.1 and ksh.1.

Requested by and ok espie@, ok jmc@


Revision tags: OPENBSD_6_9_BASE
# 1.214 11-Mar-2021 jmc

groff complains about the word "An" in an Rs/Re block, believing it a macro,
so escape it;


# 1.213 10-Mar-2021 millert

Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.219 10-Jun-2023 op

ksh: remove broken special handling of test -t

Drop the vestiges of the pre-POSIX support of `test -t' defaulting to fd
1. It doesn't work and it always succeed since "-t" is treated as a
string by default when no argument (fd) is specified.

diff by Lucas (lucas [at] sexy [dot] is) with minor change by me.
ok millert@


Revision tags: OPENBSD_7_3_BASE
# 1.218 26-Dec-2022 jmc

reformat some multiline markup, which had been causing an unwanted
space (specifically in the "alias", "readonly" and "typeset"
commands);

from josiah frentsos


Revision tags: OPENBSD_7_2_BASE
# 1.217 13-Sep-2022 kn

== in [[ does pattern matching as well

OK millert


Revision tags: OPENBSD_7_1_BASE
# 1.216 31-Mar-2022 naddy

man pages: add missing commas between subordinate and main clauses

jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@


Revision tags: OPENBSD_7_0_BASE
# 1.215 04-May-2021 naddy

shell scripts should use getopts instead of getopt

Add a prominent deprecation notice to getopt.1.
Add examples of the getopts idiom to sh.1 and ksh.1.

Requested by and ok espie@, ok jmc@


Revision tags: OPENBSD_6_9_BASE
# 1.214 11-Mar-2021 jmc

groff complains about the word "An" in an Rs/Re block, believing it a macro,
so escape it;


# 1.213 10-Mar-2021 millert

Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.218 26-Dec-2022 jmc

reformat some multiline markup, which had been causing an unwanted
space (specifically in the "alias", "readonly" and "typeset"
commands);

from josiah frentsos


Revision tags: OPENBSD_7_2_BASE
# 1.217 13-Sep-2022 kn

== in [[ does pattern matching as well

OK millert


Revision tags: OPENBSD_7_1_BASE
# 1.216 31-Mar-2022 naddy

man pages: add missing commas between subordinate and main clauses

jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@


Revision tags: OPENBSD_7_0_BASE
# 1.215 04-May-2021 naddy

shell scripts should use getopts instead of getopt

Add a prominent deprecation notice to getopt.1.
Add examples of the getopts idiom to sh.1 and ksh.1.

Requested by and ok espie@, ok jmc@


Revision tags: OPENBSD_6_9_BASE
# 1.214 11-Mar-2021 jmc

groff complains about the word "An" in an Rs/Re block, believing it a macro,
so escape it;


# 1.213 10-Mar-2021 millert

Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.217 13-Sep-2022 kn

== in [[ does pattern matching as well

OK millert


Revision tags: OPENBSD_7_1_BASE
# 1.216 31-Mar-2022 naddy

man pages: add missing commas between subordinate and main clauses

jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@


Revision tags: OPENBSD_7_0_BASE
# 1.215 04-May-2021 naddy

shell scripts should use getopts instead of getopt

Add a prominent deprecation notice to getopt.1.
Add examples of the getopts idiom to sh.1 and ksh.1.

Requested by and ok espie@, ok jmc@


Revision tags: OPENBSD_6_9_BASE
# 1.214 11-Mar-2021 jmc

groff complains about the word "An" in an Rs/Re block, believing it a macro,
so escape it;


# 1.213 10-Mar-2021 millert

Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.216 31-Mar-2022 naddy

man pages: add missing commas between subordinate and main clauses

jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@


Revision tags: OPENBSD_7_0_BASE
# 1.215 04-May-2021 naddy

shell scripts should use getopts instead of getopt

Add a prominent deprecation notice to getopt.1.
Add examples of the getopts idiom to sh.1 and ksh.1.

Requested by and ok espie@, ok jmc@


Revision tags: OPENBSD_6_9_BASE
# 1.214 11-Mar-2021 jmc

groff complains about the word "An" in an Rs/Re block, believing it a macro,
so escape it;


# 1.213 10-Mar-2021 millert

Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.215 04-May-2021 naddy

shell scripts should use getopts instead of getopt

Add a prominent deprecation notice to getopt.1.
Add examples of the getopts idiom to sh.1 and ksh.1.

Requested by and ok espie@, ok jmc@


Revision tags: OPENBSD_6_9_BASE
# 1.214 11-Mar-2021 jmc

groff complains about the word "An" in an Rs/Re block, believing it a macro,
so escape it;


# 1.213 10-Mar-2021 millert

Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.214 11-Mar-2021 jmc

groff complains about the word "An" in an Rs/Re block, believing it a macro,
so escape it;


# 1.213 10-Mar-2021 millert

Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.212 08-Mar-2021 jsg

use a journal reference instead of cstr when possible


# 1.211 08-Mar-2021 jsg

Add some references, most of these were removed when we stopped building
and installing USD/SMM/PSD docs.

jmc@ agrees with the direction, ok millert@ on an earlier diff


Revision tags: OPENBSD_6_8_BASE
# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.210 20-Sep-2020 millert

Clear screen before redrawing the line with ^L, also in input mode.
This is similar to the emacs mode clear-screen command. Unlike
bash, but like zsh, ^L also works in input mode, not just command
mode. OK kn@ tb@


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.209 07-Jul-2020 jca

Add support for set -o pipefail

With the pipefail option set, the exit status of a pipeline is 0 if all
commands succeed, or the return status of the rightmost command that
fails. This can help stronger error checking, but is not a silver
bullet. For example, commands will exhibit a non-zero exit status if
they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was
considered useful enough to be included in the next POSIX standard.

This implementation remembers the value of the pipefail option when
a pipeline is started, as described as option 1) in

https://www.austingroupbugs.net/view.php?id=789#c4102

Requested by ajacoutot@, ok millert@


Revision tags: OPENBSD_6_7_BASE
# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.208 26-Nov-2019 jmc

some corrections to CDPATH;
from chohag


Revision tags: OPENBSD_6_6_BASE
# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.207 24-Jun-2019 jca

Fix spelling


# 1.206 24-Jun-2019 schwarze

Partial revert of rev. 1.151:
Reference the First Edition (1989) of Bolsky/Korn which is about ksh88,
the shell the OpenBSD ksh(1) descends from (via pdksh).
The Second Edition (1995) of the book is about ksh93 which we don't provide.
Pointed out by Andras Farkas on bugs@.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.205 21-Jun-2019 jmc

zap trailing whitespace;


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.204 19-Jun-2019 millert

Allow string greater/less than than operators to work with test aka [.
Previously they were only recognized in [[ ... ]] expressions. This
changes sh/ksh to be consistent with test(1) as well as shells like
bash and dash. OK jca@ jmc@


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


Revision tags: OPENBSD_6_5_BASE
# 1.203 03-Apr-2019 jca

Bind ^L (C-l) to clear-screen instead of redraw

Slightly more useful for some, same defaults as bash.
No objection deraadt@ phessler@, ok tb@ kn@ benno@


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.202 16-Dec-2018 schwarze

Tweak the syntax displays to show that the list of words
in "for name in [word ...]; do list; done" can be empty.
In sh(1), clarify what happens in that case.
In ksh(1), clarify how it can happen that the list is never executed.
OK jmc@ tb@


Revision tags: OPENBSD_6_4_BASE
# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.201 18-Jun-2018 millert

Add clear-screen emacs editing command, currently not bound to a
key by default. The shell will query the terminfo database to
find the escape sequence to clear the screen. OK deraadt@


# 1.200 30-May-2018 benno

point readers to the correct place instead of having them
jump around.

suggested and ok jmc@, ok jcm@


# 1.199 18-May-2018 benno

remove the alias type='whence -v' and replace it with
a buildin command, that just calls into c_whence().
This makes type look like the buildin in other shells and makes
things like system("'type' 'git'"); work.

With lots of suggestions and feedback from anton@, kn@ and jca@.
ok kn@ jca@


Revision tags: OPENBSD_6_3_BASE
# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.198 06-Feb-2018 schwarze

Clarify that the "bind" built-in command only affects Emacs editing
mode, to avoid potential confusion pointed out by andreas dot kahari
at icm dot uu dot se on misc@.
Patch minimally tweaked based on a comment from jmc@.
OK anton@ jca@ jmc@ on the previous version without the tweak.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.


# 1.197 12-Dec-2017 tb

Document change in the default shell prompts.

Discussed with and ok jmc


# 1.196 22-Nov-2017 anton

Fix some incorrectness related to Emacs editing mode in ksh:

- Keep the order of bindings in sync between the manual and implementation
- Fix wrongly documented bindings in the manual
- Break out commands without a default binding in the manual

ok jmc@ tb@


Revision tags: OPENBSD_6_2_BASE
# 1.195 30-Aug-2017 jca

Implement HISTCONTROL ignoredups & ignorespace features

ignoredups: don't save the current line if it is identical to the last
history line.
ignorespace: don't save the current line if it starts with a space

ok anton@ millert@


# 1.194 30-Aug-2017 jca

Stop exposing the emacs-usemeta option, and warn when trying to set it.

Unused since 2012, to be removed after 6.2. Input from anton@,
ok anton@ millert@


# 1.193 19-Aug-2017 jmc

\$ in PS1 gets you the default prompt character, which differs from the
default prompt by not including a space after the character;

diff from scott cheloha


# 1.192 11-Aug-2017 guenther

Retire old behavior of requiring root prompt to contain # or \!

Requested by akoshibe and phessler
ok phessler@ anton@ jca@


# 1.191 06-Jul-2017 schwarze

fix broken cross references; found with mandoc -Tlint


# 1.190 04-Jul-2017 anton

Backout previous due to a bug discovered by zhuk@ that requires some tinkering
and is not an easy fix for now.


# 1.189 04-Jul-2017 anton

Add support for pattern substitution to variables in ksh using a common syntax
borrowed from ksh93.

Survived a ports build performed by naddy@ and encouraged by many.


# 1.188 20-Jun-2017 brynet

'^T' is documented to be bounded to transpose-chars while in emacs
mode, not "stuff". While here, remove the poorly described "stuff"
and "stuff" bind functions as well..

In the unlikely event anyone has those in .kshrc, they'll need to
be removed.

ok anton@


Revision tags: OPENBSD_6_1_BASE
# 1.187 19-Feb-2017 schwarze

Assigning to RANDOM calls srand_deterministic(3), not srand(3),
and simplify the next sentence; triggered by a different patch
from Anton dot Lindqvist at gmail dot com.

OK millert@ tb@


# 1.186 14-Nov-2016 schwarze

Markup improvements:
1. Mark up reserved words intended to appear at the beginning of command
lines with .Ic.
2. Mark up syntax elements intended to appear in the middle of command
lines with .Cm.

This is not only more systematic, but also makes internal search
commands like :tif<enter>, :tstop<enter>, and :t[[<enter> work in
man(1).


# 1.185 15-Oct-2016 jmc

remove the "in the future" notes from the past;
from ray lai


# 1.184 14-Oct-2016 schwarze

Correct description of the "bind" builtin command.

jmc@ finds the key binding stuff "disgusting" (i can't argue with that)
and doesn't want to comment on the content, but agrees with the wording.


# 1.183 07-Oct-2016 tedu

note that ulimit -m is not enforced, spotted by jmc


# 1.182 30-Sep-2016 jmc

remove unneccessary .Pp; from jan stary


# 1.181 27-Sep-2016 czarkoff

Move bug description to the BUGS section

OK natano@, jmc@

(I forgot to commit it back in mid-August when it was discussed.)


# 1.180 04-Sep-2016 nicm

Allow simple custom completions by creating an array named
"complete_commandname_argnum", for example:

set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM

To set completions for the first argument to kill(1). If no complete_*
arrays are present, the normal filename completion is offered.

positive comments from many; man page ok/tweaks jmc; ok tedu


Revision tags: OPENBSD_6_0_BASE
# 1.179 27-Apr-2016 naddy

Do not handle echo "`echo \"hi\"`" in POSIX mode differently than in
traditional mode. This aligns ksh's behavior with bash and FreeBSD sh.
The interpretation of the POSIX text is disputed, but it is unlikely
that a change from the traditional behavior was intended.

ok millert@


# 1.178 21-Mar-2016 tb

More ksh POSIX compliance fixes by Martijn Dekker:

This simple patch makes the 'command' builtin POSIX-compliant and
consistent with other current shells. It fixes two things:

a) 'command -v' does not find shell reserved words (a.k.a. keywords).
For instance, 'command -v select' outputs nothing but should output
'select'.

b) 'command -pv' always outputs the path of an external command, even
if 'command -p' would execute a builtin. For instance, 'command -p kill'
executes the 'kill' builtin, as expected, but 'command -pv kill' outputs
'/bin/kill'. The '-v' option is supposed to reflect what would actually
be executed, so 'command -pv kill' should output 'kill'. The -p option
sets the PATH to a default system value before doing the search, but
that has no bearing on the fact that builtins take precedence over
external commands.

The patch fixes both issues for 'command' without affecting the
behaviour of the ksh-specific builtin 'whence', which is handled by the
same C function.

Regression test added to obsd-regress.t.

Issues found and fixed by Martijn Dekker, ok millert@


# 1.177 06-Mar-2016 jmc

tweak previous a little;


# 1.176 06-Mar-2016 natano

Make set +o conform with POSIX.

It should be possible to use set +o to save the current shell options,
then modify them at will and later restore them to the saved value.
Therefore the output must not only contain the options which are
currently set, but also the ones that are _not_ set, so a restore
disables them if they are enabled.

from Martijn Dekker (martijn (at) inlv (dot) org)
ok sthen@, tb@


# 1.175 04-Mar-2016 millert

Fix a typo. The command is to get the default system PATH value
is "getconf PATH" not "getconf CS_PATH".


# 1.174 04-Mar-2016 deraadt

remove CSRG BSD-licensed mknod builtin code which was previously used to
accelerate install/upgrade time MAKEDEV runs. That allows ramdisk ksh
to be pledged, without needing "dpath". We'll solve the performance issues
a different way (soon).
ok otto espie natano tb tobiasu rpe


Revision tags: OPENBSD_5_9_BASE
# 1.173 29-Dec-2015 mmcc

Remove reference to $ERRNO, which was been unimplemented for >= 19
years.

From Michael Reed. ok halex@


# 1.172 26-Dec-2015 jmc

remove special characters; diff from michael reed


# 1.171 24-Nov-2015 mmcc

Revert previous tweak, pending a more complete rewording. Discussed with
halex@, sthen@, jmc@.


# 1.170 22-Nov-2015 mmcc

This man page uses "Note that" profusely, which is generally considered
bad writing style. Also, add a paragraph break and split up a
megasentence.


# 1.169 22-Nov-2015 mmcc

Don't use pdksh for self-reference and remove needless historical
context.


# 1.168 22-Nov-2015 mmcc

Remove commented-out BUGS section that directs reports to long-extinct
upstream.


# 1.167 21-Nov-2015 mmcc

"one" -> "one or more"


# 1.166 09-Nov-2015 jmc

add missing NAME entries; ok schwarze


# 1.165 30-Oct-2015 jmc

zap trailing whitespace;


# 1.164 30-Oct-2015 millert

Try to clarify the fc section a tad; fc apprently stands for "fix command".
Also the "fc -e -" syntax is obsoleted by "fc -s". OK tedu@


# 1.163 30-Oct-2015 guenther

'fc -e -' is deprecated in favor of 'fc -s', so update the built-in alias

ok millert@


# 1.162 17-Oct-2015 jmc

add missing underscore; from theo buehler


# 1.161 14-Sep-2015 schwarze

Avoid .Ns right after .Pf, it's pointless.
In some cases, do additional cleanup in the immediate vicinity.


Revision tags: OPENBSD_5_8_BASE
# 1.160 04-Jul-2015 feinerer

Use "alternation" consistently

ok jmc@


# 1.159 25-Mar-2015 jca

Bind the Delete key (ESC[3~) to delete-char-forward

ok mpi@


# 1.158 15-Mar-2015 jmc

from zhuk: paths not beginning dot (as well as slash) use CDPATH;


# 1.157 13-Mar-2015 jmc

remove the first comma from constructs like ", and," and ", or,": you can use
"and" and "or" to join sentence clauses, and you can use commas, but both hinders
reading;


Revision tags: OPENBSD_5_7_BASE
# 1.156 16-Jan-2015 schwarze

remove useless escaping; mandoc warned about some of this


# 1.155 09-Dec-2014 schwarze

put back some information what the character classes actually mean;
while here, remove the lie that regex(3) character classes would
depend on the locale;
ok jmc@


# 1.154 09-Dec-2014 jmc

no more ctype(3);


# 1.153 17-Aug-2014 jmc

update the built-ins list:
- "times" is both promoted to posix and special (ooh!)
- "pwd" is promoted to posix, but not special (aah!)

while here, jiggle the text somewhat to clarify that "non-POSIX"
actually meant when posix mode is off, not mandated by posix

joint work with guenther


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.152 12-Feb-2014 schwarze

missing .An macros, based on a patch from Jan Stary <hans at stare dot cz>


# 1.151 28-Jan-2014 jmc

update book references;
From: Jan Stary
tweaked a bit by myself


# 1.150 20-Jan-2014 schwarze

Obvious .Xr fixes, found while testing mandocdb(8).


# 1.149 18-Dec-2013 millert

Remove artificial limit on the max array index.
Adapted from a bitrig commit from Martin Natano.
OK zhuk@


# 1.148 04-Sep-2013 millert

Add a proper suspend builtin that saves/restores the tty and pgrp
as needed instead of an alias that just sends SIGSTOP. Login shells
may be suspended if they are not running in an orphan process group.
OK guenther@ jmc@


Revision tags: OPENBSD_5_4_BASE
# 1.147 13-Jun-2013 millert

Document correct interaction of -e flag with && and ||. OK jmc@


# 1.146 18-Mar-2013 mpi

Keep documentation in sync with reality and update binding examples.
This should have been part of the keybinding rewrote when support for
multi-character sequences has been added. Pointed out by mikeb@


Revision tags: OPENBSD_5_3_BASE
# 1.145 17-Jan-2013 jmc

remove some uesless Pp;


Revision tags: OPENBSD_5_2_BASE
# 1.144 08-Jul-2012 guenther

Document ${var[@]} and ${var[*]}

ok espie@


# 1.143 19-Jun-2012 jmc

for arithmetic expressions, note that:
+A parameter that is NULL or unset evaluates to 0.

original diff from robert peichaer
this version from naddy


# 1.142 30-Apr-2012 djm

generalise ksh keybinding system - bindings are no longer limited in
length and need not start with ESC or ^X; patch from marco@ feedback mpi@


Revision tags: OPENBSD_5_1_BASE
# 1.141 03-Sep-2011 jmc

make -column lists pretty again;

specifically, rewrite them to permit some markup in the column headers,
and use "Ta" instead of literal tabs; mandoc does not currently match groff
100%, but a mandoc fix may be some time off, and we've gone enough releases
with poorly formatting column lists.

in some cases i have rewritten the lists as -tag, where -column made
little sense.


Revision tags: OPENBSD_5_0_BASE
# 1.140 23-Apr-2011 sobrado

improve line breaking in SYNOPSIS now that semantics of the .Bk macro
has changed to conform with modern groff releases.

diff for route6d(8) written mostly by schwarze@, with lots of useful
advice from jmc@.

ok jmc@, schwarze@


# 1.139 09-Mar-2011 okan

substitute '~' for $HOME in the \W prompt case; matches bash's behavior.

feedback from Dan Harnett

OK deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.138 20-Sep-2010 jmc

according to ingo, it isn;t a problem to have empty [BDS]q macros, so
revert that part of yesterday's diffs;


# 1.137 18-Sep-2010 jmc

some macro cleanup:
- remove some old groff workarounds in SYNOPSIS
- avoid "Op ... Oc" constructions
- avoid empty Sq/Dq
- change some incorrect Xr


Revision tags: OPENBSD_4_8_BASE
# 1.136 15-Jul-2010 schwarze

When the first argument or arguments of a macro are opening delimiters
(parentheses and/or square brackets), both modern groff and mandoc first
output those leading delimiters as plain text, then start the macro scope
after these opening delimiters. This is similar to printing trailing
punctuation and trailing closing delimiters on a macro line outside and
after the macro scope. For example, ".Sq ( text )" is "(`text')",
not "`(text)'". Thus, we now need to quote leading opening delimiters
when we want them inside the macro scope.
These are the cases in src/bin.

"makes sense" jmc@


# 1.135 12-Jul-2010 jmc

ksh.1: add ((, )), ]], and `name' to the list of reserved words for compounds
sh.1: add ]] and `name' to the list; additionally document the commands
`select' (requested by Ross L Richardson) and [[

ok millert sobrado


# 1.134 10-May-2010 jmc

tweak previous;


# 1.133 10-May-2010 kili

unset doesn't fail except for read-only variables and functions

ok guenther@


# 1.132 27-Mar-2010 jmc

`b' and `c' arguments to mknod are not optional; from LEVAI Daniel
c_sh.c part from sobrado;

ok millert guenther


Revision tags: OPENBSD_4_7_BASE
# 1.131 26-Feb-2010 william

Array indices are limited to 0 through 10239 now.

ok jmc deraadt


# 1.130 25-Feb-2010 schwarze

get rid of overlapping blocks discouraged by mdoc.samples(7);
found by and unbreaking the build with mandoc(1);
"fine" jmc@ sobrado@


Revision tags: OPENBSD_4_6_BASE
# 1.129 28-May-2009 jmc

fix missing bracket by slightly rewriting; from Alan R. S. Bueno


# 1.128 06-Mar-2009 jmc

after some discussion with millert, pull in the character class info
from glob(7) to the shell pages - they have their own glob stuff,
and pointing to glob(7) is just not helpful.

ok millert


# 1.127 05-Mar-2009 millert

Add glob(7) and refer to it. OK jmc@ sobrado@


# 1.126 03-Mar-2009 millert

Add POSIX character class support ([:alpha:] and friends) to ksh globbing.
OK deraadt@ krw@ jmc@ sobrado@


Revision tags: OPENBSD_4_5_BASE
# 1.125 07-Feb-2009 jmc

some tweaks for previous that got missed;


# 1.124 07-Feb-2009 guenther

Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@


# 1.123 29-Jan-2009 jaredy

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to `&&' and `||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed `!'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.


Revision tags: OPENBSD_4_4_BASE
# 1.122 17-May-2008 sobrado

documentation tweaks.

ok (some time ago) jmc@


# 1.121 21-Mar-2008 millert

Make ulimit able to get and set multiple limits in a single invocation
like bash and zsh do. Requested by espie@, OK deraadt@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.120 31-May-2007 otto

Only process ENV when in interactive mode as SU says. Started by
tedu to fix make -j, SU thing spotted by naddy@; ok millert@ @tedu
jmc@ for the man page bit.


# 1.119 31-May-2007 jmc

convert to new .Dd format;


Revision tags: OPENBSD_4_1_BASE
# 1.118 30-Nov-2006 jmc

typos; from alf schlichting


Revision tags: OPENBSD_4_0_BASE
# 1.117 03-Aug-2006 jmc

comment fix; from tamas tevesz


# 1.116 26-Jul-2006 jmc

clarifications for OPTIND:

hunk #1 from tamas tevesz;
hunk #2 from otto;

ok otto


# 1.115 01-Jun-2006 jmc

simplify the PS1 section somewhat by moving the ! and \! stuff together;
ok otto


# 1.114 30-May-2006 jmc

document some advice when \$ is part of your prompt;
from otto and myself


# 1.113 29-May-2006 otto

Implement \$ and \# expansion for PS1. Whoever thought it a clever
idea to assign a special meaning to "\$" -- two chars that are already
(very) special -- deserves a spanking.


# 1.112 22-Apr-2006 jmc

back out last - it was not a command line prompt;
thanks matthias kilian


# 1.111 21-Apr-2006 jmc

missing command line prompt;


# 1.110 07-Mar-2006 jmc

simplify the description of what a restricted shell is:
sh.1 does not need to talk about rksh;
ksh.1 does not need to talk about rsh;
also references to rpdksh are not really helpful;

from tamas tevesz;
ok jaredy


Revision tags: OPENBSD_3_9_BASE
# 1.109 06-Dec-2005 jmc

make the PS1 section a little easier to read;


# 1.108 30-Nov-2005 jmc

document root PS1 feature:

from matthias kilian (pr #4924), but slightly tweaked version of his diff;
ok otto


# 1.107 16-Nov-2005 jmc

document the procedure for providing a startup file for interactive
(but non-login) shells;

document /etc/ksh.kshrc and sort FILES;

fix + ok otto@


# 1.106 12-Oct-2005 bernd

document new max array size

ok otto@


# 1.105 07-Oct-2005 jmc

brief description of mknod built-in;
add mknod to list of (regular ksh) built-ins;

ok otto@


# 1.104 06-Oct-2005 otto

Introducing mknod as a built-in. It might be against the unix
philosophy, but in this case it's worth it. ok deraadt@


# 1.103 07-Sep-2005 jmc

LINES and \\ in PS1 prompt are implemented, so remove information
which says they are not;

from matthias kilian (pr #4476);
ok otto@


Revision tags: OPENBSD_3_8_BASE
# 1.102 21-Aug-2005 millert

Comment out description for 'ulimit -v' since we don't support
RLIMIT_VMEM / RLIMIT_AS at the moment. Support for those may
go in post-3.8.


# 1.101 01-Aug-2005 jmc

more `version' removal;
ok otto@


# 1.100 01-Aug-2005 otto

Document ^V change from version to quote command


# 1.99 25-May-2005 jaredy

add missing detail from IFS example

From PR4220/TAKAHASHI Tamotsu <ttakah@lapis.plala.or.jp>


# 1.98 12-May-2005 jmc

.Xr script 7


Revision tags: OPENBSD_3_7_BASE
# 1.97 04-Mar-2005 jmc

document that $HOME is shown as `~' for PS1 \w substitutions;
diff from niall o'higgins, pr 4132 (slightly reworded);

ok otto@


# 1.96 18-Feb-2005 jmc

sort options to echo builtin;


# 1.95 16-Feb-2005 jmc

a note about why we have both EDITOR and VISUAL env vars;
ok otto@ jaredy@


# 1.94 16-Feb-2005 jmc

document that `emacs' is the default editing mode, and that as well
as being set explicitly w/ `set', modes can also be set using
EDITOR and VISUAL;

ok jaredy@ otto@


# 1.93 08-Feb-2005 jmc

oops, missed a prompt;


# 1.92 08-Feb-2005 jmc

use command prompts and literal for commands;


# 1.91 08-Feb-2005 jmc

big overhaul of these pages, to make them clearer to read;
various other issues fixed along the way;

lots of stuff from jaredy@ in here too..


# 1.90 05-Feb-2005 jmc

note that symlinks in test file are followed, except -h and -L
(just like test(1) does);

from paul de weerd;


# 1.89 02-Feb-2005 otto

Introduce POSIX hex and octal (0x... and 0...) constants in arithmetic
expressions. Work by Matthias Kilian, based on an old diff by myself.
Note: MAKEDEV should be updated. Tested by many, thanks.

ok millert@ deraadt@


# 1.88 19-Jan-2005 jmc

typo;


# 1.87 19-Jan-2005 jmc

although the description for the `comment' bind was in the page,
the bind itself (^[#) was missing;


# 1.86 17-Jan-2005 jmc

typo;


# 1.85 10-Jan-2005 jmc

typo;


# 1.84 22-Dec-2004 millert

These man pages are not derived from UCB and are actually public domain.
Verified with aaron@ who did the conversion from man -> mdoc.


# 1.83 22-Dec-2004 millert

Our times(3) just calls getrusage(2) and gettimeofday(2), converting seconds
to ticks. Since ksh needs things in seconds it then converted them back.
Avoid the silliness and use the getrusage(2) and gettimeofday(2) directly.
With man page help from jmc@


# 1.82 16-Dec-2004 jaredy

- document IFS behavior changes
- grammar, punctuation, xref, mdoc tweaks
- sort keywords
- indent example displays
- minimize against diffing between sh.1tbl
- document set -o sh
- tweak the displays of some editing and builtin commands
- rework some operator descriptions

ok jmc


# 1.81 12-Dec-2004 jmc

escape punctuation;


# 1.80 12-Dec-2004 deraadt

csh-style ! history completion, which can be activated by using
set -o csh-history (off by default)
this is not feature complete, and likely never will be. no ^
and ! has some oddities ... ksh's internal history stuff has got
some very odd behaviours that are rather nasty
ok various developers


# 1.79 04-Dec-2004 jaredy

minor tweaks; ok jmc


# 1.78 08-Nov-2004 jmc

add a more complex PS1 example, which does not use the new backslash
sequences;

from naddy@, via deraadt@


# 1.77 06-Nov-2004 jmc

correct my description of \[ and \]
found by (and ok) deraadt@


# 1.76 05-Nov-2004 jmc

document PS1 expansions;


# 1.75 05-Nov-2004 jmc

incorrect markup was messing the description of IFS. i've rearranged it
slightly so that no one (me, most likely) falls for it again.

also, make sh(1)'s IFS description a little more consistent.


# 1.74 03-Nov-2004 jaredy

HISTSIZE cranked to 500


# 1.73 28-Oct-2004 jaredy

fix spacing after period at EOL. from ray@cyth.net


# 1.72 07-Aug-2004 millert

Document ulimit -v; mickey@ OK


# 1.71 04-Aug-2004 jaredy

- mdoc and macro fixes and simplification
- punctuation and grammar fixes
- show prompts for example shell commands

help and ok jmc


# 1.70 09-May-2004 otto

Document new behavior of $RANDOM. ok deraadt@


# 1.69 30-Apr-2004 jmc

typo;
from ray at cyth dot net (PR 3762);


# 1.68 15-Mar-2004 jmc

missing commas;


# 1.67 15-Mar-2004 jmc

reversed word -> reserved word;
from Karl O. Pinc


# 1.66 19-Feb-2004 jmc

escape full stops where necessary to kill erroneous double spaces;
softly, softly, catchy monkey...


# 1.65 23-Jan-2004 jmc

`Ns' implies `No', so `Ns No' -> `Ns'; (even simpler in adduser(8))
discussed with todd@


# 1.64 15-Jan-2004 jmc

escape full stops properly to avoid double spaces;


# 1.63 27-Dec-2003 jmc

- revert a typo introduced when this page was mdoc'ed
- use .Sq rather than .Dq for single letters


# 1.62 22-Dec-2003 jmc

note that `&&' and `||' are left-associative;
from vax at carolina dot rr com (NetBSD PR 23814);

agreed (in principal) millert@ deraadt@


# 1.61 12-Dec-2003 naddy

typo; ok jmc@


# 1.60 28-Oct-2003 jmc

standard section order;


# 1.59 22-Oct-2003 jmc

macros with too many args;


# 1.58 04-Sep-2003 jmc

escapes in the wrong place;


# 1.57 02-Sep-2003 jmc

escape punctuation;
ok deraadt@


# 1.56 01-Sep-2003 naddy

In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are
taken as commands and cannot be entered literally.

Introduce a new shell option, emacs-usemeta, that allows to toggle
this behavior. The default is the traditional behavior; to enter
8-bit characters use "set +o emacs-usemeta".

ok fgsch@, henning@


# 1.55 19-Jul-2003 jmc

redrew -> redraw;
from Andrey Matveev.


# 1.54 07-Jul-2003 jmc

- convert some lists to displays
- .Ql -> .Sq where necessary
- remove some .Pp's before lists
- add missing .El
- remove some wrong macros


# 1.53 06-Jun-2003 jmc

liternal -> literal;


# 1.52 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.51 28-Apr-2003 jmc

typos;

suggestions, corrections and ok millert@


# 1.50 20-Mar-2003 jmc

typos;

from NetBSD (Soren Jacobsen)
ok millert@


# 1.49 14-Mar-2003 jmc

better document how getopts handles options;
plus typos;
from J.A. Neitzel;

Fixes PR 3141;
ok millert@


# 1.48 18-Sep-2002 deraadt

fix Xr refs; frisco@blackant.net


# 1.47 24-Sep-2001 camield

The 'newgrp' alias is explicitly disabled in our ksh, so do not mention
it in the manpage.

ok millert@


# 1.46 02-Sep-2001 aaron

Typo; addresses pr/2038 from tim@robbins.dropbear.id.au


# 1.45 25-Aug-2001 heko

OpenBSD doesn't have RLIMIT_VMEM or RLIMIT_SWAP, so we don't
have ulimit -v or -w either.
ok millert@


# 1.44 23-Aug-2001 pvalchev

fix a typo; tim@robbins.dropbear.id.au


# 1.43 03-Aug-2001 aaron

Typo; heko@iki.fi


# 1.42 31-Jul-2001 hugh

Documentation fixes per PR 1979 by Kaspar Toomik.


# 1.41 23-Jun-2001 deraadt

more .%A handling; bk@rt.fm


# 1.40 28-May-2001 aaron

Various fixes; mpech@prosoft.org.lv


# 1.39 12-Apr-2001 aaron

Insert some missing commas.


# 1.38 20-Feb-2001 aaron

Typo (introduced by me in mdoc conversion of Rev 1.15); d@


# 1.37 16-Jan-2001 aaron

typo; bk@rt.fm


# 1.36 19-Oct-2000 aaron

Where we talk about $$, also say mention that PIDs are not safe to use for
generating temporary file names, and point people to mktemp(1) instead.


# 1.35 06-Jul-2000 aaron

fix another, similar typo


# 1.34 06-Jul-2000 aaron

typo


# 1.33 21-Mar-2000 aaron

Sometimes it is confusing when a sentence begins with lowercase; d@


# 1.32 17-Mar-2000 aaron

Try to synchronize the ksh(1) and sh(1) man pages somewhat.


# 1.31 17-Mar-2000 aaron

Remove hard sentence breaks.


# 1.30 14-Mar-2000 aaron

Better mdoc formatting.


# 1.29 20-Nov-1999 dugsong

'braceexapnd' -> 'braceexpand'


# 1.28 17-Oct-1999 aaron

Minor formatting nits.


# 1.27 16-Oct-1999 aaron

Formatting fix.


# 1.26 23-Sep-1999 aaron

cetain -> certain; kwesterback@home.com


# 1.25 04-Aug-1999 millert

Turn <tab> completion on by default for people used to bash, tcsh, etc...


# 1.24 14-Jul-1999 aaron

update man page to pdksh v5.2.14


# 1.23 05-Jul-1999 aaron

mdoc'ify syntax of the more complicated commands; when I converted this man
page originally, I didn't know how to do such funky things


# 1.22 01-Jul-1999 aaron

remove trailing spaces; missed from a previous commit


# 1.21 15-Jun-1999 millert

patches from pdksh 5.2.13.11


# 1.20 14-Jun-1999 pjanzen

Fixed a bunch of typos, grammar errors, and unclear wording in the sh
man page, and the corresponding problems in the ksh page.


# 1.19 03-Jun-1999 aaron

use the hyphenated form "command-line" in the case of a compound adjective;
pjanzen@


# 1.18 30-May-1999 aaron

repairs


# 1.17 28-May-1999 aaron

be more conservative with the .Dq macro; in particular, use .Sq macros most of
the time instead when quoting 1-2 characters (makes it much easier to read);
based on a patch received awhile ago from d@


# 1.16 18-Mar-1999 aaron

``that that'' -> ``than that''; nash@mcs.net


# 1.15 02-Mar-1999 aaron

Finally, new and improved mandoc ksh/sh man pages. This took hours, and hours,
and hours... Someone please read it and find any typos I may have missed.


# 1.14 01-Mar-1999 aaron

obliveous -> oblivious; d@


# 1.13 19-Jan-1999 millert

Updates from pdksh-unstable-5.2.13.7. Most notable change is:
trap: exit traps now executed in subshells (without explicit exit call).
See the Changelog for a full list of changes.


# 1.12 29-Oct-1998 millert

Bug fixes from pdksh-unstable-5.2.13.4, including "official" versions of
some that we had already fixed locally.
o typeset -f FUNC doesn't print follows command (and expression) substitutions.
o when re-allocating memory, too much may be copied from old memory.
o set -o printed some options sans names.
o emacs mode: <esc>. in very fist command causes core dump.
o pdksh dumps core after a cd command.
o typeset -i reports on array elements that have no value
(at&t ksh reports on array base name - no index).
o ulimit -ctn unlimittttted kills shell (resource exceeded).
o ". /dev/null" says access denied.
o flag field in aliases incorrectly changed (all flags set instead of
clearing ISSET) in exec.c(flushcom).
o ${#array[*]} prints largest index instead of number of (set) elements
in an array (ksh88 does the former).
o sys_siglist[] doesn't always have NSIG non-null entries...


# 1.11 27-Sep-1998 aaron

preceeding -> preceding


# 1.10 07-Sep-1998 aaron

More man page fixes. Particularly fix uses of it's/its, affect/effect,
then/than and such. Other miscellaneous problems fixed across these source
files.


# 1.9 01-Sep-1998 deraadt

more man page fixes; aaron@ug.cs.dal.ca


# 1.8 24-Jul-1998 deraadt

fix spelling of separate; aaron@ug.cs.dal.ca


# 1.7 25-Jun-1998 millert

pdksh-5.2.13 + local changes


# 1.6 27-Mar-1998 deraadt

do not nest RS/RE


# 1.5 18-Mar-1998 marc

Document what sh/ksh does when the cd command matches a non empty path
in the CDPATH environment variable.


# 1.4 17-Jan-1998 millert

Don't document ulimit flags that don't exist


# 1.3 21-Nov-1996 downsj

sync


# 1.2 21-Nov-1996 downsj

Update to 5.2.12.


# 1.1 01-Oct-1996 downsj

Move ksh.1 to ksh.1tbl, fixing all of it's problems in one massive paradigm
shift.

Or something like that.