History log of /openbsd-current/bin/ksh/sh.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.77 21-Jun-2023 millert

ksh: escape control chars when displaying file name completions.
If there are multiple matches when using autocomplete, the list of
matching file names was output as-is. However, for a single match,
control characters are escaped before the file name is displayed.
This makes the behavior more consistent by escaping control chars
in the list of matches too. Discussed with deraadt@, OK op@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.76 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_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.75 20-Feb-2019 schwarze

When evaluating an arithmetical expression, for example inside $(()),
never do substitution (neither parameter, nor command, nor arithmetic,
nor tilde substitution) on the values of any variables encountered
inside the expression, but do recursively perform arithmetical
evaluation of subexpressions as required. This makes behaviour
more consistent, without hindering any behaviour promised in the
manual page.

A quirk originally reported by Andy Chu <andychup at gmail dot com>
was that in the past, when encountering an array index, the shell
would not only do evaluation, but also substitution on the array
index, even though substitution would not be done on the expression
in general.

tobias@ contributed to initial efforts of understanding the quirk.
patch tested in a bulk build by naddy@
"please commit" deraadt@


# 1.74 20-Nov-2018 martijn

Fix the case where the recursion detection isn't reset when the command is
interrupted.

Lots of back and forth with anton@
OK jca@, tb@, anton@


Revision tags: OPENBSD_6_4_BASE
# 1.73 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@


# 1.72 09-Apr-2018 tobias

Support 64 bit integers on 32 bit architectures.

No binary change on amd64 and there should be no differences on any
other 64 bit architecture either (because long = int64_t).

ok cheloha, tb


Revision tags: OPENBSD_6_3_BASE
# 1.71 16-Jan-2018 jca

Introduce internal_warningf() and mark internal_errorf() as noreturn

This helps tools like scan-build, and follows the example of warningf()
and errorf(). ok anton@


# 1.70 15-Jan-2018 jca

Stop pretending we support building ksh without EDIT/HISTORY support

ok anton@


# 1.69 14-Jan-2018 anton

unifdef BRACE_EXPAND; ok jca@


# 1.68 06-Jan-2018 millert

Bring back the sign compare changes, this time with a fix from otto@
that fixes the issues seen on hppa. OK deraadt@ otto@


# 1.67 05-Jan-2018 jca

unifdef JOBS support

Prompted by a mail from Klemens Nanni, who also had the same diff.
ok deraadt@ millert@


# 1.66 27-Dec-2017 millert

Add -Wshadow to Makefile and fix the resulting warnings. Many of
the warnings are due to the use of globals with generic names,
specifically "options" and "path". I've renamed "options" to
"sh_options" since it holds the shell options and "path" to
"search_path". OK jca@ tb@


# 1.65 19-Oct-2017 jca

Delete the deprecated emacs-usemeta option.

ok tb@ anton@


Revision tags: OPENBSD_6_2_BASE
# 1.64 03-Sep-2017 jca

Use PATH_MAX instead of a local define

okk deraadt@ millert@ anton@


# 1.63 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.62 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.61 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.60 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.59 29-Jun-2017 martijn

Increase the input line buffer to 4096 bytes.

Sounds good to deraadt@
OK anton@


Revision tags: OPENBSD_6_1_BASE
# 1.58 08-Sep-2016 millert

Add KSH_IGNORE_RDONLY flag and use it in var.c instead of the 0x4
magic number.


Revision tags: OPENBSD_6_0_BASE
# 1.57 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.56 30-Dec-2015 tedu

rename global "e" to genv to avoid accidental shadowing and aliasing.
ok millert nicm tb


# 1.55 14-Dec-2015 tb

Move system headers from sh.h to those files that actually need them.

ok mmcc@ a while ago


# 1.54 20-Nov-2015 tb

remove unused prototype

ok mmcc@


# 1.53 12-Nov-2015 mmcc

Use isdigit() instead of ksh's homebrewed alternative.

ok nicm@. Also discussed with millert@ and guenther@.


# 1.52 07-Nov-2015 mmcc

Make it clearer that warningf()'s first argument determines whether the
lineno is printed.

ok nicm@


# 1.51 01-Nov-2015 mmcc

Add uses of areallocarray(). mksh and Bitrig ksh already have similar
functions. With help from Theo Buehler.

ok nicm@


# 1.50 23-Oct-2015 mmcc

Remove two comments listing functionless files. Trivial, no functional
change.


# 1.49 23-Oct-2015 mmcc

proto.h contains many function prototypes. It's apparently separate from
sh.h because the pdksh devs used a prototype generator (last run in
1992). Merging it into sh.h makes things clearer.

ok nicm@


# 1.48 22-Oct-2015 mmcc

Final removal of EXTERN.

ok nicm@


# 1.47 21-Oct-2015 mmcc

Penultimate commit to remove EXTERN.

ok nicm@


# 1.46 19-Oct-2015 mmcc

Remove the define NOT, replace it with '!'. No binary change.

"The ^ is used in regular expressions and many versions of fnmatch(3)
accept both ! and ^. However, we are never going to accept ^ instead of
! so I think this makes sense" -millert@

"go for it" -nicm@


# 1.45 19-Oct-2015 mmcc

A little style(9) for sh.h includes

ok nicm@


# 1.44 19-Oct-2015 mmcc

Move stddef.h include from sh.h to the file that uses it.

ok nicm@


# 1.43 19-Oct-2015 mmcc

Move string.h include from sh.h to the files that use it.

ok nicm@


# 1.42 19-Oct-2015 mmcc

Move limits.h include from sh.h to the files that actually need it. No
binary change.

ok nicm@


# 1.41 19-Oct-2015 mmcc

More removal of EXTERN.

ok nicm@


# 1.40 18-Oct-2015 mmcc

Move more EXTERN-defined globals from sh.h.

ok nicm@


# 1.39 17-Oct-2015 mmcc

Drop two useless defines.

ok nicm@


# 1.38 17-Oct-2015 mmcc

Move a system header include from the global header (sh.h) into the
files that need it. No binary change.

"This looks fine" -nicm@


# 1.37 14-Sep-2015 nicm

Replace Tflag typedef with just int; ok tedu


# 1.36 14-Sep-2015 nicm

Apply the ancient art of tedu to ksh_limval.h. ok guenther


# 1.35 10-Sep-2015 nicm

Replace newline and space defines by "\n" and " " directly, from Michael
McConville. ok millert


# 1.34 10-Sep-2015 nicm

Remove INT32 define and just use int, from Martijn van Duren and Michael
McConville. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.33 18-Dec-2013 millert

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


# 1.32 28-Nov-2013 sobrado

remove trailing whitespaces; use tabs instead of spaces where appropriate;
no binary changes.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.31 10-Sep-2012 tedu

fake a sigwinch after each job, so if the terminal changes size,
we'll notice and update


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.30 04-Jan-2010 deraadt

Crank max array size in ksh to 10K-1, since 2047 is too restrictive.
Please keep in mind that ksh accesses are not O(1) in any sense.
Needed by todd, ok otto, guenther


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.29 11-Dec-2005 deraadt

remove unused variables and functions


# 1.28 04-Oct-2005 otto

Bump max array size. Needed for upcoming MAKEDEV speedup. ok deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.27 28-Mar-2005 deraadt

spacing


Revision tags: OPENBSD_3_7_BASE
# 1.26 21-Feb-2005 otto

Set \u in prompt expansion to the right value, while avoiding getpw* calls,
which might be very inconvenient when the yp server is not available.

ok deraadt@ millert@


# 1.25 22-Dec-2004 millert

Use stdbool.h instead of rolling our own bools.


# 1.24 18-Dec-2004 millert

Use _PATH_BSHELL instead of hardcoding "/bin/sh"


# 1.23 18-Dec-2004 millert

Flags set in signal handlers should be volatile sig_atomic_t


# 1.22 18-Dec-2004 millert

Use the BSD sig_t instead of homegrown handler_t
Remove KSH_SA_FLAGS


# 1.21 18-Dec-2004 millert

Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian


# 1.20 18-Dec-2004 millert

Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.
First step in making the ksh code easier to read. From Matthias Kilian


# 1.19 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


