Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/bc/gen/dc_help.txt
39482 views
1
/*
2
* *****************************************************************************
3
*
4
* SPDX-License-Identifier: BSD-2-Clause
5
*
6
* Copyright (c) 2018-2025 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
36
usage: %s [options] [file...]
37
38
dc is a reverse-polish notation command-line calculator which supports unlimited
39
precision arithmetic. For details, use `man %s` or see the online documentation
40
at https://github.com/gavinhoward/bc/tree/%s/manuals/dc/%s.1.md .
41
42
This dc is (mostly) compatible with the OpenBSD dc and the GNU dc. See the
43
OpenBSD man page (http://man.openbsd.org/OpenBSD-current/man1/dc.1) and the GNU
44
dc manual (https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html)
45
for details.
46
47
This dc has a few differences from the two above:
48
49
1) When printing a byte stream (command "P"), this bc follows what the FreeBSD
50
dc does.
51
2) This dc implements the GNU extensions for divmod ("~") and modular
52
exponentiation ("|").
53
3) This dc implements all FreeBSD extensions, except for "J" and "M".
54
4) This dc does not implement the run command ("!"), for security reasons.
55
5) Like the FreeBSD dc, this dc supports extended registers. However, they are
56
implemented differently. When it encounters whitespace where a register
57
should be, it skips the whitespace. If the character following is not
58
a lowercase letter, an error is issued. Otherwise, the register name is
59
parsed by the following regex:
60
61
[a-z][a-z0-9_]*
62
63
This generally means that register names will be surrounded by whitespace.
64
65
Examples:
66
67
l idx s temp L index S temp2 < do_thing
68
69
Also note that, unlike the FreeBSD dc, extended registers are not even
70
parsed unless the "-x" option is given. Instead, the space after a command
71
that requires a register name is taken as the register name.
72
73
Options:
74
75
-C --no-digit-clamp
76
77
Disables clamping of digits that are larger than or equal to the current
78
ibase when parsing numbers.
79
80
This means that the value added to a number from a digit is always that
81
digit's value multiplied by the value of ibase raised to the power of the
82
digit's position, which starts from 0 at the least significant digit.
83
84
If multiple of this option and the -c option are given, the last is used.
85
86
-c --digit-clamp
87
88
Enables clamping of digits that are larger than or equal to the current
89
ibase when parsing numbers.
90
91
This means that digits that the value added to a number from a digit that
92
is greater than or equal to the ibase is the value of ibase minus 1 all
93
multiplied by the value of ibase raised to the power of the digit's
94
position, which starts from 0 at the least significant digit.
95
96
If multiple of this option and the -C option are given, the last is used.
97
{{ A H N HN }}
98
99
-E seed --seed=seed
100
101
Sets the builtin variable seed to the given value assuming that the given
102
value is in base 10. It is a fatal error if the given value is not a valid
103
number.
104
{{ end }}
105
106
-e expr --expression=expr
107
108
Run "expr" and quit. If multiple expressions or files (see below) are
109
given, they are all run. After running, dc will exit.
110
111
-f file --file=file
112
113
Run the dc code in "file" and exit. See above.
114
115
-h --help
116
117
Print this usage message and exit.
118
119
-I ibase --ibase=ibase
120
121
Sets the builtin variable ibase to the given value assuming that the given
122
value is in base 10. It is a fatal error if the given value is not a valid
123
number.
124
125
-i --interactive
126
127
Put dc into interactive mode. See the man page for more details.
128
129
-L --no-line-length
130
131
Disable line length checking.
132
133
-O obase --obase=obase
134
135
Sets the builtin variable obase to the given value assuming that the given
136
value is in base 10. It is a fatal error if the given value is not a valid
137
number.
138
139
-P --no-prompt
140
141
Disable the prompts in interactive mode.
142
143
-R --no-read-prompt
144
145
Disable the read prompt in interactive mode.
146
147
-S scale --scale=scale
148
149
Sets the builtin variable scale to the given value assuming that the given
150
value is in base 10. It is a fatal error if the given value is not a valid
151
number.
152
153
-V --version
154
155
Print version and copyright and exit.
156
157
-x --extended-register
158
159
Enable extended register mode.
160
161
-z --leading-zeroes
162
163
Enable leading zeroes on numbers greater than -1 and less than 1.
164
165
Environment variables:
166
167
DC_ENV_ARGS
168
169
Command-line arguments to use on every run.
170
171
DC_LINE_LENGTH
172
173
If an integer, the number of characters to print on a line before
174
wrapping. Using 0 will disable line length checking.
175
176
DC_SIGINT_RESET
177
178
If an integer and non-zero, reset on SIGINT, rather than exit, when in
179
interactive mode.
180
181
If zero, do not reset on SIGINT in all cases, but exit instead.
182
183
Overrides the default, which is %s.
184
185
DC_TTY_MODE
186
187
If an integer and non-zero, enable TTY mode when it is available.
188
189
If zero, disable TTY mode in all cases.
190
191
Overrides the default, which is TTY mode %s.
192
193
DC_PROMPT
194
195
If an integer and non-zero, enable prompt when TTY mode is possible.
196
197
If zero, disable prompt in all cases.
198
199
Overrides the default, which is prompt %s.
200
201
DC_EXPR_EXIT
202
203
If an integer and non-zero, exit when expressions or expression files are
204
given on the command-line, and does not exit when an integer and zero.
205
206
Overrides the default, which is %s.
207
208
DC_DIGIT_CLAMP
209
210
If an integer and non-zero, clamp digits larger than or equal to the
211
current ibase when parsing numbers.
212
213
Overrides the default, which is %s.
214
215