xref: /freebsd/contrib/bc/gen/bc_help.txt (revision 53b70c86)
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 bc help text.
33 *
34 */
35
36usage: %s [options] [file...]
37
38bc is a command-line, arbitrary-precision calculator with a Turing-complete
39language. For details, use `man %s` or see the online documentation at
40https://git.yzena.com/gavin/bc/src/tag/%s/manuals/bc/%s.1.md.
41
42This bc is compatible with both the GNU bc and the POSIX bc spec. See the GNU bc
43manual (https://www.gnu.org/software/bc/manual/bc.html) and bc spec
44(http://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
45for details.
46
47This bc has three differences to the GNU bc:
48
49  1) Arrays can be passed to the builtin "length" function to get the number of
50     elements currently in the array. The following example prints "1":
51
52       a[0] = 0
53       length(a[])
54
55  2) The precedence of the boolean "not" operator (!) is equal to that of the
56     unary minus (-), or negation, operator. This still allows POSIX-compliant
57     scripts to work while somewhat preserving expected behavior (versus C) and
58     making parsing easier.
59  3) This bc has many more extensions than the GNU bc does. For details, see the
60     man page or online documentation.
61
62This bc also implements the dot (.) extension of the BSD bc.
63
64Options:
65
66  -e  expr  --expression=expr
67
68      Run "expr" and quit. If multiple expressions or files (see below) are
69      given, they are all run before executing from stdin.
70
71  -f  file  --file=file
72
73      Run the bc code in "file" and exit. See above as well.
74
75  -g  --global-stacks
76
77      Turn scale, ibase, and obase into stacks. This makes the value of each be
78      be restored on returning from functions. See the man page or online
79      documentation for more details.
80
81  -h  --help
82
83      Print this usage message and exit.
84
85  -i  --interactive
86
87      Force interactive mode.
88
89  -l  --mathlib
90
91      Use predefined math routines:
92
93          s(expr)  =  sine of expr in radians
94          c(expr)  =  cosine of expr in radians
95          a(expr)  =  arctangent of expr, returning radians
96          l(expr)  =  natural log of expr
97          e(expr)  =  raises e to the power of expr
98          j(n, x)  =  Bessel function of integer order n of x
99
100      This bc may load more functions with these options. See the manpage or
101      online documentation for details.
102
103  -P  --no-prompt
104
105      Disable the prompts in interactive mode.
106
107  -R  --no-read-prompt
108
109      Disable the read prompt in interactive mode.
110
111  -r  keyword  --redefine=keyword
112
113      Redefines "keyword" and allows it to be used as a function, variable, and
114      array name. This is useful when this bc gives parse errors on scripts
115      meant for other bc implementations.
116
117      Only keywords that are not in the POSIX bc spec may be redefined.
118
119      It is a fatal error to attempt to redefine a keyword that cannot be
120      redefined or does not exist.
121
122  -q  --quiet
123
124      Don't print version and copyright.
125
126  -s  --standard
127
128      Error if any non-POSIX extensions are used.
129
130  -w  --warn
131
132      Warn if any non-POSIX extensions are used.
133
134  -v  --version
135
136      Print version information and copyright and exit.
137
138Environment variables:
139
140  POSIXLY_CORRECT
141
142      Error if any non-POSIX extensions are used.
143
144  BC_ENV_ARGS
145
146      Command-line arguments to use on every run.
147
148  BC_LINE_LENGTH
149
150      If an integer, the number of characters to print on a line before
151      wrapping.
152
153  BC_BANNER
154
155      If an integer and non-zero, display the copyright banner in interactive
156      mode.
157
158      Overrides the default, which is %s print the banner.
159
160  BC_SIGINT_RESET
161
162      If an integer and non-zero, reset on SIGINT, rather than exit, when in
163      interactive mode.
164
165      Overrides the default, which is %s.
166
167  BC_TTY_MODE
168
169      If an integer and non-zero, enable TTY mode when it is available.
170
171      Overrides the default, which is TTY mode %s.
172
173  BC_PROMPT
174
175      If an integer and non-zero, enable prompt when TTY mode is possible.
176
177      Overrides the default, which is prompt %s.
178