Revision tags: OPENBSD_3_6_BASE
# 1.18 31-May-2004 otto

Remove redundant errno declaration. ok deraadt@


# 1.17 10-May-2004 pvalchev

double the command line buffer size (1024 -> 2048); ok millert deraadt


Revision tags: OPENBSD_3_5_BASE
# 1.16 08-Feb-2004 deraadt

forget about 16 bit machines; millert ok


# 1.15 22-Oct-2003 jmc

typos from Jared Yanovich;
ok deraadt@


Revision tags: OPENBSD_3_4_BASE
# 1.14 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.13 16-May-2003 jsyn

fix several constant overflows, remove the strerror prototype (shouldn't be
there), and cleanup some whitespace; help from, and okay millert@


Revision tags: OPENBSD_3_3_BASE
# 1.12 07-Oct-2002 vincent

int -> uid_t

ok millert


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.11 01-Mar-2002 espie

this is needed too


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.10 15-Jul-1999 millert

o Set default line edit mode to emacs (VISUAL/EDITOR or user can override)
o Spell environment correctly


# 1.9 15-Jun-1999 millert

patches from pdksh 5.2.13.11


Revision tags: OPENBSD_2_5_BASE
# 1.8 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.7 08-Jan-1999 millert

bug fixes from pdksh-unstable-5.2.13.5; some of which we already had.


Revision tags: OPENBSD_2_4_BASE
# 1.6 25-Jun-1998 millert

pdksh-5.2.13 + local changes


Revision tags: OPENBSD_2_3_BASE
# 1.5 02-Jan-1997 downsj

Add FSH (set -o sh), initialize it if we're /bin/sh, and add the first use:
don't set $_ if we're non-interactive.


# 1.4 18-Dec-1996 niklas

Up limit of available user file descriptors (e.g. for redirections) to 32


# 1.3 01-Oct-1996 downsj

Integrate pdksh 5.2.9.


# 1.2 19-Aug-1996 downsj

update to pdksh-5.2.8


# 1.1 14-Aug-1996 downsj

branches: 1.1.1;
Initial revision


# 1.76 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_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.75 20-Feb-2019 schwarze

When evaluating an arithmetical expression, for example inside $(()),
never do substitution (neither parameter, nor command, nor arithmetic,
nor tilde substitution) on the values of any variables encountered
inside the expression, but do recursively perform arithmetical
evaluation of subexpressions as required. This makes behaviour
more consistent, without hindering any behaviour promised in the
manual page.

A quirk originally reported by Andy Chu <andychup at gmail dot com>
was that in the past, when encountering an array index, the shell
would not only do evaluation, but also substitution on the array
index, even though substitution would not be done on the expression
in general.

tobias@ contributed to initial efforts of understanding the quirk.
patch tested in a bulk build by naddy@
"please commit" deraadt@


# 1.74 20-Nov-2018 martijn

Fix the case where the recursion detection isn't reset when the command is
interrupted.

Lots of back and forth with anton@
OK jca@, tb@, anton@


Revision tags: OPENBSD_6_4_BASE
# 1.73 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@


# 1.72 09-Apr-2018 tobias

Support 64 bit integers on 32 bit architectures.

No binary change on amd64 and there should be no differences on any
other 64 bit architecture either (because long = int64_t).

ok cheloha, tb


Revision tags: OPENBSD_6_3_BASE
# 1.71 16-Jan-2018 jca

Introduce internal_warningf() and mark internal_errorf() as noreturn

This helps tools like scan-build, and follows the example of warningf()
and errorf(). ok anton@


# 1.70 15-Jan-2018 jca

Stop pretending we support building ksh without EDIT/HISTORY support

ok anton@


# 1.69 14-Jan-2018 anton

unifdef BRACE_EXPAND; ok jca@


# 1.68 06-Jan-2018 millert

Bring back the sign compare changes, this time with a fix from otto@
that fixes the issues seen on hppa. OK deraadt@ otto@


# 1.67 05-Jan-2018 jca

unifdef JOBS support

Prompted by a mail from Klemens Nanni, who also had the same diff.
ok deraadt@ millert@


# 1.66 27-Dec-2017 millert

Add -Wshadow to Makefile and fix the resulting warnings. Many of
the warnings are due to the use of globals with generic names,
specifically "options" and "path". I've renamed "options" to
"sh_options" since it holds the shell options and "path" to
"search_path". OK jca@ tb@


# 1.65 19-Oct-2017 jca

Delete the deprecated emacs-usemeta option.

ok tb@ anton@


Revision tags: OPENBSD_6_2_BASE
# 1.64 03-Sep-2017 jca

Use PATH_MAX instead of a local define

okk deraadt@ millert@ anton@


# 1.63 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.62 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.61 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.60 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.59 29-Jun-2017 martijn

Increase the input line buffer to 4096 bytes.

Sounds good to deraadt@
OK anton@


Revision tags: OPENBSD_6_1_BASE
# 1.58 08-Sep-2016 millert

Add KSH_IGNORE_RDONLY flag and use it in var.c instead of the 0x4
magic number.


Revision tags: OPENBSD_6_0_BASE
# 1.57 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.56 30-Dec-2015 tedu

rename global "e" to genv to avoid accidental shadowing and aliasing.
ok millert nicm tb


# 1.55 14-Dec-2015 tb

Move system headers from sh.h to those files that actually need them.

ok mmcc@ a while ago


# 1.54 20-Nov-2015 tb

remove unused prototype

ok mmcc@


# 1.53 12-Nov-2015 mmcc

Use isdigit() instead of ksh's homebrewed alternative.

ok nicm@. Also discussed with millert@ and guenther@.


# 1.52 07-Nov-2015 mmcc

Make it clearer that warningf()'s first argument determines whether the
lineno is printed.

ok nicm@


# 1.51 01-Nov-2015 mmcc

Add uses of areallocarray(). mksh and Bitrig ksh already have similar
functions. With help from Theo Buehler.

ok nicm@


# 1.50 23-Oct-2015 mmcc

Remove two comments listing functionless files. Trivial, no functional
change.


# 1.49 23-Oct-2015 mmcc

proto.h contains many function prototypes. It's apparently separate from
sh.h because the pdksh devs used a prototype generator (last run in
1992). Merging it into sh.h makes things clearer.

ok nicm@


# 1.48 22-Oct-2015 mmcc

Final removal of EXTERN.

ok nicm@


# 1.47 21-Oct-2015 mmcc

Penultimate commit to remove EXTERN.

ok nicm@


# 1.46 19-Oct-2015 mmcc

Remove the define NOT, replace it with '!'. No binary change.

"The ^ is used in regular expressions and many versions of fnmatch(3)
accept both ! and ^. However, we are never going to accept ^ instead of
! so I think this makes sense" -millert@

"go for it" -nicm@


# 1.45 19-Oct-2015 mmcc

A little style(9) for sh.h includes

ok nicm@


# 1.44 19-Oct-2015 mmcc

Move stddef.h include from sh.h to the file that uses it.

ok nicm@


# 1.43 19-Oct-2015 mmcc

Move string.h include from sh.h to the files that use it.

ok nicm@


# 1.42 19-Oct-2015 mmcc

Move limits.h include from sh.h to the files that actually need it. No
binary change.

ok nicm@


# 1.41 19-Oct-2015 mmcc

More removal of EXTERN.

ok nicm@


# 1.40 18-Oct-2015 mmcc

Move more EXTERN-defined globals from sh.h.

ok nicm@


# 1.39 17-Oct-2015 mmcc

Drop two useless defines.

ok nicm@


# 1.38 17-Oct-2015 mmcc

Move a system header include from the global header (sh.h) into the
files that need it. No binary change.

"This looks fine" -nicm@


# 1.37 14-Sep-2015 nicm

Replace Tflag typedef with just int; ok tedu


# 1.36 14-Sep-2015 nicm

Apply the ancient art of tedu to ksh_limval.h. ok guenther


# 1.35 10-Sep-2015 nicm

Replace newline and space defines by "\n" and " " directly, from Michael
McConville. ok millert


# 1.34 10-Sep-2015 nicm

Remove INT32 define and just use int, from Martijn van Duren and Michael
McConville. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.33 18-Dec-2013 millert

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


