xref: /freebsd/contrib/bc/gen/dc_help.txt (revision 8a272653d9fbd9fc37691c9aad6a05089b4ecb4d)
1/*
2 * *****************************************************************************
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 *
6 * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * * Redistributions of source code must retain the above copyright notice, this
12 *   list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above copyright notice,
15 *   this list of conditions and the following disclaimer in the documentation
16 *   and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * *****************************************************************************
31 *
32 * The dc help text.
33 *
34 */
35
36usage: %s [options] [file...]
37
38dc is a reverse-polish notation command-line calculator which supports unlimited
39precision arithmetic. For details, use `man %s`.
40
41This dc is (mostly) compatible with the FreeBSD dc and the GNU dc. See the
42FreeBSD man page (https://www.unix.com/man-page/FreeBSD/1/dc/) and the GNU dc
43manual (https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html) for
44details.
45
46This dc has a few differences from the two above:
47
48  1) When printing a byte stream (command "P"), this bc follows what the FreeBSD
49     dc does.
50  2) This dc implements the GNU extensions for divmod ("~") and modular
51     exponentiation ("|").
52  3) This dc implements all FreeBSD extensions, except for "J" and "M".
53  4) This dc does not implement the run command ("!"), for security reasons.
54  5) Like the FreeBSD dc, this dc supports extended registers. However, they are
55     implemented differently. When it encounters whitespace where a register
56     should be, it skips the whitespace. If the character following is not
57     a lowercase letter, an error is issued. Otherwise, the register name is
58     parsed by the following regex:
59
60       [a-z][a-z0-9_]*
61
62     This generally means that register names will be surrounded by whitespace.
63
64     Examples:
65
66       l idx s temp L index S temp2 < do_thing
67
68     Also note that, unlike the FreeBSD dc, extended registers are not even
69     parsed unless the "-x" option is given. Instead, the space after a command
70     that requires a register name is taken as the register name.
71
72Options:
73
74  -e  expr  --expression=expr
75
76      Run "expr" and quit. If multiple expressions or files (see below) are
77      given, they are all run. After running, dc will exit.
78
79  -f  file  --file=file
80
81      Run the dc code in "file" and exit. See above.
82
83  -h  --help
84
85      Print this usage message and exit.
86
87  -i  --interactive
88
89      Put dc into interactive mode. See the man page for more details.
90
91  -P  --no-prompt
92
93      Disable the prompt in interactive mode.
94
95  -V  --version
96
97      Print version and copyright and exit.
98
99  -x  --extended-register
100
101      Enable extended register mode.
102