Skip to content
Permalink
Browse files

Introduce ${.sh.install_prefix}

This var will be useful for doing things like finding the man pages
for builtins. It will hold the value of `meson --prefix=/path`.
Typically, /usr or /usr/local.
  • Loading branch information...
krader1961 committed Sep 2, 2019
1 parent dc9fccc commit a54c289880f20b3f1060cc33233badddb0747ce6
@@ -1,4 +1,18 @@
# ksh 2020.0.0-alpha1 (version TBD, this is a work in progress)
# ksh git head (version TBD, this is a work in progress)

## Deprecations

## Notable non-backward compatible changes

## Notable fixes and improvements

- A .sh.install_prefix var has been introduced to reflect the `meson -prefix=`
value. This will be used to establish the location of supporting files such
as man pages and autoloaded functions.

## Other significant changes

# ksh 2020.0.0-beta1 (version TBD, this is a work in progress)

This documents changes since the AST code, which includes the `ksh` program,
was moved to Github. That is, the ksh93u+ source. The next stable version will
@@ -36,6 +36,7 @@
// platform feature detection and naming conventions.
#mesondefine DEBUG_BUILD
#mesondefine MESON_BUILD
#mesondefine INSTALL_PREFIX
#mesondefine OSNAME
#mesondefine HOSTTYPE
#mesondefine BASH_MACHTYPE
@@ -6,6 +6,7 @@ cpu = host_machine.cpu()
system = host_machine.system()
# So the `config_ast.h` and other dynamically generated headers can be found (see below).
configuration_incdir = include_directories(['.'])
install_prefix = get_option('prefix')

if get_option('warnings-are-errors') == true
add_global_arguments('-Werror', language: 'c')
@@ -228,6 +229,7 @@ wchar_t_size = cc.sizeof('wchar_t', prefix: '#include <wchar.h>')

feature_data = configuration_data()
feature_data.set('MESON_BUILD', 1)
feature_data.set_quoted('INSTALL_PREFIX', install_prefix)
if system == 'darwin'
feature_data.set('_DARWIN_C_SOURCE', 1)
endif
@@ -100,6 +100,7 @@ const struct shtable2 shtab_variables[] = {
{".sh.pwdfd", NV_INTEGER, NULL},
{".sh.sig", 0, NULL},
{".sh.op_astbin", NV_NOFREE, SH_CMDLIB_DIR},
{".sh.install_prefix", NV_RDONLY | NV_NOFREE, INSTALL_PREFIX},
{"SH_OPTIONS", 0, NULL},
{"SHLVL", NV_INTEGER | NV_NOFREE | NV_EXPORT, NULL},
{"COMP_CWORD", NV_INTEGER | NV_SHORT | NV_UNSIGN, NULL},
@@ -1681,6 +1681,14 @@ The pathname of the file than contains the current command.
.B .sh.fun
The name of the current function that is being executed.
.TP
.B .sh.install_prefix
The root directory where ksh was configured to install the ksh binary and supporting files (e.g.,
man pages). Typical values are
.BR /usr/local ,
and
.BR /usr .
It is readonly and cannot be modified.
.TP
.B .sh.level
Set to the current function depth. This can be changed
inside a DEBUG trap and will set the context to the specified
@@ -2224,7 +2232,7 @@ The value consists of blank separated
words. For each
.I name\^
that is the name of a known option the variable
.BI .sh.opt_ name\^
.BI .sh.op_ name\^
is assigned
.IR value .
Currently the only valid option name is
@@ -91,15 +91,17 @@
#define SH_PWDFD (shgd->bltin_nodes + 65)
#define SH_SIG (shgd->bltin_nodes + 66)
#define SH_ASTBIN (shgd->bltin_nodes + 67)
#define OPTIONS (shgd->bltin_nodes + 68)
#define SHLVL (shgd->bltin_nodes + 69)
#define COMP_CWORD (shgd->bltin_nodes + 70)
#define COMP_LINE (shgd->bltin_nodes + 71)
#define COMP_POINT (shgd->bltin_nodes + 72)
#define COMP_WORDS (shgd->bltin_nodes + 73)
#define COMP_KEY (shgd->bltin_nodes + 74)
#define COMPREPLY (shgd->bltin_nodes + 75)
#define COMP_WORDBREAKS (shgd->bltin_nodes + 76)
// #define COMP_TYPE (shgd->bltin_nodes + 77)
// #define SH_INSTALL_PREFIX (shgd->bltin_nodes + 68)
#define OPTIONS (shgd->bltin_nodes + 69)
#define SHLVL (shgd->bltin_nodes + 70)
#define COMP_CWORD (shgd->bltin_nodes + 71)
#define COMP_LINE (shgd->bltin_nodes + 72)
#define COMP_POINT (shgd->bltin_nodes + 73)
#define COMP_WORDS (shgd->bltin_nodes + 74)
#define COMP_KEY (shgd->bltin_nodes + 75)
#define COMPREPLY (shgd->bltin_nodes + 76)
#define COMP_WORDBREAKS (shgd->bltin_nodes + 77)
// #define COMP_TYPE (shgd->bltin_nodes + 78)
// #define CSWIDTH (shgd->bltin_nodes + 79)

#endif // _VARIABLES_H
@@ -1748,7 +1748,7 @@ static_fn Dt_t *inittree(Shell_t *shp, const struct shtable2 *name_vals) {
nv_setsize(np, nv_isattr(np, NV_INTEGER) ? 10 : 0);
// The sole reason for using nv_isattr(np, NV_TABLE) here appears to be the special `.sh`
// compound var. At this point the nv_isattr test is true while nv_istable(np) is false.
// Ffter the nv_mount() the reverse is true.
// After the nv_mount() the reverse is true.
if (nv_isattr(np, NV_TABLE)) {
dict = dtopen(&_Nvdisc, Dtoset);
nv_mount(np, NULL, dict);
@@ -1463,7 +1463,11 @@ static_fn void write_indent(Sfio_t *out, char *str, int n, int indent) {
int sh_outtype(Shell_t *shp, Sfio_t *out) {
Namval_t node, *mp, *tp;
Dt_t *dp;
char *cp, *sp, *xp, nvtype[sizeof(NV_CLASS)];
char *cp, *sp, *xp;
// Warning: It would appear at first glance that the use of a char array isn't necessary.
// However, the nv_open() call chain mutates the string. So we have to copy the readonly
// string into a mutable buffer.
char nvtype[sizeof(NV_CLASS)];
Sfio_t *iop = NULL;
int n = 0, indent = 0;
cp = shp->prefix;

0 comments on commit a54c289

Please sign in to comment.
You can’t perform that action at this time.