# 1.32 28-Nov-2013 sobrado

remove trailing whitespaces; use tabs instead of spaces where appropriate;
no binary changes.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.31 10-Sep-2012 tedu

fake a sigwinch after each job, so if the terminal changes size,
we'll notice and update


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.30 04-Jan-2010 deraadt

Crank max array size in ksh to 10K-1, since 2047 is too restrictive.
Please keep in mind that ksh accesses are not O(1) in any sense.
Needed by todd, ok otto, guenther


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.29 11-Dec-2005 deraadt

remove unused variables and functions


# 1.28 04-Oct-2005 otto

Bump max array size. Needed for upcoming MAKEDEV speedup. ok deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.27 28-Mar-2005 deraadt

spacing


Revision tags: OPENBSD_3_7_BASE
# 1.26 21-Feb-2005 otto

Set \u in prompt expansion to the right value, while avoiding getpw* calls,
which might be very inconvenient when the yp server is not available.

ok deraadt@ millert@


# 1.25 22-Dec-2004 millert

Use stdbool.h instead of rolling our own bools.


# 1.24 18-Dec-2004 millert

Use _PATH_BSHELL instead of hardcoding "/bin/sh"


# 1.23 18-Dec-2004 millert

Flags set in signal handlers should be volatile sig_atomic_t


# 1.22 18-Dec-2004 millert

Use the BSD sig_t instead of homegrown handler_t
Remove KSH_SA_FLAGS


# 1.21 18-Dec-2004 millert

Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian


# 1.20 18-Dec-2004 millert

Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.
First step in making the ksh code easier to read. From Matthias Kilian


# 1.19 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


Revision tags: OPENBSD_3_6_BASE
# 1.18 31-May-2004 otto

Remove redundant errno declaration. ok deraadt@


# 1.17 10-May-2004 pvalchev

double the command line buffer size (1024 -> 2048); ok millert deraadt


Revision tags: OPENBSD_3_5_BASE
# 1.16 08-Feb-2004 deraadt

forget about 16 bit machines; millert ok


# 1.15 22-Oct-2003 jmc

typos from Jared Yanovich;
ok deraadt@


Revision tags: OPENBSD_3_4_BASE
# 1.14 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.13 16-May-2003 jsyn

fix several constant overflows, remove the strerror prototype (shouldn't be
there), and cleanup some whitespace; help from, and okay millert@


Revision tags: OPENBSD_3_3_BASE
# 1.12 07-Oct-2002 vincent

int -> uid_t

ok millert


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.11 01-Mar-2002 espie

this is needed too


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.10 15-Jul-1999 millert

o Set default line edit mode to emacs (VISUAL/EDITOR or user can override)
o Spell environment correctly


# 1.9 15-Jun-1999 millert

patches from pdksh 5.2.13.11


Revision tags: OPENBSD_2_5_BASE
# 1.8 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.7 08-Jan-1999 millert

bug fixes from pdksh-unstable-5.2.13.5; some of which we already had.


Revision tags: OPENBSD_2_4_BASE
# 1.6 25-Jun-1998 millert

pdksh-5.2.13 + local changes


Revision tags: OPENBSD_2_3_BASE
# 1.5 02-Jan-1997 downsj

Add FSH (set -o sh), initialize it if we're /bin/sh, and add the first use:
don't set $_ if we're non-interactive.


# 1.4 18-Dec-1996 niklas

Up limit of available user file descriptors (e.g. for redirections) to 32


# 1.3 01-Oct-1996 downsj

Integrate pdksh 5.2.9.


# 1.2 19-Aug-1996 downsj

update to pdksh-5.2.8


# 1.1 14-Aug-1996 downsj

branches: 1.1.1;
Initial revision


# 1.75 20-Feb-2019 schwarze

When evaluating an arithmetical expression, for example inside $(()),
never do substitution (neither parameter, nor command, nor arithmetic,
nor tilde substitution) on the values of any variables encountered
inside the expression, but do recursively perform arithmetical
evaluation of subexpressions as required. This makes behaviour
more consistent, without hindering any behaviour promised in the
manual page.

A quirk originally reported by Andy Chu <andychup at gmail dot com>
was that in the past, when encountering an array index, the shell
would not only do evaluation, but also substitution on the array
index, even though substitution would not be done on the expression
in general.

tobias@ contributed to initial efforts of understanding the quirk.
patch tested in a bulk build by naddy@
"please commit" deraadt@


# 1.74 20-Nov-2018 martijn

Fix the case where the recursion detection isn't reset when the command is
interrupted.

Lots of back and forth with anton@
OK jca@, tb@, anton@


Revision tags: OPENBSD_6_4_BASE
# 1.73 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@


# 1.72 09-Apr-2018 tobias

Support 64 bit integers on 32 bit architectures.

No binary change on amd64 and there should be no differences on any
other 64 bit architecture either (because long = int64_t).

ok cheloha, tb


Revision tags: OPENBSD_6_3_BASE
# 1.71 16-Jan-2018 jca

Introduce internal_warningf() and mark internal_errorf() as noreturn

This helps tools like scan-build, and follows the example of warningf()
and errorf(). ok anton@


# 1.70 15-Jan-2018 jca

Stop pretending we support building ksh without EDIT/HISTORY support

ok anton@


# 1.69 14-Jan-2018 anton

unifdef BRACE_EXPAND; ok jca@


# 1.68 06-Jan-2018 millert

Bring back the sign compare changes, this time with a fix from otto@
that fixes the issues seen on hppa. OK deraadt@ otto@


# 1.67 05-Jan-2018 jca

unifdef JOBS support

Prompted by a mail from Klemens Nanni, who also had the same diff.
ok deraadt@ millert@


# 1.66 27-Dec-2017 millert

Add -Wshadow to Makefile and fix the resulting warnings. Many of
the warnings are due to the use of globals with generic names,
specifically "options" and "path". I've renamed "options" to
"sh_options" since it holds the shell options and "path" to
"search_path". OK jca@ tb@


# 1.65 19-Oct-2017 jca

Delete the deprecated emacs-usemeta option.

ok tb@ anton@


Revision tags: OPENBSD_6_2_BASE
# 1.64 03-Sep-2017 jca

Use PATH_MAX instead of a local define

okk deraadt@ millert@ anton@


# 1.63 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.62 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.61 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.60 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.59 29-Jun-2017 martijn

Increase the input line buffer to 4096 bytes.

Sounds good to deraadt@
OK anton@


Revision tags: OPENBSD_6_1_BASE
# 1.58 08-Sep-2016 millert

Add KSH_IGNORE_RDONLY flag and use it in var.c instead of the 0x4
magic number.


Revision tags: OPENBSD_6_0_BASE
# 1.57 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.56 30-Dec-2015 tedu

rename global "e" to genv to avoid accidental shadowing and aliasing.
ok millert nicm tb


# 1.55 14-Dec-2015 tb

Move system headers from sh.h to those files that actually need them.

ok mmcc@ a while ago


# 1.54 20-Nov-2015 tb

remove unused prototype

ok mmcc@


# 1.53 12-Nov-2015 mmcc

Use isdigit() instead of ksh's homebrewed alternative.

ok nicm@. Also discussed with millert@ and guenther@.


# 1.52 07-Nov-2015 mmcc

Make it clearer that warningf()'s first argument determines whether the
lineno is printed.

ok nicm@


# 1.51 01-Nov-2015 mmcc

Add uses of areallocarray(). mksh and Bitrig ksh already have similar
functions. With help from Theo Buehler.

ok nicm@


# 1.50 23-Oct-2015 mmcc

Remove two comments listing functionless files. Trivial, no functional
change.


# 1.49 23-Oct-2015 mmcc

proto.h contains many function prototypes. It's apparently separate from
sh.h because the pdksh devs used a prototype generator (last run in
1992). Merging it into sh.h makes things clearer.

ok nicm@


# 1.48 22-Oct-2015 mmcc

Final removal of EXTERN.

ok nicm@


# 1.47 21-Oct-2015 mmcc

Penultimate commit to remove EXTERN.

ok nicm@


# 1.46 19-Oct-2015 mmcc

