Skip to content

Commit

Permalink
Fix various typos / Update README.md
Browse files Browse the repository at this point in the history
README.md:
- Add a table of contents.
- Start a list of system-specific instructions for installing build
  dependencies in README.md, initially for Android/Termux and
  macOS. Runtime dependencies are also mentioned where applicable
  (yes, there are system that ship without tput(1) and getconf(1)).

Other files:
- Fix various typos.
  • Loading branch information
McDutchie committed Dec 7, 2024
1 parent b587179 commit c38c57b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 13 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,47 @@ and click on commit messages for full details.
For all fixes, see [the commit log](https://github.com/ksh93/ksh/commits/1.0).
For known issues in the current release, see [TODO](https://github.com/ksh93/ksh/blob/1.0/TODO).

## Build
## Table of contents ##

* [Installing from source](#user-content-installing-from-source)
* [Prepare](#user-content-prepare)
* [Build](#user-content-build)
* [Test](#user-content-test)
* [Install](#user-content-install)
* [What is ksh93?](#user-content-what-is-ksh93)

## Installing from source

You can download a [release](releases) tarball,
or clone the current code from the 1.0 branch:
`git clone -b 1.0 https://github.com/ksh93/ksh`

### Prepare

The build system requires only a basic POSIX-compatible shell, utilities and
compiler environment. The `cc`, `ar` and `getconf` commands are needed at
build time. The `tput` and `getconf` commands are used at runtime if
available (for multiline editing and to complete the `getconf` built-in,
respectively). Not all systems come with all of these preinstalled. Here are
system-specific instructions for making them available:

* **Android/[Termux](https://termux.dev/):**
install dependencies using `pkg install`.
* Build dependencies: `clang`, `binutils`, `getconf`
* Runtime dependencies (optional): `ncurses-utils`, `getconf`
* **macOS:**
install the Xcode Command Line Tools:
`xcode-select --install`

### Build

To build ksh with a custom configuration of features, edit
[`src/cmd/ksh93/SHOPT.sh`](https://github.com/ksh93/ksh/blob/1.0/src/cmd/ksh93/SHOPT.sh).

On systems such as NetBSD and OpenBSD, where `/bin/ksh` is not ksh93 and the
preinstalled `/etc/ksh.kshrc` profile script is incompatible with ksh93, you'll
want to disable `SHOPT_SYSRC` to avoid loading it on startup -- unless you can
edit it to make it compatible with ksh93. This geneerally involves differences
edit it to make it compatible with ksh93. This generally involves differences
in the declaration and usage of local variables in functions.

Then `cd` to the top directory and run:
Expand All @@ -37,6 +69,7 @@ bin/package make
```

To suppress compiler output, use `quiet make` instead of `make`.

In some non-POSIX shells you might need to prepend `sh` to all calls to `bin/package`.

Parallel building is supported by appending `-j` followed by the
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/INIT/README-mamake.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ written as a separate line to its standard input. The value of the expansion
is the output of *s* with each newline changed back into a space, except
that a terminating newline (if any) is discarded.
This mechanism allows easy editing of variable values containing multiple
pathnames using line-oriented utilities thet read from standard input,
pathnames using line-oriented utilities that read from standard input,
such as `sed`(1) or `grep`(1).
For example, if the automatic variable `%{^}` (see below) contains `foo.c
bar.c baz.c`, then `%{^|sed 's/\.c$//'}` yields `foo bar baz`.
Expand Down Expand Up @@ -169,7 +169,7 @@ previously processed or referenced prerequisites.

`%{?}` is a space-separate list of the current rule's previously processed
prerequisites that have been updated by a shell action (see `exec` below)
during the current `mamake` run. Prequisites that were already up to date,
during the current `mamake` run. Prerequisites that were already up to date,
or prerequisites that do not contain a shell action, are not included.

## Commands ##
Expand Down Expand Up @@ -340,7 +340,7 @@ of the line in the rule.
After MAM variable expansion, *viewpathing* is applied.
The first colon-separated element of `%{VPATH}` is considered
the object code directory and the second the source code directory;
viewpathing provides the first with a vew to the second.
viewpathing provides the first with a view to the second.
Viewpathing applies two transformations.

The first is *prerequisite replacement*.
Expand Down Expand Up @@ -375,7 +375,7 @@ in the following format is written to standard error:

# path/to/Mamfile: startline-endline: rule

During script execution, shell action comands are traced using the
During script execution, shell action commands are traced using the
shell's xtrace option, unless the rule has the `notrace` attribute.

#### Strict level 2+ change ####
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/INIT/mamake.c
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ static void run(Rule_t *r, char *s)
if (x && state.shim)
{
/* Also subject the user-set shim to viewpathing
* (plus other code preprended above, but it should not contain anything viewpathable) */
* (plus other code prepended above, but it should not contain anything viewpathable) */
char *pre = use(buf);
size_t n = strlen(pre);
if (!(tofree = malloc(n + strlen(s) + 1)))
Expand Down Expand Up @@ -2233,7 +2233,7 @@ static void make(Rule_t *r, Makestate_t *parentstate)
{
/* loop block done */
if (*t)
error_out("superflous arguments", u);
error_out("syntax error", u);
break;
}
/* make block done */
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/ksh93/features/externs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ tst note{ determining size of PID variables }end output{
exit 1
}end

# execve(3) breakage on Android/Termux (as of API 35)
# execve(3) breakage on Android/Termux (early versions of API 35)
tst execve_ignores_argv0 note{ does execve(3) ignore the specified argv[0] }end output{
#include <string.h>
#include <unistd.h>
Expand All @@ -201,7 +201,7 @@ tst execve_ignores_argv0 note{ does execve(3) ignore the specified argv[0] }end
sprintf(b,"_KSH_EXECVE_TEST_%d=y",(int)getpid());
newenv[0] = b;
newenv[1] = NULL;
/* check if we've alreay been re-exec'ed */
/* check if we've already been re-exec'ed */
for (i = 0; environ[i]; i++)
if (strcmp(environ[i],newenv[0])==0)
return !(strcmp(argv[0],"TEST_OK")!=0);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/kshrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typeset .rc
.rc.tty=${.rc.tty#/dev/}

if [[ -v INSTALLROOT ]]
then # do not intefere with the regular ksh history
then # do not interfere with the regular ksh history
[[ -d $INSTALLROOT/var ]] || mkdir -p "$INSTALLROOT/var"
HISTFILE=$INSTALLROOT/var/sh_history_${.rc.tty//\//_}
fi
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/sh/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static void check_typedef(struct comnod *tp, char intypeset)
* Hack to avoid an inconsistent state if a 'typeset -T' or 'enum' declaration is parsed but not executed:
*
* The parser needs to know about to-be-created type built-ins before their declarations are executed,
* otherwise assignment-arguments with parenteses -- e.g., Type_t foo=(bar baz) -- are a syntax error if
* otherwise assignment-arguments with parentheses -- e.g., Type_t foo=(bar baz) -- are a syntax error if
* parsed within the same pass as the 'typeset -T Type_t=(...)' declaration. This would be especially bad
* in dot scripts, which are completely parsed in one single sh_parse() call before execution.
*
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libast/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ make install virtual
note *

note * The standards test influences all subsequent iffe feature tests, so must be made first
note * Block parallellisation here by nesting FEATURE/standards in ast_standards.h
note * Block parallelisation here by nesting FEATURE/standards in ast_standards.h
make ast_standards.h
make FEATURE/standards
makp features/standards
Expand Down

0 comments on commit c38c57b

Please sign in to comment.