summaryrefslogtreecommitdiff
path: root/man/1
diff options
context:
space:
mode:
Diffstat (limited to 'man/1')
-rw-r--r--man/1/sh-expr50
-rw-r--r--man/1/sh-mload68
2 files changed, 107 insertions, 11 deletions
diff --git a/man/1/sh-expr b/man/1/sh-expr
index 976e6c04..be9d2b97 100644
--- a/man/1/sh-expr
+++ b/man/1/sh-expr
@@ -1,8 +1,10 @@
.TH SH-EXPR 1
.SH NAME
-expr, ntest \- shell module for simple arithmetic.
+expr, ntest, mpexpr \- shell module for simple arithmetic.
.SH SYNOPSIS
.B load expr
+OR
+.B load mpexpr
.B ${expr
[
@@ -19,10 +21,17 @@ expr, ntest \- shell module for simple arithmetic.
.br
.SH DESCRIPTION
.I Expr
-is a loadable module for
+and
+.I mpexpr
+are loadable modules for
.IR sh (1)
-that provides support for simple integer arithmetic.
-It provides one command,
+that provide support for integer arithmetic.
+.I Expr
+uses 64-bit signed integers;
+.I mpexpr
+uses arbitrary-precision signed integers.
+They each provide the same interface:
+a command
.IR ntest ,
which performs a simple boolean test
on its integer argument, and the
@@ -54,15 +63,16 @@ Alternative names are given for some operators;
this is to avoid the necessity of quoting operators
that contain
.IR sh (1)
-metacharacters. All operations use 64-bit signed
-integers; integers are given in the same form acceptable
+metacharacters. Integers are given in the same form acceptable
to Limbo. The relational operators yield either
1 (true) or 0 (false). If the
.B -r
option is given,
.I radix
-specifies an output base for numbers yielded by
-.IR expr .
+specifies an output base for printed numbers.
+It may be from 2 to 36;
+.I mpexpr
+also allows 64 to specify base64 notation.
Numbers are printed in a form suitable for re-interpretation
by
.IR expr .
@@ -70,8 +80,9 @@ by
When all its arguments have been evaluated,
.B expr
yields all the values remaining on its stack, first pushed
-first. The operators supported by expr are as follows (the number
-of operands required in is given parentheses):
+first. Note that bitwise operators treat their operands as if they
+were stored in two's complement form. The operators supported by expr are as follows (the number
+of operands required in is given parentheses).
.TP 15
.BR + \ (2)
Addition
@@ -148,13 +159,30 @@ pushes on the stack a sequence of numbers ranging
numerically from its first argument up to and including
its second argument. If its second argument is
less than its first, the sequence will descend.
+.TP
+.BR rand \ (1)
+(\fImpexpr\fP only). Push a secure random number;
+the argument value gives the size of the number, in bits.
+.TP
+.BR bits \ (1)
+(\fImpexpr\fP only). Push the size, in bits, of the argument.
+.TP
+.BR expmod ", " invert " (2)"
+(\fImpexpr\fP only). See
+.IR ipint (2).
+.TP
+.BR exp ", " xx ", " **
+(\fImpexpr\fP only). Exponentiation.
.SH SOURCE
.B /appl/cmd/sh/expr.b
.SH SEE ALSO
.IR sh (1),
.IR sh-std (1),
-.IR sh-tk (1)
+.IR sh-tk (1),
+.IR keyring-ipint (2)
.SH BUGS
Postfix notation can be confusing.
Any operators that contain shell metacharacters (e.g. ``*'', ``>'')
must be quoted to avoid interpretation by the shell.
+Base64 notation can contain # characters, which need
+quoting to avoid interpretation by the shell.
diff --git a/man/1/sh-mload b/man/1/sh-mload
new file mode 100644
index 00000000..e56cb92a
--- /dev/null
+++ b/man/1/sh-mload
@@ -0,0 +1,68 @@
+.TH SH-MLOAD 1
+.SH NAME
+mload, munload \- namespace separation for shell modules
+.SH SYNOPSIS
+.B load mload
+
+.B mload
+.I name
+[
+.IR path ...
+]
+.br
+.B munload
+.I name
+[
+.IR path ...
+]
+.br
+.SH DESCRIPTION
+.I Mload
+is a loadable module for
+.IR sh (1)
+that allows the simultaneous use of shell modules with
+potentially clashing command name spaces.
+.B Mload
+creates a new namespace
+.I name
+and loads each
+.I path
+as a builtin module in the same way as
+.B load
+(see
+.IR sh (1)).
+Any commands or substitution builtins defined
+by the modules are accessible by giving
+the command and its arguments as arguments to
+the
+.I name
+command.
+.PP
+.B Munload
+unloads a module from the namespace
+.IR name .
+If no modules remain in the namespace,
+.I name
+is undefined as a command.
+.SH EXAMPLE
+Load
+.I mpexpr
+in a different namespace from
+.I expr
+(see
+.IR sh-expr (1)):
+.EX
+load expr
+mload mp mpexpr
+echo ${expr 1 2 +}
+echo ${mp expr 2 300 xx}
+.EE
+.SH SOURCE
+.B /appl/cmd/sh/mload.b
+.SH SEE ALSO
+.IR sh (1),
+.SH BUGS
+Because of the way shell modules are implemented,
+the namespaces are global across all processes that
+share an instance of
+.IR mload .