Remove the define NOT, replace it with '!'. No binary change.

"The ^ is used in regular expressions and many versions of fnmatch(3)
accept both ! and ^. However, we are never going to accept ^ instead of
! so I think this makes sense" -millert@

"go for it" -nicm@


# 1.45 19-Oct-2015 mmcc

A little style(9) for sh.h includes

ok nicm@


# 1.44 19-Oct-2015 mmcc

Move stddef.h include from sh.h to the file that uses it.

ok nicm@


# 1.43 19-Oct-2015 mmcc

Move string.h include from sh.h to the files that use it.

ok nicm@


# 1.42 19-Oct-2015 mmcc

Move limits.h include from sh.h to the files that actually need it. No
binary change.

ok nicm@


# 1.41 19-Oct-2015 mmcc

More removal of EXTERN.

ok nicm@


# 1.40 18-Oct-2015 mmcc

Move more EXTERN-defined globals from sh.h.

ok nicm@


# 1.39 17-Oct-2015 mmcc

Drop two useless defines.

ok nicm@


# 1.38 17-Oct-2015 mmcc

Move a system header include from the global header (sh.h) into the
files that need it. No binary change.

"This looks fine" -nicm@


# 1.37 14-Sep-2015 nicm

Replace Tflag typedef with just int; ok tedu


# 1.36 14-Sep-2015 nicm

Apply the ancient art of tedu to ksh_limval.h. ok guenther


# 1.35 10-Sep-2015 nicm

Replace newline and space defines by "\n" and " " directly, from Michael
McConville. ok millert


# 1.34 10-Sep-2015 nicm

Remove INT32 define and just use int, from Martijn van Duren and Michael
McConville. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.33 18-Dec-2013 millert

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


# 1.32 28-Nov-2013 sobrado

remove trailing whitespaces; use tabs instead of spaces where appropriate;
no binary changes.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.31 10-Sep-2012 tedu

fake a sigwinch after each job, so if the terminal changes size,
we'll notice and update


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.30 04-Jan-2010 deraadt

Crank max array size in ksh to 10K-1, since 2047 is too restrictive.
Please keep in mind that ksh accesses are not O(1) in any sense.
Needed by todd, ok otto, guenther


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.29 11-Dec-2005 deraadt

remove unused variables and functions


# 1.28 04-Oct-2005 otto

Bump max array size. Needed for upcoming MAKEDEV speedup. ok deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.27 28-Mar-2005 deraadt

spacing


Revision tags: OPENBSD_3_7_BASE
# 1.26 21-Feb-2005 otto

Set \u in prompt expansion to the right value, while avoiding getpw* calls,
which might be very inconvenient when the yp server is not available.

ok deraadt@ millert@


# 1.25 22-Dec-2004 millert

Use stdbool.h instead of rolling our own bools.


# 1.24 18-Dec-2004 millert

Use _PATH_BSHELL instead of hardcoding "/bin/sh"


# 1.23 18-Dec-2004 millert

Flags set in signal handlers should be volatile sig_atomic_t


# 1.22 18-Dec-2004 millert

Use the BSD sig_t instead of homegrown handler_t
Remove KSH_SA_FLAGS


# 1.21 18-Dec-2004 millert

Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian


# 1.20 18-Dec-2004 millert

Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.
First step in making the ksh code easier to read. From Matthias Kilian


# 1.19 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


Revision tags: OPENBSD_3_6_BASE
# 1.18 31-May-2004 otto

Remove redundant errno declaration. ok deraadt@


# 1.17 10-May-2004 pvalchev

double the command line buffer size (1024 -> 2048); ok millert deraadt


Revision tags: OPENBSD_3_5_BASE
# 1.16 08-Feb-2004 deraadt

forget about 16 bit machines; millert ok


# 1.15 22-Oct-2003 jmc

typos from Jared Yanovich;
ok deraadt@


Revision tags: OPENBSD_3_4_BASE
# 1.14 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.13 16-May-2003 jsyn

fix several constant overflows, remove the strerror prototype (shouldn't be
there), and cleanup some whitespace; help from, and okay millert@


Revision tags: OPENBSD_3_3_BASE
# 1.12 07-Oct-2002 vincent

int -> uid_t

ok millert


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.11 01-Mar-2002 espie

this is needed too


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.10 15-Jul-1999 millert

o Set default line edit mode to emacs (VISUAL/EDITOR or user can override)
o Spell environment correctly


# 1.9 15-Jun-1999 millert

patches from pdksh 5.2.13.11


Revision tags: OPENBSD_2_5_BASE
# 1.8 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.7 08-Jan-1999 millert

bug fixes from pdksh-unstable-5.2.13.5; some of which we already had.


Revision tags: OPENBSD_2_4_BASE
# 1.6 25-Jun-1998 millert

pdksh-5.2.13 + local changes


Revision tags: OPENBSD_2_3_BASE
# 1.5 02-Jan-1997 downsj

Add FSH (set -o sh), initialize it if we're /bin/sh, and add the first use:
don't set $_ if we're non-interactive.


# 1.4 18-Dec-1996 niklas

Up limit of available user file descriptors (e.g. for redirections) to 32


# 1.3 01-Oct-1996 downsj

Integrate pdksh 5.2.9.


# 1.2 19-Aug-1996 downsj

update to pdksh-5.2.8


# 1.1 14-Aug-1996 downsj

branches: 1.1.1;
Initial revision


# 1.74 20-Nov-2018 martijn

Fix the case where the recursion detection isn't reset when the command is
interrupted.

Lots of back and forth with anton@
OK jca@, tb@, anton@


Revision tags: OPENBSD_6_4_BASE
# 1.73 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@


# 1.72 09-Apr-2018 tobias

Support 64 bit integers on 32 bit architectures.

No binary change on amd64 and there should be no differences on any
other 64 bit architecture either (because long = int64_t).

ok cheloha, tb


Revision tags: OPENBSD_6_3_BASE
# 1.71 16-Jan-2018 jca

Introduce internal_warningf() and mark internal_errorf() as noreturn

This helps tools like scan-build, and follows the example of warningf()
and errorf(). ok anton@


# 1.70 15-Jan-2018 jca

Stop pretending we support building ksh without EDIT/HISTORY support

ok anton@


# 1.69 14-Jan-2018 anton

unifdef BRACE_EXPAND; ok jca@


# 1.68 06-Jan-2018 millert

Bring back the sign compare changes, this time with a fix from otto@
that fixes the issues seen on hppa. OK deraadt@ otto@


# 1.67 05-Jan-2018 jca

unifdef JOBS support

Prompted by a mail from Klemens Nanni, who also had the same diff.
ok deraadt@ millert@


# 1.66 27-Dec-2017 millert

Add -Wshadow to Makefile and fix the resulting warnings. Many of
the warnings are due to the use of globals with generic names,
specifically "options" and "path". I've renamed "options" to
"sh_options" since it holds the shell options and "path" to
"search_path". OK jca@ tb@


# 1.65 19-Oct-2017 jca

Delete the deprecated emacs-usemeta option.

ok tb@ anton@


Revision tags: OPENBSD_6_2_BASE
# 1.64 03-Sep-2017 jca

Use PATH_MAX instead of a local define

okk deraadt@ millert@ anton@


# 1.63 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.62 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.61 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.60 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.59 29-Jun-2017 martijn

Increase the input line buffer to 4096 bytes.

Sounds good to deraadt@
OK anton@


Revision tags: OPENBSD_6_1_BASE
# 1.58 08-Sep-2016 millert

Add KSH_IGNORE_RDONLY flag and use it in var.c instead of the 0x4
magic number.


Revision tags: OPENBSD_6_0_BASE
# 1.57 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.56 30-Dec-2015 tedu

rename global "e" to genv to avoid accidental shadowing and aliasing.
ok millert nicm tb


# 1.55 14-Dec-2015 tb

Move system headers from sh.h to those files that actually need them.

ok mmcc@ a while ago


# 1.54 20-Nov-2015 tb

remove unused prototype

ok mmcc@


# 1.53 12-Nov-2015 mmcc

Use isdigit() instead of ksh's homebrewed alternative.

ok nicm@. Also discussed with millert@ and guenther@.


