mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
Compare commits
340
Commits
| 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 |
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
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
*.a
|
||||
*.core
|
||||
*.o
|
||||
*.so
|
||||
*.swp
|
||||
*~
|
||||
_.tinderbox.*
|
||||
_.universe-toolchain
|
||||
_.amd64.*
|
||||
_.arm.*
|
||||
_.arm64.*
|
||||
_.i386.*
|
||||
_.ia64.*
|
||||
_.mips.*
|
||||
_.pc98.*
|
||||
_.powerpc.*
|
||||
_.riscv.*
|
||||
_.sparc64.*
|
||||
_.sun4v.*
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
ID
|
||||
cscope.files
|
||||
cscope.in.out
|
||||
cscope.out
|
||||
cscope.po.out
|
||||
+2
-1
@@ -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
|
||||
|
||||
+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
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
FreeBSD Source:
|
||||
---------------
|
||||
This is the top level of the FreeBSD source directory. This file
|
||||
was last revised on:
|
||||
$FreeBSD$
|
||||
|
||||
FreeBSD is an operating system used to power modern servers,
|
||||
desktops, and embedded platforms. A large community has
|
||||
continually developed it for more than thirty years. Its
|
||||
advanced networking, security, and storage features have
|
||||
made FreeBSD the platform of choice for many of the
|
||||
busiest web sites and most pervasive embedded networking
|
||||
and storage devices.
|
||||
|
||||
For copyright information, please see the file COPYRIGHT in this
|
||||
directory. Additional copyright information also exists for some
|
||||
sources in this tree - please see the specific source directories for
|
||||
more information.
|
||||
|
||||
The Makefile in this directory supports a number of targets for
|
||||
building components (or all) of the FreeBSD source tree. See build(7), config(8),
|
||||
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html, and
|
||||
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
|
||||
for more information, including setting make(1) variables.
|
||||
|
||||
Source Roadmap:
|
||||
---------------
|
||||
```
|
||||
bin System/user commands.
|
||||
|
||||
cddl Various commands and libraries under the Common Development
|
||||
and Distribution License.
|
||||
|
||||
contrib Packages contributed by 3rd parties.
|
||||
|
||||
crypto Cryptography stuff (see crypto/README).
|
||||
|
||||
etc Template files for /etc.
|
||||
|
||||
gnu Various commands and libraries under the GNU Public License.
|
||||
Please see gnu/COPYING* for more information.
|
||||
|
||||
include System include files.
|
||||
|
||||
kerberos5 Kerberos5 (Heimdal) package.
|
||||
|
||||
lib System libraries.
|
||||
|
||||
libexec System daemons.
|
||||
|
||||
release Release building Makefile & associated tools.
|
||||
|
||||
rescue Build system for statically linked /rescue utilities.
|
||||
|
||||
sbin System commands.
|
||||
|
||||
secure Cryptographic libraries and commands.
|
||||
|
||||
share Shared resources.
|
||||
|
||||
stand Boot loader sources.
|
||||
|
||||
sys Kernel sources.
|
||||
|
||||
sys/<arch>/conf Kernel configuration files. GENERIC is the configuration
|
||||
used in release builds. NOTES contains documentation of
|
||||
all possible entries.
|
||||
|
||||
tests Regression tests which can be run by Kyua. See tests/README
|
||||
for additional information.
|
||||
|
||||
tools Utilities for regression testing and miscellaneous tasks.
|
||||
|
||||
usr.bin User commands.
|
||||
|
||||
usr.sbin System administration commands.
|
||||
```
|
||||
|
||||
For information on synchronizing your source tree with one or more of
|
||||
the FreeBSD Project's development branches, please see:
|
||||
|
||||
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html
|
||||
@@ -11,6 +11,212 @@ handbook:
|
||||
Items affecting the ports and packages system can be found in
|
||||
/usr/ports/UPDATING. Please read that file before running portupgrade.
|
||||
|
||||
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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#
|
||||
.POSIX:
|
||||
|
||||
VERSION = 3.2.6
|
||||
VERSION = 3.3.3
|
||||
|
||||
SRC = %%SRC%%
|
||||
OBJ = %%OBJ%%
|
||||
|
||||
@@ -1,5 +1,51 @@
|
||||
# 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.
|
||||
|
||||
@@ -342,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
|
||||
@@ -253,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"
|
||||
}
|
||||
@@ -1199,17 +1199,12 @@ SRC_TARGETS=""
|
||||
|
||||
src_files=$(find_src_files $unneeded)
|
||||
|
||||
temp_ifs="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
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
|
||||
|
||||
IFS="$temp_ifs"
|
||||
|
||||
contents=$(replace "$contents" "HEADERS" "$headers")
|
||||
|
||||
contents=$(replace "$contents" "BC_ENABLED" "$bc")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -176,11 +176,15 @@ 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__)
|
||||
|
||||
@@ -356,6 +356,7 @@ typedef struct BcVm {
|
||||
uint16_t line_len;
|
||||
|
||||
bool no_exit_exprs;
|
||||
bool exit_exprs;
|
||||
bool eof;
|
||||
#endif // !BC_ENABLE_LIBRARY
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
@@ -503,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
|
||||
|
||||
@@ -608,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
|
||||
@@ -953,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 }}
|
||||
|
||||
@@ -1011,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**.
|
||||
@@ -1696,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**
|
||||
|
||||
+49
-37
@@ -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" "January 2021" "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].
|
||||
@@ -569,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
|
||||
@@ -679,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]
|
||||
@@ -1125,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.
|
||||
@@ -1186,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
|
||||
@@ -1944,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
|
||||
@@ -1956,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
|
||||
|
||||
@@ -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.
|
||||
@@ -444,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
|
||||
|
||||
@@ -542,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
|
||||
@@ -873,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.
|
||||
|
||||
@@ -925,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**.
|
||||
@@ -1594,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**
|
||||
|
||||
+48
-36
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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**
|
||||
|
||||
+48
-36
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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**
|
||||
|
||||
+48
-36
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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**
|
||||
|
||||
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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**
|
||||
|
||||
+48
-36
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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**
|
||||
|
||||
+48
-36
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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**
|
||||
|
||||
+48
-36
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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**
|
||||
|
||||
+48
-36
@@ -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" "January 2021" "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
|
||||
|
||||
@@ -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
@@ -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" "January 2021" "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].
|
||||
@@ -564,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
|
||||
@@ -674,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]
|
||||
@@ -1120,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.
|
||||
@@ -1181,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
|
||||
@@ -1939,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
|
||||
@@ -1951,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
|
||||
|
||||
@@ -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.
|
||||
@@ -440,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
|
||||
|
||||
@@ -538,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
|
||||
@@ -869,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.
|
||||
|
||||
@@ -921,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**.
|
||||
@@ -1590,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**
|
||||
|
||||
+49
-37
@@ -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" "January 2021" "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].
|
||||
@@ -564,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
|
||||
@@ -674,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]
|
||||
@@ -1120,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.
|
||||
@@ -1181,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
|
||||
@@ -1939,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
|
||||
@@ -1951,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
|
||||
|
||||
@@ -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.
|
||||
@@ -440,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
|
||||
|
||||
@@ -538,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
|
||||
@@ -869,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.
|
||||
|
||||
@@ -921,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**.
|
||||
@@ -1590,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**
|
||||
|
||||
+49
-37
@@ -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" "January 2021" "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].
|
||||
@@ -559,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
|
||||
@@ -669,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]
|
||||
@@ -1115,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.
|
||||
@@ -1176,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
|
||||
@@ -1934,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
|
||||
@@ -1946,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
|
||||
|
||||
@@ -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.
|
||||
@@ -436,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
|
||||
|
||||
@@ -534,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
|
||||
@@ -865,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.
|
||||
|
||||
@@ -917,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**.
|
||||
@@ -1586,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**
|
||||
|
||||
+49
-37
@@ -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" "January 2021" "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].
|
||||
@@ -559,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
|
||||
@@ -669,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]
|
||||
@@ -1115,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.
|
||||
@@ -1176,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
|
||||
@@ -1934,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
|
||||
@@ -1946,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
|
||||
|
||||
@@ -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.
|
||||
@@ -436,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
|
||||
|
||||
@@ -534,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
|
||||
@@ -865,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.
|
||||
|
||||
@@ -917,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**.
|
||||
@@ -1586,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**
|
||||
|
||||
+49
-37
@@ -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" "January 2021" "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].
|
||||
@@ -569,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
|
||||
@@ -679,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]
|
||||
@@ -1125,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.
|
||||
@@ -1186,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
|
||||
@@ -1944,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
|
||||
@@ -1956,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
|
||||
|
||||
@@ -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.
|
||||
@@ -444,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
|
||||
|
||||
@@ -542,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
|
||||
@@ -873,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.
|
||||
|
||||
@@ -925,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**.
|
||||
@@ -1594,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
@@ -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" "January 2021" "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,25 +172,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.
|
||||
@@ -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].
|
||||
@@ -564,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
|
||||
@@ -674,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]
|
||||
@@ -1120,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.
|
||||
@@ -1181,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
|
||||
@@ -1939,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
|
||||
@@ -1951,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
|
||||
|
||||
@@ -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,63 +140,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**.
|
||||
|
||||
@@ -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.
|
||||
@@ -440,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
|
||||
|
||||
@@ -538,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
|
||||
@@ -869,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.
|
||||
|
||||
@@ -921,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**.
|
||||
@@ -1590,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**
|
||||
|
||||
+49
-37
@@ -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" "January 2021" "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,25 +172,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.
|
||||
@@ -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].
|
||||
@@ -564,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
|
||||
@@ -674,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]
|
||||
@@ -1120,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.
|
||||
@@ -1181,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
|
||||
@@ -1939,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
|
||||
@@ -1951,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
|
||||
|
||||
@@ -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,63 +140,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**.
|
||||
|
||||
@@ -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.
|
||||
@@ -440,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
|
||||
|
||||
@@ -538,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
|
||||
@@ -869,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.
|
||||
|
||||
@@ -921,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**.
|
||||
@@ -1590,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**
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "BCL" "3" "January 2021" "Gavin D. Howard" "Libraries Manual"
|
||||
.TH "BCL" "3" "March 2021" "Gavin D. Howard" "Libraries Manual"
|
||||
.SH NAME
|
||||
.PP
|
||||
bcl - library of arbitrary precision decimal arithmetic
|
||||
|
||||
+38
-38
@@ -426,7 +426,7 @@ All procedures in this section require a valid current context.
|
||||
bcl(3) will encode an error in the return value, if there was one. The error
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**void bcl_num_free(BclNumber** *n***)**
|
||||
@@ -487,7 +487,7 @@ subsection below.
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_PARSE_INVALID_STR**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
@@ -524,7 +524,7 @@ subsection below.
|
||||
bcl(3) will encode an error in the return value, if there was one. The error
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
## Math
|
||||
@@ -551,7 +551,7 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_sub(BclNumber** *a***, BclNumber** *b***)**
|
||||
@@ -568,7 +568,7 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_mul(BclNumber** *a***, BclNumber** *b***)**
|
||||
@@ -587,7 +587,7 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_div(BclNumber** *a***, BclNumber** *b***)**
|
||||
@@ -606,8 +606,8 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_mod(BclNumber** *a***, BclNumber** *b***)**
|
||||
@@ -626,8 +626,8 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_pow(BclNumber** *a***, BclNumber** *b***)**
|
||||
@@ -649,10 +649,10 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_MATH_OVERFLOW**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_MATH_OVERFLOW**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_lshift(BclNumber** *a***, BclNumber** *b***)**
|
||||
@@ -671,8 +671,8 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_rshift(BclNumber** *a***, BclNumber** *b***)**
|
||||
@@ -691,8 +691,8 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_sqrt(BclNumber** *a***)**
|
||||
@@ -709,8 +709,8 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclError bcl_divmod(BclNumber** *a***, BclNumber** *b***, BclNumber \****c***, BclNumber \****d***)**
|
||||
@@ -719,7 +719,7 @@ All procedures in this section can return the following errors:
|
||||
into the space pointed to by *c*, and puts the modulus in a new number which
|
||||
is put into the space pointed to by *d*.
|
||||
|
||||
*b* cannot be **0**.
|
||||
*b* cannot be **0**.
|
||||
|
||||
*a* and *b* are consumed; they cannot be used after the call. See the
|
||||
**Consumption and Propagation** subsection below.
|
||||
@@ -731,8 +731,8 @@ All procedures in this section can return the following errors:
|
||||
function can return:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_modexp(BclNumber** *a***, BclNumber** *b***, BclNumber** *c***)**
|
||||
@@ -751,10 +751,10 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_MATH_DIVIDE_BY_ZERO**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
## Miscellaneous
|
||||
@@ -791,7 +791,7 @@ All procedures in this section can return the following errors:
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
## Pseudo-Random Number Generator
|
||||
@@ -852,9 +852,9 @@ procedures require a valid current context.
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_frand(size_t** *places***)**
|
||||
@@ -868,7 +868,7 @@ procedures require a valid current context.
|
||||
bcl(3) will encode an error in the return value, if there was one. The error
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclNumber bcl_ifrand(BclNumber** *a***, size_t** *places***)**
|
||||
@@ -887,9 +887,9 @@ procedures require a valid current context.
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_MATH_NEGATIVE**
|
||||
* **BCL_ERROR_MATH_NON_INTEGER**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclError bcl_rand_seedWithNum(BclNumber** *n***)**
|
||||
@@ -904,7 +904,7 @@ procedures require a valid current context.
|
||||
function can return:
|
||||
|
||||
* **BCL_ERROR_INVALID_NUM**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
|
||||
Note that if **bcl_rand_seed2num(***void***)** or
|
||||
**bcl_rand_seed2num_err(BclNumber)** are called right after this function,
|
||||
@@ -917,7 +917,7 @@ procedures require a valid current context.
|
||||
If there was no error, **BCL_ERROR_NONE** is returned. Otherwise, this
|
||||
function can return:
|
||||
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
|
||||
**void bcl_rand_reseed(***void***)**
|
||||
|
||||
@@ -935,7 +935,7 @@ procedures require a valid current context.
|
||||
bcl(3) will encode an error in the return value, if there was one. The error
|
||||
can be queried with **bcl_err(BclNumber)**. Possible errors include:
|
||||
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_INVALID_CONTEXT**
|
||||
* **BCL_ERROR_FATAL_ALLOC_ERR**
|
||||
|
||||
**BclRandInt bcl_rand_int(***void***)**
|
||||
|
||||
@@ -164,6 +164,22 @@ Can be overridden by passing the `--bindir` option to `configure.sh`.
|
||||
|
||||
Defaults to `$PREFIX/bin`.
|
||||
|
||||
### `INCLUDEDIR`
|
||||
|
||||
The directory to install header files in.
|
||||
|
||||
Can be overridden by passing the `--includedir` option to `configure.sh`.
|
||||
|
||||
Defaults to `$PREFIX/include`.
|
||||
|
||||
### `LIBDIR`
|
||||
|
||||
The directory to install libraries in.
|
||||
|
||||
Can be overridden by passing the `--libdir` option to `configure.sh`.
|
||||
|
||||
Defaults to `$PREFIX/lib`.
|
||||
|
||||
### `DATAROOTDIR`
|
||||
|
||||
The root directory to install data files in.
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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.
|
||||
@@ -92,35 +92,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -128,7 +135,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -209,7 +218,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -938,7 +947,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1073,7 +1082,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1159,17 +1168,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -235,7 +247,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1024,7 +1036,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1164,7 +1176,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1247,17 +1259,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -198,7 +207,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -900,7 +909,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1033,7 +1042,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1109,17 +1118,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+41
-29
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -824,7 +836,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -959,7 +971,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1039,17 +1051,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -740,7 +749,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -868,7 +877,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -942,17 +951,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+41
-29
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -824,7 +836,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -959,7 +971,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1039,17 +1051,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -740,7 +749,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -868,7 +877,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -942,17 +951,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+41
-29
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -824,7 +836,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -959,7 +971,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1039,17 +1051,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -740,7 +749,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -868,7 +877,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -942,17 +951,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -819,7 +831,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -954,7 +966,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1034,17 +1046,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -737,7 +746,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -865,7 +874,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -939,17 +948,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+41
-29
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -819,7 +831,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -954,7 +966,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1034,17 +1046,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -737,7 +746,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -865,7 +874,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -939,17 +948,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+41
-29
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -824,7 +836,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -959,7 +971,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1039,17 +1051,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -740,7 +749,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -868,7 +877,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -942,17 +951,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+41
-29
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -819,7 +831,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -954,7 +966,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1034,17 +1046,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -737,7 +746,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -865,7 +874,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -939,17 +948,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+41
-29
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -819,7 +831,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -954,7 +966,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1034,17 +1046,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -737,7 +746,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -865,7 +874,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -939,17 +948,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -235,7 +247,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1024,7 +1036,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1164,7 +1176,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1247,17 +1259,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -198,7 +207,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -900,7 +909,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1033,7 +1042,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1109,17 +1118,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -235,7 +247,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1024,7 +1036,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1164,7 +1176,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1247,17 +1259,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -198,7 +207,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -900,7 +909,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1033,7 +1042,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1109,17 +1118,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -230,7 +242,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1019,7 +1031,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1159,7 +1171,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1242,17 +1254,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -195,7 +204,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -897,7 +906,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1030,7 +1039,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1106,17 +1115,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -230,7 +242,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1019,7 +1031,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1159,7 +1171,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1242,17 +1254,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -195,7 +204,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -897,7 +906,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1030,7 +1039,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1106,17 +1115,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,7 +85,7 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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
|
||||
@@ -98,7 +97,7 @@ 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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -107,7 +106,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -116,26 +115,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -144,6 +153,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -235,7 +247,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1024,7 +1036,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1164,7 +1176,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1247,17 +1259,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,21 +64,21 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-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
|
||||
@@ -87,35 +87,42 @@ The following are the options that dc(1) accepts.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -123,7 +130,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -198,7 +207,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -900,7 +909,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1033,7 +1042,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1109,17 +1118,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -230,7 +242,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1019,7 +1031,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1159,7 +1171,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1242,17 +1254,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -195,7 +204,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -897,7 +906,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1030,7 +1039,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1106,17 +1115,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
+42
-30
@@ -25,18 +25,17 @@
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.SH Name
|
||||
.PP
|
||||
dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]\[en]version\f[R]]
|
||||
[\f[B]\[en]help\f[R]] [\f[B]\[en]interactive\f[R]]
|
||||
[\f[B]\[en]no-prompt\f[R]] [\f[B]\[en]extended-register\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]dc\f[R] [\f[B]-hiPvVx\f[R]] [\f[B]--version\f[R]]
|
||||
[\f[B]--help\f[R]] [\f[B]--interactive\f[R]] [\f[B]--no-prompt\f[R]]
|
||||
[\f[B]--extended-register\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
|
||||
@@ -47,13 +46,13 @@ Arithmetic operations pop arguments off of the stack and push the
|
||||
results.
|
||||
.PP
|
||||
If no files are given on the command-line as extra arguments (i.e., not
|
||||
as \f[B]-f\f[R] or \f[B]\[en]file\f[R] arguments), then dc(1) reads from
|
||||
as \f[B]-f\f[R] or \f[B]--file\f[R] arguments), then dc(1) reads from
|
||||
\f[B]stdin\f[R].
|
||||
Otherwise, those files are processed, and dc(1) will then exit.
|
||||
.PP
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where \f[B]-e\f[R] (\f[B]\[en]expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]\[en]file\f[R]) arguments cause dc(1) to execute them
|
||||
implementations, where \f[B]-e\f[R] (\f[B]--expression\f[R]) and
|
||||
\f[B]-f\f[R] (\f[B]--file\f[R]) arguments cause dc(1) to execute them
|
||||
and exit.
|
||||
The reason for this is that this dc(1) allows users to set arguments in
|
||||
the environment variable \f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT
|
||||
@@ -72,13 +71,13 @@ argument or define the environment variable \f[B]DC_EXPR_EXIT\f[R].
|
||||
.PP
|
||||
The following are the options that dc(1) accepts.
|
||||
.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]-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.
|
||||
.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
|
||||
@@ -86,14 +85,14 @@ Forces interactive mode.
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.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]-x\f[R] \f[B]\[en]extended-register\f[R]
|
||||
\f[B]-x\f[R] \f[B]--extended-register\f[R]
|
||||
Enables extended register mode.
|
||||
See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
\f[B]REGISTERS\f[R] section for more information.
|
||||
@@ -102,7 +101,7 @@ See the \f[I]Extended Register Mode\f[R] subsection of the
|
||||
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
|
||||
@@ -111,26 +110,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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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], whether on the command-line or in
|
||||
\f[B]DC_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, dc(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, dc(1) will exit, unless
|
||||
If this option is given on the command-line (i.e., not in
|
||||
\f[B]DC_ENV_ARGS\f[R], see the \f[B]ENVIRONMENT VARIABLES\f[R] section),
|
||||
then after processing all expressions and files, dc(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].
|
||||
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, dc(1) will give a fatal error and
|
||||
exit.
|
||||
.PP
|
||||
This is a \f[B]non-portable extension\f[R].
|
||||
.RE
|
||||
@@ -139,6 +148,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 dc(1) implementations, this dc(1) will
|
||||
issue a fatal error (see the \f[B]EXIT STATUS\f[R] section) if it cannot
|
||||
@@ -230,7 +242,7 @@ guaranteed to \f[B]NOT\f[R] be cryptographically secure.
|
||||
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
|
||||
This means that the pseudo-random values from dc(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.
|
||||
@@ -1019,7 +1031,7 @@ Unlike most other dc(1) implentations, this dc(1) provides nearly
|
||||
unlimited amounts of registers, if extended register mode is enabled.
|
||||
.PP
|
||||
If extended register mode is enabled (\f[B]-x\f[R] or
|
||||
\f[B]\[en]extended-register\f[R] command-line arguments are given), then
|
||||
\f[B]--extended-register\f[R] command-line arguments are given), then
|
||||
normal single character registers are used \f[I]unless\f[R] the
|
||||
character immediately following a command that needs a register name is
|
||||
a space (according to \f[B]isspace()\f[R]) and not a newline
|
||||
@@ -1159,7 +1171,7 @@ will be correctly parsed, but the string \f[B]\[lq]/home/gavin/some
|
||||
The quote parsing will handle either kind of quotes, \f[B]\[cq]\f[R] or
|
||||
\f[B]\[lq]\f[R]. Thus, if you have a file with any number of single
|
||||
quotes in the name, you can use double quotes as the outside quotes, as
|
||||
in \f[B]\[rq]some `bc' file.bc\[dq]\f[R], and vice versa if you have a
|
||||
in \f[B]\[rq]some `dc' file.dc\[dq]\f[R], and vice versa if you have a
|
||||
file with double quotes.
|
||||
However, handling a file with both kinds of quotes in
|
||||
\f[B]DC_ENV_ARGS\f[R] is not supported due to the complexity of the
|
||||
@@ -1242,17 +1254,17 @@ interactive mode (see the \f[B]INTERACTIVE MODE\f[R] section), since
|
||||
dc(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 dc(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
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the
|
||||
\f[B]RESET\f[R] section), and in normal execution, flushes
|
||||
|
||||
@@ -34,7 +34,7 @@ dc - arbitrary-precision decimal reverse-Polish notation calculator
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**dc** [**-hiPvVx**] [**--version**] [**--help**] [**--interactive**] [**--no-prompt**] [**--extended-register**] [**-e** *expr*] [**--expression**=*expr*...] [**-f** *file*...] [**-file**=*file*...] [*file*...]
|
||||
**dc** [**-hiPvVx**] [**-\-version**] [**-\-help**] [**-\-interactive**] [**-\-no-prompt**] [**-\-extended-register**] [**-e** *expr*] [**-\-expression**=*expr*...] [**-f** *file*...] [**-\-file**=*file*...] [*file*...]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -43,11 +43,11 @@ notation) to store numbers and results of computations. Arithmetic operations
|
||||
pop arguments off of the stack and push the results.
|
||||
|
||||
If no files are given on the command-line as extra arguments (i.e., not as
|
||||
**-f** or **--file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
**-f** or **-\-file** arguments), then dc(1) reads from **stdin**. Otherwise,
|
||||
those files are processed, and dc(1) will then exit.
|
||||
|
||||
This is different from the dc(1) on OpenBSD and possibly other dc(1)
|
||||
implementations, where **-e** (**--expression**) and **-f** (**--file**)
|
||||
implementations, where **-e** (**-\-expression**) and **-f** (**-\-file**)
|
||||
arguments cause dc(1) to execute them and exit. The reason for this is that this
|
||||
dc(1) allows users to set arguments in the environment variable **DC_ENV_ARGS**
|
||||
(see the **ENVIRONMENT VARIABLES** section). Any expressions given on the
|
||||
@@ -64,55 +64,62 @@ as the last command-line argument or define the environment variable
|
||||
|
||||
The following are the options that dc(1) accepts.
|
||||
|
||||
**-h**, **--help**
|
||||
**-h**, **-\-help**
|
||||
|
||||
: Prints a usage message and quits.
|
||||
|
||||
**-v**, **-V**, **--version**
|
||||
**-v**, **-V**, **-\-version**
|
||||
|
||||
: Print the version information (copyright header) and exit.
|
||||
|
||||
**-i**, **--interactive**
|
||||
**-i**, **-\-interactive**
|
||||
|
||||
: Forces interactive mode. (See the **INTERACTIVE MODE** section.)
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-P**, **--no-prompt**
|
||||
**-P**, **-\-no-prompt**
|
||||
|
||||
: This option is a no-op.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
**-x** **--extended-register**
|
||||
**-x** **-\-extended-register**
|
||||
|
||||
: Enables extended register mode. See the *Extended Register Mode* subsection
|
||||
of the **REGISTERS** section for more information.
|
||||
|
||||
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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(1) will exit, unless **-** (**stdin**) was given
|
||||
as an argument at least once to **-f** or **-\-file**, whether on the
|
||||
command-line or in **DC_ENV_ARGS**. However, if any other **-e**,
|
||||
**-\-expression**, **-f**, or **-\-file** arguments are given after **-f-**
|
||||
or equivalent is given, dc(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, dc(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 **DC_ENV_ARGS**,
|
||||
see the **ENVIRONMENT VARIABLES** section), then after processing all
|
||||
expressions and files, dc(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, dc(1) will give a fatal error and exit.
|
||||
|
||||
This is a **non-portable extension**.
|
||||
|
||||
@@ -120,7 +127,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 dc(1) implementations, this dc(1) will issue a fatal
|
||||
error (see the **EXIT STATUS** section) if it cannot write to **stdout**, so if
|
||||
@@ -195,7 +204,7 @@ command or the **"** command that does not get receive a value of **0** or
|
||||
**'** and **"** commands 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. This
|
||||
means that the pseudo-random values from bc(1) should only be used where a
|
||||
means that the pseudo-random values from dc(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.
|
||||
|
||||
@@ -897,7 +906,7 @@ follows any command that needs a register name. The only exception is a newline
|
||||
Unlike most other dc(1) implentations, this dc(1) provides nearly unlimited
|
||||
amounts of registers, if extended register mode is enabled.
|
||||
|
||||
If extended register mode is enabled (**-x** or **--extended-register**
|
||||
If extended register mode is enabled (**-x** or **-\-extended-register**
|
||||
command-line arguments are given), then normal single character registers are
|
||||
used *unless* the character immediately following a command that needs a
|
||||
register name is a space (according to **isspace()**) and not a newline
|
||||
@@ -1030,7 +1039,7 @@ dc(1) recognizes the following environment variables:
|
||||
|
||||
The quote parsing will handle either kind of quotes, **'** or **"**. Thus,
|
||||
if you have a file with any number of single quotes in the name, you can use
|
||||
double quotes as the outside quotes, as in **"some 'bc' file.bc"**, and vice
|
||||
double quotes as the outside quotes, as in **"some 'dc' file.dc"**, and vice
|
||||
versa if you have a file with double quotes. However, handling a file with
|
||||
both kinds of quotes in **DC_ENV_ARGS** is not supported due to the
|
||||
complexity of the parsing, though such files are still supported on the
|
||||
@@ -1106,17 +1115,17 @@ The other statuses will only be returned when dc(1) is not in interactive mode
|
||||
(see the **INTERACTIVE MODE** section), since dc(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 dc(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
|
||||
|
||||
Like bc(1), dc(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, dc(1) attempts to recover from errors (see the **RESET**
|
||||
|
||||
@@ -1 +1 @@
|
||||
.TH "BC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "BC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
@@ -1 +1 @@
|
||||
.TH "BCL" "3" "January 2021" "Gavin D. Howard" "Libraries Manual"
|
||||
.TH "BCL" "3" "March 2021" "Gavin D. Howard" "Libraries Manual"
|
||||
@@ -1 +1 @@
|
||||
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
|
||||
@@ -575,7 +575,7 @@ if [ "$run_tests" -ne 0 ]; then
|
||||
printf '\n'
|
||||
printf ' <github_release> %s release.sh RELEASE.md\\\n' "$version"
|
||||
printf ' tests/afl.py tests/radamsa.sh tests/radamsa.txt tests/randmath.py \\\n'
|
||||
printf ' tests/bc/scripts/timeconst.bc\n'
|
||||
printf ' tests/fuzzing/ tests/bc/scripts/timeconst.bc\n'
|
||||
|
||||
fi
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ static void bc_args_file(const char *file) {
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void bc_args(int argc, char *argv[]) {
|
||||
void bc_args(int argc, char *argv[], bool exit_exprs) {
|
||||
|
||||
int c;
|
||||
size_t i;
|
||||
@@ -109,6 +109,7 @@ void bc_args(int argc, char *argv[]) {
|
||||
if (vm.no_exit_exprs)
|
||||
bc_vm_verr(BC_ERR_FATAL_OPTION, "-e (--expression)");
|
||||
bc_args_exprs(opts.optarg);
|
||||
vm.exit_exprs = (exit_exprs || vm.exit_exprs);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -119,6 +120,7 @@ void bc_args(int argc, char *argv[]) {
|
||||
if (vm.no_exit_exprs)
|
||||
bc_vm_verr(BC_ERR_FATAL_OPTION, "-f (--file)");
|
||||
bc_args_file(opts.optarg);
|
||||
vm.exit_exprs = (exit_exprs || vm.exit_exprs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2138,7 +2138,7 @@ size_t bc_num_len(const BcNum *restrict n) {
|
||||
|
||||
size_t len = n->len;
|
||||
|
||||
if (BC_NUM_ZERO(n)) return 0;
|
||||
if (BC_NUM_ZERO(n)) return n->scale ? n->scale : 1;
|
||||
|
||||
if (BC_NUM_RDX_VAL(n) == len) {
|
||||
|
||||
|
||||
@@ -1440,6 +1440,8 @@ static void bc_program_printStream(BcProgram *p) {
|
||||
size_t idx = (r->t == BC_RESULT_STR) ? r->d.loc.loc : n->scale;
|
||||
bc_program_printChars(*((char**) bc_vec_item(p->strs, idx)));
|
||||
}
|
||||
|
||||
bc_vec_pop(&p->results);
|
||||
}
|
||||
|
||||
static void bc_program_nquit(BcProgram *p, uchar inst) {
|
||||
|
||||
+3
-3
@@ -315,7 +315,7 @@ static void bc_vm_envArgs(const char* const env_args_name) {
|
||||
buf = NULL;
|
||||
bc_vec_push(&vm.env_args, &buf);
|
||||
|
||||
bc_args((int) vm.env_args.len - 1, bc_vec_item(&vm.env_args, 0));
|
||||
bc_args((int) vm.env_args.len - 1, bc_vec_item(&vm.env_args, 0), false);
|
||||
}
|
||||
|
||||
static size_t bc_vm_envLen(const char *var) {
|
||||
@@ -820,7 +820,7 @@ static void bc_vm_exec(void) {
|
||||
|
||||
BC_SIG_UNLOCK;
|
||||
|
||||
if (!vm.no_exit_exprs) return;
|
||||
if (!vm.no_exit_exprs && vm.exit_exprs) return;
|
||||
}
|
||||
|
||||
for (i = 0; i < vm.files.len; ++i) {
|
||||
@@ -905,7 +905,7 @@ void bc_vm_boot(int argc, char *argv[], const char *env_len,
|
||||
#endif // BC_ENABLED
|
||||
|
||||
bc_vm_envArgs(env_args);
|
||||
bc_args(argc, argv);
|
||||
bc_args(argc, argv, true);
|
||||
|
||||
#if BC_ENABLED
|
||||
if (BC_IS_POSIX) vm.flags &= ~(BC_FLAG_G);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
length(0)
|
||||
length(0.0000)
|
||||
length(0.00000000)
|
||||
length(0.00000000000)
|
||||
length(1)
|
||||
length(12)
|
||||
length(123)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
0
|
||||
1
|
||||
4
|
||||
8
|
||||
11
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
@@ -84,6 +84,12 @@ cbrt(27)
|
||||
cbrt(-27)
|
||||
cbrt(4096)
|
||||
cbrt(-4096)
|
||||
root(0, 3)
|
||||
root(0, 4)
|
||||
root(0, 5)
|
||||
root(0.0000000000000, 3)
|
||||
root(0.0000000000000, 4)
|
||||
root(0.0000000000000, 5)
|
||||
root(16, 4)
|
||||
root(3125, 5)
|
||||
root(-3125, 5)
|
||||
|
||||
@@ -84,6 +84,12 @@
|
||||
-3.00000000000000000000
|
||||
16.00000000000000000000
|
||||
-16.00000000000000000000
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
2.00000000000000000000
|
||||
5.00000000000000000000
|
||||
-5.00000000000000000000
|
||||
|
||||
@@ -15,8 +15,9 @@ t[11] = -1.74
|
||||
t[12] = -2
|
||||
t[13] = -3.2345
|
||||
t[14] = -100
|
||||
t[15] = 0.0000000000000000
|
||||
|
||||
l = 15
|
||||
l = 16
|
||||
|
||||
a[0] = t[0]
|
||||
|
||||
@@ -30,7 +31,11 @@ l -= 1
|
||||
|
||||
for (i = 0; i < l; ++i) {
|
||||
for (j = 0; j < l; ++j) {
|
||||
print "j(", a[i], ", ", a[j], ")\n"
|
||||
print "j(", a[i]
|
||||
if (a[i] == 0 && scale(a[i]) > 0) print ".0000000000000000"
|
||||
print ", ", a[j]
|
||||
if (a[j] == 0 && scale(a[j]) > 0) print ".0000000000000000"
|
||||
print ")\n"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 1641 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user