mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
Compare commits
482
Commits
stable/14
...
releng/13.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fe9c9de03 | ||
|
|
707cecae4e | ||
|
|
77cd23716f | ||
|
|
9f398ead89 | ||
|
|
70a2cf7bb2 | ||
|
|
dd349089ff | ||
|
|
056ffc74a7 | ||
|
|
5430423b6d | ||
|
|
277c0c4d25 | ||
|
|
c864c8cf08 | ||
|
|
d7fd130ebe | ||
|
|
9854ff0880 | ||
|
|
b00046e526 | ||
|
|
b2b2382427 | ||
|
|
e724f3ce79 | ||
|
|
b85c68857d | ||
|
|
4996f46e03 | ||
|
|
00ca345e83 | ||
|
|
5b789e0c92 | ||
|
|
312522780e | ||
|
|
42f2f9f09c | ||
|
|
3324a4bc8d | ||
|
|
b8ae329db9 | ||
|
|
210991b1f2 | ||
|
|
c3540b3a2b | ||
|
|
f5be20afc3 | ||
|
|
0abaf7f630 | ||
|
|
9dc74c5a4b | ||
|
|
0d1db5c325 | ||
|
|
6eb932a969 | ||
|
|
cbfb77f195 | ||
|
|
7ba07a1452 | ||
|
|
cf15ab553d | ||
|
|
3847c17aa2 | ||
|
|
e5733e6d90 | ||
|
|
f151464add | ||
|
|
b0c8bc5d9c | ||
|
|
3e0a1e1241 | ||
|
|
4378aee9f8 | ||
|
|
60cacd2e41 | ||
|
|
dfca965af4 | ||
|
|
f2caded7f5 | ||
|
|
3286a8dc83 | ||
|
|
3d81b7e211 | ||
|
|
68cda3edb6 | ||
|
|
2646dd6659 | ||
|
|
11754a6111 | ||
|
|
847819dca1 | ||
|
|
b76aaa3542 | ||
|
|
5cd45ad478 | ||
|
|
940681634e | ||
|
|
2261c814b7 | ||
|
|
060510ba8b | ||
|
|
c8a2cc4ba8 | ||
|
|
ec08bc89d4 | ||
|
|
4f590ee3ed | ||
|
|
3ef67fed44 | ||
|
|
f66e348099 | ||
|
|
b368bb75ba | ||
|
|
d1fffaed23 | ||
|
|
4647d115ff | ||
|
|
78f91c1fbf | ||
|
|
ba5ed8109c | ||
|
|
dac086497e | ||
|
|
b74cdf1ece | ||
|
|
8acc450613 | ||
|
|
8023e729a5 | ||
|
|
7d900abe62 | ||
|
|
312510880e | ||
|
|
61acb3179a | ||
|
|
6fe25201ea | ||
|
|
f32130a195 | ||
|
|
c690965773 | ||
|
|
22b58630d6 | ||
|
|
b62d492067 | ||
|
|
fc7402d50d | ||
|
|
a8a91efa74 | ||
|
|
ea31abc261 | ||
|
|
5003c6014c | ||
|
|
df7114e92e | ||
|
|
273977acb0 | ||
|
|
4710439ec5 | ||
|
|
724bc23da1 | ||
|
|
f8a134d0ef | ||
|
|
0e7f02a1a9 | ||
|
|
b7fbdb5042 | ||
|
|
40d278253d | ||
|
|
6605a2a163 | ||
|
|
7745d71597 | ||
|
|
42d99e4efa | ||
|
|
407e5a8d68 | ||
|
|
2e70fcbb15 | ||
|
|
411cbdb1f2 | ||
|
|
3765afa4da | ||
|
|
589d5d28a8 | ||
|
|
6f4f8a441a | ||
|
|
367fcd5bce | ||
|
|
d6616e3dba | ||
|
|
b56440b343 | ||
|
|
af6611e5ad | ||
|
|
fa6d101e5f | ||
|
|
c9b4e5e9ae | ||
|
|
72280d7e57 | ||
|
|
1f84105d7a | ||
|
|
7d3f5a19f4 | ||
|
|
2a878f01f2 | ||
|
|
4f5b454509 | ||
|
|
e011488bae | ||
|
|
f979a90f42 | ||
|
|
4ec92bce4e | ||
|
|
f7e3976ed0 | ||
|
|
a9c7d90862 | ||
|
|
064f09616c | ||
|
|
3ef46634cd | ||
|
|
8f731a397a | ||
|
|
c145b79546 | ||
|
|
11660fa28f | ||
|
|
faa41af1fe | ||
|
|
4c6c8f51fd | ||
|
|
cb370b1971 | ||
|
|
56dd03e0f2 | ||
|
|
1aa6884953 | ||
|
|
1a15924593 | ||
|
|
45910f6638 | ||
|
|
e6e8762dff | ||
|
|
9ac43bb747 | ||
|
|
13c22f7495 | ||
|
|
290e4d98ab | ||
|
|
3b9e12f66e | ||
|
|
003e38a01c | ||
|
|
d4803b958c | ||
|
|
3dbc2213da | ||
|
|
7a1f6858da | ||
|
|
2b1bcf70b4 | ||
|
|
1690984a83 | ||
|
|
11d8457138 | ||
|
|
e9bdfe2dd4 | ||
|
|
cb603e3ea2 | ||
|
|
2d227a6ec3 | ||
|
|
19fdc20297 | ||
|
|
dba80ca2cf | ||
|
|
3af5680fe2 | ||
|
|
6db19df195 | ||
|
|
f9c8aed244 | ||
|
|
995755b959 | ||
|
|
adc22165c0 | ||
|
|
c637a66be4 | ||
|
|
64b30c3671 | ||
|
|
fd7d1ec21a | ||
|
|
1ceb3c6c3b | ||
|
|
677a7288ad | ||
|
|
5235fb3137 | ||
|
|
04b20818b9 | ||
|
|
f279cbcbdf | ||
|
|
84e5f9455a | ||
|
|
c7ea14ed61 | ||
|
|
03572a87a8 | ||
|
|
02a8fe639a | ||
|
|
456d115263 | ||
|
|
a239b47cc9 | ||
|
|
bb60a68985 | ||
|
|
fb6ac317c0 | ||
|
|
eed4d02d7f | ||
|
|
d2faf2e6b2 | ||
|
|
e33a2b2905 | ||
|
|
2fa2d50ead | ||
|
|
8d25741b63 | ||
|
|
bafab32168 | ||
|
|
9705c012c1 | ||
|
|
85ec7f28cb | ||
|
|
acd98bcb28 | ||
|
|
60e8939aa8 | ||
|
|
fdd7609f10 | ||
|
|
9d39df7bd9 | ||
|
|
f122a87192 | ||
|
|
9bf608d00a | ||
|
|
ac94eec58a | ||
|
|
8ae87de4df | ||
|
|
bd7a41bed0 | ||
|
|
4a5108cdc9 | ||
|
|
cea301aee3 | ||
|
|
22c1852a04 | ||
|
|
9f1e0822cd | ||
|
|
3bde9c57df | ||
|
|
065b9549d3 | ||
|
|
b8ffda0a37 | ||
|
|
43a2f41379 | ||
|
|
5fdc5c5dba | ||
|
|
661e2b8e14 | ||
|
|
d2d99e6757 | ||
|
|
3664067ea9 | ||
|
|
2d379aed1e | ||
|
|
20f9e2a723 | ||
|
|
945184b92f | ||
|
|
6f930137ca | ||
|
|
2751e264df | ||
|
|
811deba9df | ||
|
|
91a611e521 | ||
|
|
229f1e4b14 | ||
|
|
59b8f72a21 | ||
|
|
856af5ff74 | ||
|
|
f3054d18bf | ||
|
|
90cf334642 | ||
|
|
c0708f6835 | ||
|
|
f495e9ed95 | ||
|
|
de3e66f4bb | ||
|
|
abe709deef | ||
|
|
3e95150e8c | ||
|
|
eb62c494bf | ||
|
|
963c8fa8b2 | ||
|
|
5eabef5a82 | ||
|
|
5a1ecfa5a9 | ||
|
|
84c6bae8db | ||
|
|
a7926435c1 | ||
|
|
113bd64cdf | ||
|
|
18b6283014 | ||
|
|
310ae6a0df | ||
|
|
9745047839 | ||
|
|
e32bc25362 | ||
|
|
97bfffafda | ||
|
|
52d4c9e2fa | ||
|
|
5dde6e460a | ||
|
|
f1847ed16e | ||
|
|
8f686c0f29 | ||
|
|
ce9bc83f91 | ||
|
|
f3a1daebaf | ||
|
|
6e3f19537a | ||
|
|
b287d46c38 | ||
|
|
16961e5e3f | ||
|
|
9bef28f294 | ||
|
|
298fde182f | ||
|
|
d1015ac544 | ||
|
|
eed0fd5903 | ||
|
|
eadca59970 | ||
|
|
28d0541398 | ||
|
|
f8272ff1d2 | ||
|
|
2e4940262c | ||
|
|
8ef69a7e8f | ||
|
|
f889959e0a | ||
|
|
bccb8dda0e | ||
|
|
9fc9a50119 | ||
|
|
b62d17802d | ||
|
|
0c3cdbf429 | ||
|
|
b3162f7d99 | ||
|
|
2b2c2c7128 | ||
|
|
56119250bb | ||
|
|
02c163e49b | ||
|
|
b4cc32336d | ||
|
|
984c11f5aa | ||
|
|
c200745702 | ||
|
|
9ab31d3d60 | ||
|
|
57582311c3 | ||
|
|
6a61e5e0a1 | ||
|
|
fc54784b47 | ||
|
|
8ecc621480 | ||
|
|
b95a453656 | ||
|
|
041d9a1e05 | ||
|
|
1eb60112b2 | ||
|
|
d6cb4c5669 | ||
|
|
3d66df7026 | ||
|
|
442719c0c6 | ||
|
|
ee0b7e05e7 | ||
|
|
e680f3c0bd | ||
|
|
5ad3a9988c | ||
|
|
8305d6906f | ||
|
|
6daafec208 | ||
|
|
ce132d4aab | ||
|
|
b3e8229935 | ||
|
|
035021b98a | ||
|
|
f82cffcf2f | ||
|
|
ce9af53d08 | ||
|
|
4b737a9c58 | ||
|
|
d7296b8939 | ||
|
|
ae093a0614 | ||
|
|
4e3fa977a1 | ||
|
|
dd250d3def | ||
|
|
f3f042d850 | ||
|
|
5d07525b81 | ||
|
|
5de955fe43 | ||
|
|
1d0d443daa | ||
|
|
07efb4cef7 | ||
|
|
26b11d047d | ||
|
|
a310973472 | ||
|
|
9f00cb5fa8 | ||
|
|
889cf2bf73 | ||
|
|
150b4388d3 | ||
|
|
eb7d18ff0a | ||
|
|
d560d01b02 | ||
|
|
03c31d3ca3 | ||
|
|
c3942b4284 | ||
|
|
f49177221a | ||
|
|
0abf8ecb11 | ||
|
|
0be7053c91 | ||
|
|
223debfb95 | ||
|
|
ba4d5b4d59 | ||
|
|
f7e7c4d406 | ||
|
|
28025add11 | ||
|
|
e57523de19 | ||
|
|
726e20f450 | ||
|
|
23f8fe51af | ||
|
|
00abeecb4a | ||
|
|
6666b1d45a | ||
|
|
f28545524c | ||
|
|
4689ab1eab | ||
|
|
f560a8b1a4 | ||
|
|
1e76911d62 | ||
|
|
2f4f3e2512 | ||
|
|
b3cfe07d74 | ||
|
|
15e64578cb | ||
|
|
72d3aeb1b2 | ||
|
|
f63b87ec3e | ||
|
|
678abec026 | ||
|
|
6461715f1a | ||
|
|
4a3d252cf3 | ||
|
|
46d3e8cd88 | ||
|
|
dc57f21252 | ||
|
|
f28ccd8d95 | ||
|
|
0b54d27647 | ||
|
|
bfb217a826 | ||
|
|
abfcf9a17d | ||
|
|
c48cbd0254 | ||
|
|
c41fef90a7 | ||
|
|
7100be11ec | ||
|
|
f69cd089cc | ||
|
|
1f0bc379eb | ||
|
|
07eed38ae2 | ||
|
|
45c95531c0 | ||
|
|
82874dcb36 | ||
|
|
8cb8d8d998 | ||
|
|
20204c4681 | ||
|
|
07e8f560fb | ||
|
|
741627c88b | ||
|
|
bb79ec97e5 | ||
|
|
9fb4377f41 | ||
|
|
b494fc41b7 | ||
|
|
25a4522f88 | ||
|
|
afdbccbf40 | ||
|
|
e45bb3902e | ||
|
|
b94f25eb62 | ||
|
|
638e531019 | ||
|
|
4c44dbde54 | ||
|
|
7726fc9940 | ||
|
|
3f3b216c0b | ||
|
|
211afd1e23 | ||
|
|
6bc5d49aba | ||
|
|
2a3cbb6c89 | ||
|
|
f5f50ec156 | ||
|
|
74216f4cae | ||
|
|
10977b9f84 | ||
|
|
88452cb151 | ||
|
|
8efe1ef1c7 | ||
|
|
87cefd5c3d | ||
|
|
0c839497c1 | ||
|
|
6d4bc364ab | ||
|
|
31026a4677 | ||
|
|
06eda1d83c | ||
|
|
1fb5b28604 | ||
|
|
1a2bc12c4b | ||
|
|
6d3ce617f3 | ||
|
|
2edd6140e9 | ||
|
|
55764c48f5 | ||
|
|
88a580ebee | ||
|
|
068f2402d2 | ||
|
|
397aaa3bcc | ||
|
|
9c829699aa | ||
|
|
15443b4d40 | ||
|
|
1cb79e809a | ||
|
|
4295dd589e | ||
|
|
b680dba476 | ||
|
|
620455079f | ||
|
|
683d086626 | ||
|
|
b6cbf02ad8 | ||
|
|
63a3f59066 | ||
|
|
ca9e7ac2fb | ||
|
|
37fed6c860 | ||
|
|
d0982de778 | ||
|
|
d37a305bc5 | ||
|
|
f31de79df2 | ||
|
|
1535f67017 | ||
|
|
8a680912a1 | ||
|
|
1996360d73 | ||
|
|
18697b446b | ||
|
|
51ab5e0d82 | ||
|
|
601ac82194 | ||
|
|
e3cd8246c7 | ||
|
|
13de72571e | ||
|
|
10625515ad | ||
|
|
c738bfc506 | ||
|
|
4e29933d09 | ||
|
|
a66467dcfd | ||
|
|
b79f2bc6c5 | ||
|
|
0d381d1b92 | ||
|
|
cd925aaa73 | ||
|
|
4d85bfa412 | ||
|
|
91a07ed50f | ||
|
|
ff119f7c4a | ||
|
|
3ac9e87b76 | ||
|
|
ec06521ee8 | ||
|
|
ffd05df717 | ||
|
|
f19a4e97d3 | ||
|
|
c415d0df47 | ||
|
|
14640ac789 | ||
|
|
3728c4d314 | ||
|
|
0702bf9c49 | ||
|
|
71b4605138 | ||
|
|
006ec2ed15 | ||
|
|
6a3047840d | ||
|
|
be03df57d6 | ||
|
|
3975d4c9e1 | ||
|
|
e5b674594e | ||
|
|
2bf72739da | ||
|
|
233225ef7d | ||
|
|
1077e49657 | ||
|
|
569ac57608 | ||
|
|
e13587448a | ||
|
|
dcba4f2b43 | ||
|
|
742285d283 | ||
|
|
82efef21d0 | ||
|
|
51927c36b8 | ||
|
|
1f28a3afe4 | ||
|
|
9375a93b6c | ||
|
|
247f652e62 | ||
|
|
8a44ccd058 | ||
|
|
872a0097fd | ||
|
|
7ba12ba0a2 | ||
|
|
e8d3e38845 | ||
|
|
fc301c224b | ||
|
|
e92ab3adf4 | ||
|
|
dde453cf7d | ||
|
|
aa411f6ba1 | ||
|
|
c700b1baba | ||
|
|
3eae6412b5 | ||
|
|
410994f463 | ||
|
|
996912046b | ||
|
|
ba0689009b | ||
|
|
c5fcd06736 | ||
|
|
080f149046 | ||
|
|
afea6cb020 | ||
|
|
dcee996423 | ||
|
|
6bc1f84255 | ||
|
|
22aca67268 | ||
|
|
b760436e13 | ||
|
|
b06fd805cc | ||
|
|
3f185aacc5 | ||
|
|
c060c19240 | ||
|
|
38da7d23b6 | ||
|
|
7ba4d0f829 | ||
|
|
e4c81e46ac | ||
|
|
a8ca736bb4 | ||
|
|
e0e00874a3 | ||
|
|
7754ef5a37 | ||
|
|
2ef3f7f5c3 | ||
|
|
514caf57cd | ||
|
|
bb8fa72dae | ||
|
|
1f9ee757d9 | ||
|
|
1aa1ede1fd | ||
|
|
81f3a59c46 | ||
|
|
a455b23cf3 | ||
|
|
ef6fb23322 | ||
|
|
19d2d50e43 | ||
|
|
010196adcf | ||
|
|
76dd854f47 | ||
|
|
e6341fd722 | ||
|
|
633f82126b | ||
|
|
2e81490464 | ||
|
|
ed05bfceb8 | ||
|
|
5d58f58b0d | ||
|
|
40cb0344eb | ||
|
|
03d837b565 | ||
|
|
f2b5999b21 | ||
|
|
da2dfec8f7 | ||
|
|
7b49246c89 | ||
|
|
8e0504d165 | ||
|
|
f76393a630 | ||
|
|
d1c39af0ec | ||
|
|
1c9891b8df | ||
|
|
035f4ea71e | ||
|
|
62bcf61ab1 | ||
|
|
51d73a3e46 | ||
|
|
d5bd29ed50 | ||
|
|
02611ef8ee | ||
|
|
bfd1570515 |
No files matched your search
+11
-5
@@ -1,11 +1,14 @@
|
||||
# $FreeBSD$
|
||||
|
||||
freebsd_instance:
|
||||
# image: freebsd-12-1-stable-amd64
|
||||
# We need a newer image to install llvm11
|
||||
image_family: freebsd-12-1-snap
|
||||
compute_engine_instance:
|
||||
# Image list available via
|
||||
# gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images
|
||||
platform: freebsd
|
||||
image_project: freebsd-org-cloud-dev
|
||||
image: freebsd-13-0-release-amd64
|
||||
cpu: 8
|
||||
memory: 24G
|
||||
disk: 40
|
||||
|
||||
env:
|
||||
CIRRUS_CLONE_DEPTH: 1
|
||||
@@ -14,7 +17,7 @@ task:
|
||||
only_if: $CIRRUS_BRANCH != 'svn_head'
|
||||
timeout_in: 120m
|
||||
install_script:
|
||||
- pkg install -y qemu42 uefi-edk2-qemu-x86_64 llvm11
|
||||
- pkg install -y qemu uefi-edk2-qemu-x86_64 llvm11
|
||||
setup_user_script:
|
||||
- pw useradd user
|
||||
- mkdir -p /usr/obj/$(pwd -P)
|
||||
@@ -25,3 +28,6 @@ task:
|
||||
- su user -c "make CROSS_TOOLCHAIN=llvm11 WITHOUT_TOOLCHAIN=yes PKG_FORMAT=tar packages"
|
||||
test_script:
|
||||
- sh tools/boot/ci-qemu-test.sh
|
||||
post_script:
|
||||
- df -m
|
||||
- du -m -s /usr/obj
|
||||
+3
-6
@@ -2299,7 +2299,8 @@ _bootstrap_tools_links+=crunchgen
|
||||
# Note: kbdcontrol can not be bootstrapped on non-FreeBSD systems
|
||||
.if !defined(CROSSBUILD_HOST)
|
||||
.if (${BOOTSTRAPPING} < 1003501 || \
|
||||
(${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103))
|
||||
(${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103) || \
|
||||
(!exists(/usr/sbin/kbdcontrol)))
|
||||
_kbdcontrol= usr.sbin/kbdcontrol
|
||||
.else
|
||||
_bootstrap_tools_links+=kbdcontrol
|
||||
@@ -2898,7 +2899,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
|
||||
lib/libzstd \
|
||||
${_lib_casper} \
|
||||
lib/ncurses/ncurses \
|
||||
lib/libopie lib/libpam/libpam ${_lib_libthr} \
|
||||
lib/libopie lib/libpam/libpam lib/libthr \
|
||||
${_lib_libradius} lib/libsbuf lib/libtacplus \
|
||||
lib/libgeom \
|
||||
${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
|
||||
@@ -2932,10 +2933,6 @@ _prebuild_libs+= lib/libc++
|
||||
lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
|
||||
lib/libkvm__L: lib/libelf__L
|
||||
|
||||
.if ${MK_LIBTHR} != "no"
|
||||
_lib_libthr= lib/libthr
|
||||
.endif
|
||||
|
||||
.if ${MK_RADIUS_SUPPORT} != "no"
|
||||
_lib_libradius= lib/libradius
|
||||
.endif
|
||||
|
||||
+22
-3
@@ -36,6 +36,17 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20210204: bump shared libraries which link against ncurses
|
||||
OLD_LIBS+=lib/libedit.so.7
|
||||
OLD_LIBS+=usr/lib/libdialog.so.8
|
||||
OLD_LIBS+=usr/lib/libdpv.so.1
|
||||
OLD_LIBS+=usr/lib/libform.so.5
|
||||
OLD_LIBS+=usr/lib/libformw.so.5
|
||||
OLD_LIBS+=usr/lib/libmenu.so.5
|
||||
OLD_LIBS+=usr/lib/libmenuw.so.5
|
||||
OLD_LIBS+=usr/lib/libpanel.so.5
|
||||
OLD_LIBS+=usr/lib/libpanelw.so.5
|
||||
|
||||
# 20210116: if_wl_wavelan.h removed
|
||||
.if ${TARGET_ARCH} == "i386"
|
||||
OLD_FILES+=usr/include/machine/if_wl_wavelan.h
|
||||
@@ -1201,11 +1212,19 @@ OLD_DIRS+=usr/lib/clang/10.0.0/lib/freebsd
|
||||
OLD_DIRS+=usr/lib/clang/10.0.0/lib
|
||||
OLD_DIRS+=usr/lib/clang/10.0.0
|
||||
|
||||
# 20200520: xform_userland.h removed
|
||||
OLD_FILES+=usr/include/crypto/xform_userland.h
|
||||
|
||||
# 20200515: libalias cuseeme protocol support retired
|
||||
OLD_LIBS+=lib/libalias_cuseeme.so
|
||||
OLD_FILES+=usr/lib/libalias_cuseeme.a
|
||||
OLD_FILES+=usr/lib/libalias_cuseeme_p.a
|
||||
|
||||
# 20200511: Remove deprecated crypto algorithms
|
||||
OLD_FILES+=usr/include/crypto/cast.h
|
||||
OLD_FILES+=usr/include/crypto/castsb.h
|
||||
OLD_FILES+=usr/include/crypto/skipjack.h
|
||||
|
||||
# 20200511: Remove ubsec(4)
|
||||
OLD_FILES+=usr/share/man/man4/ubsec.4.gz
|
||||
|
||||
@@ -1241,6 +1260,7 @@ OLD_FILES+=usr/share/man/man1/gdbserver.1.gz
|
||||
OLD_FILES+=usr/share/man/man1/kgdb.1.gz
|
||||
|
||||
# 20200327: OCF refactoring
|
||||
OLD_FILES+=usr/include/crypto/cryptosoft.h
|
||||
OLD_FILES+=usr/share/man/man9/crypto_find_driver.9.gz
|
||||
OLD_FILES+=usr/share/man/man9/crypto_register.9.gz
|
||||
OLD_FILES+=usr/share/man/man9/crypto_unregister.9.gz
|
||||
@@ -2590,8 +2610,9 @@ OLD_FILES+=usr/bin/mklocale
|
||||
OLD_FILES+=usr/share/man/man1/mklocale.1.gz
|
||||
OLD_FILES+=usr/bin/colldef
|
||||
OLD_FILES+=usr/share/man/man1/colldef.1.gz
|
||||
# 20190904: Remove boot1.efifat
|
||||
# 20190904: Remove boot1.efifat and gptboot.efifat (which never should have been)
|
||||
OLD_FILES+=boot/boot1.efifat
|
||||
OLD_FILES+=boot/gptboot.efifat
|
||||
# 20190903: pc-sysinstall(8) removed
|
||||
OLD_FILES+=usr/share/examples/pc-sysinstall/README
|
||||
OLD_FILES+=usr/share/examples/pc-sysinstall/pc-autoinstall.conf
|
||||
@@ -8558,8 +8579,6 @@ OLD_FILES+=etc/rc.firewall6
|
||||
OLD_FILES+=usr/share/examples/etc/rc.firewall6
|
||||
# 20091117: removal of rc.early(8) link
|
||||
OLD_FILES+=usr/share/man/man8/rc.early.8.gz
|
||||
# 20091117: usr/share/zoneinfo/GMT link removed
|
||||
OLD_FILES+=usr/share/zoneinfo/GMT
|
||||
# 20091027: pselect.3 implemented as syscall
|
||||
OLD_FILES+=usr/share/man/man3/pselect.3.gz
|
||||
# 20091005: fusword.9 and susword.9 removed
|
||||
|
||||
@@ -10,6 +10,10 @@ newline. Entries should be separated by a newline.
|
||||
|
||||
Changes to this file should not be MFCed.
|
||||
|
||||
f76393a6305b6:
|
||||
Add AES-GCM support to armv8crypto(4) providing accelerated
|
||||
support for KTLS, IPsec, and other crypto API consumers.
|
||||
|
||||
074a91f746bd:
|
||||
The aesni(4) and armv8crypto(4) devices are now included in
|
||||
GENERIC on amd64, i386, and arm64.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Updating Information for FreeBSD current users.
|
||||
Updating Information for FreeBSD stable/13 users.
|
||||
|
||||
This file is maintained and copyrighted by M. Warner Losh <[email protected]>.
|
||||
See end of file for further details. For commonly done items, please see the
|
||||
@@ -11,20 +11,219 @@ handbook:
|
||||
Items affecting the ports and packages system can be found in
|
||||
/usr/ports/UPDATING. Please read that file before running portupgrade.
|
||||
|
||||
NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
|
||||
FreeBSD 13.x has many debugging features turned on, in both the kernel
|
||||
and userland. These features attempt to detect incorrect use of
|
||||
system primitives, and encourage loud failure through extra sanity
|
||||
checking and fail stop semantics. They also substantially impact
|
||||
system performance. If you want to do performance measurement,
|
||||
benchmarking, and optimization, you'll want to turn them off. This
|
||||
includes various WITNESS- related kernel options, INVARIANTS, malloc
|
||||
debugging flags in userland, and various verbose features in the
|
||||
kernel. Many developers choose to disable these features on build
|
||||
machines to maximize performance. (To completely disable malloc
|
||||
debugging, define WITH_MALLOC_PRODUCTION in /etc/src.conf and rebuild
|
||||
world, or to merely disable the most expensive debugging functionality
|
||||
at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
20220830:
|
||||
13.0-RELEASE-p13 FreeBSD-SA-22:13.zlib
|
||||
FreeBSD-EN-22:20.tzdata
|
||||
|
||||
zlib heap buffer overflow [SA-22:13.zlib]
|
||||
|
||||
Timezone database information update [EN-22:20.tzdata]
|
||||
|
||||
20220726:
|
||||
13.0-RELEASE-p12 FreeBSD-SA-22:09.elf
|
||||
FreeBSD-SA-22:10.aio
|
||||
FreeBSD-SA-22:11.vm
|
||||
FreeBSD-SA-22:12.lib9p
|
||||
FreeBSD-EN-22:17.cam
|
||||
FreeBSD-EN-22:19.pam_exec
|
||||
|
||||
Out of bounds read in elf_note_prpsinfo() [SA-22:09.elf]
|
||||
|
||||
AIO credential reference count leak [SA-22:10.aio]
|
||||
|
||||
Memory disclosure by stale virtual memory mapping [SA-22:11.vm]
|
||||
|
||||
Missing bounds check in 9p message handling [SA-22:12.lib9p]
|
||||
|
||||
Kernel memory corruption during SCSI error recovery [EN-22:17.cam]
|
||||
|
||||
NULL pointer dereference in pam_exec(8) [EN-22:19.pam_exec]
|
||||
|
||||
20220405:
|
||||
13.0-RELEASE-p11 FreeBSD-EN-22:15.pf
|
||||
FreeBSD-SA-22:04.netmap
|
||||
FreeBSD-SA-22:05.bhyve
|
||||
FreeBSD-SA-22:06.ioctl
|
||||
FreeBSD-SA-22:07.wifi_meshid
|
||||
FreeBSD-SA-22:08.zlib
|
||||
|
||||
pf(4) tables may fail to load [EN-22:15.pf]
|
||||
|
||||
Potential jail escape vulnerabilities in netmap [SA-22:04.netmap]
|
||||
|
||||
Bhyve e82545 device emulation out-of-bounds write [SA-22:05.bhyve]
|
||||
|
||||
mpr/mps/mpt driver ioctl heap out-of-bounds write [SA-22:06.ioctl]
|
||||
|
||||
802.11 heap buffer overflow [SA-22:07.wifi_meshid]
|
||||
|
||||
zlib compression out-of-bounds write [SA-22:08.zlib]
|
||||
|
||||
20220322:
|
||||
13.0-RELEASE-p10 FreeBSD-EN-22:14.tzdata
|
||||
|
||||
Timezone database information update. [EN-22:14.tzdata]
|
||||
|
||||
20220321:
|
||||
13.0-RELEASE-p9 FreeBSD-EN-22:13.zfs
|
||||
|
||||
Fix ZFS data loss [FreeBSD-EN-22:13.zfs]
|
||||
|
||||
20220315:
|
||||
13.0-RELEASE-p8 FreeBSD-EN-22:10.zfs
|
||||
FreeBSD-EN-22:11.zfs
|
||||
FreeBSD-EN-22:12.zfs
|
||||
FreeBSD-SA-22:02.wifi
|
||||
FreeBSD-SA-22:03.openssl
|
||||
|
||||
ZFS writes fail to update file size [FreeBSD-EN-22:10.zfs]
|
||||
|
||||
ZFS lseek(2) inconsistencies [FreeBSD-EN-22:11.zfs]
|
||||
|
||||
ZFS panic upon concurrent 'zfs list' calls [FreeBSD-EN-22:12.zfs]
|
||||
|
||||
Multiple WiFi issues [FreeBSD-SA-22:02.wifi]
|
||||
|
||||
OpenSSL certificate parsing infinite loop [FreeBSD-SA-22:03.openssl]
|
||||
|
||||
20220201:
|
||||
13.0-RELEASE-p7 FreeBSD-EN-22:07.la57
|
||||
|
||||
Fix Intel CPU LA57 boot failure [EN-22:07.la57]
|
||||
|
||||
20220111:
|
||||
13.0-RELEASE-p6 FreeBSD-EN-22:01.fsck_ffs
|
||||
FreeBSD-EN-22:02.xsave
|
||||
FreeBSD-EN-22:03.hyperv
|
||||
FreeBSD-EN-22:05.tail
|
||||
FreeBSD-EN-22:06.libalias
|
||||
FreeBSD-SA-22:01.vt
|
||||
|
||||
Fix fsck_ffs bad inode number errors [EN-22:01.fsck_ffs]
|
||||
|
||||
Correct size of the amd64 SSE area in the xsave layout [FreeBSD-EN-22:02.xsave]
|
||||
|
||||
Prepopulate Hyper-V PCI device bars [FreeBSD-EN-22:03.hyperv]
|
||||
|
||||
Fix "tail -F" file rotation detection [FreeBSD-EN-22:05.tail]
|
||||
|
||||
Fix fragmented UDP packets handling [FreeBSD-EN-22:06.libalias]
|
||||
|
||||
Fix vt console buffer overflow [FreeBSD-SA-22:01.vt]
|
||||
|
||||
20211103:
|
||||
13.0-RELEASE-p5 FreeBSD-EN-21:26.libevent
|
||||
FreeBSD-EN-21:27.caroot
|
||||
FreeBSD-EN-21:28.vmci
|
||||
FreeBSD-EN-21:29.tzdata
|
||||
|
||||
Fix libevent1 ABI breakage. [EN-21:26.libevent]
|
||||
|
||||
Root certificate bundle update. [EN-21:27.caroot]
|
||||
|
||||
Fix kernel panic in vmci driver initialization. [EN-21:28.vmci]
|
||||
|
||||
Timezone database information update. [EN-21:29.tzdata]
|
||||
|
||||
20210824:
|
||||
13.0-RELEASE-p4 FreeBSD-EN-21:23.virtio_blk
|
||||
FreeBSD-EN-21:24.libcrypto
|
||||
FreeBSD-EN-21:25.bhyve
|
||||
FreeBSD-SA-21:13.bhyve
|
||||
FreeBSD-SA-21:14.ggatec
|
||||
FreeBSD-SA-21:15.libfetch
|
||||
FreeBSD-SA-21:16.openssl
|
||||
|
||||
Fix virtio_blk(4) failing to attach on some hypervisors. [EN-21:23.virtio_blk]
|
||||
|
||||
Fix OpenSSL 1.1.1e API functions not being exported. [EN-21:24.libcrypto]
|
||||
|
||||
Fix NVMe iovec construction for large IOs. [EN-21:25.bhyve]
|
||||
|
||||
Fix missing error handling in bhyve(8) device models. [SA-21:13.bhyve]
|
||||
|
||||
Fix remote code execution in ggatec(8). [SA-21:14.ggatec]
|
||||
|
||||
Fix libfetch out of bounds read. [SA-21:15.libfetch]
|
||||
|
||||
Fix multiple OpenSSL vulnerabilities. [SA-21:16.openssl]
|
||||
|
||||
20210629:
|
||||
13.0-RELEASE-p3 FreeBSD-EN-21:18.libc++
|
||||
FreeBSD-EN-21:19.libcasper
|
||||
FreeBSD-EN-21:20.vlan
|
||||
FreeBSD-EN-21:21.ipfw
|
||||
FreeBSD-EN-21:22.linux_futex
|
||||
|
||||
Missing C++20 headers in libc++ [EN-21:18.libc++]
|
||||
|
||||
libcasper assertion failure [EN-21:19.libcasper]
|
||||
|
||||
Missing backwards compatibility in vlan(4) [EN-21:20.vlan]
|
||||
|
||||
Kernel panic with ipfw link-layer filtering enabled [EN-21:21.ipfw]
|
||||
|
||||
Linux compatibility layer futex(2) system call vulnerability [EN-21:22.linux_futex]
|
||||
|
||||
20210601:
|
||||
13.0-RELEASE-p2 FreeBSD-EN-21:17.libradius
|
||||
|
||||
Incorrect validation in rad_get_attr(3) [FreeBSD-EN-21:17.libradius]
|
||||
|
||||
20210526:
|
||||
13.0-RELEASE-p1 FreeBSD-EN-21:12.divert
|
||||
FreeBSD-EN-21:13.mpt
|
||||
FreeBSD-EN-21:14.pms
|
||||
FreeBSD-EN-21:15.virtio
|
||||
FreeBSD-EN-21:16.bc
|
||||
FreeBSD-SA-21:11.smap
|
||||
FreeBSD-SA-21:12.libradius
|
||||
|
||||
Kernel double free when transmitting on a divert socket [FreeBSD-EN-21:12.divert]
|
||||
|
||||
mpt(4) I/O errors with a large maxphys value [FreeBSD-EN-21:13.mpt]
|
||||
|
||||
pms(4) data corruption [FreeBSD-EN-21:14.pms]
|
||||
|
||||
virtio(4) device probing fails [FreeBSD-EN-21:15.virtio]
|
||||
|
||||
dc update [FreeBSD-EN-21:16.bc]
|
||||
|
||||
SMAP bypass [FreeBSD-SA-21:11.smap]
|
||||
|
||||
Missing message validation in libradius(3) [FreeBSD-SA-21:12.libradius]
|
||||
|
||||
20210413:
|
||||
13.0-RELEASE.
|
||||
|
||||
20210406:
|
||||
13.0-RC5-p1 FreeBSD-SA-21:08.vm
|
||||
FreeBSD-SA-21:10.jail_mount
|
||||
|
||||
Memory disclosure by stale virtual memory mapping [SA-21:08.vm]
|
||||
|
||||
Jail escape possible by mounting over jail root [SA-21:10.jail_mount]
|
||||
|
||||
20210325:
|
||||
13.0-RC3-p1 FreeBSD-SA-21:07.openssl
|
||||
|
||||
Fix multiple OpenSSL issues [SA-21:07.openssl]
|
||||
|
||||
20210223:
|
||||
13.0-BETA3-p1 FreeBSD-SA-21:03.pam_login_access
|
||||
FreeBSD-SA-21:06.xen
|
||||
|
||||
login.access fails to apply rules [SA-21:03.pam_login_access]
|
||||
|
||||
Xen grant mapping error handling issues [SA-21:06.xen]
|
||||
|
||||
20210202:
|
||||
Various LinuxKPI functionality was added which conflicts with DRM.
|
||||
Please update your drm-kmod port to after the __FreeBSD_verison 1300139
|
||||
update.
|
||||
|
||||
20210122:
|
||||
The stable/13 branch has been created from main.
|
||||
|
||||
20210108:
|
||||
PC Card attachments for all devices have been removed. In the case of
|
||||
|
||||
@@ -717,7 +717,7 @@ extern dt_pcb_t *yypcb; /* pointer to current parser control block */
|
||||
extern char yyintprefix; /* int token prefix for macros (+/-) */
|
||||
extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */
|
||||
extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */
|
||||
extern char yytext[]; /* lex input buffer */
|
||||
extern char *yytext; /* lex input buffer */
|
||||
extern int yylineno; /* lex line number */
|
||||
extern int yydebug; /* lex debugging */
|
||||
extern dt_node_t *yypragma; /* lex token list for control lines */
|
||||
|
||||
@@ -28,11 +28,9 @@ _libicp_rescue= libicp_rescue
|
||||
_libzfs= libzfs
|
||||
_libzutil= libzutil
|
||||
_libzfsbootenv= libzfsbootenv
|
||||
.if ${MK_LIBTHR} != "no"
|
||||
_libzpool= libzpool
|
||||
_libtpool= libtpool
|
||||
.endif
|
||||
.endif
|
||||
|
||||
SUBDIR_DEPEND_libctf= libspl
|
||||
SUBDIR_DEPEND_libdtrace= libctf
|
||||
|
||||
@@ -129,8 +129,6 @@ SRCS+= dis_tables.c
|
||||
DSRCS+= regs_x86.d
|
||||
.endif
|
||||
|
||||
LFLAGS+=-l
|
||||
|
||||
YFLAGS+=-d
|
||||
|
||||
LIBADD= ctf elf proc pthread rtld_db
|
||||
|
||||
@@ -161,6 +161,7 @@ KERNEL_C = \
|
||||
zfs_debug.c \
|
||||
zfs_fm.c \
|
||||
zfs_fuid.c \
|
||||
zfs_racct.c \
|
||||
zfs_sa.c \
|
||||
zfs_znode.c \
|
||||
zfs_ratelimit.c \
|
||||
|
||||
@@ -15,12 +15,10 @@ SUBDIR.${MK_TESTS}+= tests
|
||||
|
||||
.if ${MK_ZFS} != "no"
|
||||
_zinject= zinject
|
||||
.if ${MK_LIBTHR} != "no"
|
||||
_ztest= ztest
|
||||
_zstream = zstream
|
||||
_zstreamdump = zstreamdump
|
||||
.endif
|
||||
.endif
|
||||
|
||||
SUBDIR_PARALLEL=
|
||||
|
||||
|
||||
@@ -13,10 +13,8 @@ SUBDIR= ${_dtrace} \
|
||||
SUBDIR.${MK_TESTS}+= tests
|
||||
|
||||
.if ${MK_ZFS} != "no"
|
||||
.if ${MK_LIBTHR} != "no"
|
||||
_zdb= zdb
|
||||
_zhack= zhack
|
||||
.endif
|
||||
. if ${MK_CXX} != "no"
|
||||
_zfsd= zfsd
|
||||
. endif
|
||||
|
||||
@@ -34,6 +34,13 @@ config.mak
|
||||
timeconst.bc
|
||||
Makefile
|
||||
|
||||
tests/fuzzing/bc_outputs1/*
|
||||
tests/fuzzing/bc_outputs2/*
|
||||
tests/fuzzing/bc_outputs3/*
|
||||
tests/fuzzing/dc_outputs/*
|
||||
tests/bc_outputs/*
|
||||
tests/dc_outputs/*
|
||||
|
||||
.gdb_history
|
||||
|
||||
# Ignore the generated test files
|
||||
@@ -57,5 +64,7 @@ perf.data.old
|
||||
*.html
|
||||
*.profraw
|
||||
|
||||
core.*
|
||||
|
||||
cscope*.out
|
||||
tags
|
||||
+50
-2
@@ -1,6 +1,6 @@
|
||||
# License
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard <yzena.tech@gmail.com>
|
||||
Copyright (c) 2018-2021 Gavin D. Howard <yzena.tech@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
@@ -31,7 +31,7 @@ copyrights and license:
|
||||
Copyright (c) 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com><br>
|
||||
Copyright (c) 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com><br>
|
||||
Copyright (c) 2018 rain-1 <rain1@openmailbox.org><br>
|
||||
Copyright (c) 2018-2020, Gavin D. Howard <yzena.tech@gmail.com>
|
||||
Copyright (c) 2018-2021, Gavin D. Howard <yzena.tech@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
@@ -53,3 +53,51 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
## Rand
|
||||
|
||||
The files `src/rand.c` and `include/rand.h` are under the following copyrights
|
||||
and license:
|
||||
|
||||
Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
|
||||
Copyright (c) 2018-2021 Gavin D. Howard <yzena.tech@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## `safe-install.sh`
|
||||
|
||||
The file `safe-install.sh` is under the following copyright and license:
|
||||
|
||||
Copyright (c) 2021 Rich Felker
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the “Software”), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+89
-33
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
@@ -29,7 +29,7 @@
|
||||
#
|
||||
.POSIX:
|
||||
|
||||
VERSION = 3.2.4
|
||||
VERSION = 3.3.3
|
||||
|
||||
SRC = %%SRC%%
|
||||
OBJ = %%OBJ%%
|
||||
@@ -41,6 +41,13 @@ BC_ENABLED = %%BC_ENABLED%%
|
||||
DC_ENABLED_NAME = DC_ENABLED
|
||||
DC_ENABLED = %%DC_ENABLED%%
|
||||
|
||||
HEADERS = include/args.h include/file.h include/lang.h include/lex.h include/num.h include/opt.h include/parse.h include/program.h include/read.h include/status.h include/vector.h include/vm.h
|
||||
BC_HEADERS = include/bc.h
|
||||
DC_HEADERS = include/dc.h
|
||||
HISTORY_HEADERS = include/history.h
|
||||
EXTRA_MATH_HEADERS = include/rand.h
|
||||
LIBRARY_HEADERS = include/bcl.h include/library.h
|
||||
|
||||
GEN_DIR = gen
|
||||
GEN = %%GEN%%
|
||||
GEN_EXEC = $(GEN_DIR)/$(GEN)
|
||||
@@ -82,6 +89,11 @@ DC = dc
|
||||
BC_EXEC = $(BIN)/$(EXEC_PREFIX)$(BC)
|
||||
DC_EXEC = $(BIN)/$(EXEC_PREFIX)$(DC)
|
||||
|
||||
BC_TEST_OUTPUTS = tests/bc_outputs
|
||||
BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
|
||||
DC_TEST_OUTPUTS = tests/dc_outputs
|
||||
DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs
|
||||
|
||||
LIB = libbcl
|
||||
LIB_NAME = $(LIB).a
|
||||
LIBBC = $(BIN)/$(LIB_NAME)
|
||||
@@ -125,6 +137,9 @@ BC_ENABLE_NLS = %%NLS%%
|
||||
BC_ENABLE_PROMPT = %%PROMPT%%
|
||||
BC_LONG_BIT = %%LONG_BIT%%
|
||||
|
||||
BC_ENABLE_AFL = %%FUZZ%%
|
||||
BC_ENABLE_MEMCHECK = %%MEMCHECK%%
|
||||
|
||||
RM = rm
|
||||
MKDIR = mkdir
|
||||
|
||||
@@ -138,6 +153,8 @@ LOCALE_UNINSTALL = ./locale_uninstall.sh
|
||||
|
||||
VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
|
||||
|
||||
TEST_STARS = "***********************************************************************"
|
||||
|
||||
BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
|
||||
|
||||
CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED)
|
||||
@@ -147,7 +164,8 @@ CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
|
||||
CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN)
|
||||
CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT)
|
||||
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
|
||||
CPPFLAGS = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
|
||||
CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
|
||||
CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL)
|
||||
CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%%
|
||||
LDFLAGS = %%LDFLAGS%%
|
||||
|
||||
@@ -159,20 +177,15 @@ HOSTCC = %%HOSTCC%%
|
||||
BC_LIB_C_ARGS = bc_lib bc_lib_name $(BC_ENABLED_NAME) 1
|
||||
BC_LIB2_C_ARGS = bc_lib2 bc_lib2_name "$(BC_ENABLED_NAME) && $(BC_ENABLE_EXTRA_MATH_NAME)" 1
|
||||
|
||||
OBJS = $(BC_HELP_O) $(DC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
|
||||
OBJ_TARGETS = $(DC_HELP_O) $(BC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
|
||||
OBJS = $(DC_HELP_O) $(BC_HELP_O) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
all: %%DEFAULT_TARGET%%
|
||||
|
||||
all: %%ALL_PREREQ%%
|
||||
%%DEFAULT_TARGET%%: %%DEFAULT_TARGET_PREREQS%%
|
||||
%%DEFAULT_TARGET_CMD%%
|
||||
|
||||
execs: make_bin $(OBJ_TARGETS)
|
||||
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(EXEC)
|
||||
%%LINK%%
|
||||
|
||||
library: make_bin $(OBJ) $(BC_LIB_O) $(BC_LIB2_O)
|
||||
ar -r -cu $(LIBBC) $(BC_LIB_O) $(BC_LIB2_O) $(OBJ)
|
||||
%%SECOND_TARGET%%: %%SECOND_TARGET_PREREQS%%
|
||||
%%SECOND_TARGET_CMD%%
|
||||
|
||||
$(GEN_EXEC):
|
||||
%%GEN_EXEC_TARGET%%
|
||||
@@ -180,18 +193,32 @@ $(GEN_EXEC):
|
||||
$(BC_LIB_C): $(GEN_EXEC) $(BC_LIB)
|
||||
$(GEN_EMU) $(GEN_EXEC) $(BC_LIB) $(BC_LIB_C) $(BC_LIB_C_ARGS)
|
||||
|
||||
$(BC_LIB_O): $(BC_LIB_C)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
$(BC_LIB2_C): $(GEN_EXEC) $(BC_LIB2)
|
||||
$(GEN_EMU) $(GEN_EXEC) $(BC_LIB2) $(BC_LIB2_C) $(BC_LIB2_C_ARGS)
|
||||
|
||||
$(BC_LIB2_O): $(BC_LIB2_C)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
$(BC_HELP_C): $(GEN_EXEC) $(BC_HELP)
|
||||
$(GEN_EMU) $(GEN_EXEC) $(BC_HELP) $(BC_HELP_C) bc_help "" $(BC_ENABLED_NAME)
|
||||
|
||||
$(BC_HELP_O): $(BC_HELP_C)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
$(DC_HELP_C): $(GEN_EXEC) $(DC_HELP)
|
||||
$(GEN_EMU) $(GEN_EXEC) $(DC_HELP) $(DC_HELP_C) dc_help "" $(DC_ENABLED_NAME)
|
||||
|
||||
make_bin:
|
||||
$(DC_HELP_O): $(DC_HELP_C)
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
$(BIN):
|
||||
$(MKDIR) -p $(BIN)
|
||||
|
||||
headers: %%HEADERS%%
|
||||
|
||||
help:
|
||||
@printf 'available targets:\n'
|
||||
@printf '\n'
|
||||
@@ -222,41 +249,68 @@ help:
|
||||
@printf ' valgrind_dc runs the dc test suite, if dc has been built,\n'
|
||||
@printf ' through valgrind\n'
|
||||
|
||||
run_all_tests:
|
||||
%%BC_ALL_TESTS%%
|
||||
%%TIMECONST_ALL_TESTS%%
|
||||
%%DC_ALL_TESTS%%
|
||||
|
||||
check: test
|
||||
|
||||
test: %%TESTS%%
|
||||
|
||||
test_bc:
|
||||
%%BC_TEST%%
|
||||
test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_stdin test_bc_read test_bc_errors test_bc_other
|
||||
@printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'
|
||||
|
||||
test_dc:
|
||||
%%DC_TEST%%
|
||||
test_bc_tests:%%BC_TESTS%%
|
||||
|
||||
time_test: time_test_bc timeconst time_test_dc
|
||||
test_bc_scripts:%%BC_SCRIPT_TESTS%%
|
||||
|
||||
time_test_bc:
|
||||
%%BC_TIME_TEST%%
|
||||
test_bc_stdin:
|
||||
@sh tests/stdin.sh bc %%BC_TEST_EXEC%%
|
||||
|
||||
time_test_dc:
|
||||
%%DC_TIME_TEST%%
|
||||
test_bc_read:
|
||||
@sh tests/read.sh bc %%BC_TEST_EXEC%%
|
||||
|
||||
test_bc_errors:
|
||||
@sh tests/errors.sh bc %%BC_TEST_EXEC%%
|
||||
|
||||
test_bc_other:
|
||||
@sh tests/other.sh bc %%BC_TEST_EXEC%%
|
||||
|
||||
test_bc_header:
|
||||
@printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'
|
||||
|
||||
test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_stdin test_dc_read test_dc_errors test_dc_other
|
||||
@printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'
|
||||
|
||||
test_dc_tests:%%DC_TESTS%%
|
||||
|
||||
test_dc_scripts:%%DC_SCRIPT_TESTS%%
|
||||
|
||||
test_dc_stdin:
|
||||
@sh tests/stdin.sh dc %%DC_TEST_EXEC%%
|
||||
|
||||
test_dc_read:
|
||||
@sh tests/read.sh dc %%DC_TEST_EXEC%%
|
||||
|
||||
test_dc_errors:
|
||||
@sh tests/errors.sh dc %%DC_TEST_EXEC%%
|
||||
|
||||
test_dc_other:
|
||||
@sh tests/other.sh dc %%DC_TEST_EXEC%%
|
||||
|
||||
test_dc_header:
|
||||
@printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'
|
||||
|
||||
timeconst:
|
||||
%%TIMECONST%%
|
||||
|
||||
library_test: library
|
||||
library_test: $(LIBBC)
|
||||
$(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
|
||||
|
||||
test_library: library_test
|
||||
$(BCL_TEST)
|
||||
|
||||
valgrind: valgrind_bc valgrind_dc
|
||||
|
||||
valgrind_bc:
|
||||
%%VG_BC_TEST%%
|
||||
|
||||
valgrind_dc:
|
||||
%%VG_DC_TEST%%
|
||||
|
||||
karatsuba:
|
||||
%%KARATSUBA%%
|
||||
|
||||
@@ -296,6 +350,8 @@ clean:%%CLEAN_PREREQS%%
|
||||
@$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O)
|
||||
@$(RM) -f $(BC_HELP_C) $(BC_HELP_O)
|
||||
@$(RM) -f $(DC_HELP_C) $(DC_HELP_O)
|
||||
@$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
|
||||
@$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
|
||||
|
||||
clean_config: clean
|
||||
@printf 'Cleaning config...\n'
|
||||
|
||||
@@ -1,5 +1,86 @@
|
||||
# News
|
||||
|
||||
## 3.3.3
|
||||
|
||||
This is a production release with one tweak and fixes for manuals.
|
||||
|
||||
The tweak is that `length(0)` returns `1` instead of `0`. In `3.3.1`, I changed
|
||||
it so `length(0.x)`, where `x` could be any number of digits, returned the
|
||||
`scale`, but `length(0)` still returned `0` because I believe that `0` has `0`
|
||||
significant digits.
|
||||
|
||||
After request of FreeBSD and considering the arguments of a mathematician,
|
||||
compatibility with other `bc`'s, and the expectations of users, I decided to
|
||||
make the change.
|
||||
|
||||
The fixes for manuals fixed a bug where `--` was rendered as `-`.
|
||||
|
||||
## 3.3.2
|
||||
|
||||
This is a production release that fixes a divide-by-zero bug in `root()` in the
|
||||
[extended math library][16]. All previous versions with `root()` have the bug.
|
||||
|
||||
## 3.3.1
|
||||
|
||||
This is a production release that fixes a bug.
|
||||
|
||||
The bug was in the reporting of number length when the value was 0.
|
||||
|
||||
## 3.3.0
|
||||
|
||||
This is a production release that changes one behavior and fixes documentation
|
||||
bugs.
|
||||
|
||||
The changed behavior is the treatment of `-e` and `-f` when given through
|
||||
`BC_ENV_ARGS` or `DC_ENV_ARGS`. Now `bc` and `dc` do not exit when those options
|
||||
(or their equivalents) are given through those environment variables. However,
|
||||
`bc` and `dc` still exit when they or their equivalents are given on the
|
||||
command-line.
|
||||
|
||||
## 3.2.7
|
||||
|
||||
This is a production release that removes a small non-portable shell operation
|
||||
in `configure.sh`. This problem was only noticed on OpenBSD, not FreeBSD or
|
||||
Linux.
|
||||
|
||||
Non-OpenBSD users do ***NOT*** need to upgrade, although NetBSD users may also
|
||||
need to upgrade.
|
||||
|
||||
## 3.2.6
|
||||
|
||||
This is a production release that fixes the build on FreeBSD.
|
||||
|
||||
There was a syntax error in `configure.sh` that the Linux shell did not catch,
|
||||
and FreeBSD depends on the existence of `tests/all.sh`.
|
||||
|
||||
All users that already upgraded to `3.2.5` should update to this release, with
|
||||
my apologies for the poor release of `3.2.5`. Other users should skip `3.2.5` in
|
||||
favor of this version.
|
||||
|
||||
## 3.2.5
|
||||
|
||||
This is a production release that fixes several bugs and adds a couple small
|
||||
things.
|
||||
|
||||
The two most important bugs were bugs that causes `dc` to access memory
|
||||
out-of-bounds (crash in debug builds). This was found by upgrading to `afl++`
|
||||
from `afl`. Both were caused by a failure to distinguish between the same two
|
||||
cases.
|
||||
|
||||
Another bug was the failure to put all of the licenses in the `LICENSE.md` file.
|
||||
|
||||
Third, some warnings by `scan-build` were found and eliminated. This needed one
|
||||
big change: `bc` and `dc` now bail out as fast as possible on fatal errors
|
||||
instead of unwinding the stack.
|
||||
|
||||
Fourth, the pseudo-random number now attempts to seed itself with `/dev/random`
|
||||
if `/dev/urandom` fails.
|
||||
|
||||
Finally, this release has a few quality-of-life changes to the build system. The
|
||||
usage should not change at all; the only thing that changed was making sure the
|
||||
`Makefile.in` was written to rebuild properly when headers changed and to not
|
||||
rebuild when not necessary.
|
||||
|
||||
## 3.2.4
|
||||
|
||||
This is a production release that fixes a warning on `gcc` 6 or older, which
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Notice
|
||||
|
||||
Copyright 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
## Contributors
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ Systems that are known to work:
|
||||
* Mac OSX
|
||||
* Solaris* (as long as the Solaris version supports POSIX 2008)
|
||||
* AIX
|
||||
* HP-UX* (except for history)
|
||||
|
||||
Please submit bug reports if this `bc` does not build out of the box on any
|
||||
system besides Windows. If Windows binaries are needed, they can be found at
|
||||
@@ -341,7 +342,7 @@ Folders:
|
||||
[20]: https://git.yzena.com/gavin/bc
|
||||
[21]: https://gavinhoward.com/2020/04/i-am-moving-away-from-github/
|
||||
[22]: https://www.deepl.com/translator
|
||||
[23]: https://svnweb.freebsd.org/base/head/contrib/bc/
|
||||
[23]: https://cgit.freebsd.org/src/tree/contrib/bc
|
||||
[24]: https://bugs.freebsd.org/
|
||||
[25]: https://reviews.freebsd.org/
|
||||
[26]: ./manuals/bcl.3.md
|
||||
+283
-62
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
@@ -33,6 +33,8 @@ script=$(basename "$script")
|
||||
|
||||
. "$scriptdir/functions.sh"
|
||||
|
||||
cd "$scriptdir"
|
||||
|
||||
usage() {
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
@@ -48,7 +50,7 @@ usage() {
|
||||
printf 'usage:\n'
|
||||
printf ' %s -h\n' "$script"
|
||||
printf ' %s --help\n' "$script"
|
||||
printf ' %s [-a|-bD|-dB|-c] [-EfgGHlMNPT] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
|
||||
printf ' %s [-a|-bD|-dB|-c] [-CEfgGHlmMNPtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\n' "$script"
|
||||
printf ' %s \\\n' "$script"
|
||||
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage]\\\n'
|
||||
printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
|
||||
@@ -73,6 +75,8 @@ usage() {
|
||||
printf ' Generate test coverage code. Requires gcov and regcovr.\n'
|
||||
printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n'
|
||||
printf ' Requires a compiler that use gcc-compatible coverage options\n'
|
||||
printf ' -C, --disable-clean\n'
|
||||
printf ' Disable the clean that configure.sh does before configure.\n'
|
||||
printf ' -d, --dc-only\n'
|
||||
printf ' Build dc only. It is an error if "-b", "--bc-only", "-D", or\n'
|
||||
printf ' "--disable-dc" are specified too.\n'
|
||||
@@ -107,6 +111,8 @@ usage() {
|
||||
printf ' Installs all locales, regardless of how many are on the system. This\n'
|
||||
printf ' option is useful for package maintainers who want to make sure that\n'
|
||||
printf ' a package contains all of the locales that end users might need.\n'
|
||||
printf ' -m, --enable-memcheck\n'
|
||||
printf ' Enable memcheck mode, to ensure no memory leaks. For development only.\n'
|
||||
printf ' -M, --disable-man-pages\n'
|
||||
printf ' Disable installing manpages.\n'
|
||||
printf ' -N, --disable-nls\n'
|
||||
@@ -119,9 +125,15 @@ usage() {
|
||||
printf ' Disables the prompt in the built bc. The prompt will never show up,\n'
|
||||
printf ' or in other words, it will be permanently disabled and cannot be\n'
|
||||
printf ' enabled.\n'
|
||||
printf ' -t, --enable-test-timing\n'
|
||||
printf ' Enable the timing of tests. This is for development only.\n'
|
||||
printf ' -T, --disable-strip\n'
|
||||
printf ' Disable stripping symbols from the compiled binary or binaries.\n'
|
||||
printf ' Stripping symbols only happens when debug mode is off.\n'
|
||||
printf ' -v, --enable-valgrind\n'
|
||||
printf ' Enable a build appropriate for valgrind. For development only.\n'
|
||||
printf ' -z, --enable-fuzz-mode\n'
|
||||
printf ' Enable fuzzing mode. THIS IS FOR DEVELOPMENT ONLY.\n'
|
||||
printf ' --prefix PREFIX\n'
|
||||
printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n'
|
||||
printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
|
||||
@@ -241,7 +253,7 @@ replace_ext() {
|
||||
_replace_ext_ext1="$2"
|
||||
_replace_ext_ext2="$3"
|
||||
|
||||
_replace_ext_result=${_replace_ext_file%.$_replace_ext_ext1}.$_replace_ext_ext2
|
||||
_replace_ext_result="${_replace_ext_file%.$_replace_ext_ext1}.$_replace_ext_ext2"
|
||||
|
||||
printf '%s\n' "$_replace_ext_result"
|
||||
}
|
||||
@@ -277,6 +289,23 @@ replace() {
|
||||
substring_replace "$_replace_str" "%%$_replace_needle%%" "$_replace_replacement"
|
||||
}
|
||||
|
||||
find_src_files() {
|
||||
|
||||
if [ "$#" -ge 1 ] && [ "$1" != "" ]; then
|
||||
|
||||
while [ "$#" -ge 1 ]; do
|
||||
_find_src_files_a="${1## }"
|
||||
shift
|
||||
_find_src_files_args="$_find_src_files_args ! -path src/${_find_src_files_a}"
|
||||
done
|
||||
|
||||
else
|
||||
_find_src_files_args="-print"
|
||||
fi
|
||||
|
||||
printf '%s\n' $(find src/ -depth -name "*.c" $_find_src_files_args)
|
||||
}
|
||||
|
||||
gen_file_list() {
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
@@ -291,15 +320,9 @@ gen_file_list() {
|
||||
cd "$scriptdir"
|
||||
|
||||
if [ "$#" -ge 1 ]; then
|
||||
|
||||
while [ "$#" -ge 1 ]; do
|
||||
a="$1"
|
||||
shift
|
||||
args="$args ! -path src/${a}"
|
||||
done
|
||||
|
||||
_gen_file_list_unneeded="$@"
|
||||
else
|
||||
args="-print"
|
||||
_gen_file_list_unneeded=""
|
||||
fi
|
||||
|
||||
_gen_file_list_needle_src="SRC"
|
||||
@@ -307,7 +330,7 @@ gen_file_list() {
|
||||
_gen_file_list_needle_gcda="GCDA"
|
||||
_gen_file_list_needle_gcno="GCNO"
|
||||
|
||||
_gen_file_list_replacement=$(find src/ -depth -name "*.c" $args | tr '\n' ' ')
|
||||
_gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ')
|
||||
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
|
||||
"$_gen_file_list_needle_src" "$_gen_file_list_replacement")
|
||||
|
||||
@@ -328,6 +351,101 @@ gen_file_list() {
|
||||
printf '%s\n' "$_gen_file_list_contents"
|
||||
}
|
||||
|
||||
gen_tests() {
|
||||
|
||||
_gen_tests_name="$1"
|
||||
shift
|
||||
|
||||
_gen_tests_uname="$1"
|
||||
shift
|
||||
|
||||
_gen_tests_extra_math="$1"
|
||||
shift
|
||||
|
||||
_gen_tests_time_tests="$1"
|
||||
shift
|
||||
|
||||
_gen_tests_extra_required=$(cat tests/extra_required.txt)
|
||||
|
||||
for _gen_tests_t in $(cat "$scriptdir/tests/$_gen_tests_name/all.txt"); do
|
||||
|
||||
if [ "$_gen_tests_extra_math" -eq 0 ]; then
|
||||
|
||||
if [ -z "${_gen_tests_extra_required##*$_gen_tests_t*}" ]; then
|
||||
printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \
|
||||
"$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \
|
||||
"$_gen_tests_t" >> "$scriptdir/Makefile"
|
||||
continue
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
printf 'test_%s_%s:\n\t@sh tests/test.sh %s %s %s %s %s\n\n' \
|
||||
"$_gen_tests_name" "$_gen_tests_t" "$_gen_tests_name" \
|
||||
"$_gen_tests_t" "$generate_tests" "$time_tests" \
|
||||
"$*" >> "$scriptdir/Makefile"
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
gen_test_targets() {
|
||||
|
||||
_gen_test_targets_name="$1"
|
||||
shift
|
||||
|
||||
_gen_test_targets_tests=$(cat "$scriptdir/tests/${_gen_test_targets_name}/all.txt")
|
||||
|
||||
for _gen_test_targets_t in $_gen_test_targets_tests; do
|
||||
printf ' test_%s_%s' "$_gen_test_targets_name" "$_gen_test_targets_t"
|
||||
done
|
||||
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
gen_script_tests() {
|
||||
|
||||
_gen_script_tests_name="$1"
|
||||
shift
|
||||
|
||||
_gen_script_tests_extra_math="$1"
|
||||
shift
|
||||
|
||||
_gen_script_tests_generate="$1"
|
||||
shift
|
||||
|
||||
_gen_script_tests_time="$1"
|
||||
shift
|
||||
|
||||
_gen_script_tests_tests=$(cat "$scriptdir/tests/$_gen_script_tests_name/scripts/all.txt")
|
||||
|
||||
for _gen_script_tests_f in $_gen_script_tests_tests; do
|
||||
|
||||
_gen_script_tests_b=$(basename "$_gen_script_tests_f" ".${_gen_script_tests_name}")
|
||||
|
||||
printf 'test_%s_script_%s:\n\t@sh tests/script.sh %s %s %s 1 %s %s %s\n\n' \
|
||||
"$_gen_script_tests_name" "$_gen_script_tests_b" "$_gen_script_tests_name" \
|
||||
"$_gen_script_tests_f" "$_gen_script_tests_extra_math" "$_gen_script_tests_generate" \
|
||||
"$_gen_script_tests_time" "$*" >> "$scriptdir/Makefile"
|
||||
done
|
||||
}
|
||||
|
||||
gen_script_test_targets() {
|
||||
|
||||
_gen_script_test_targets_name="$1"
|
||||
shift
|
||||
|
||||
_gen_script_test_targets_tests=$(cat "$scriptdir/tests/$_gen_script_test_targets_name/scripts/all.txt")
|
||||
|
||||
for _gen_script_test_targets_f in $_gen_script_test_targets_tests; do
|
||||
_gen_script_test_targets_b=$(basename "$_gen_script_test_targets_f" \
|
||||
".$_gen_script_test_targets_name")
|
||||
printf ' test_%s_script_%s' "$_gen_script_test_targets_name" \
|
||||
"$_gen_script_test_targets_b"
|
||||
done
|
||||
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
bc_only=0
|
||||
dc_only=0
|
||||
coverage=0
|
||||
@@ -344,14 +462,20 @@ force=0
|
||||
strip_bin=1
|
||||
all_locales=0
|
||||
library=0
|
||||
fuzz=0
|
||||
time_tests=0
|
||||
vg=0
|
||||
memcheck=0
|
||||
clean=1
|
||||
|
||||
while getopts "abBcdDEfgGhHk:lMNO:PST-" opt; do
|
||||
while getopts "abBcdDEfgGhHk:lMmNO:PStTvz-" opt; do
|
||||
|
||||
case "$opt" in
|
||||
a) library=1 ;;
|
||||
b) bc_only=1 ;;
|
||||
B) dc_only=1 ;;
|
||||
c) coverage=1 ;;
|
||||
C) clean=0 ;;
|
||||
d) dc_only=1 ;;
|
||||
D) bc_only=1 ;;
|
||||
E) extra_math=0 ;;
|
||||
@@ -362,11 +486,15 @@ while getopts "abBcdDEfgGhHk:lMNO:PST-" opt; do
|
||||
H) hist=0 ;;
|
||||
k) karatsuba_len="$OPTARG" ;;
|
||||
l) all_locales=1 ;;
|
||||
m) memcheck=1 ;;
|
||||
M) install_manpages=0 ;;
|
||||
N) nls=0 ;;
|
||||
O) optimization="$OPTARG" ;;
|
||||
P) prompt=0 ;;
|
||||
t) time_tests=1 ;;
|
||||
T) strip_bin=0 ;;
|
||||
v) vg=1 ;;
|
||||
z) fuzz=1 ;;
|
||||
-)
|
||||
arg="$1"
|
||||
arg="${arg#--}"
|
||||
@@ -465,6 +593,7 @@ while getopts "abBcdDEfgGhHk:lMNO:PST-" opt; do
|
||||
shift ;;
|
||||
disable-bc) dc_only=1 ;;
|
||||
disable-dc) bc_only=1 ;;
|
||||
disable-clean) clean=0 ;;
|
||||
disable-extra-math) extra_math=0 ;;
|
||||
disable-generated-tests) generate_tests=0 ;;
|
||||
disable-history) hist=0 ;;
|
||||
@@ -472,16 +601,24 @@ while getopts "abBcdDEfgGhHk:lMNO:PST-" opt; do
|
||||
disable-nls) nls=0 ;;
|
||||
disable-prompt) prompt=0 ;;
|
||||
disable-strip) strip_bin=0 ;;
|
||||
enable-test-timing) time_tests=1 ;;
|
||||
enable-valgrind) vg=1 ;;
|
||||
enable-fuzz-mode) fuzz=1 ;;
|
||||
enable-memcheck) memcheck=1 ;;
|
||||
install-all-locales) all_locales=1 ;;
|
||||
help* | bc-only* | dc-only* | coverage* | debug*)
|
||||
usage "No arg allowed for --$arg option" ;;
|
||||
disable-bc* | disable-dc* | disable-extra-math*)
|
||||
disable-bc* | disable-dc* | disable-clean*)
|
||||
usage "No arg allowed for --$arg option" ;;
|
||||
disable-extra-math*)
|
||||
usage "No arg allowed for --$arg option" ;;
|
||||
disable-generated-tests* | disable-history*)
|
||||
usage "No arg allowed for --$arg option" ;;
|
||||
disable-man-pages* | disable-nls* | disable-strip*)
|
||||
usage "No arg allowed for --$arg option" ;;
|
||||
install-all-locales*)
|
||||
enable-fuzz-mode* | enable-test-timing* | enable-valgrind*)
|
||||
usage "No arg allowed for --$arg option" ;;
|
||||
enable-memcheck* | install-all-locales*)
|
||||
usage "No arg allowed for --$arg option" ;;
|
||||
'') break ;; # "--" terminates argument processing
|
||||
* ) usage "Invalid option $LONG_OPTARG" ;;
|
||||
@@ -493,6 +630,12 @@ while getopts "abBcdDEfgGhHk:lMNO:PST-" opt; do
|
||||
|
||||
done
|
||||
|
||||
if [ "$clean" -ne 0 ]; then
|
||||
if [ -f ./Makefile ]; then
|
||||
make clean_config > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$bc_only" -eq 1 ] && [ "$dc_only" -eq 1 ]; then
|
||||
usage "Can only specify one of -b(-D) or -d(-B)"
|
||||
fi
|
||||
@@ -581,21 +724,19 @@ executable="BC_EXEC"
|
||||
tests="test_bc timeconst test_dc"
|
||||
|
||||
bc_test="@tests/all.sh bc $extra_math 1 $generate_tests 0 \$(BC_EXEC)"
|
||||
bc_time_test="@tests/all.sh bc $extra_math 1 $generate_tests 1 \$(BC_EXEC)"
|
||||
|
||||
dc_test="@tests/all.sh dc $extra_math 1 $generate_tests 0 \$(DC_EXEC)"
|
||||
dc_time_test="@tests/all.sh dc $extra_math 1 $generate_tests 1 \$(DC_EXEC)"
|
||||
|
||||
timeconst="@tests/bc/timeconst.sh tests/bc/scripts/timeconst.bc \$(BC_EXEC)"
|
||||
|
||||
# In order to have cleanup at exit, we need to be in
|
||||
# debug mode, so don't run valgrind without that.
|
||||
if [ "$debug" -ne 0 ]; then
|
||||
vg_bc_test="@tests/all.sh bc $extra_math 1 $generate_tests 0 valgrind \$(VALGRIND_ARGS) \$(BC_EXEC)"
|
||||
vg_dc_test="@tests/all.sh dc $extra_math 1 $generate_tests 0 valgrind \$(VALGRIND_ARGS) \$(DC_EXEC)"
|
||||
if [ "$vg" -ne 0 ]; then
|
||||
debug=1
|
||||
bc_test_exec='valgrind $(VALGRIND_ARGS) $(BC_EXEC)'
|
||||
dc_test_exec='valgrind $(VALGRIND_ARGS) $(DC_EXEC)'
|
||||
else
|
||||
vg_bc_test="@printf 'Cannot run valgrind without debug flags\\\\n'"
|
||||
vg_dc_test="@printf 'Cannot run valgrind without debug flags\\\\n'"
|
||||
bc_test_exec='$(BC_EXEC)'
|
||||
dc_test_exec='$(DC_EXEC)'
|
||||
fi
|
||||
|
||||
karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
|
||||
@@ -605,7 +746,29 @@ bc_lib="\$(GEN_DIR)/lib.o"
|
||||
bc_help="\$(GEN_DIR)/bc_help.o"
|
||||
dc_help="\$(GEN_DIR)/dc_help.o"
|
||||
|
||||
if [ "$bc_only" -eq 1 ]; then
|
||||
default_target_prereqs="\$(BIN) \$(OBJS)"
|
||||
default_target_cmd="\$(CC) \$(CFLAGS) \$(OBJS) \$(LDFLAGS) -o \$(EXEC)"
|
||||
default_target="\$(DC_EXEC)"
|
||||
|
||||
second_target_prereqs=""
|
||||
second_target_cmd="$default_target_cmd"
|
||||
second_target="\$(BC_EXEC)"
|
||||
|
||||
if [ "$library" -ne 0 ]; then
|
||||
|
||||
extra_math=1
|
||||
nls=0
|
||||
hist=0
|
||||
prompt=0
|
||||
bc=1
|
||||
dc=1
|
||||
|
||||
default_target_prereqs="\$(BIN) \$(OBJ)"
|
||||
default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)"
|
||||
default_target="\$(LIBBC)"
|
||||
tests="test_library"
|
||||
|
||||
elif [ "$bc_only" -eq 1 ]; then
|
||||
|
||||
bc=1
|
||||
dc=0
|
||||
@@ -615,14 +778,16 @@ if [ "$bc_only" -eq 1 ]; then
|
||||
executables="bc"
|
||||
|
||||
dc_test="@printf 'No dc tests to run\\\\n'"
|
||||
dc_time_test="@printf 'No dc tests to run\\\\n'"
|
||||
vg_dc_test="@printf 'No dc tests to run\\\\n'"
|
||||
|
||||
install_prereqs=" install_execs"
|
||||
install_man_prereqs=" install_bc_manpage"
|
||||
uninstall_prereqs=" uninstall_bc"
|
||||
uninstall_man_prereqs=" uninstall_bc_manpage"
|
||||
|
||||
default_target="\$(BC_EXEC)"
|
||||
second_target="\$(DC_EXEC)"
|
||||
tests="test_bc timeconst"
|
||||
|
||||
elif [ "$dc_only" -eq 1 ]; then
|
||||
|
||||
bc=0
|
||||
@@ -637,8 +802,6 @@ elif [ "$dc_only" -eq 1 ]; then
|
||||
executable="DC_EXEC"
|
||||
|
||||
bc_test="@printf 'No bc tests to run\\\\n'"
|
||||
bc_time_test="@printf 'No bc tests to run\\\\n'"
|
||||
vg_bc_test="@printf 'No bc tests to run\\\\n'"
|
||||
|
||||
timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'"
|
||||
|
||||
@@ -647,6 +810,8 @@ elif [ "$dc_only" -eq 1 ]; then
|
||||
uninstall_prereqs=" uninstall_dc"
|
||||
uninstall_man_prereqs=" uninstall_dc_manpage"
|
||||
|
||||
tests="test_dc"
|
||||
|
||||
else
|
||||
|
||||
bc=1
|
||||
@@ -654,8 +819,6 @@ else
|
||||
|
||||
executables="bc and dc"
|
||||
|
||||
link="\$(LINK) \$(BIN) \$(EXEC_PREFIX)\$(DC)"
|
||||
|
||||
karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)"
|
||||
karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)"
|
||||
|
||||
@@ -672,6 +835,18 @@ else
|
||||
tests="test_library"
|
||||
fi
|
||||
|
||||
second_target_prereqs="$default_target_prereqs"
|
||||
default_target_prereqs="$second_target"
|
||||
default_target_cmd="\$(LINK) \$(BIN) \$(EXEC_PREFIX)\$(DC)"
|
||||
|
||||
fi
|
||||
|
||||
if [ "$fuzz" -ne 0 ]; then
|
||||
debug=1
|
||||
hist=0
|
||||
prompt=0
|
||||
nls=0
|
||||
optimization="3"
|
||||
fi
|
||||
|
||||
if [ "$debug" -eq 1 ]; then
|
||||
@@ -763,16 +938,6 @@ else
|
||||
uninstall_man_prereqs=""
|
||||
fi
|
||||
|
||||
if [ "$library" -ne 0 ]; then
|
||||
extra_math=1
|
||||
nls=0
|
||||
hist=0
|
||||
prompt=0
|
||||
ALL_PREREQ="library"
|
||||
else
|
||||
ALL_PREREQ="execs"
|
||||
fi
|
||||
|
||||
if [ "$nls" -ne 0 ]; then
|
||||
|
||||
set +e
|
||||
@@ -913,13 +1078,21 @@ else
|
||||
fi
|
||||
|
||||
manpage_args=""
|
||||
unneeded=""
|
||||
headers="\$(HEADERS)"
|
||||
|
||||
if [ "$extra_math" -eq 0 ]; then
|
||||
manpage_args="E"
|
||||
unneeded="$unneeded rand.c"
|
||||
else
|
||||
headers="$headers \$(EXTRA_MATH_HEADERS)"
|
||||
fi
|
||||
|
||||
if [ "$hist" -eq 0 ]; then
|
||||
manpage_args="${manpage_args}H"
|
||||
unneeded="$unneeded history.c"
|
||||
else
|
||||
headers="$headers \$(HISTORY_HEADERS)"
|
||||
fi
|
||||
|
||||
if [ "$nls" -eq 0 ]; then
|
||||
@@ -930,26 +1103,16 @@ if [ "$prompt" -eq 0 ]; then
|
||||
manpage_args="${manpage_args}P"
|
||||
fi
|
||||
|
||||
if [ "$manpage_args" = "" ]; then
|
||||
manpage_args="A"
|
||||
fi
|
||||
|
||||
unneeded=""
|
||||
|
||||
if [ "$hist" -eq 0 ]; then
|
||||
unneeded="$unneeded history.c"
|
||||
fi
|
||||
|
||||
if [ "$bc" -eq 0 ]; then
|
||||
unneeded="$unneeded bc.c bc_lex.c bc_parse.c"
|
||||
else
|
||||
headers="$headers \$(BC_HEADERS)"
|
||||
fi
|
||||
|
||||
if [ "$dc" -eq 0 ]; then
|
||||
unneeded="$unneeded dc.c dc_lex.c dc_parse.c"
|
||||
fi
|
||||
|
||||
if [ "$extra_math" -eq 0 ]; then
|
||||
unneeded="$unneeded rand.c"
|
||||
else
|
||||
headers="$headers \$(DC_HEADERS)"
|
||||
fi
|
||||
|
||||
if [ "$library" -ne 0 ]; then
|
||||
@@ -957,10 +1120,24 @@ if [ "$library" -ne 0 ]; then
|
||||
unneeded="$unneeded lang.c lex.c parse.c program.c"
|
||||
unneeded="$unneeded bc.c bc_lex.c bc_parse.c"
|
||||
unneeded="$unneeded dc.c dc_lex.c dc_parse.c"
|
||||
headers="$headers \$(LIBRARY_HEADERS)"
|
||||
else
|
||||
unneeded="$unneeded library.c"
|
||||
fi
|
||||
|
||||
if [ "$manpage_args" = "" ]; then
|
||||
manpage_args="A"
|
||||
fi
|
||||
|
||||
if [ "$vg" -ne 0 ]; then
|
||||
memcheck=1
|
||||
fi
|
||||
|
||||
bc_tests=$(gen_test_targets bc)
|
||||
bc_script_tests=$(gen_script_test_targets bc)
|
||||
dc_tests=$(gen_test_targets dc)
|
||||
dc_script_tests=$(gen_script_test_targets dc)
|
||||
|
||||
# Print out the values; this is for debugging.
|
||||
if [ "$bc" -ne 0 ]; then
|
||||
printf 'Building bc\n'
|
||||
@@ -978,6 +1155,7 @@ printf 'BC_ENABLE_HISTORY=%s\n' "$hist"
|
||||
printf 'BC_ENABLE_EXTRA_MATH=%s\n' "$extra_math"
|
||||
printf 'BC_ENABLE_NLS=%s\n' "$nls"
|
||||
printf 'BC_ENABLE_PROMPT=%s\n' "$prompt"
|
||||
printf 'BC_ENABLE_AFL=%s\n' "$fuzz"
|
||||
printf '\n'
|
||||
printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len"
|
||||
printf '\n'
|
||||
@@ -1012,20 +1190,45 @@ replacement='*** WARNING: Autogenerated from Makefile.in. DO NOT MODIFY ***'
|
||||
contents=$(replace "$contents" "$needle" "$replacement")
|
||||
|
||||
if [ "$unneeded" = "" ]; then
|
||||
contents=$(gen_file_list "$contents" "library.c")
|
||||
else
|
||||
contents=$(gen_file_list "$contents" $unneeded)
|
||||
unneeded="library.c"
|
||||
fi
|
||||
|
||||
contents=$(gen_file_list "$contents" $unneeded)
|
||||
|
||||
SRC_TARGETS=""
|
||||
|
||||
src_files=$(find_src_files $unneeded)
|
||||
|
||||
for f in $src_files; do
|
||||
o=$(replace_ext "$f" "c" "o")
|
||||
SRC_TARGETS=$(printf '%s\n\n%s: %s %s\n\t$(CC) $(CFLAGS) -o %s -c %s\n' \
|
||||
"$SRC_TARGETS" "$o" "$headers" "$f" "$o" "$f")
|
||||
done
|
||||
|
||||
contents=$(replace "$contents" "HEADERS" "$headers")
|
||||
|
||||
contents=$(replace "$contents" "BC_ENABLED" "$bc")
|
||||
contents=$(replace "$contents" "DC_ENABLED" "$dc")
|
||||
contents=$(replace "$contents" "LINK" "$link")
|
||||
|
||||
contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test")
|
||||
contents=$(replace "$contents" "BC_TESTS" "$bc_tests")
|
||||
contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests")
|
||||
contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec")
|
||||
contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst")
|
||||
|
||||
contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test")
|
||||
contents=$(replace "$contents" "DC_TESTS" "$dc_tests")
|
||||
contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests")
|
||||
contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec")
|
||||
|
||||
contents=$(replace "$contents" "LIBRARY" "$library")
|
||||
contents=$(replace "$contents" "HISTORY" "$hist")
|
||||
contents=$(replace "$contents" "EXTRA_MATH" "$extra_math")
|
||||
contents=$(replace "$contents" "NLS" "$nls")
|
||||
contents=$(replace "$contents" "PROMPT" "$prompt")
|
||||
contents=$(replace "$contents" "FUZZ" "$fuzz")
|
||||
contents=$(replace "$contents" "MEMCHECK" "$memcheck")
|
||||
|
||||
contents=$(replace "$contents" "BC_LIB_O" "$bc_lib")
|
||||
contents=$(replace "$contents" "BC_HELP_O" "$bc_help")
|
||||
contents=$(replace "$contents" "DC_HELP_O" "$dc_help")
|
||||
@@ -1057,7 +1260,18 @@ contents=$(replace "$contents" "UNINSTALL_MAN_PREREQS" "$uninstall_man_prereqs")
|
||||
contents=$(replace "$contents" "UNINSTALL_PREREQS" "$uninstall_prereqs")
|
||||
contents=$(replace "$contents" "UNINSTALL_LOCALES_PREREQS" "$uninstall_locales_prereqs")
|
||||
|
||||
contents=$(replace "$contents" "DEFAULT_TARGET" "$default_target")
|
||||
contents=$(replace "$contents" "DEFAULT_TARGET_PREREQS" "$default_target_prereqs")
|
||||
contents=$(replace "$contents" "DEFAULT_TARGET_CMD" "$default_target_cmd")
|
||||
contents=$(replace "$contents" "SECOND_TARGET" "$second_target")
|
||||
contents=$(replace "$contents" "SECOND_TARGET_PREREQS" "$second_target_prereqs")
|
||||
contents=$(replace "$contents" "SECOND_TARGET_CMD" "$second_target_cmd")
|
||||
|
||||
contents=$(replace "$contents" "ALL_PREREQ" "$ALL_PREREQ")
|
||||
contents=$(replace "$contents" "BC_EXEC_PREREQ" "$bc_exec_prereq")
|
||||
contents=$(replace "$contents" "BC_EXEC_CMD" "$bc_exec_cmd")
|
||||
contents=$(replace "$contents" "DC_EXEC_PREREQ" "$dc_exec_prereq")
|
||||
contents=$(replace "$contents" "DC_EXEC_CMD" "$dc_exec_cmd")
|
||||
|
||||
contents=$(replace "$contents" "EXECUTABLES" "$executables")
|
||||
contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
|
||||
@@ -1065,10 +1279,7 @@ contents=$(replace "$contents" "EXEC" "$executable")
|
||||
contents=$(replace "$contents" "TESTS" "$tests")
|
||||
|
||||
contents=$(replace "$contents" "BC_TEST" "$bc_test")
|
||||
contents=$(replace "$contents" "BC_TIME_TEST" "$bc_time_test")
|
||||
|
||||
contents=$(replace "$contents" "DC_TEST" "$dc_test")
|
||||
contents=$(replace "$contents" "DC_TIME_TEST" "$dc_time_test")
|
||||
|
||||
contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test")
|
||||
contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test")
|
||||
@@ -1086,7 +1297,17 @@ contents=$(replace "$contents" "GEN_EXEC_TARGET" "$GEN_EXEC_TARGET")
|
||||
contents=$(replace "$contents" "CLEAN_PREREQS" "$CLEAN_PREREQS")
|
||||
contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
|
||||
|
||||
printf '%s\n' "$contents" > "$scriptdir/Makefile"
|
||||
printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "$scriptdir/Makefile"
|
||||
|
||||
if [ "$bc" -ne 0 ]; then
|
||||
gen_tests bc BC "$extra_math" "$time_tests" $bc_test_exec
|
||||
gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec
|
||||
fi
|
||||
|
||||
if [ "$dc" -ne 0 ]; then
|
||||
gen_tests dc DC "$extra_math" "$time_tests" $dc_test_exec
|
||||
gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec
|
||||
fi
|
||||
|
||||
cd "$scriptdir"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
+68
-22
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
@@ -59,10 +59,56 @@ err_exit() {
|
||||
fi
|
||||
|
||||
printf '%s\n' "$1"
|
||||
printf '\nexiting...\n'
|
||||
exit "$2"
|
||||
}
|
||||
|
||||
checktest_retcode() {
|
||||
|
||||
_checktest_retcode_d="$1"
|
||||
shift
|
||||
|
||||
_checktest_retcode_err="$1"
|
||||
shift
|
||||
|
||||
_checktest_retcode_name="$1"
|
||||
shift
|
||||
|
||||
if [ "$_checktest_retcode_err" -ne 0 ]; then
|
||||
printf 'FAIL!!!\n'
|
||||
err_exit "$_checktest_retcode_d failed test '$_checktest_retcode_name' with error code $_checktest_retcode_err" 1
|
||||
fi
|
||||
}
|
||||
|
||||
checktest() {
|
||||
|
||||
_checktest_d="$1"
|
||||
shift
|
||||
|
||||
_checktest_err="$1"
|
||||
shift
|
||||
|
||||
_checktest_name="$1"
|
||||
shift
|
||||
|
||||
_checktest_test_path="$1"
|
||||
shift
|
||||
|
||||
_checktest_results_name="$1"
|
||||
shift
|
||||
|
||||
checktest_retcode "$_checktest_d" "$_checktest_err" "$_checktest_name"
|
||||
|
||||
_checktest_diff=$(diff "$_checktest_test_path" "$_checktest_results_name")
|
||||
|
||||
_checktest_err="$?"
|
||||
|
||||
if [ "$_checktest_err" -ne 0 ]; then
|
||||
printf 'FAIL!!!\n'
|
||||
printf '%s\n' "$_checktest_diff"
|
||||
err_exit "$_checktest_d failed test $_checktest_name" 1
|
||||
fi
|
||||
}
|
||||
|
||||
die() {
|
||||
|
||||
_die_d="$1"
|
||||
@@ -99,49 +145,49 @@ checkcrash() {
|
||||
fi
|
||||
}
|
||||
|
||||
checktest()
|
||||
checkerrtest()
|
||||
{
|
||||
_checktest_d="$1"
|
||||
_checkerrtest_d="$1"
|
||||
shift
|
||||
|
||||
_checktest_error="$1"
|
||||
_checkerrtest_error="$1"
|
||||
shift
|
||||
|
||||
_checktest_name="$1"
|
||||
_checkerrtest_name="$1"
|
||||
shift
|
||||
|
||||
_checktest_out="$1"
|
||||
_checkerrtest_out="$1"
|
||||
shift
|
||||
|
||||
_checktest_exebase="$1"
|
||||
_checkerrtest_exebase="$1"
|
||||
shift
|
||||
|
||||
checkcrash "$_checktest_d" "$_checktest_error" "$_checktest_name"
|
||||
checkcrash "$_checkerrtest_d" "$_checkerrtest_error" "$_checkerrtest_name"
|
||||
|
||||
if [ "$_checktest_error" -eq 0 ]; then
|
||||
die "$_checktest_d" "returned no error" "$_checktest_name" 127
|
||||
if [ "$_checkerrtest_error" -eq 0 ]; then
|
||||
die "$_checkerrtest_d" "returned no error" "$_checkerrtest_name" 127
|
||||
fi
|
||||
|
||||
if [ "$_checktest_error" -eq 100 ]; then
|
||||
if [ "$_checkerrtest_error" -eq 100 ]; then
|
||||
|
||||
_checktest_output=$(cat "$_checktest_out")
|
||||
_checktest_fatal_error="Fatal error"
|
||||
_checkerrtest_output=$(cat "$_checkerrtest_out")
|
||||
_checkerrtest_fatal_error="Fatal error"
|
||||
|
||||
if [ "${_checktest_output##*$_checktest_fatal_error*}" ]; then
|
||||
printf "%s\n" "$_checktest_output"
|
||||
die "$_checktest_d" "had memory errors on a non-fatal error" \
|
||||
"$_checktest_name" "$_checktest_error"
|
||||
if [ "${_checkerrtest_output##*$_checkerrtest_fatal_error*}" ]; then
|
||||
printf "%s\n" "$_checkerrtest_output"
|
||||
die "$_checkerrtest_d" "had memory errors on a non-fatal error" \
|
||||
"$_checkerrtest_name" "$_checkerrtest_error"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -s "$_checktest_out" ]; then
|
||||
die "$_checktest_d" "produced no error message" "$_checktest_name" "$_checktest_error"
|
||||
if [ ! -s "$_checkerrtest_out" ]; then
|
||||
die "$_checkerrtest_d" "produced no error message" "$_checkerrtest_name" "$_checkerrtest_error"
|
||||
fi
|
||||
|
||||
# Display the error messages if not directly running exe.
|
||||
# This allows the script to print valgrind output.
|
||||
if [ "$_checktest_exebase" != "bc" -a "$_checktest_exebase" != "dc" ]; then
|
||||
cat "$_checktest_out"
|
||||
if [ "$_checkerrtest_exebase" != "bc" -a "$_checkerrtest_exebase" != "dc" ]; then
|
||||
cat "$_checkerrtest_out"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -110,7 +110,7 @@ define root(x,n){
|
||||
if(n<0)sqrt(n)
|
||||
n=n$
|
||||
if(n==0)x/n
|
||||
if(n==1)return x
|
||||
if(x==0||n==1)return x
|
||||
if(n==2)return sqrt(x)
|
||||
s=scale
|
||||
scale=0
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <libgen.h>
|
||||
|
||||
static const char* const bc_gen_header =
|
||||
"// Copyright (c) 2018-2020 Gavin D. Howard and contributors.\n"
|
||||
"// Copyright (c) 2018-2021 Gavin D. Howard and contributors.\n"
|
||||
"// Licensed under the 2-clause BSD license.\n"
|
||||
"// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n\n";
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
@@ -64,7 +64,7 @@ if [ -n "$remove_tabs" ]; then
|
||||
fi
|
||||
|
||||
cat<<EOF
|
||||
// Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
// Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
// Licensed under the 2-clause BSD license.
|
||||
// *** AUTOMATICALLY GENERATED FROM ${input}. DO NOT MODIFY. ***
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <status.h>
|
||||
#include <vm.h>
|
||||
|
||||
void bc_args(int argc, char *argv[]);
|
||||
void bc_args(int argc, char *argv[], bool exit_exprs);
|
||||
|
||||
extern const char* const bc_args_env_name;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -236,7 +236,9 @@ void bc_num_zero(BcNum *restrict n);
|
||||
void bc_num_one(BcNum *restrict n);
|
||||
ssize_t bc_num_cmpZero(const BcNum *n);
|
||||
|
||||
#if !defined(NDEBUG) || BC_ENABLE_LIBRARY
|
||||
bool bc_num_strValid(const char *restrict val);
|
||||
#endif // !defined(NDEBUG) || BC_ENABLE_LIBRARY
|
||||
void bc_num_parse(BcNum *restrict n, const char *restrict val, BcBigDig base);
|
||||
void bc_num_print(BcNum *restrict n, BcBigDig base, bool newline);
|
||||
#if DC_ENABLED
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,32 +1,4 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2019 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* *****************************************************************************
|
||||
*
|
||||
* Parts of this code are adapted from the following:
|
||||
@@ -38,9 +10,10 @@
|
||||
*
|
||||
* -----------------------------------------------------------------------------
|
||||
*
|
||||
* Parts of this code are also under the following license:
|
||||
* This code is under the following license:
|
||||
*
|
||||
* Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -46,6 +46,16 @@
|
||||
#define DC_ENABLED (1)
|
||||
#endif // DC_ENABLED
|
||||
|
||||
#if BC_ENABLE_AFL
|
||||
#ifndef __AFL_HAVE_MANUAL_CONTROL
|
||||
#error Must compile with afl-clang-fast for fuzzing
|
||||
#endif // __AFL_HAVE_MANUAL_CONTROL
|
||||
#endif // BC_ENABLE_AFL
|
||||
|
||||
#ifndef BC_ENABLE_MEMCHECK
|
||||
#define BC_ENABLE_MEMCHECK (0)
|
||||
#endif // BC_ENABLE_MEMCHECK
|
||||
|
||||
#include <bcl.h>
|
||||
|
||||
typedef enum BcStatus {
|
||||
@@ -166,14 +176,18 @@ typedef enum BcErr {
|
||||
#endif // __STDC_VERSION__
|
||||
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#if defined(__has_attribute) && __has_attribute(fallthrough)
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(fallthrough)
|
||||
#define BC_FALLTHROUGH __attribute__((fallthrough));
|
||||
#else // defined(__has_attribute) && __has_attribute(fallthrough)
|
||||
#else // __has_attribute(fallthrough)
|
||||
#define BC_FALLTHROUGH
|
||||
#endif // defined(__has_attribute) && __has_attribute(fallthrough)
|
||||
#endif // __has_attribute(fallthrough)
|
||||
#else // defined(__has_attribute)
|
||||
#define BC_FALLTHROUGH
|
||||
#endif // defined(__has_attribute)
|
||||
#else // defined(__clang__) || defined(__GNUC__)
|
||||
#define BC_FALLTHROUGH
|
||||
#endif //defined(__clang__) || defined(__GNUC__)
|
||||
#endif // defined(__clang__) || defined(__GNUC__)
|
||||
|
||||
// Workarounds for AIX's POSIX incompatibility.
|
||||
#ifndef SIZE_MAX
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -91,6 +91,7 @@ bool bc_map_insert(BcVec *restrict v, const char *name,
|
||||
size_t bc_map_index(const BcVec *restrict v, const char *name);
|
||||
|
||||
#define bc_vec_pop(v) (bc_vec_npop((v), 1))
|
||||
#define bc_vec_popAll(v) (bc_vec_npop((v), (v)->len))
|
||||
#define bc_vec_top(v) (bc_vec_item_rev((v), 0))
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
+14
-6
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
* Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -318,7 +318,7 @@ typedef struct BcVm {
|
||||
#if !BC_ENABLE_LIBRARY
|
||||
BcParse prs;
|
||||
BcProgram prog;
|
||||
#endif // BC_ENABLE_LIBRARY
|
||||
#endif // !BC_ENABLE_LIBRARY
|
||||
|
||||
BcVec jmp_bufs;
|
||||
|
||||
@@ -343,7 +343,7 @@ typedef struct BcVm {
|
||||
const char* file;
|
||||
|
||||
const char *sigmsg;
|
||||
#endif // BC_ENABLE_LIBRARY
|
||||
#endif // !BC_ENABLE_LIBRARY
|
||||
volatile sig_atomic_t sig_lock;
|
||||
volatile sig_atomic_t sig;
|
||||
#if !BC_ENABLE_LIBRARY
|
||||
@@ -356,8 +356,9 @@ typedef struct BcVm {
|
||||
uint16_t line_len;
|
||||
|
||||
bool no_exit_exprs;
|
||||
bool exit_exprs;
|
||||
bool eof;
|
||||
#endif // BC_ENABLE_LIBRARY
|
||||
#endif // !BC_ENABLE_LIBRARY
|
||||
|
||||
BcBigDig maxes[BC_PROG_GLOBALS_LEN + BC_ENABLE_EXTRA_MATH];
|
||||
|
||||
@@ -382,7 +383,7 @@ typedef struct BcVm {
|
||||
const char *err_msgs[BC_ERR_NELEMS];
|
||||
|
||||
const char *locale;
|
||||
#endif // BC_ENABLE_LIBRARY
|
||||
#endif // !BC_ENABLE_LIBRARY
|
||||
|
||||
BcBigDig last_base;
|
||||
BcBigDig last_pow;
|
||||
@@ -392,7 +393,7 @@ typedef struct BcVm {
|
||||
#if !BC_ENABLE_LIBRARY
|
||||
char *env_args_buffer;
|
||||
BcVec env_args;
|
||||
#endif // BC_ENABLE_LIBRARY
|
||||
#endif // !BC_ENABLE_LIBRARY
|
||||
|
||||
BcNum max;
|
||||
BcNum max2;
|
||||
@@ -436,8 +437,15 @@ void bc_vm_jmp(void);
|
||||
|
||||
#if BC_ENABLE_LIBRARY
|
||||
void bc_vm_handleError(BcErr e);
|
||||
void bc_vm_fatalError(BcErr e);
|
||||
void bc_vm_atexit(void);
|
||||
#else // BC_ENABLE_LIBRARY
|
||||
void bc_vm_handleError(BcErr e, size_t line, ...);
|
||||
#if !BC_ENABLE_LIBRARY && !BC_ENABLE_MEMCHECK
|
||||
BC_NORETURN
|
||||
#endif // !BC_ENABLE_LIBRARY && !BC_ENABLE_MEMCHECK
|
||||
void bc_vm_fatalError(BcErr e);
|
||||
int bc_vm_atexit(int status);
|
||||
#endif // BC_ENABLE_LIBRARY
|
||||
|
||||
extern const char bc_copyright[];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
@@ -121,20 +121,20 @@ else:
|
||||
|
||||
p = run([ "make", "clean" ])
|
||||
|
||||
print("Testing \"make -j4\"")
|
||||
print("Testing \"make -j12\"")
|
||||
|
||||
if p.returncode != 0:
|
||||
print("make returned an error ({}); exiting...".format(p.returncode))
|
||||
sys.exit(p.returncode)
|
||||
|
||||
p = run([ "make", "-j4" ])
|
||||
p = run([ "make", "-j12" ])
|
||||
|
||||
if p.returncode == 0:
|
||||
makecmd = [ "make", "-j4" ]
|
||||
print("Using \"make -j4\"")
|
||||
makecmd = [ "make", "-j12" ]
|
||||
print("Using \"make -j12\"")
|
||||
else:
|
||||
makecmd = [ "make" ]
|
||||
print("Not using \"make -j4\"")
|
||||
print("Not using \"make -j12\"")
|
||||
|
||||
if test_num != 0:
|
||||
mx2 = test_num
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$ $
|
||||
$ SPDX-License-Identifier: BSD-2-Clause
|
||||
$ $
|
||||
$ Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
$ Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
$ $
|
||||
$ Redistribution and use in source and binary forms, with or without
|
||||
$ modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -61,7 +60,7 @@ especially) the GNU bc(1).
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
{{ A H N P HN HP NP HNP }}
|
||||
: Turns the globals **ibase**, **obase**, **scale**, and **seed** into stacks.
|
||||
@@ -152,17 +151,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
{{ A H N P HN HP NP HNP }}
|
||||
@@ -178,7 +177,7 @@ The following are the options that bc(1) accepts.
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
{{ end }}
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
{{ A E H N EH EN HN EHN }}
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
@@ -193,57 +192,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -251,7 +257,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -295,8 +303,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -459,7 +467,10 @@ generator.
|
||||
**Note**: The values returned by the pseudo-random number generator with
|
||||
**rand()** and **irand(E)** are guaranteed to *NOT* be cryptographically secure.
|
||||
This is a consequence of using a seeded pseudo-random number generator. However,
|
||||
they *are* guaranteed to be reproducible with identical **seed** values.
|
||||
they *are* guaranteed to be reproducible with identical **seed** values. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
reproducible stream of pseudo-random numbers is *ESSENTIAL*. In any other case,
|
||||
use a non-seeded pseudo-random number generator.
|
||||
{{ end }}
|
||||
|
||||
## Numbers
|
||||
@@ -500,7 +511,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -605,7 +616,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -950,12 +961,12 @@ This is a **non-portable extension**.
|
||||
{{ A H N P HN HP NP HNP }}
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the *Extended Library* subsection below), are available when the
|
||||
**-l** or **--mathlib** command-line flags are given, except that the extended
|
||||
**-l** or **-\-mathlib** command-line flags are given, except that the extended
|
||||
math library is not available when the **-s** option, the **-w** option, or
|
||||
equivalents are given.
|
||||
{{ end }}
|
||||
{{ E EH EN EP EHN EHP ENP EHNP }}
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
{{ end }}
|
||||
|
||||
@@ -1008,8 +1019,8 @@ The [standard][1] defines the following functions for the math library:
|
||||
{{ A H N P HN HP NP HNP }}
|
||||
## Extended Library
|
||||
|
||||
The extended library is *not* loaded when the **-s**/**--standard** or
|
||||
**-w**/**--warn** options are given since they are not part of the library
|
||||
The extended library is *not* loaded when the **-s**/**-\-standard** or
|
||||
**-w**/**-\-warn** options are given since they are not part of the library
|
||||
defined by the [standard][1].
|
||||
|
||||
The extended library is a **non-portable extension**.
|
||||
@@ -1693,17 +1704,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+54
-38
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -60,7 +59,7 @@ implementations.
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.TP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
Turns the globals \f[B]ibase\f[R], \f[B]obase\f[R], \f[B]scale\f[R], and
|
||||
\f[B]seed\f[R] into stacks.
|
||||
.RS
|
||||
@@ -152,10 +151,10 @@ is ignored.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -163,7 +162,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library and the extended math library before
|
||||
running any code, including any expressions or files specified on the
|
||||
@@ -173,7 +172,7 @@ command line.
|
||||
To learn what is in the libraries, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section) This is mostly for those users that
|
||||
@@ -185,18 +184,18 @@ Most of those users would want to put this option in
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -205,15 +204,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -221,7 +220,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -230,26 +229,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -258,6 +267,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -309,8 +321,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -519,6 +531,10 @@ generator with \f[B]rand()\f[R] and \f[B]irand(E)\f[R] are guaranteed to
|
||||
This is a consequence of using a seeded pseudo-random number generator.
|
||||
However, they \f[I]are\f[R] guaranteed to be reproducible with identical
|
||||
\f[B]seed\f[R] values.
|
||||
This means that the pseudo-random values from bc(1) should only be used
|
||||
where a reproducible stream of pseudo-random numbers is
|
||||
\f[I]ESSENTIAL\f[R].
|
||||
In any other case, use a non-seeded pseudo-random number generator.
|
||||
.SS Numbers
|
||||
.PP
|
||||
Numbers are strings made up of digits, uppercase letters, and at most
|
||||
@@ -565,7 +581,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -675,7 +691,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -1121,7 +1137,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.PP
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the \f[I]Extended Library\f[R] subsection below), are
|
||||
available when the \f[B]-l\f[R] or \f[B]\[en]mathlib\f[R] command-line
|
||||
available when the \f[B]-l\f[R] or \f[B]--mathlib\f[R] command-line
|
||||
flags are given, except that the extended math library is not available
|
||||
when the \f[B]-s\f[R] option, the \f[B]-w\f[R] option, or equivalents
|
||||
are given.
|
||||
@@ -1182,7 +1198,7 @@ Functions\f[R] subsection below).
|
||||
.SS Extended Library
|
||||
.PP
|
||||
The extended library is \f[I]not\f[R] loaded when the
|
||||
\f[B]-s\f[R]/\f[B]\[en]standard\f[R] or \f[B]-w\f[R]/\f[B]\[en]warn\f[R]
|
||||
\f[B]-s\f[R]/\f[B]--standard\f[R] or \f[B]-w\f[R]/\f[B]--warn\f[R]
|
||||
options are given since they are not part of the library defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html).
|
||||
.PP
|
||||
@@ -1940,11 +1956,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1952,7 +1968,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -55,7 +54,7 @@ other implementations.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
: Turns the globals **ibase**, **obase**, **scale**, and **seed** into stacks.
|
||||
|
||||
@@ -123,17 +122,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library and the extended math library before running any code,
|
||||
@@ -141,7 +140,7 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the libraries, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
See the **TTY MODE** section) This is mostly for those users that do not
|
||||
@@ -151,57 +150,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -209,7 +215,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -253,8 +261,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -403,7 +411,10 @@ generator.
|
||||
**Note**: The values returned by the pseudo-random number generator with
|
||||
**rand()** and **irand(E)** are guaranteed to *NOT* be cryptographically secure.
|
||||
This is a consequence of using a seeded pseudo-random number generator. However,
|
||||
they *are* guaranteed to be reproducible with identical **seed** values.
|
||||
they *are* guaranteed to be reproducible with identical **seed** values. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
reproducible stream of pseudo-random numbers is *ESSENTIAL*. In any other case,
|
||||
use a non-seeded pseudo-random number generator.
|
||||
|
||||
## Numbers
|
||||
|
||||
@@ -441,7 +452,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -539,7 +550,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -870,7 +881,7 @@ This is a **non-portable extension**.
|
||||
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the *Extended Library* subsection below), are available when the
|
||||
**-l** or **--mathlib** command-line flags are given, except that the extended
|
||||
**-l** or **-\-mathlib** command-line flags are given, except that the extended
|
||||
math library is not available when the **-s** option, the **-w** option, or
|
||||
equivalents are given.
|
||||
|
||||
@@ -922,8 +933,8 @@ The [standard][1] defines the following functions for the math library:
|
||||
|
||||
## Extended Library
|
||||
|
||||
The extended library is *not* loaded when the **-s**/**--standard** or
|
||||
**-w**/**--warn** options are given since they are not part of the library
|
||||
The extended library is *not* loaded when the **-s**/**-\-standard** or
|
||||
**-w**/**-\-warn** options are given since they are not part of the library
|
||||
defined by the [standard][1].
|
||||
|
||||
The extended library is a **non-portable extension**.
|
||||
@@ -1591,17 +1602,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+49
-37
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -58,7 +57,7 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -115,10 +114,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -126,7 +125,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -135,7 +134,7 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section) This is mostly for those users that
|
||||
@@ -147,18 +146,18 @@ Most of those users would want to put this option in
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -167,15 +166,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -183,7 +182,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -192,26 +191,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -220,6 +229,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -271,8 +283,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -432,7 +444,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -515,7 +527,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -895,7 +907,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1200,11 +1212,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1212,7 +1224,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -54,7 +53,7 @@ especially) the GNU bc(1).
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -107,17 +106,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -125,7 +124,7 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
See the **TTY MODE** section) This is mostly for those users that do not
|
||||
@@ -135,57 +134,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -193,7 +199,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -237,8 +245,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -357,7 +365,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -431,7 +439,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -707,7 +715,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -983,17 +991,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+49
-37
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -112,10 +111,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -123,7 +122,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -132,7 +131,7 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section) This is mostly for those users that
|
||||
@@ -144,18 +143,18 @@ Most of those users would want to put this option in
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -164,15 +163,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -180,7 +179,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -189,26 +188,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -217,6 +226,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -268,8 +280,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -429,7 +441,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -512,7 +524,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -892,7 +904,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1197,11 +1209,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1209,7 +1221,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -51,7 +50,7 @@ command line and executes them before reading from **stdin**.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -104,17 +103,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -122,7 +121,7 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
See the **TTY MODE** section) This is mostly for those users that do not
|
||||
@@ -132,57 +131,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -190,7 +196,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -234,8 +242,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -354,7 +362,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -428,7 +436,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -704,7 +712,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -980,17 +988,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+49
-37
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -112,10 +111,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -123,7 +122,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -132,7 +131,7 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section) This is mostly for those users that
|
||||
@@ -144,18 +143,18 @@ Most of those users would want to put this option in
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -164,15 +163,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -180,7 +179,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -189,26 +188,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -217,6 +226,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -268,8 +280,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -429,7 +441,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -512,7 +524,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -892,7 +904,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1197,11 +1209,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1209,7 +1221,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -51,7 +50,7 @@ command line and executes them before reading from **stdin**.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -104,17 +103,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -122,7 +121,7 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
See the **TTY MODE** section) This is mostly for those users that do not
|
||||
@@ -132,57 +131,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -190,7 +196,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -234,8 +242,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -354,7 +362,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -428,7 +436,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -704,7 +712,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -980,17 +988,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -112,10 +111,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -123,7 +122,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -132,25 +131,25 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
This option is a no-op.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -159,15 +158,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -175,7 +174,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -184,26 +183,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -212,6 +221,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -263,8 +275,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -424,7 +436,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -507,7 +519,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -887,7 +899,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1192,11 +1204,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1204,7 +1216,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -51,7 +50,7 @@ command line and executes them before reading from **stdin**.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -104,17 +103,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -122,63 +121,70 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -186,7 +192,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -230,8 +238,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -350,7 +358,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -424,7 +432,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -700,7 +708,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -976,17 +984,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+49
-37
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -112,10 +111,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -123,7 +122,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -132,25 +131,25 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
This option is a no-op.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -159,15 +158,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -175,7 +174,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -184,26 +183,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -212,6 +221,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -263,8 +275,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -424,7 +436,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -507,7 +519,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -887,7 +899,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1192,11 +1204,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1204,7 +1216,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -51,7 +50,7 @@ command line and executes them before reading from **stdin**.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -104,17 +103,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -122,63 +121,70 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -186,7 +192,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -230,8 +238,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -350,7 +358,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -424,7 +432,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -700,7 +708,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -976,17 +984,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+49
-37
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -58,7 +57,7 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -115,10 +114,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -126,7 +125,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -135,7 +134,7 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section) This is mostly for those users that
|
||||
@@ -147,18 +146,18 @@ Most of those users would want to put this option in
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -167,15 +166,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -183,7 +182,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -192,26 +191,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -220,6 +229,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -271,8 +283,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -432,7 +444,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -515,7 +527,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -895,7 +907,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1200,11 +1212,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1212,7 +1224,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -54,7 +53,7 @@ especially) the GNU bc(1).
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -107,17 +106,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -125,7 +124,7 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
See the **TTY MODE** section) This is mostly for those users that do not
|
||||
@@ -135,57 +134,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -193,7 +199,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -237,8 +245,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -357,7 +365,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -431,7 +439,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -707,7 +715,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -983,17 +991,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+49
-37
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -58,7 +57,7 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -115,10 +114,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -126,7 +125,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -135,25 +134,25 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
This option is a no-op.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -162,15 +161,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -178,7 +177,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -187,26 +186,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -215,6 +224,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -266,8 +278,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -427,7 +439,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -510,7 +522,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -890,7 +902,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1195,11 +1207,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1207,7 +1219,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -54,7 +53,7 @@ especially) the GNU bc(1).
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -107,17 +106,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -125,63 +124,70 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -189,7 +195,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -233,8 +241,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -353,7 +361,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -427,7 +435,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -703,7 +711,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -979,17 +987,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+49
-37
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -58,7 +57,7 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.PP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
@@ -115,10 +114,10 @@ This is a **non-portable extension**.
|
||||
\f[R]
|
||||
.fi
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -126,7 +125,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library before running any code, including
|
||||
any expressions or files specified on the command line.
|
||||
@@ -135,25 +134,25 @@ any expressions or files specified on the command line.
|
||||
To learn what is in the library, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
This option is a no-op.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -162,15 +161,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -178,7 +177,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -187,26 +186,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -215,6 +224,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -266,8 +278,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -427,7 +439,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -510,7 +522,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -890,7 +902,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.SH LIBRARY
|
||||
.PP
|
||||
All of the functions below are available when the \f[B]-l\f[R] or
|
||||
\f[B]\[en]mathlib\f[R] command-line flags are given.
|
||||
\f[B]--mathlib\f[R] command-line flags are given.
|
||||
.SS Standard Library
|
||||
.PP
|
||||
The
|
||||
@@ -1195,11 +1207,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1207,7 +1219,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -54,7 +53,7 @@ especially) the GNU bc(1).
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
Turns the globals **ibase**, **obase**, and **scale** into stacks.
|
||||
|
||||
@@ -107,17 +106,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library before running any code, including any expressions or files
|
||||
@@ -125,63 +124,70 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the library, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -189,7 +195,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -233,8 +241,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -353,7 +361,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -427,7 +435,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -703,7 +711,7 @@ This is a **non-portable extension**.
|
||||
|
||||
# LIBRARY
|
||||
|
||||
All of the functions below are available when the **-l** or **--mathlib**
|
||||
All of the functions below are available when the **-l** or **-\-mathlib**
|
||||
command-line flags are given.
|
||||
|
||||
## Standard Library
|
||||
@@ -979,17 +987,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+54
-38
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.TP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
Turns the globals \f[B]ibase\f[R], \f[B]obase\f[R], \f[B]scale\f[R], and
|
||||
\f[B]seed\f[R] into stacks.
|
||||
.RS
|
||||
@@ -147,10 +146,10 @@ is ignored.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -158,7 +157,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library and the extended math library before
|
||||
running any code, including any expressions or files specified on the
|
||||
@@ -168,7 +167,7 @@ command line.
|
||||
To learn what is in the libraries, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section) This is mostly for those users that
|
||||
@@ -180,18 +179,18 @@ Most of those users would want to put this option in
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -200,15 +199,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -216,7 +215,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -225,26 +224,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -253,6 +262,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -304,8 +316,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -514,6 +526,10 @@ generator with \f[B]rand()\f[R] and \f[B]irand(E)\f[R] are guaranteed to
|
||||
This is a consequence of using a seeded pseudo-random number generator.
|
||||
However, they \f[I]are\f[R] guaranteed to be reproducible with identical
|
||||
\f[B]seed\f[R] values.
|
||||
This means that the pseudo-random values from bc(1) should only be used
|
||||
where a reproducible stream of pseudo-random numbers is
|
||||
\f[I]ESSENTIAL\f[R].
|
||||
In any other case, use a non-seeded pseudo-random number generator.
|
||||
.SS Numbers
|
||||
.PP
|
||||
Numbers are strings made up of digits, uppercase letters, and at most
|
||||
@@ -560,7 +576,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -670,7 +686,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -1116,7 +1132,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.PP
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the \f[I]Extended Library\f[R] subsection below), are
|
||||
available when the \f[B]-l\f[R] or \f[B]\[en]mathlib\f[R] command-line
|
||||
available when the \f[B]-l\f[R] or \f[B]--mathlib\f[R] command-line
|
||||
flags are given, except that the extended math library is not available
|
||||
when the \f[B]-s\f[R] option, the \f[B]-w\f[R] option, or equivalents
|
||||
are given.
|
||||
@@ -1177,7 +1193,7 @@ Functions\f[R] subsection below).
|
||||
.SS Extended Library
|
||||
.PP
|
||||
The extended library is \f[I]not\f[R] loaded when the
|
||||
\f[B]-s\f[R]/\f[B]\[en]standard\f[R] or \f[B]-w\f[R]/\f[B]\[en]warn\f[R]
|
||||
\f[B]-s\f[R]/\f[B]--standard\f[R] or \f[B]-w\f[R]/\f[B]--warn\f[R]
|
||||
options are given since they are not part of the library defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html).
|
||||
.PP
|
||||
@@ -1935,11 +1951,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1947,7 +1963,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -51,7 +50,7 @@ command line and executes them before reading from **stdin**.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
: Turns the globals **ibase**, **obase**, **scale**, and **seed** into stacks.
|
||||
|
||||
@@ -119,17 +118,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library and the extended math library before running any code,
|
||||
@@ -137,7 +136,7 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the libraries, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
See the **TTY MODE** section) This is mostly for those users that do not
|
||||
@@ -147,57 +146,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -205,7 +211,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -249,8 +257,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -399,7 +407,10 @@ generator.
|
||||
**Note**: The values returned by the pseudo-random number generator with
|
||||
**rand()** and **irand(E)** are guaranteed to *NOT* be cryptographically secure.
|
||||
This is a consequence of using a seeded pseudo-random number generator. However,
|
||||
they *are* guaranteed to be reproducible with identical **seed** values.
|
||||
they *are* guaranteed to be reproducible with identical **seed** values. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
reproducible stream of pseudo-random numbers is *ESSENTIAL*. In any other case,
|
||||
use a non-seeded pseudo-random number generator.
|
||||
|
||||
## Numbers
|
||||
|
||||
@@ -437,7 +448,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -535,7 +546,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -866,7 +877,7 @@ This is a **non-portable extension**.
|
||||
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the *Extended Library* subsection below), are available when the
|
||||
**-l** or **--mathlib** command-line flags are given, except that the extended
|
||||
**-l** or **-\-mathlib** command-line flags are given, except that the extended
|
||||
math library is not available when the **-s** option, the **-w** option, or
|
||||
equivalents are given.
|
||||
|
||||
@@ -918,8 +929,8 @@ The [standard][1] defines the following functions for the math library:
|
||||
|
||||
## Extended Library
|
||||
|
||||
The extended library is *not* loaded when the **-s**/**--standard** or
|
||||
**-w**/**--warn** options are given since they are not part of the library
|
||||
The extended library is *not* loaded when the **-s**/**-\-standard** or
|
||||
**-w**/**-\-warn** options are given since they are not part of the library
|
||||
defined by the [standard][1].
|
||||
|
||||
The extended library is a **non-portable extension**.
|
||||
@@ -1587,17 +1598,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+54
-38
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.TP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
Turns the globals \f[B]ibase\f[R], \f[B]obase\f[R], \f[B]scale\f[R], and
|
||||
\f[B]seed\f[R] into stacks.
|
||||
.RS
|
||||
@@ -147,10 +146,10 @@ is ignored.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -158,7 +157,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library and the extended math library before
|
||||
running any code, including any expressions or files specified on the
|
||||
@@ -168,7 +167,7 @@ command line.
|
||||
To learn what is in the libraries, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
Disables the prompt in TTY mode.
|
||||
(The prompt is only enabled in TTY mode.
|
||||
See the \f[B]TTY MODE\f[R] section) This is mostly for those users that
|
||||
@@ -180,18 +179,18 @@ Most of those users would want to put this option in
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -200,15 +199,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -216,7 +215,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -225,26 +224,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -253,6 +262,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -304,8 +316,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -514,6 +526,10 @@ generator with \f[B]rand()\f[R] and \f[B]irand(E)\f[R] are guaranteed to
|
||||
This is a consequence of using a seeded pseudo-random number generator.
|
||||
However, they \f[I]are\f[R] guaranteed to be reproducible with identical
|
||||
\f[B]seed\f[R] values.
|
||||
This means that the pseudo-random values from bc(1) should only be used
|
||||
where a reproducible stream of pseudo-random numbers is
|
||||
\f[I]ESSENTIAL\f[R].
|
||||
In any other case, use a non-seeded pseudo-random number generator.
|
||||
.SS Numbers
|
||||
.PP
|
||||
Numbers are strings made up of digits, uppercase letters, and at most
|
||||
@@ -560,7 +576,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -670,7 +686,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -1116,7 +1132,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.PP
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the \f[I]Extended Library\f[R] subsection below), are
|
||||
available when the \f[B]-l\f[R] or \f[B]\[en]mathlib\f[R] command-line
|
||||
available when the \f[B]-l\f[R] or \f[B]--mathlib\f[R] command-line
|
||||
flags are given, except that the extended math library is not available
|
||||
when the \f[B]-s\f[R] option, the \f[B]-w\f[R] option, or equivalents
|
||||
are given.
|
||||
@@ -1177,7 +1193,7 @@ Functions\f[R] subsection below).
|
||||
.SS Extended Library
|
||||
.PP
|
||||
The extended library is \f[I]not\f[R] loaded when the
|
||||
\f[B]-s\f[R]/\f[B]\[en]standard\f[R] or \f[B]-w\f[R]/\f[B]\[en]warn\f[R]
|
||||
\f[B]-s\f[R]/\f[B]--standard\f[R] or \f[B]-w\f[R]/\f[B]--warn\f[R]
|
||||
options are given since they are not part of the library defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html).
|
||||
.PP
|
||||
@@ -1935,11 +1951,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1947,7 +1963,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -51,7 +50,7 @@ command line and executes them before reading from **stdin**.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
: Turns the globals **ibase**, **obase**, **scale**, and **seed** into stacks.
|
||||
|
||||
@@ -119,17 +118,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library and the extended math library before running any code,
|
||||
@@ -137,7 +136,7 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the libraries, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: Disables the prompt in TTY mode. (The prompt is only enabled in TTY mode.
|
||||
See the **TTY MODE** section) This is mostly for those users that do not
|
||||
@@ -147,57 +146,64 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -205,7 +211,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -249,8 +257,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -399,7 +407,10 @@ generator.
|
||||
**Note**: The values returned by the pseudo-random number generator with
|
||||
**rand()** and **irand(E)** are guaranteed to *NOT* be cryptographically secure.
|
||||
This is a consequence of using a seeded pseudo-random number generator. However,
|
||||
they *are* guaranteed to be reproducible with identical **seed** values.
|
||||
they *are* guaranteed to be reproducible with identical **seed** values. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
reproducible stream of pseudo-random numbers is *ESSENTIAL*. In any other case,
|
||||
use a non-seeded pseudo-random number generator.
|
||||
|
||||
## Numbers
|
||||
|
||||
@@ -437,7 +448,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -535,7 +546,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -866,7 +877,7 @@ This is a **non-portable extension**.
|
||||
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the *Extended Library* subsection below), are available when the
|
||||
**-l** or **--mathlib** command-line flags are given, except that the extended
|
||||
**-l** or **-\-mathlib** command-line flags are given, except that the extended
|
||||
math library is not available when the **-s** option, the **-w** option, or
|
||||
equivalents are given.
|
||||
|
||||
@@ -918,8 +929,8 @@ The [standard][1] defines the following functions for the math library:
|
||||
|
||||
## Extended Library
|
||||
|
||||
The extended library is *not* loaded when the **-s**/**--standard** or
|
||||
**-w**/**--warn** options are given since they are not part of the library
|
||||
The extended library is *not* loaded when the **-s**/**-\-standard** or
|
||||
**-w**/**-\-warn** options are given since they are not part of the library
|
||||
defined by the [standard][1].
|
||||
|
||||
The extended library is a **non-portable extension**.
|
||||
@@ -1587,17 +1598,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+54
-38
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.TP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
Turns the globals \f[B]ibase\f[R], \f[B]obase\f[R], \f[B]scale\f[R], and
|
||||
\f[B]seed\f[R] into stacks.
|
||||
.RS
|
||||
@@ -147,10 +146,10 @@ is ignored.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -158,7 +157,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library and the extended math library before
|
||||
running any code, including any expressions or files specified on the
|
||||
@@ -168,25 +167,25 @@ command line.
|
||||
To learn what is in the libraries, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
This option is a no-op.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -195,15 +194,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -211,7 +210,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -220,26 +219,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -248,6 +257,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -299,8 +311,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -509,6 +521,10 @@ generator with \f[B]rand()\f[R] and \f[B]irand(E)\f[R] are guaranteed to
|
||||
This is a consequence of using a seeded pseudo-random number generator.
|
||||
However, they \f[I]are\f[R] guaranteed to be reproducible with identical
|
||||
\f[B]seed\f[R] values.
|
||||
This means that the pseudo-random values from bc(1) should only be used
|
||||
where a reproducible stream of pseudo-random numbers is
|
||||
\f[I]ESSENTIAL\f[R].
|
||||
In any other case, use a non-seeded pseudo-random number generator.
|
||||
.SS Numbers
|
||||
.PP
|
||||
Numbers are strings made up of digits, uppercase letters, and at most
|
||||
@@ -555,7 +571,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -665,7 +681,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -1111,7 +1127,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.PP
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the \f[I]Extended Library\f[R] subsection below), are
|
||||
available when the \f[B]-l\f[R] or \f[B]\[en]mathlib\f[R] command-line
|
||||
available when the \f[B]-l\f[R] or \f[B]--mathlib\f[R] command-line
|
||||
flags are given, except that the extended math library is not available
|
||||
when the \f[B]-s\f[R] option, the \f[B]-w\f[R] option, or equivalents
|
||||
are given.
|
||||
@@ -1172,7 +1188,7 @@ Functions\f[R] subsection below).
|
||||
.SS Extended Library
|
||||
.PP
|
||||
The extended library is \f[I]not\f[R] loaded when the
|
||||
\f[B]-s\f[R]/\f[B]\[en]standard\f[R] or \f[B]-w\f[R]/\f[B]\[en]warn\f[R]
|
||||
\f[B]-s\f[R]/\f[B]--standard\f[R] or \f[B]-w\f[R]/\f[B]--warn\f[R]
|
||||
options are given since they are not part of the library defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html).
|
||||
.PP
|
||||
@@ -1930,11 +1946,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1942,7 +1958,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
@@ -34,8 +34,7 @@ bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**bc** [**-ghilPqsvVw**] [**--global-stacks**] [**--help**] [**--interactive**] [**--mathlib**] [**--no-prompt**] [**--quiet**] [**--standard**] [**--warn**] [**--version**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...]
|
||||
[*file*...]
|
||||
**bc** [**-ghilPqsvVw**] [**-\-global-stacks**] [**-\-help**] [**-\-interactive**] [**-\-mathlib**] [**-\-no-prompt**] [**-\-quiet**] [**-\-standard**] [**-\-warn**] [**-\-version**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -51,7 +50,7 @@ command line and executes them before reading from **stdin**.
|
||||
|
||||
The following are the options that bc(1) accepts.
|
||||
|
||||
**-g**, **--global-stacks**
|
||||
**-g**, **-\-global-stacks**
|
||||
|
||||
: Turns the globals **ibase**, **obase**, **scale**, and **seed** into stacks.
|
||||
|
||||
@@ -119,17 +118,17 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-l**, **--mathlib**
|
||||
**-l**, **-\-mathlib**
|
||||
|
||||
: Sets **scale** (see the **SYNTAX** section) to **20** and loads the included
|
||||
math library and the extended math library before running any code,
|
||||
@@ -137,63 +136,70 @@ The following are the options that bc(1) accepts.
|
||||
|
||||
To learn what is in the libraries, see the **LIBRARY** section.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-q**, **--quiet**
|
||||
**-q**, **-\-quiet**
|
||||
|
||||
: This option is for compatibility with the [GNU bc(1)][2]; it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header. This bc(1) only
|
||||
prints the copyright header if one or more of the **-v**, **-V**, or
|
||||
**--version** options are given.
|
||||
**-\-version** options are given.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-s**, **--standard**
|
||||
**-s**, **-\-standard**
|
||||
|
||||
: Process exactly the language defined by the [standard][1] and error if any
|
||||
extensions are used.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-w**, **--warn**
|
||||
**-w**, **-\-warn**
|
||||
|
||||
: Like **-s** and **--standard**, except that warnings (and not errors) are
|
||||
: Like **-s** and **-\-standard**, except that warnings (and not errors) are
|
||||
printed for non-standard extensions and execution continues normally.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-e** *expr*, **--expression**=*expr*
|
||||
**-e** *expr*, **-\-expression**=*expr*
|
||||
|
||||
: Evaluates *expr*. If multiple expressions are given, they are evaluated in
|
||||
order. If files are given as well (see below), the expressions and files are
|
||||
evaluated in the order given. This means that if a file is given before an
|
||||
expression, the file is read in and evaluated first.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
However, if any other **-e**, **--expression**, **-f**, or **--file**
|
||||
arguments are given after that, bc(1) will give a fatal error and exit.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **BC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-f** *file*, **--file**=*file*
|
||||
**-f** *file*, **-\-file**=*file*
|
||||
|
||||
: Reads in *file* and evaluates it, line by line, as though it were read
|
||||
through **stdin**. If expressions are also given (see above), the
|
||||
expressions are evaluated in the order given.
|
||||
|
||||
After processing all expressions and files, bc(1) will exit, unless **-**
|
||||
(**stdin**) was given as an argument at least once to **-f** or **--file**.
|
||||
If this option is given on the command-line (i.e., not in **BC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, bc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**. However, if any other
|
||||
**-e**, **-\-expression**, **-f**, or **-\-file** arguments are given after
|
||||
**-f-** or equivalent is given, bc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -201,7 +207,9 @@ All long options are **non-portable extensions**.
|
||||
|
||||
# STDOUT
|
||||
|
||||
Any non-error output is written to **stdout**.
|
||||
Any non-error output is written to **stdout**. In addition, if history (see the
|
||||
**HISTORY** section) and the prompt (see the **TTY MODE** section) are enabled,
|
||||
both are output to **stdout**.
|
||||
|
||||
**Note**: Unlike other bc(1) implementations, this bc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -245,8 +253,8 @@ Identifiers with more than one character (letter) are a
|
||||
|
||||
**ibase** is a global variable determining how to interpret constant numbers. It
|
||||
is the "input" base, or the number base used for interpreting input numbers.
|
||||
**ibase** is initially **10**. If the **-s** (**--standard**) and **-w**
|
||||
(**--warn**) flags were not given on the command line, the max allowable value
|
||||
**ibase** is initially **10**. If the **-s** (**-\-standard**) and **-w**
|
||||
(**-\-warn**) flags were not given on the command line, the max allowable value
|
||||
for **ibase** is **36**. Otherwise, it is **16**. The min allowable value for
|
||||
**ibase** is **2**. The max allowable value for **ibase** can be queried in
|
||||
bc(1) programs with the **maxibase()** built-in function.
|
||||
@@ -395,7 +403,10 @@ generator.
|
||||
**Note**: The values returned by the pseudo-random number generator with
|
||||
**rand()** and **irand(E)** are guaranteed to *NOT* be cryptographically secure.
|
||||
This is a consequence of using a seeded pseudo-random number generator. However,
|
||||
they *are* guaranteed to be reproducible with identical **seed** values.
|
||||
they *are* guaranteed to be reproducible with identical **seed** values. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
reproducible stream of pseudo-random numbers is *ESSENTIAL*. In any other case,
|
||||
use a non-seeded pseudo-random number generator.
|
||||
|
||||
## Numbers
|
||||
|
||||
@@ -433,7 +444,7 @@ The following arithmetic and logical operators can be used. They are listed in
|
||||
order of decreasing precedence. Operators in the same group have the same
|
||||
precedence.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: Type: Prefix and Postfix
|
||||
|
||||
@@ -531,7 +542,7 @@ precedence.
|
||||
|
||||
The operators will be described in more detail below.
|
||||
|
||||
**++** **--**
|
||||
**++** **-\-**
|
||||
|
||||
: The prefix and postfix **increment** and **decrement** operators behave
|
||||
exactly like they would in C. They require a named expression (see the
|
||||
@@ -862,7 +873,7 @@ This is a **non-portable extension**.
|
||||
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the *Extended Library* subsection below), are available when the
|
||||
**-l** or **--mathlib** command-line flags are given, except that the extended
|
||||
**-l** or **-\-mathlib** command-line flags are given, except that the extended
|
||||
math library is not available when the **-s** option, the **-w** option, or
|
||||
equivalents are given.
|
||||
|
||||
@@ -914,8 +925,8 @@ The [standard][1] defines the following functions for the math library:
|
||||
|
||||
## Extended Library
|
||||
|
||||
The extended library is *not* loaded when the **-s**/**--standard** or
|
||||
**-w**/**--warn** options are given since they are not part of the library
|
||||
The extended library is *not* loaded when the **-s**/**-\-standard** or
|
||||
**-w**/**-\-warn** options are given since they are not part of the library
|
||||
defined by the [standard][1].
|
||||
|
||||
The extended library is a **non-portable extension**.
|
||||
@@ -1583,17 +1594,17 @@ The other statuses will only be returned when bc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since bc(1) resets its state (see the
|
||||
**RESET** section) and accepts more input when one of those errors occurs in
|
||||
interactive mode. This is also the case when interactive mode is forced by the
|
||||
**-i** flag or **--interactive** option.
|
||||
**-i** flag or **-\-interactive** option.
|
||||
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the **-i** flag or
|
||||
**--interactive** option.
|
||||
**-\-interactive** option.
|
||||
|
||||
# INTERACTIVE MODE
|
||||
|
||||
Per the [standard][1], bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both **stdin** and **stdout**
|
||||
are hooked to a terminal, but the **-i** flag and **--interactive** option can
|
||||
are hooked to a terminal, but the **-i** flag and **-\-interactive** option can
|
||||
turn it on in other cases.
|
||||
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+54
-38
@@ -1,7 +1,7 @@
|
||||
.\"
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018-2020 Gavin D. Howard and contributors.
|
||||
.\" Copyright (c) 2018-2021 Gavin D. Howard and contributors.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions are met:
|
||||
@@ -25,19 +25,18 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BC" "1" "October 2020" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bc - arbitrary-precision decimal arithmetic language and calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]\[en]global-stacks\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]mathlib\f[R]] [\f[B]\[en]no-prompt\f[R]]
|
||||
[\f[B]\[en]quiet\f[R]] [\f[B]\[en]standard\f[R]] [\f[B]\[en]warn\f[R]]
|
||||
[\f[B]\[en]version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]\[en]expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]-file\f[R]=\f[I]file\f[R]\&...]
|
||||
\f[B]bc\f[R] [\f[B]-ghilPqsvVw\f[R]] [\f[B]--global-stacks\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--mathlib\f[R]]
|
||||
[\f[B]--no-prompt\f[R]] [\f[B]--quiet\f[R]] [\f[B]--standard\f[R]]
|
||||
[\f[B]--warn\f[R]] [\f[B]--version\f[R]] [\f[B]-e\f[R] \f[I]expr\f[R]]
|
||||
[\f[B]--expression\f[R]=\f[I]expr\f[R]\&...] [\f[B]-f\f[R]
|
||||
\f[I]file\f[R]\&...] [\f[B]--file\f[R]=\f[I]file\f[R]\&...]
|
||||
[\f[I]file\f[R]\&...]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -55,7 +54,7 @@ the command line and executes them before reading from \f[B]stdin\f[R].
|
||||
.PP
|
||||
The following are the options that bc(1) accepts.
|
||||
.TP
|
||||
\f[B]-g\f[R], \f[B]\[en]global-stacks\f[R]
|
||||
\f[B]-g\f[R], \f[B]--global-stacks\f[R]
|
||||
Turns the globals \f[B]ibase\f[R], \f[B]obase\f[R], \f[B]scale\f[R], and
|
||||
\f[B]seed\f[R] into stacks.
|
||||
.RS
|
||||
@@ -147,10 +146,10 @@ is ignored.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-h\f[R], \f[B]\[en]help\f[R]
|
||||
\f[B]-h\f[R], \f[B]--help\f[R]
|
||||
Prints a usage message and quits.
|
||||
.TP
|
||||
\f[B]-i\f[R], \f[B]\[en]interactive\f[R]
|
||||
\f[B]-i\f[R], \f[B]--interactive\f[R]
|
||||
Forces interactive mode.
|
||||
(See the \f[B]INTERACTIVE MODE\f[R] section.)
|
||||
.RS
|
||||
@@ -158,7 +157,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-l\f[R], \f[B]\[en]mathlib\f[R]
|
||||
\f[B]-l\f[R], \f[B]--mathlib\f[R]
|
||||
Sets \f[B]scale\f[R] (see the \f[B]SYNTAX\f[R] section) to \f[B]20\f[R]
|
||||
and loads the included math library and the extended math library before
|
||||
running any code, including any expressions or files specified on the
|
||||
@@ -168,25 +167,25 @@ command line.
|
||||
To learn what is in the libraries, see the \f[B]LIBRARY\f[R] section.
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-P\f[R], \f[B]\[en]no-prompt\f[R]
|
||||
\f[B]-P\f[R], \f[B]--no-prompt\f[R]
|
||||
This option is a no-op.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-q\f[R], \f[B]\[en]quiet\f[R]
|
||||
\f[B]-q\f[R], \f[B]--quiet\f[R]
|
||||
This option is for compatibility with the GNU
|
||||
bc(1) (https://www.gnu.org/software/bc/); it is a no-op.
|
||||
Without this option, GNU bc(1) prints a copyright header.
|
||||
This bc(1) only prints the copyright header if one or more of the
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]\[en]version\f[R] options are given.
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], or \f[B]--version\f[R] options are given.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-s\f[R], \f[B]\[en]standard\f[R]
|
||||
\f[B]-s\f[R], \f[B]--standard\f[R]
|
||||
Process exactly the language defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html)
|
||||
and error if any extensions are used.
|
||||
@@ -195,15 +194,15 @@ and error if any extensions are used.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]\[en]version\f[R]
|
||||
\f[B]-v\f[R], \f[B]-V\f[R], \f[B]--version\f[R]
|
||||
Print the version information (copyright header) and exit.
|
||||
.RS
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-w\f[R], \f[B]\[en]warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]\[en]standard\f[R], except that warnings (and
|
||||
\f[B]-w\f[R], \f[B]--warn\f[R]
|
||||
Like \f[B]-s\f[R] and \f[B]--standard\f[R], except that warnings (and
|
||||
not errors) are printed for non-standard extensions and execution
|
||||
continues normally.
|
||||
.RS
|
||||
@@ -211,7 +210,7 @@ continues normally.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]\[en]expression\f[R]=\f[I]expr\f[R]
|
||||
\f[B]-e\f[R] \f[I]expr\f[R], \f[B]--expression\f[R]=\f[I]expr\f[R]
|
||||
Evaluates \f[I]expr\f[R].
|
||||
If multiple expressions are given, they are evaluated in order.
|
||||
If files are given as well (see below), the expressions and files are
|
||||
@@ -220,26 +219,36 @@ This means that if a file is given before an expression, the file is
|
||||
read in and evaluated first.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]\[en]expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]\[en]file\f[R] arguments are given after that,
|
||||
bc(1) will give a fatal error and exit.
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R], whether on the command-line or in
|
||||
\f[B]BC_ENV_ARGS\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
.TP
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]\[en]file\f[R]=\f[I]file\f[R]
|
||||
\f[B]-f\f[R] \f[I]file\f[R], \f[B]--file\f[R]=\f[I]file\f[R]
|
||||
Reads in \f[I]file\f[R] and evaluates it, line by line, as though it
|
||||
were read through \f[B]stdin\f[R].
|
||||
If expressions are also given (see above), the expressions are evaluated
|
||||
in the order given.
|
||||
.RS
|
||||
.PP
|
||||
After processing all expressions and files, bc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]BC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, bc(1) will exit, unless
|
||||
\f[B]-\f[R] (\f[B]stdin\f[R]) was given as an argument at least once to
|
||||
\f[B]-f\f[R] or \f[B]\[en]file\f[R].
|
||||
\f[B]-f\f[R] or \f[B]--file\f[R].
|
||||
However, if any other \f[B]-e\f[R], \f[B]--expression\f[R],
|
||||
\f[B]-f\f[R], or \f[B]--file\f[R] arguments are given after
|
||||
\f[B]-f-\f[R] or equivalent is given, bc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -248,6 +257,9 @@ All long options are \f[B]non-portable extensions\f[R].
|
||||
.SH STDOUT
|
||||
.PP
|
||||
Any non-error output is written to \f[B]stdout\f[R].
|
||||
In addition, if history (see the \f[B]HISTORY\f[R] section) and the
|
||||
prompt (see the \f[B]TTY MODE\f[R] section) are enabled, both are output
|
||||
to \f[B]stdout\f[R].
|
||||
.PP
|
||||
\f[B]Note\f[R]: Unlike other bc(1) implementations, this bc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -299,8 +311,8 @@ constant numbers.
|
||||
It is the \[lq]input\[rq] base, or the number base used for interpreting
|
||||
input numbers.
|
||||
\f[B]ibase\f[R] is initially \f[B]10\f[R].
|
||||
If the \f[B]-s\f[R] (\f[B]\[en]standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]\[en]warn\f[R]) flags were not given on the command line, the max
|
||||
If the \f[B]-s\f[R] (\f[B]--standard\f[R]) and \f[B]-w\f[R]
|
||||
(\f[B]--warn\f[R]) flags were not given on the command line, the max
|
||||
allowable value for \f[B]ibase\f[R] is \f[B]36\f[R].
|
||||
Otherwise, it is \f[B]16\f[R].
|
||||
The min allowable value for \f[B]ibase\f[R] is \f[B]2\f[R].
|
||||
@@ -509,6 +521,10 @@ generator with \f[B]rand()\f[R] and \f[B]irand(E)\f[R] are guaranteed to
|
||||
This is a consequence of using a seeded pseudo-random number generator.
|
||||
However, they \f[I]are\f[R] guaranteed to be reproducible with identical
|
||||
\f[B]seed\f[R] values.
|
||||
This means that the pseudo-random values from bc(1) should only be used
|
||||
where a reproducible stream of pseudo-random numbers is
|
||||
\f[I]ESSENTIAL\f[R].
|
||||
In any other case, use a non-seeded pseudo-random number generator.
|
||||
.SS Numbers
|
||||
.PP
|
||||
Numbers are strings made up of digits, uppercase letters, and at most
|
||||
@@ -555,7 +571,7 @@ The following arithmetic and logical operators can be used.
|
||||
They are listed in order of decreasing precedence.
|
||||
Operators in the same group have the same precedence.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
Type: Prefix and Postfix
|
||||
.RS
|
||||
.PP
|
||||
@@ -665,7 +681,7 @@ Description: \f[B]boolean or\f[R]
|
||||
.PP
|
||||
The operators will be described in more detail below.
|
||||
.TP
|
||||
\f[B]++\f[R] \f[B]\[en]\f[R]
|
||||
\f[B]++\f[R] \f[B]--\f[R]
|
||||
The prefix and postfix \f[B]increment\f[R] and \f[B]decrement\f[R]
|
||||
operators behave exactly like they would in C.
|
||||
They require a named expression (see the \f[I]Named Expressions\f[R]
|
||||
@@ -1111,7 +1127,7 @@ This is a \f[B]non-portable extension\f[R].
|
||||
.PP
|
||||
All of the functions below, including the functions in the extended math
|
||||
library (see the \f[I]Extended Library\f[R] subsection below), are
|
||||
available when the \f[B]-l\f[R] or \f[B]\[en]mathlib\f[R] command-line
|
||||
available when the \f[B]-l\f[R] or \f[B]--mathlib\f[R] command-line
|
||||
flags are given, except that the extended math library is not available
|
||||
when the \f[B]-s\f[R] option, the \f[B]-w\f[R] option, or equivalents
|
||||
are given.
|
||||
@@ -1172,7 +1188,7 @@ Functions\f[R] subsection below).
|
||||
.SS Extended Library
|
||||
.PP
|
||||
The extended library is \f[I]not\f[R] loaded when the
|
||||
\f[B]-s\f[R]/\f[B]\[en]standard\f[R] or \f[B]-w\f[R]/\f[B]\[en]warn\f[R]
|
||||
\f[B]-s\f[R]/\f[B]--standard\f[R] or \f[B]-w\f[R]/\f[B]--warn\f[R]
|
||||
options are given since they are not part of the library defined by the
|
||||
standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html).
|
||||
.PP
|
||||
@@ -1930,11 +1946,11 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
bc(1) resets its state (see the \f[B]RESET\f[R] section) and accepts
|
||||
more input when one of those errors occurs in interactive mode.
|
||||
This is also the case when interactive mode is forced by the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.PP
|
||||
These exit statuses allow bc(1) to be used in shell scripting with error
|
||||
checking, and its normal behavior can be forced by using the
|
||||
\f[B]-i\f[R] flag or \f[B]\[en]interactive\f[R] option.
|
||||
\f[B]-i\f[R] flag or \f[B]--interactive\f[R] option.
|
||||
.SH INTERACTIVE MODE
|
||||
.PP
|
||||
Per the
|
||||
@@ -1942,7 +1958,7 @@ standard (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
|
||||
bc(1) has an interactive mode and a non-interactive mode.
|
||||
Interactive mode is turned on automatically when both \f[B]stdin\f[R]
|
||||
and \f[B]stdout\f[R] are hooked to a terminal, but the \f[B]-i\f[R] flag
|
||||
and \f[B]\[en]interactive\f[R] option can turn it on in other cases.
|
||||
and \f[B]--interactive\f[R] option can turn it on in other cases.
|
||||
.PP
|
||||
In interactive mode, bc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
Loaded 100 of 1915 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user