# 1.52 07-Nov-2015 mmcc

Make it clearer that warningf()'s first argument determines whether the
lineno is printed.

ok nicm@


# 1.51 01-Nov-2015 mmcc

Add uses of areallocarray(). mksh and Bitrig ksh already have similar
functions. With help from Theo Buehler.

ok nicm@


# 1.50 23-Oct-2015 mmcc

Remove two comments listing functionless files. Trivial, no functional
change.


# 1.49 23-Oct-2015 mmcc

proto.h contains many function prototypes. It's apparently separate from
sh.h because the pdksh devs used a prototype generator (last run in
1992). Merging it into sh.h makes things clearer.

ok nicm@


# 1.48 22-Oct-2015 mmcc

Final removal of EXTERN.

ok nicm@


# 1.47 21-Oct-2015 mmcc

Penultimate commit to remove EXTERN.

ok nicm@


# 1.46 19-Oct-2015 mmcc

Remove the define NOT, replace it with '!'. No binary change.

"The ^ is used in regular expressions and many versions of fnmatch(3)
accept both ! and ^. However, we are never going to accept ^ instead of
! so I think this makes sense" -millert@

"go for it" -nicm@


# 1.45 19-Oct-2015 mmcc

A little style(9) for sh.h includes

ok nicm@


# 1.44 19-Oct-2015 mmcc

Move stddef.h include from sh.h to the file that uses it.

ok nicm@


# 1.43 19-Oct-2015 mmcc

Move string.h include from sh.h to the files that use it.

ok nicm@


# 1.42 19-Oct-2015 mmcc

Move limits.h include from sh.h to the files that actually need it. No
binary change.

ok nicm@


# 1.41 19-Oct-2015 mmcc

More removal of EXTERN.

ok nicm@


# 1.40 18-Oct-2015 mmcc

Move more EXTERN-defined globals from sh.h.

ok nicm@


# 1.39 17-Oct-2015 mmcc

Drop two useless defines.

ok nicm@


# 1.38 17-Oct-2015 mmcc

Move a system header include from the global header (sh.h) into the
files that need it. No binary change.

"This looks fine" -nicm@


# 1.37 14-Sep-2015 nicm

Replace Tflag typedef with just int; ok tedu


# 1.36 14-Sep-2015 nicm

Apply the ancient art of tedu to ksh_limval.h. ok guenther


# 1.35 10-Sep-2015 nicm

Replace newline and space defines by "\n" and " " directly, from Michael
McConville. ok millert


# 1.34 10-Sep-2015 nicm

Remove INT32 define and just use int, from Martijn van Duren and Michael
McConville. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.33 18-Dec-2013 millert

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


# 1.32 28-Nov-2013 sobrado

remove trailing whitespaces; use tabs instead of spaces where appropriate;
no binary changes.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.31 10-Sep-2012 tedu

fake a sigwinch after each job, so if the terminal changes size,
we'll notice and update


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.30 04-Jan-2010 deraadt

Crank max array size in ksh to 10K-1, since 2047 is too restrictive.
Please keep in mind that ksh accesses are not O(1) in any sense.
Needed by todd, ok otto, guenther


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.29 11-Dec-2005 deraadt

remove unused variables and functions


# 1.28 04-Oct-2005 otto

Bump max array size. Needed for upcoming MAKEDEV speedup. ok deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.27 28-Mar-2005 deraadt

spacing


Revision tags: OPENBSD_3_7_BASE
# 1.26 21-Feb-2005 otto

Set \u in prompt expansion to the right value, while avoiding getpw* calls,
which might be very inconvenient when the yp server is not available.

ok deraadt@ millert@


# 1.25 22-Dec-2004 millert

Use stdbool.h instead of rolling our own bools.


# 1.24 18-Dec-2004 millert

Use _PATH_BSHELL instead of hardcoding "/bin/sh"


# 1.23 18-Dec-2004 millert

Flags set in signal handlers should be volatile sig_atomic_t


# 1.22 18-Dec-2004 millert

Use the BSD sig_t instead of homegrown handler_t
Remove KSH_SA_FLAGS


# 1.21 18-Dec-2004 millert

Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian


# 1.20 18-Dec-2004 millert

Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.
First step in making the ksh code easier to read. From Matthias Kilian


# 1.19 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


Revision tags: OPENBSD_3_6_BASE
# 1.18 31-May-2004 otto

Remove redundant errno declaration. ok deraadt@


# 1.17 10-May-2004 pvalchev

double the command line buffer size (1024 -> 2048); ok millert deraadt


Revision tags: OPENBSD_3_5_BASE
# 1.16 08-Feb-2004 deraadt

forget about 16 bit machines; millert ok


# 1.15 22-Oct-2003 jmc

typos from Jared Yanovich;
ok deraadt@


Revision tags: OPENBSD_3_4_BASE
# 1.14 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.13 16-May-2003 jsyn

fix several constant overflows, remove the strerror prototype (shouldn't be
there), and cleanup some whitespace; help from, and okay millert@


Revision tags: OPENBSD_3_3_BASE
# 1.12 07-Oct-2002 vincent

int -> uid_t

ok millert


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.11 01-Mar-2002 espie

this is needed too


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.10 15-Jul-1999 millert

o Set default line edit mode to emacs (VISUAL/EDITOR or user can override)
o Spell environment correctly


# 1.9 15-Jun-1999 millert

patches from pdksh 5.2.13.11


Revision tags: OPENBSD_2_5_BASE
# 1.8 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.7 08-Jan-1999 millert

bug fixes from pdksh-unstable-5.2.13.5; some of which we already had.


Revision tags: OPENBSD_2_4_BASE
# 1.6 25-Jun-1998 millert

pdksh-5.2.13 + local changes


Revision tags: OPENBSD_2_3_BASE
# 1.5 02-Jan-1997 downsj

Add FSH (set -o sh), initialize it if we're /bin/sh, and add the first use:
don't set $_ if we're non-interactive.


# 1.4 18-Dec-1996 niklas

Up limit of available user file descriptors (e.g. for redirections) to 32


# 1.3 01-Oct-1996 downsj

Integrate pdksh 5.2.9.


# 1.2 19-Aug-1996 downsj

update to pdksh-5.2.8


# 1.1 14-Aug-1996 downsj

branches: 1.1.1;
Initial revision


# 1.73 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@


# 1.72 09-Apr-2018 tobias

Support 64 bit integers on 32 bit architectures.

No binary change on amd64 and there should be no differences on any
other 64 bit architecture either (because long = int64_t).

ok cheloha, tb


Revision tags: OPENBSD_6_3_BASE
# 1.71 16-Jan-2018 jca

Introduce internal_warningf() and mark internal_errorf() as noreturn

This helps tools like scan-build, and follows the example of warningf()
and errorf(). ok anton@


# 1.70 15-Jan-2018 jca

Stop pretending we support building ksh without EDIT/HISTORY support

ok anton@


# 1.69 14-Jan-2018 anton

unifdef BRACE_EXPAND; ok jca@


# 1.68 06-Jan-2018 millert

Bring back the sign compare changes, this time with a fix from otto@
that fixes the issues seen on hppa. OK deraadt@ otto@


# 1.67 05-Jan-2018 jca

unifdef JOBS support

Prompted by a mail from Klemens Nanni, who also had the same diff.
ok deraadt@ millert@


# 1.66 27-Dec-2017 millert

Add -Wshadow to Makefile and fix the resulting warnings. Many of
the warnings are due to the use of globals with generic names,
specifically "options" and "path". I've renamed "options" to
"sh_options" since it holds the shell options and "path" to
"search_path". OK jca@ tb@


# 1.65 19-Oct-2017 jca

Delete the deprecated emacs-usemeta option.

ok tb@ anton@


Revision tags: OPENBSD_6_2_BASE
# 1.64 03-Sep-2017 jca

Use PATH_MAX instead of a local define

okk deraadt@ millert@ anton@


# 1.63 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.62 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.61 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.60 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.59 29-Jun-2017 martijn

Increase the input line buffer to 4096 bytes.

Sounds good to deraadt@
OK anton@


Revision tags: OPENBSD_6_1_BASE
# 1.58 08-Sep-2016 millert

