xref: /freebsd/contrib/bc/gen/dc_help.txt (revision d43fa8ef534ac87a16843d45264f56cf11e0fcbc)
1252884aeSStefan Eßer/*
2252884aeSStefan Eßer * *****************************************************************************
3252884aeSStefan Eßer *
43aa99676SStefan Eßer * SPDX-License-Identifier: BSD-2-Clause
5252884aeSStefan Eßer *
610328f8bSStefan Eßer * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
7252884aeSStefan Eßer *
8252884aeSStefan Eßer * Redistribution and use in source and binary forms, with or without
9252884aeSStefan Eßer * modification, are permitted provided that the following conditions are met:
10252884aeSStefan Eßer *
11252884aeSStefan Eßer * * Redistributions of source code must retain the above copyright notice, this
12252884aeSStefan Eßer *   list of conditions and the following disclaimer.
13252884aeSStefan Eßer *
14252884aeSStefan Eßer * * Redistributions in binary form must reproduce the above copyright notice,
15252884aeSStefan Eßer *   this list of conditions and the following disclaimer in the documentation
16252884aeSStefan Eßer *   and/or other materials provided with the distribution.
17252884aeSStefan Eßer *
18252884aeSStefan Eßer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19252884aeSStefan Eßer * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20252884aeSStefan Eßer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21252884aeSStefan Eßer * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22252884aeSStefan Eßer * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23252884aeSStefan Eßer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24252884aeSStefan Eßer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25252884aeSStefan Eßer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26252884aeSStefan Eßer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27252884aeSStefan Eßer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28252884aeSStefan Eßer * POSSIBILITY OF SUCH DAMAGE.
29252884aeSStefan Eßer *
30252884aeSStefan Eßer * *****************************************************************************
31252884aeSStefan Eßer *
32252884aeSStefan Eßer * The dc help text.
33252884aeSStefan Eßer *
34252884aeSStefan Eßer */
35252884aeSStefan Eßer
36252884aeSStefan Eßerusage: %s [options] [file...]
37252884aeSStefan Eßer
38252884aeSStefan Eßerdc is a reverse-polish notation command-line calculator which supports unlimited
397e5c51e5SStefan Eßerprecision arithmetic. For details, use `man %s` or see the online documentation
407e5c51e5SStefan Eßerat https://git.yzena.com/gavin/bc/src/tag/%s/manuals/bc/%s.1.md.
41252884aeSStefan Eßer
427e5c51e5SStefan EßerThis dc is (mostly) compatible with the OpenBSD dc and the GNU dc. See the
437e5c51e5SStefan EßerOpenBSD man page (http://man.openbsd.org/OpenBSD-current/man1/dc.1) and the GNU
447e5c51e5SStefan Eßerdc manual (https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html)
457e5c51e5SStefan Eßerfor details.
46252884aeSStefan Eßer
47252884aeSStefan EßerThis dc has a few differences from the two above:
48252884aeSStefan Eßer
49252884aeSStefan Eßer  1) When printing a byte stream (command "P"), this bc follows what the FreeBSD
50252884aeSStefan Eßer     dc does.
51252884aeSStefan Eßer  2) This dc implements the GNU extensions for divmod ("~") and modular
52252884aeSStefan Eßer     exponentiation ("|").
53252884aeSStefan Eßer  3) This dc implements all FreeBSD extensions, except for "J" and "M".
54252884aeSStefan Eßer  4) This dc does not implement the run command ("!"), for security reasons.
55252884aeSStefan Eßer  5) Like the FreeBSD dc, this dc supports extended registers. However, they are
56252884aeSStefan Eßer     implemented differently. When it encounters whitespace where a register
57252884aeSStefan Eßer     should be, it skips the whitespace. If the character following is not
58252884aeSStefan Eßer     a lowercase letter, an error is issued. Otherwise, the register name is
59252884aeSStefan Eßer     parsed by the following regex:
60252884aeSStefan Eßer
61252884aeSStefan Eßer       [a-z][a-z0-9_]*
62252884aeSStefan Eßer
63252884aeSStefan Eßer     This generally means that register names will be surrounded by whitespace.
64252884aeSStefan Eßer
65252884aeSStefan Eßer     Examples:
66252884aeSStefan Eßer
67252884aeSStefan Eßer       l idx s temp L index S temp2 < do_thing
68252884aeSStefan Eßer
69252884aeSStefan Eßer     Also note that, unlike the FreeBSD dc, extended registers are not even
70252884aeSStefan Eßer     parsed unless the "-x" option is given. Instead, the space after a command
71252884aeSStefan Eßer     that requires a register name is taken as the register name.
72252884aeSStefan Eßer
73252884aeSStefan EßerOptions:
74252884aeSStefan Eßer
75252884aeSStefan Eßer  -e  expr  --expression=expr
76252884aeSStefan Eßer
77252884aeSStefan Eßer      Run "expr" and quit. If multiple expressions or files (see below) are
78252884aeSStefan Eßer      given, they are all run. After running, dc will exit.
79252884aeSStefan Eßer
80252884aeSStefan Eßer  -f  file  --file=file
81252884aeSStefan Eßer
82252884aeSStefan Eßer      Run the dc code in "file" and exit. See above.
83252884aeSStefan Eßer
84252884aeSStefan Eßer  -h  --help
85252884aeSStefan Eßer
86252884aeSStefan Eßer      Print this usage message and exit.
87252884aeSStefan Eßer
88252884aeSStefan Eßer  -i  --interactive
89252884aeSStefan Eßer
90252884aeSStefan Eßer      Put dc into interactive mode. See the man page for more details.
91252884aeSStefan Eßer
92*d43fa8efSStefan Eßer  -L  --no-line-length
93*d43fa8efSStefan Eßer
94*d43fa8efSStefan Eßer      Disable line length checking.
95*d43fa8efSStefan Eßer
96252884aeSStefan Eßer  -P  --no-prompt
97252884aeSStefan Eßer
987e5c51e5SStefan Eßer      Disable the prompts in interactive mode.
997e5c51e5SStefan Eßer
1007e5c51e5SStefan Eßer  -R  --no-read-prompt
1017e5c51e5SStefan Eßer
1027e5c51e5SStefan Eßer      Disable the read prompt in interactive mode.
103252884aeSStefan Eßer
104252884aeSStefan Eßer  -V  --version
105252884aeSStefan Eßer
106252884aeSStefan Eßer      Print version and copyright and exit.
107252884aeSStefan Eßer
108252884aeSStefan Eßer  -x  --extended-register
109252884aeSStefan Eßer
110252884aeSStefan Eßer      Enable extended register mode.
11144d4804dSStefan Eßer
112*d43fa8efSStefan Eßer  -z  --leading-zeroes
113*d43fa8efSStefan Eßer
114*d43fa8efSStefan Eßer      Enable leading zeroes on numbers greater than -1 and less than 1.
115*d43fa8efSStefan Eßer
11644d4804dSStefan EßerEnvironment variables:
11744d4804dSStefan Eßer
11844d4804dSStefan Eßer  DC_ENV_ARGS
11944d4804dSStefan Eßer
12044d4804dSStefan Eßer      Command-line arguments to use on every run.
12144d4804dSStefan Eßer
12244d4804dSStefan Eßer  DC_LINE_LENGTH
12344d4804dSStefan Eßer
12444d4804dSStefan Eßer      If an integer, the number of characters to print on a line before
125*d43fa8efSStefan Eßer      wrapping. Using 0 will disable line length checking.
12644d4804dSStefan Eßer
12744d4804dSStefan Eßer  DC_SIGINT_RESET
12844d4804dSStefan Eßer
12944d4804dSStefan Eßer      If an integer and non-zero, reset on SIGINT, rather than exit, when in
13044d4804dSStefan Eßer      interactive mode.
13144d4804dSStefan Eßer
13244d4804dSStefan Eßer      Overrides the default, which is %s.
13344d4804dSStefan Eßer
13444d4804dSStefan Eßer  DC_TTY_MODE
13544d4804dSStefan Eßer
13644d4804dSStefan Eßer      If an integer and non-zero, enable TTY mode when it is available.
13744d4804dSStefan Eßer
13844d4804dSStefan Eßer      Overrides the default, which is TTY mode %s.
13944d4804dSStefan Eßer
14044d4804dSStefan Eßer  DC_PROMPT
14144d4804dSStefan Eßer
14244d4804dSStefan Eßer      If an integer and non-zero, enable prompt when TTY mode is possible.
14344d4804dSStefan Eßer
14444d4804dSStefan Eßer      Overrides the default, which is prompt %s.
145