Add KSH_IGNORE_RDONLY flag and use it in var.c instead of the 0x4
magic number.


Revision tags: OPENBSD_6_0_BASE
# 1.57 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.56 30-Dec-2015 tedu

rename global "e" to genv to avoid accidental shadowing and aliasing.
ok millert nicm tb


# 1.55 14-Dec-2015 tb

Move system headers from sh.h to those files that actually need them.

ok mmcc@ a while ago


# 1.54 20-Nov-2015 tb

remove unused prototype

ok mmcc@


# 1.53 12-Nov-2015 mmcc

Use isdigit() instead of ksh's homebrewed alternative.

ok nicm@. Also discussed with millert@ and guenther@.


# 1.52 07-Nov-2015 mmcc

Make it clearer that warningf()'s first argument determines whether the
lineno is printed.

ok nicm@


# 1.51 01-Nov-2015 mmcc

Add uses of areallocarray(). mksh and Bitrig ksh already have similar
functions. With help from Theo Buehler.

ok nicm@


# 1.50 23-Oct-2015 mmcc

Remove two comments listing functionless files. Trivial, no functional
change.


# 1.49 23-Oct-2015 mmcc

proto.h contains many function prototypes. It's apparently separate from
sh.h because the pdksh devs used a prototype generator (last run in
1992). Merging it into sh.h makes things clearer.

ok nicm@


# 1.48 22-Oct-2015 mmcc

Final removal of EXTERN.

ok nicm@


# 1.47 21-Oct-2015 mmcc

Penultimate commit to remove EXTERN.

ok nicm@


# 1.46 19-Oct-2015 mmcc

Remove the define NOT, replace it with '!'. No binary change.

"The ^ is used in regular expressions and many versions of fnmatch(3)
accept both ! and ^. However, we are never going to accept ^ instead of
! so I think this makes sense" -millert@

"go for it" -nicm@


# 1.45 19-Oct-2015 mmcc

A little style(9) for sh.h includes

ok nicm@


# 1.44 19-Oct-2015 mmcc

Move stddef.h include from sh.h to the file that uses it.

ok nicm@


# 1.43 19-Oct-2015 mmcc

Move string.h include from sh.h to the files that use it.

ok nicm@


# 1.42 19-Oct-2015 mmcc

Move limits.h include from sh.h to the files that actually need it. No
binary change.

ok nicm@


# 1.41 19-Oct-2015 mmcc

More removal of EXTERN.

ok nicm@


# 1.40 18-Oct-2015 mmcc

Move more EXTERN-defined globals from sh.h.

ok nicm@


# 1.39 17-Oct-2015 mmcc

Drop two useless defines.

ok nicm@


# 1.38 17-Oct-2015 mmcc

Move a system header include from the global header (sh.h) into the
files that need it. No binary change.

"This looks fine" -nicm@


# 1.37 14-Sep-2015 nicm

Replace Tflag typedef with just int; ok tedu


# 1.36 14-Sep-2015 nicm

Apply the ancient art of tedu to ksh_limval.h. ok guenther


# 1.35 10-Sep-2015 nicm

Replace newline and space defines by "\n" and " " directly, from Michael
McConville. ok millert


# 1.34 10-Sep-2015 nicm

Remove INT32 define and just use int, from Martijn van Duren and Michael
McConville. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.33 18-Dec-2013 millert

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


# 1.32 28-Nov-2013 sobrado

remove trailing whitespaces; use tabs instead of spaces where appropriate;
no binary changes.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.31 10-Sep-2012 tedu

fake a sigwinch after each job, so if the terminal changes size,
we'll notice and update


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.30 04-Jan-2010 deraadt

Crank max array size in ksh to 10K-1, since 2047 is too restrictive.
Please keep in mind that ksh accesses are not O(1) in any sense.
Needed by todd, ok otto, guenther


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.29 11-Dec-2005 deraadt

remove unused variables and functions


# 1.28 04-Oct-2005 otto

Bump max array size. Needed for upcoming MAKEDEV speedup. ok deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.27 28-Mar-2005 deraadt

spacing


Revision tags: OPENBSD_3_7_BASE
# 1.26 21-Feb-2005 otto

Set \u in prompt expansion to the right value, while avoiding getpw* calls,
which might be very inconvenient when the yp server is not available.

ok deraadt@ millert@


# 1.25 22-Dec-2004 millert

Use stdbool.h instead of rolling our own bools.


# 1.24 18-Dec-2004 millert

Use _PATH_BSHELL instead of hardcoding "/bin/sh"


# 1.23 18-Dec-2004 millert

Flags set in signal handlers should be volatile sig_atomic_t


# 1.22 18-Dec-2004 millert

Use the BSD sig_t instead of homegrown handler_t
Remove KSH_SA_FLAGS


# 1.21 18-Dec-2004 millert

Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian


# 1.20 18-Dec-2004 millert

Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.
First step in making the ksh code easier to read. From Matthias Kilian


# 1.19 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


Revision tags: OPENBSD_3_6_BASE
# 1.18 31-May-2004 otto

Remove redundant errno declaration. ok deraadt@


# 1.17 10-May-2004 pvalchev

double the command line buffer size (1024 -> 2048); ok millert deraadt


Revision tags: OPENBSD_3_5_BASE
# 1.16 08-Feb-2004 deraadt

forget about 16 bit machines; millert ok


# 1.15 22-Oct-2003 jmc

typos from Jared Yanovich;
ok deraadt@


Revision tags: OPENBSD_3_4_BASE
# 1.14 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.13 16-May-2003 jsyn

fix several constant overflows, remove the strerror prototype (shouldn't be
there), and cleanup some whitespace; help from, and okay millert@


Revision tags: OPENBSD_3_3_BASE
# 1.12 07-Oct-2002 vincent

int -> uid_t

ok millert


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.11 01-Mar-2002 espie

this is needed too


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.10 15-Jul-1999 millert

o Set default line edit mode to emacs (VISUAL/EDITOR or user can override)
o Spell environment correctly


# 1.9 15-Jun-1999 millert

patches from pdksh 5.2.13.11


Revision tags: OPENBSD_2_5_BASE
# 1.8 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.7 08-Jan-1999 millert

bug fixes from pdksh-unstable-5.2.13.5; some of which we already had.


Revision tags: OPENBSD_2_4_BASE
# 1.6 25-Jun-1998 millert

pdksh-5.2.13 + local changes


Revision tags: OPENBSD_2_3_BASE
# 1.5 02-Jan-1997 downsj

Add FSH (set -o sh), initialize it if we're /bin/sh, and add the first use:
don't set $_ if we're non-interactive.


# 1.4 18-Dec-1996 niklas

Up limit of available user file descriptors (e.g. for redirections) to 32


# 1.3 01-Oct-1996 downsj

Integrate pdksh 5.2.9.


# 1.2 19-Aug-1996 downsj

update to pdksh-5.2.8


# 1.1 14-Aug-1996 downsj

branches: 1.1.1;
Initial revision


# 1.72 09-Apr-2018 tobias

Support 64 bit integers on 32 bit architectures.

No binary change on amd64 and there should be no differences on any
other 64 bit architecture either (because long = int64_t).

ok cheloha, tb


Revision tags: OPENBSD_6_3_BASE
# 1.71 16-Jan-2018 jca

Introduce internal_warningf() and mark internal_errorf() as noreturn

This helps tools like scan-build, and follows the example of warningf()
and errorf(). ok anton@


# 1.70 15-Jan-2018 jca

Stop pretending we support building ksh without EDIT/HISTORY support

ok anton@


# 1.69 14-Jan-2018 anton

unifdef BRACE_EXPAND; ok jca@


# 1.68 06-Jan-2018 millert

Bring back the sign compare changes, this time with a fix from otto@
that fixes the issues seen on hppa. OK deraadt@ otto@


# 1.67 05-Jan-2018 jca

unifdef JOBS support

Prompted by a mail from Klemens Nanni, who also had the same diff.
ok deraadt@ millert@


# 1.66 27-Dec-2017 millert

Add -Wshadow to Makefile and fix the resulting warnings. Many of
the warnings are due to the use of globals with generic names,
specifically "options" and "path". I've renamed "options" to
"sh_options" since it holds the shell options and "path" to
"search_path". OK jca@ tb@


# 1.65 19-Oct-2017 jca

Delete the deprecated emacs-usemeta option.

ok tb@ anton@


Revision tags: OPENBSD_6_2_BASE
# 1.64 03-Sep-2017 jca

Use PATH_MAX instead of a local define

okk deraadt@ millert@ anton@


# 1.63 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.62 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.61 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.60 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.59 29-Jun-2017 martijn

Increase the input line buffer to 4096 bytes.

Sounds good to deraadt@
OK anton@


Revision tags: OPENBSD_6_1_BASE
# 1.58 08-Sep-2016 millert

Add KSH_IGNORE_RDONLY flag and use it in var.c instead of the 0x4
magic number.


Revision tags: OPENBSD_6_0_BASE
# 1.57 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.56 30-Dec-2015 tedu

rename global "e" to genv to avoid accidental shadowing and aliasing.
ok millert nicm tb


# 1.55 14-Dec-2015 tb

Move system headers from sh.h to those files that actually need them.

ok mmcc@ a while ago


# 1.54 20-Nov-2015 tb

remove unused prototype

ok mmcc@


# 1.53 12-Nov-2015 mmcc

Use isdigit() instead of ksh's homebrewed alternative.

ok nicm@. Also discussed with millert@ and guenther@.


# 1.52 07-Nov-2015 mmcc

Make it clearer that warningf()'s first argument determines whether the
lineno is printed.

ok nicm@


# 1.51 01-Nov-2015 mmcc

Add uses of areallocarray(). mksh and Bitrig ksh already have similar
functions. With help from Theo Buehler.

ok nicm@


# 1.50 23-Oct-2015 mmcc

Remove two comments listing functionless files. Trivial, no functional
change.


# 1.49 23-Oct-2015 mmcc

proto.h contains many function prototypes. It's apparently separate from
sh.h because the pdksh devs used a prototype generator (last run in
1992). Merging it into sh.h makes things clearer.

ok nicm@


# 1.48 22-Oct-2015 mmcc

Final removal of EXTERN.

ok nicm@


# 1.47 21-Oct-2015 mmcc

Penultimate commit to remove EXTERN.

ok nicm@


# 1.46 19-Oct-2015 mmcc

Remove the define NOT, replace it with '!'. No binary change.

"The ^ is used in regular expressions and many versions of fnmatch(3)
accept both ! and ^. However, we are never going to accept ^ instead of
! so I think this makes sense" -millert@

"go for it" -nicm@


# 1.45 19-Oct-2015 mmcc

A little style(9) for sh.h includes

ok nicm@


# 1.44 19-Oct-2015 mmcc

Move stddef.h include from sh.h to the file that uses it.

ok nicm@


# 1.43 19-Oct-2015 mmcc

Move string.h include from sh.h to the files that use it.

ok nicm@


# 1.42 19-Oct-2015 mmcc

Move limits.h include from sh.h to the files that actually need it. No
binary change.

ok nicm@


# 1.41 19-Oct-2015 mmcc

More removal of EXTERN.

ok nicm@


# 1.40 18-Oct-2015 mmcc

Move more EXTERN-defined globals from sh.h.

ok nicm@


# 1.39 17-Oct-2015 mmcc

Drop two useless defines.

ok nicm@


# 1.38 17-Oct-2015 mmcc

Move a system header include from the global header (sh.h) into the
files that need it. No binary change.

"This looks fine" -nicm@


# 1.37 14-Sep-2015 nicm

Replace Tflag typedef with just int; ok tedu


# 1.36 14-Sep-2015 nicm

Apply the ancient art of tedu to ksh_limval.h. ok guenther


# 1.35 10-Sep-2015 nicm

Replace newline and space defines by "\n" and " " directly, from Michael
McConville. ok millert


# 1.34 10-Sep-2015 nicm

Remove INT32 define and just use int, from Martijn van Duren and Michael
McConville. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.33 18-Dec-2013 millert

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


# 1.32 28-Nov-2013 sobrado

remove trailing whitespaces; use tabs instead of spaces where appropriate;
no binary changes.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.31 10-Sep-2012 tedu

fake a sigwinch after each job, so if the terminal changes size,
we'll notice and update


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.30 04-Jan-2010 deraadt

Crank max array size in ksh to 10K-1, since 2047 is too restrictive.
Please keep in mind that ksh accesses are not O(1) in any sense.
Needed by todd, ok otto, guenther


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.29 11-Dec-2005 deraadt

remove unused variables and functions


# 1.28 04-Oct-2005 otto

Bump max array size. Needed for upcoming MAKEDEV speedup. ok deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.27 28-Mar-2005 deraadt

spacing


Revision tags: OPENBSD_3_7_BASE
# 1.26 21-Feb-2005 otto

Set \u in prompt expansion to the right value, while avoiding getpw* calls,
which might be very inconvenient when the yp server is not available.

ok deraadt@ millert@


# 1.25 22-Dec-2004 millert

Use stdbool.h instead of rolling our own bools.


# 1.24 18-Dec-2004 millert

Use _PATH_BSHELL instead of hardcoding "/bin/sh"


# 1.23 18-Dec-2004 millert

Flags set in signal handlers should be volatile sig_atomic_t


# 1.22 18-Dec-2004 millert

Use the BSD sig_t instead of homegrown handler_t
Remove KSH_SA_FLAGS


# 1.21 18-Dec-2004 millert

Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian


# 1.20 18-Dec-2004 millert

Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.
First step in making the ksh code easier to read. From Matthias Kilian


# 1.19 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


Revision tags: OPENBSD_3_6_BASE
# 1.18 31-May-2004 otto

Remove redundant errno declaration. ok deraadt@


# 1.17 10-May-2004 pvalchev

double the command line buffer size (1024 -> 2048); ok millert deraadt


Revision tags: OPENBSD_3_5_BASE
# 1.16 08-Feb-2004 deraadt

forget about 16 bit machines; millert ok


# 1.15 22-Oct-2003 jmc

typos from Jared Yanovich;
ok deraadt@


Revision tags: OPENBSD_3_4_BASE
# 1.14 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.13 16-May-2003 jsyn

fix several constant overflows, remove the strerror prototype (shouldn't be
there), and cleanup some whitespace; help from, and okay millert@


Revision tags: OPENBSD_3_3_BASE
# 1.12 07-Oct-2002 vincent

int -> uid_t

ok millert


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.11 01-Mar-2002 espie

this is needed too


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.10 15-Jul-1999 millert

o Set default line edit mode to emacs (VISUAL/EDITOR or user can override)
o Spell environment correctly


# 1.9 15-Jun-1999 millert

patches from pdksh 5.2.13.11


Revision tags: OPENBSD_2_5_BASE
# 1.8 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.7 08-Jan-1999 millert

bug fixes from pdksh-unstable-5.2.13.5; some of which we already had.


Revision tags: OPENBSD_2_4_BASE
# 1.6 25-Jun-1998 millert

pdksh-5.2.13 + local changes


Revision tags: OPENBSD_2_3_BASE
# 1.5 02-Jan-1997 downsj

Add FSH (set -o sh), initialize it if we're /bin/sh, and add the first use:
don't set $_ if we're non-interactive.


# 1.4 18-Dec-1996 niklas

Up limit of available user file descriptors (e.g. for redirections) to 32


# 1.3 01-Oct-1996 downsj

Integrate pdksh 5.2.9.


# 1.2 19-Aug-1996 downsj

update to pdksh-5.2.8


# 1.1 14-Aug-1996 downsj

branches: 1.1.1;
Initial revision


# 1.71 16-Jan-2018 jca

Introduce internal_warningf() and mark internal_errorf() as noreturn

This helps tools like scan-build, and follows the example of warningf()
and errorf(). ok anton@


# 1.70 15-Jan-2018 jca

Stop pretending we support building ksh without EDIT/HISTORY support

ok anton@


# 1.69 14-Jan-2018 anton

unifdef BRACE_EXPAND; ok jca@


# 1.68 06-Jan-2018 millert

Bring back the sign compare changes, this time with a fix from otto@
that fixes the issues seen on hppa. OK deraadt@ otto@


# 1.67 05-Jan-2018 jca

unifdef JOBS support

Prompted by a mail from Klemens Nanni, who also had the same diff.
ok deraadt@ millert@


# 1.66 27-Dec-2017 millert

Add -Wshadow to Makefile and fix the resulting warnings. Many of
the warnings are due to the use of globals with generic names,
specifically "options" and "path". I've renamed "options" to
"sh_options" since it holds the shell options and "path" to
"search_path". OK jca@ tb@


# 1.65 19-Oct-2017 jca

Delete the deprecated emacs-usemeta option.

ok tb@ anton@


Revision tags: OPENBSD_6_2_BASE
# 1.64 03-Sep-2017 jca

Use PATH_MAX instead of a local define

okk deraadt@ millert@ anton@


# 1.63 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.62 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.61 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.60 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.59 29-Jun-2017 martijn

Increase the input line buffer to 4096 bytes.

Sounds good to deraadt@
OK anton@


Revision tags: OPENBSD_6_1_BASE
# 1.58 08-Sep-2016 millert

Add KSH_IGNORE_RDONLY flag and use it in var.c instead of the 0x4
magic number.


Revision tags: OPENBSD_6_0_BASE
# 1.57 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.56 30-Dec-2015 tedu

rename global "e" to genv to avoid accidental shadowing and aliasing.
ok millert nicm tb


# 1.55 14-Dec-2015 tb

Move system headers from sh.h to those files that actually need them.

ok mmcc@ a while ago


# 1.54 20-Nov-2015 tb

remove unused prototype

ok mmcc@


# 1.53 12-Nov-2015 mmcc

Use isdigit() instead of ksh's homebrewed alternative.

ok nicm@. Also discussed with millert@ and guenther@.


# 1.52 07-Nov-2015 mmcc

Make it clearer that warningf()'s first argument determines whether the
lineno is printed.

ok nicm@


# 1.51 01-Nov-2015 mmcc

Add uses of areallocarray(). mksh and Bitrig ksh already have similar
functions. With help from Theo Buehler.

ok nicm@


# 1.50 23-Oct-2015 mmcc

Remove two comments listing functionless files. Trivial, no functional
change.


# 1.49 23-Oct-2015 mmcc

proto.h contains many function prototypes. It's apparently separate from
sh.h because the pdksh devs used a prototype generator (last run in
1992). Merging it into sh.h makes things clearer.

ok nicm@


# 1.48 22-Oct-2015 mmcc

Final removal of EXTERN.

ok nicm@


# 1.47 21-Oct-2015 mmcc

Penultimate commit to remove EXTERN.

ok nicm@


# 1.46 19-Oct-2015 mmcc

Remove the define NOT, replace it with '!'. No binary change.

"The ^ is used in regular expressions and many versions of fnmatch(3)
accept both ! and ^. However, we are never going to accept ^ instead of
! so I think this makes sense" -millert@

"go for it" -nicm@


# 1.45 19-Oct-2015 mmcc

A little style(9) for sh.h includes

ok nicm@


# 1.44 19-Oct-2015 mmcc

Move stddef.h include from sh.h to the file that uses it.

ok nicm@


# 1.43 19-Oct-2015 mmcc

Move string.h include from sh.h to the files that use it.

ok nicm@


# 1.42 19-Oct-2015 mmcc

Move limits.h include from sh.h to the files that actually need it. No
binary change.

ok nicm@


# 1.41 19-Oct-2015 mmcc

More removal of EXTERN.

ok nicm@


# 1.40 18-Oct-2015 mmcc

Move more EXTERN-defined globals from sh.h.

ok nicm@


# 1.39 17-Oct-2015 mmcc

Drop two useless defines.

ok nicm@


# 1.38 17-Oct-2015 mmcc

Move a system header include from the global header (sh.h) into the
files that need it. No binary change.

"This looks fine" -nicm@


# 1.37 14-Sep-2015 nicm

Replace Tflag typedef with just int; ok tedu


# 1.36 14-Sep-2015 nicm

Apply the ancient art of tedu to ksh_limval.h. ok guenther


# 1.35 10-Sep-2015 nicm

Replace newline and space defines by "\n" and " " directly, from Michael
McConville. ok millert


# 1.34 10-Sep-2015 nicm

Remove INT32 define and just use int, from Martijn van Duren and Michael
McConville. ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.33 18-Dec-2013 millert

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


# 1.32 28-Nov-2013 sobrado

remove trailing whitespaces; use tabs instead of spaces where appropriate;
no binary changes.


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.31 10-Sep-2012 tedu

fake a sigwinch after each job, so if the terminal changes size,
we'll notice and update


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.30 04-Jan-2010 deraadt

Crank max array size in ksh to 10K-1, since 2047 is too restrictive.
Please keep in mind that ksh accesses are not O(1) in any sense.
Needed by todd, ok otto, guenther


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.29 11-Dec-2005 deraadt

remove unused variables and functions


# 1.28 04-Oct-2005 otto

Bump max array size. Needed for upcoming MAKEDEV speedup. ok deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.27 28-Mar-2005 deraadt

spacing


Revision tags: OPENBSD_3_7_BASE
# 1.26 21-Feb-2005 otto

Set \u in prompt expansion to the right value, while avoiding getpw* calls,
which might be very inconvenient when the yp server is not available.

ok deraadt@ millert@


# 1.25 22-Dec-2004 millert

Use stdbool.h instead of rolling our own bools.


# 1.24 18-Dec-2004 millert

Use _PATH_BSHELL instead of hardcoding "/bin/sh"


# 1.23 18-Dec-2004 millert

Flags set in signal handlers should be volatile sig_atomic_t


# 1.22 18-Dec-2004 millert

Use the BSD sig_t instead of homegrown handler_t
Remove KSH_SA_FLAGS


# 1.21 18-Dec-2004 millert

Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian


# 1.20 18-Dec-2004 millert

Remove unused OS dependent #ifdef blocks, #defines and macro abstraction.
First step in making the ksh code easier to read. From Matthias Kilian


# 1.19 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


Revision tags: OPENBSD_3_6_BASE
# 1.18 31-May-2004 otto

Remove redundant errno declaration. ok deraadt@


# 1.17 10-May-2004 pvalchev

double the command line buffer size (1024 -> 2048); ok millert deraadt


Revision tags: OPENBSD_3_5_BASE
# 1.16 08-Feb-2004 deraadt

forget about 16 bit machines; millert ok


# 1.15 22-Oct-2003 jmc

typos from Jared Yanovich;
ok deraadt@


Revision tags: OPENBSD_3_4_BASE
# 1.14 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.13 16-May-2003 jsyn

fix several constant overflows, remove the strerror prototype (shouldn't be
there), and cleanup some whitespace; help from, and okay millert@


Revision tags: OPENBSD_3_3_BASE
# 1.12 07-Oct-2002 vincent

int -> uid_t

ok millert


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.11 01-Mar-2002 espie

this is needed too


Revision tags: OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE
# 1.10 15-Jul-1999 millert

o Set default line edit mode to emacs (VISUAL/EDITOR or user can override)
o Spell environment correctly


# 1.9 15-Jun-1999 millert

patches from pdksh 5.2.13.11


Revision tags: OPENBSD_2_5_BASE
# 1.8 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.7 08-Jan-1999 millert

bug fixes from pdksh-unstable-5.2.13.5; some of which we already had.


Revision tags: OPENBSD_2_4_BASE
# 1.6 25-Jun-1998 millert

pdksh-5.2.13 + local changes


Revision tags: OPENBSD_2_3_BASE
# 1.5 02-Jan-1997 downsj

Add FSH (set -o sh), initialize it if we're /bin/sh, and add the first use:
don't set $_ if we're non-interactive.


# 1.4 18-Dec-1996 niklas

Up limit of available user file descriptors (e.g. for redirections) to 32


# 1.3 01-Oct-1996 downsj

Integrate pdksh 5.2.9.


# 1.2 19-Aug-1996 downsj

update to pdksh-5.2.8


# 1.1 14-Aug-1996 downsj

branches: 1.1.1;
Initial revision