Compare commits

...
Author SHA1 Message Date
Ed Maste 5fe9c9de03 Add UPDATING entries and bump version
Approved by:	so
2022-08-30 19:08:32 -04:00
Philip Paeps 707cecae4e contrib/tzdata: import tzdata 2022b and 2022c
Changes: https://github.com/eggert/tz/blob/2022b/NEWS
Changes: https://github.com/eggert/tz/blob/2022c/NEWS

The tzdata2022b import restored the zoneinfo/GMT link.
Don't delete it again with 'make delete-old'.

(cherry picked from commit 9f9fc6bb80)
(cherry picked from commit f5d5282cf7)
(cherry picked from commit 5f33eb7266)
(cherry picked from commit f7cb477316)

Approved by:	so
2022-08-30 19:01:22 -04:00
Mark Adler 77cd23716f zlib: Fix a bug when getting a gzip header extra field with inflate().
If the extra field was larger than the space the user provided with
inflateGetHeader(), and if multiple calls of inflate() delivered
the extra header data, then there could be a buffer overflow of the
provided space. This commit assures that provided space is not
exceeded.

(cherry picked from zlib commit eff308af425b67093bab25f80f1ae950166bece1)
(cherry picked from zlib commit 1eb7682f845ac9e9bf9ae35bbfb3bad5dacbd91d)

(cherry picked from commit dc3509f1aa)
(cherry picked from commit 2969066f73)
(cherry picked from commit 10cc2bf5f7)

Approved by:	so
Security:	CVE-2022-37434
2022-08-30 18:57:49 -04:00
Mark Johnston 9f398ead89 Add UPDATING entries and bump version.
Approved by:	so
2022-08-09 16:00:03 -04:00
Konrad Sewiłło-Jopek 70a2cf7bb2 lib9p: Remove potential buffer overwrite in l9p_puqids()
Structure l9p_f_wralk reserves at most L9P_MAX_WELEM entries
and that number actually set the maximum we can safely use.

Approved by:	so
Security:	FreeBSD-SA-22:12.lib9p
PR:		265385
Reviewed by:	markj

(cherry picked from commit 2dd83b3f05)
(cherry picked from commit c536045c51)
2022-08-09 16:00:03 -04:00
Mark Johnston dd349089ff vm_fault: Shoot down shared mappings in vm_fault_copy_entry()
As in vm_fault_cow(), it's possible, albeit rare, for multiple vm_maps
to share a shadow object.  When copying a page from a backing object
into the shadow, all mappings of the source page must therefore be
removed.  Otherwise, future operations on the object tree may detect
that the source page is fully shadowed and thus can be freed.

Approved by:	so
Security:	FreeBSD-SA-22:11.vm
Reviewed by:	alc, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35635

(cherry picked from commit 5c50e900ad)
(cherry picked from commit 3ea8c7ad90)
2022-08-09 15:59:49 -04:00
Konstantin Belousov 056ffc74a7 elf_note_prpsinfo: handle more failures from proc_getargv()
Resulting sbuf_len() from proc_getargv() might return 0 if user mangled
ps_strings enough. Also, sbuf_len() API contract is to return -1 if the
buffer overflowed. The later should not occur because get_ps_strings()
checks for catenated length, but check for this subtle detail explicitly
as well to be more resilent.

The end result is that p_comm is used in this situations.

Approved by:	so
Security:	FreeBSD-SA-22:09.elf
Reported by:	Josef 'Jeff' Sipek <[email protected]>
Reviewed by:	delphij, markj
admbugs:	988
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35391

(cherry picked from commit 00d17cf342)
(cherry picked from commit 8a44a2c644)
2022-08-09 15:59:14 -04:00
Alexander Motin 5430423b6d CAM: Keep periph_links when restoring CCB in camperiphdone().
While recovery command executed, some other commands from the periph
may complete, that may affect periph_links of this CCB.  So restoring
original CCB we must keep current periph_links as more up to date.

I've found this triggering assertions with debug kernel and suspect
some memory corruptions otherwise when spun down disk receives two
or sometimes more concurrent requests.

Approved by:	so
Security:	FreeBSD-EN-22:17.cam
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 404f001161)
(cherry picked from commit 84849cfd1d)
2022-07-25 17:09:17 -04:00
Yan Ka Chiu 277c0c4d25 pam_exec: fix segfault when authtok is null
According to pam_exec(8), the `expose_authtok` option should be ignored
when the service function is `pam_sm_setcred`. Currently `pam_exec` only
prevent prompt for anth token when `expose_authtok` is set on
`pam_sm_setcred`. This subsequently led to segfault when there isn't an
existing auth token available.

Bug reported on this: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263893

After reading https://reviews.freebsd.org/rS349556 I am not sure if the
default behaviour supposed to be simply not prompt for authentication
token, or is it to ignore the option entirely as stated in the man page.

This patch is therefore only adding an additional NULL check on the item
`pam_get_item` provide, and exit with `PAM_SYSTEM_ERR` when such item is
NULL.

Approved by:	so
Security:	FreeBSD-EN-22:19.pam_exec
MFC after:	1 week
Reviewed by:	des, khng
Differential Revision:	https://reviews.freebsd.org/D35169

(cherry picked from commit b75e0eed34)
(cherry picked from commit ea80848e1c)
2022-07-25 17:08:46 -04:00
Konstantin Belousov c864c8cf08 aio_aqueue(): avoid ucred leak on failure path
Approved by:	so
Security:	FreeBSD-SA-22:10.aio
PR:		258698

(cherry picked from commit 45c2c7c484)
(cherry picked from commit 9499d3c1e4)
2022-07-25 16:01:25 -04:00
Ed Maste d7fd130ebe Add UPDATING entries and bump version.
Approved by:	so
2022-04-05 19:33:47 -04:00
Ed Maste 9854ff0880 Assure that the number of bits for deflatePrime() is valid.
Cherry picked from zlib 4346a16853e19b45787ce933666026903fb8f3f8

Approved by:	so
Security:	FreeBSD-SA-22:08.zlib
2022-04-05 19:33:30 -04:00
Ed Maste b00046e526 zlib: Fix a bug that can crash deflate on some input when using Z_FIXED.
Cherry picked from zlib 5c44459c3b28a9bd3283aaceab7c615f8020c531:

This bug was reported by Danilo Ramos of Eideticom, Inc. It has
lain in wait 13 years before being found! The bug was introduced
in zlib 1.2.2.2, with the addition of the Z_FIXED option. That
option forces the use of fixed Huffman codes. For rare inputs with
a large number of distant matches, the pending buffer into which
the compressed data is written can overwrite the distance symbol
table which it overlays. That results in corrupted output due to
invalid distances, and can result in out-of-bound accesses,
crashing the application.

The fix here combines the distance buffer and literal/length
buffers into a single symbol buffer. Now three bytes of pending
buffer space are opened up for each literal or length/distance
pair consumed, instead of the previous two bytes. This assures
that the pending buffer cannot overwrite the symbol table, since
the maximum fixed code compressed length/distance is 31 bits, and
since there are four bytes of pending space for every three bytes
of symbol space.

Approved by:	so
Security:	CVE-2018-25032
Security:	FreeBSD-SA-22:08.zlib
2022-04-05 19:32:46 -04:00
Bjoern A. Zeeb b2b2382427 net80211: validate Mesh ID length in ieee80211_parse_beacon
Reported by:	m00nbsd working with Trend Micro Zero Day Initiative

(cherry picked from commit fb8c87b4f3)
(cherry picked from commit 72617f9246)

Approved by:	so
Security:	CVE-2022-23088
Security:	FreeBSD-SA-22:07.wifi_meshid
2022-04-05 23:27:01 +00:00
Ed Maste e724f3ce79 mpr/mps/mpt: verify cfg page ioctl lengths
*_CFG_PAGE ioctl handlers in the mpr, mps, and mpt drivers allocated a
buffer of a caller-specified size, but copied to it a fixed size header.
Add checks that the size is at least the required minimum.

Note that the device nodes are owned by root:operator with 0640
permissions so the ioctls are not available to unprivileged users.

This change includes suggestions from scottl, markj and mav.

Two of the mpt cases were reported by Lucas Leong (@_wmliang_) of
Trend Micro Zero Day Initiative; scottl reported the third case in mpt.
Same issue found in mpr and mps after discussion with imp.

Reported by:	Lucas Leong (@_wmliang_), Trend Micro Zero Day Initiative
Reviewed by:	imp, mav
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34692

(cherry picked from commit 8276c4149b)
(cherry picked from commit 0b29e1b9f9)

Approved by:	so
Security:	CVE-2022-23086
Security:	FreeBSD-SA-22:06.ioctl
2022-04-05 23:26:48 +00:00
Mark Johnston b85c68857d bhyve: validate e82545 checksum offset field
Reported by:	Mehdi Talbi, Synacktiv

(cherry picked from commit b0aa20bec5)
(cherry picked from commit 53f7220947)

Approved by:    so
Security:	CVE-2022-23087
Security:       FreeBSD-SA-22:05.bhyve
2022-04-05 23:26:02 +00:00
Vincenzo Maffione 4996f46e03 netmap: Fix TOCTOU vulnerability in nmreq_copyin
The total size of the user-provided nmreq was first computed and then
trusted during the copyin. This might lead to kernel memory corruption
and escape from jails/containers.

Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Security: CVE-2022-23084
MFC after:	3 days

(cherry picked from commit 3937299165)
(cherry picked from commit 9f600a260a)

Approved by:	so
Security:	FreeBSD-SA-22:04.netmap
2022-04-05 23:26:02 +00:00
Vincenzo Maffione 00ca345e83 netmap: Fix integer overflow in nmreq_copyin
An unsanitized field in an option could be abused, causing an integer
overflow followed by kernel memory corruption. This might be used
to escape jails/containers.

Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro
Zero Day Initiative
Security: CVE-2022-23085

(cherry picked from commit 694ea59c70)
(cherry picked from commit 9df8dd3ea3)

Approved by:	so
Security:	FreeBSD-SA-22:04.netmap
2022-04-05 23:26:02 +00:00
Mark Johnston 5b789e0c92 pf: Initialize the table entry zone limit at initialization time
The limit may later be updated by the "set limit" directive in pf.conf.
UMA does not permit a limit to be set on a zone after any items have
been allocated from a zone.

Other UMA zones used by pf do not appear to be susceptible to this
problem: they either set a limit at zone creation time or never set one
at all.

PR:		260406
Reviewed by:	kp
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 7d1ab86691)
(cherry picked from commit 1487f84223)

Approved by:	so
Security:	FreeBSD-EN-22:15.pf
2022-04-05 23:26:02 +00:00
Gordon Tetlow 312522780e Add UPDATING entries and bump version.
Approved by:	so
2022-03-22 09:25:42 -07:00
Philip Paeps 42f2f9f09c contrib/tzdata: import tzdata 2022a
Merge commit '971fa603f2bdf16273135a00ff16c5585520c53f'

Changes: https://github.com/eggert/tz/blob/2022a/NEWS

With this merge, we return to our previous long-standing practice of
distributing the IANA Time Zone Database unmodified.

Releases of tzdb since 2021b have merged some time zones where clocks
have agreed since 1970.  The overwhelming majority of users will not be
affected by this change.  A port of the newly created global-tz fork of
the IANA Time Zone database (misc/global-tz) is available for users who
need more granular pre-1970 time zone history.

Approved by:	so
Security:	FreeBSD-EN-22:14.tzdata

(cherry picked from commit 8ea5af2b77)
(cherry picked from commit 5dbd160076)
2022-03-22 15:54:07 +00:00
Gordon Tetlow 3324a4bc8d Add UPDATING entry and bump version.
Approved by:	so
2022-03-21 21:51:59 -07:00
Brian Behlendorf b8ae329db9 Restore dirty dnode detection logic
In addition to flushing memory mapped regions when checking holes,
commit de198f2d95 modified the dirty dnode detection logic to check
the dn->dn_dirty_records instead of the dn->dn_dirty_link.  Relying
on the dirty record has not be reliable, switch back to the previous
method.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue #11900
Closes #12745
(cherry picked from commit d7e640cf95)

Approved by:	so
Security:	FreeBSD-EN-22:13.zfs
2022-03-20 10:10:36 -04:00
Martin Matuška 210991b1f2 FreeBSD: fix world build after de198f2d9
The inline function vn_flush_cached_data() in vnode.h
must not be compiled when building BASE.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Signed-off-by: Martin Matuska <[email protected]>
Closes #12743
(cherry picked from commit b8dcfb2c9f)

Approved by:	so
2022-03-15 16:52:41 -04:00
Mark Johnston c3540b3a2b Add UPDATING entries and bump version
Approved by:	so
2022-03-15 14:09:52 -04:00
Brian Behlendorf f5be20afc3 Fix lseek(SEEK_DATA/SEEK_HOLE) mmap consistency
When using lseek(2) to report data/holes memory mapped regions of
the file were ignored.  This could result in incorrect results.
To handle this zfs_holey_common() was updated to asynchronously
writeback any dirty mmap(2) regions prior to reporting holes.

Additionally, while not strictly required, the dn_struct_rwlock is
now held over the dirty check to prevent the dnode structure from
changing.  This ensures that a clean dnode can't be dirtied before
the data/hole is located.  The range lock is now also taken to
ensure the call cannot race with zfs_write().

Furthermore, the code was refactored to provide a dnode_is_dirty()
helper function which checks the dnode for any dirty records to
determine its dirtiness.

Reviewed-by: Matthew Ahrens <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Rich Ercolani <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #11900
Closes #12724
(cherry picked from commit 664d487a5d)

Approved by:	so
Security:	FreeBSD-EN-22:11.zfs
2022-03-15 14:09:52 -04:00
Ryan Moeller 0abaf7f630 FreeBSD: Clean up zfsdev_close to match Linux
Resolve some oddities in zfsdev_close() which could result in a
panic and were not present in the equivalent function for Linux.

- Remove unused definition ZFS_MIN_MINOR
- FreeBSD: Simplify zfsdev state destruction
- Assert zs_minor is valid in zfsdev_close
- Make locking around zfsdev state match Linux

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #11720

Approved by:	so
Security:	FreeBSD-EN-22:12.zfs
2022-03-15 14:09:52 -04:00
Mark Johnston 9dc74c5a4b Fix handling of errors from dmu_write_uio_dbuf() on FreeBSD
FreeBSD's implementation of zfs_uio_fault_move() returns EFAULT when a
page fault occurs while copying data in or out of user buffers.  The VFS
treats such errors specially and will retry the I/O operation (which may
have made some partial progress).

When the FreeBSD and Linux implementations of zfs_write() were merged,
the handling of errors from dmu_write_uio_dbuf() changed such that
EFAULT is not handled as a partial write.  For example, when appending
to a file, the z_size field of the znode is not updated after a partial
write resulting in EFAULT.

Restore the old handling of errors from dmu_write_uio_dbuf() to fix
this.  This should have no impact on Linux, which has special handling
for EFAULT already.

Reviewed-by: Andriy Gapon <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Mark Johnston <[email protected]>
Closes #12964
(cherry picked from commit 063daa8350)
(cherry picked from commit b55a7f3422)

Approved by:	so
Security:	FreeBSD-EN-22:10.zfs
2022-03-15 14:09:52 -04:00
Bjoern A. Zeeb 0d1db5c325 net80211: correct length check in ieee80211_ies_expand()
In ieee80211_ies_expand() we are looping over Elements
(also known as Information Elements or IEs).
The comment suggests that we assume well-formedness of
the IEs themselves.
Checking the buffer length being least 2 (1 byte Element ID and
1 byte Length fields) rather than just 1 before accessing ie[1]
is still good practise and can prevent and out-of-bounds read in
case the input is not behaving according to the comment.

Reported by:	(coypu sdf.org)
admbugs:	857

(cherry picked from commit 09dd08f167)
(cherry picked from commit 32c2c00e3f)

Approved by:	so
Security:	FreeBSD-SA-22:02.wifi
2022-03-15 13:45:36 -04:00
Bjoern A. Zeeb 6eb932a969 net80211: proper ssid length check in setmlme_assoc_adhoc()
A user supplied SSID length is used without proper checks in
setmlme_assoc_adhoc() which can lead to copies beyond the end
of the user supplied buffer.
The ssid is a fixed size array for the ioctl and the argument
to setmlme_assoc_adhoc().
In addition to an ssid_len check of 0 also error in case the
ssid_len is larger than the size of the ssid array to prevent
problems.

PR:		254737
Reported by:	Tommaso (cutesmilee.research protonmail.com)

(cherry picked from commit 526370fb85)
(cherry picked from commit 0525ece355)
(cherry picked from commit ab5678c6c0)

Approved by:	so
Security:	FreeBSD-SA-22:02.wifi
2022-03-15 13:45:27 -04:00
Mathy Vanhoef cbfb77f195 net80211: prevent plaintext injection by A-MSDU RFC1042/EAPOL frames
No longer accept plaintext A-MSDU frames that start with an RFC1042
header with EtherType EAPOL.  This is done by only accepting EAPOL
packets that are included in non-aggregated 802.11 frames.

Note that before this patch, FreeBSD also only accepted EAPOL frames
that are sent in a non-aggregated 802.11 frame due to bugs in
processing EAPOL packets inside A-MSDUs. In other words,
compatibility with legitimate devices remains the same.

This relates to section 6.5 in the 2021 Usenix "FragAttacks" (Fragment
and Forge: Breaking Wi-Fi Through Frame Aggregation and Fragmentation)
paper.

Submitted by:	Mathy Vanhoef (Mathy.Vanhoef kuleuven.be)
Security:	CVE-2020-26144
PR:		256120

(cherry picked from commit ffc19cf52d)
(cherry picked from commit 8b2ba742cc)

Approved by:	so
Security:	FreeBSD-SA-22:02.wifi
2022-03-15 13:45:19 -04:00
Mathy Vanhoef 7ba07a1452 net80211: mitigation against A-MSDU design flaw
Mitigate A-MSDU injection attacks by detecting if the destination address
of a subframe equals an RFC1042 (i.e., LLC/SNAP) header, and if so
dropping the complete A-MSDU frame.  This mitigates known attacks,
although new (unknown) aggregation-based attacks may remain possible.

This defense works because in A-MSDU aggregation injection attacks, a
normal encrypted Wi-Fi frame is turned into an A-MSDU frame. This means
the first 6 bytes of the first A-MSDU subframe correspond to an RFC1042
header. In other words, the destination MAC address of the first A-MSDU
subframe contains the start of an RFC1042 header during an aggregation
attack. We can detect this and thereby prevent this specific attack.

This relates to section 7.2 in the 2021 Usenix "FragAttacks" (Fragment
and Forge: Breaking Wi-Fi Through Frame Aggregation and Fragmentation)
paper.

Submitted by:	Mathy Vanhoef (Mathy.Vanhoef kuleuven.be)
Security:	CVE-2020-24588
PR:		256119

(cherry picked from commit f024bdf115)
(cherry picked from commit 41ca1d50a8)

Approved by:	so
Security:	FreeBSD-SA-22:02.wifi
2022-03-15 13:45:11 -04:00
Mathy Vanhoef cf15ab553d net80211: reject mixed plaintext/encrypted fragments
ieee80211_defrag() accepts fragmented 802.11 frames in a protected Wi-Fi
network even when some of the fragments are not encrypted.
Track whether the fragments are encrypted or not and only accept
successive ones if they match the state of the first fragment.

This relates to section 6.3 in the 2021 Usenix "FragAttacks" (Fragment
and Forge: Breaking Wi-Fi Through Frame Aggregation and Fragmentation)
paper.

Submitted by:	Mathy Vanhoef (Mathy.Vanhoef kuleuven.be)
Security:	CVE-2020-26147
PR:		256118

(cherry picked from commit 11572d7d7f)
(cherry picked from commit e13d483c56)

Approved by:	so
Security:	FreeBSD-SA-22:02.wifi
2022-03-15 13:43:54 -04:00
Gordon Tetlow 3847c17aa2 Fix a bug in BN_mod_sqrt() that can cause it to loop forever.
Obtained from:	OpenSSL Project
Security:	CVE-2022-0778
Security:	FreeBSD-SA-22:03.openssl

(cherry picked from commit fdc418f15e)
(cherry picked from commit 5f3d952f6e)

Approved by:	so
2022-03-15 13:43:02 -04:00
Gordon Tetlow e5733e6d90 Add UPDATING entries and bump version.
Approved by:	so
2022-02-01 09:44:31 -08:00
Konstantin Belousov f151464add amd64: disable LA57 by default for now
(cherry picked from commit 72a42ec63b)
(cherry picked from commit df6241fcef)

Approved by:	so
Security:	FreeBSD-EN-22:07.la57
2022-02-01 09:43:46 -08:00
Ed Maste b0c8bc5d9c Add UPDATING entries and bump version
Approved by:	so
2022-01-11 12:51:57 -05:00
Ed Maste 3e0a1e1241 vt: bound buffer access in redraw optimization
PR:		248628
Reported by:	oleg
Reviewed by:	cem, oleg (both earlier)
Fixes:		ee97b2336a ("Speed up vt(4) by keeping...")
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32059

(cherry picked from commit dbc7ca5945)
(cherry picked from commit e4fcff8ee1)

Approved by:	so
Security:	FreeBSD-SA-22:01.vt
2022-01-10 09:51:54 -05:00
Maxim Sobolev 4378aee9f8 Fix fragmented UDP packets handling since rev.360967.
Consider IP_MF flag when checking length of the UDP packet to
match the declared value.

Sponsored by:	Sippy Software, Inc.
Differential Revision:	https://reviews.freebsd.org/D32363
MFC after:	2 weeks

(cherry picked from commit 461e6f23db)
(cherry picked from commit 73c5a2566d)

Approved by:	so
Sponsored by:	The FreeBSD Foundation [rework for 13.0]
Errata:		FreeBSD-EN-22:06.libalias
2022-01-10 09:51:54 -05:00
Chuck Silvers 60cacd2e41 tail: fix "tail -F" file rotation detection
When checking if the newly opened file is the same as the old one,
we need to fstat() the new file descriptor, not the old one again.

Reviewed by:	glebius
Sponsored by:	Netflix

(cherry picked from commit 7787e7eed9)
(cherry picked from commit 8c59e863e2)

Approved by:	so
Errata:		FreeBSD-EN-22:05.tail
2022-01-10 09:51:54 -05:00
Wei Hu dfca965af4 Hyper-V: vPCI: Prepopulate device bars
In recent Hyper-V releases on Windows Server 2022, vPCI code does not
initialize the last 4 bit of device bar registers. This behavior change
could result weird problems cuasing PCI code failure when configuring
bars.

Just write all 1's to those bars whose probed values are not the same
as current read ones. This seems to make Hyper-V vPCI and
pci_write_bar() to cooperate correctly on these releases.

Reported by:	[email protected]
Tested by:	[email protected]
MFC after:	2 weeks
Sponsored by:	Microsoft

(cherry picked from commit 75412a521f)
(cherry picked from commit d11e9de955)

Approved by:	so
Errata:		FreeBSD-EN-22:03.hyperv
2022-01-10 09:51:54 -05:00
Konstantin Belousov f2caded7f5 amd64: correct size of the SSE area in the xsave layout
(cherry picked from commit 73b357be92)
(cherry picked from commit 1d6ebddb62)

Approved by:	so
Errata:		FreeBSD-EN-22:02.xsave
2022-01-10 09:51:54 -05:00
Kirk McKusick 3286a8dc83 fsck_ffs: fix bad inode number errors
Fix fsck_ffs Pass 1b error exit "bad inode number 2 to nextinode".

(cherry picked from commit bc444e2ec6)
(cherry picked from commit fab7c18ce3)

Fix fsck_ffs Pass 1b error exit "bad inode number 256 to nextinode".

(cherry picked from commit fe815b88b5)

PR:           255979
Sponsored by: Netflix

(cherry picked from commit e198c1dc8f)

Approved by:	so
Errata:		FreeBSD-EN-22:01.fsck_ffs
2022-01-10 09:51:48 -05:00
Ed Maste 3d81b7e211 Fix Cirrus-CI boot smoke test
We now use compute_engine_instance which allows us to specify a custom
disk size.  Also go back to using the default qemu version (rather than
qemu42 or qemu-devel) as any issues were fixed some time ago.

Reviewed by:	lwhsu, markj
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30082

(cherry picked from commit a7d593dd1d)
(cherry picked from commit 982cd96206)
(cherry picked from commit 407abff2b9)
(cherry picked from commit 87c0db9d01)
(cherry picked from commit cec2682cd2)
(cherry picked from commit 088dbb4b8d)

Note that this does not have any effect on built artifacts (and thus is
not an EN candidate) but allows Cirrus-CI to be used on the releng
branch.

Approved by:	so
2022-01-10 09:48:00 -05:00
Emmanuel Vadot 68cda3edb6 rtld: Do not install libmap.conf when installing the COMPAT32 version
This has the effect of installing the same file twice at the same location
and confuse pkgbase as we add this file twice in the package config part.

Approved by:	so (markj@)
MFC after:  1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit d0f0e0bd74)
2022-01-10 09:16:36 +01:00
Gordon Tetlow 2646dd6659 Add UPDATING entries and bump version.
Approved by:    so
2021-11-03 13:53:11 -07:00
Gordon Tetlow 11754a6111 Timezone database information update.
Approved by:	so
Security:	EN-21:29.tzdata
2021-11-03 13:44:52 -07:00
Gordon Tetlow 847819dca1 Fix kernel panic in vmci driver initialization.
Approved by:	so
Security:	EN-21:28.vmci
2021-11-03 13:40:19 -07:00
Gordon Tetlow b76aaa3542 Root certificate bundle update.
Approved by:	so
Security:	EN-21:27.caroot
2021-11-03 13:37:26 -07:00
Gordon Tetlow 5cd45ad478 Fix libevent1 ABI breakage.
Approved by:	so
Security:	EN-21:26.libevent
2021-11-03 13:37:22 -07:00
Gordon Tetlow 940681634e Add UPDATING entries and bump version.
Approved by:	so
2021-08-24 11:23:29 -07:00
Gordon Tetlow 2261c814b7 Fix multiple OpenSSL vulnerabilities.
Approved by:    so
Security:       SA-21:16.openssl
Security:       CVE-2021-3711
Security:       CVE-2021-3712
2021-08-24 11:08:04 -07:00
Gordon Tetlow 060510ba8b Fix libfetch out of bounds read.
Approved by:	so
Security:	SA-21:15.libfetch
Security:	CVE-2021-36159
2021-08-24 11:00:47 -07:00
Gordon Tetlow c8a2cc4ba8 Fix remote code execution in ggatec(8).
Approved by:	so
Security:	SA-21:14.ggatec
Security:	CVE-2021-29630
2021-08-24 10:37:45 -07:00
Gordon Tetlow ec08bc89d4 Fix missing error handling in bhyve(8) device models.
Approved by:	so
Security:	SA-21:13.bhyve
Security:	CVE-2021-29631
2021-08-24 10:33:35 -07:00
Gordon Tetlow 4f590ee3ed Fix NVMe iovec construction for large IOs.
Approved by:	so
Security:	EN-21:25.bhyve
2021-08-24 10:28:07 -07:00
Gordon Tetlow 3ef67fed44 Fix OpenSSL 1.1.1e API functions not being exported.
Approved by:	so
Security:	EN-21:24.libcrypto
2021-08-24 10:25:47 -07:00
Gordon Tetlow f66e348099 Fix virtio_blk(4) failing to attach on some hypervisors.
Approved by:	so
Security:	EN-21:23.virtio_blk
2021-08-24 09:36:55 -07:00
Mark Johnston b368bb75ba Add UPDATING entries and bump version
Approved by:	so
2021-06-29 16:06:47 -04:00
Dmitry Chagin d1fffaed23 linux(4): Prevent integer overflow in futex_requeue.
To prevent a signed integer overflow in futex_requeue add a sanity check
to catch negative values of nrwake or nrrequeue.

Approved by:	so
Security:	EN-21:22.linux_futex

(cherry picked from commit 25b09d6f39)
(cherry picked from commit 7a37d13b6c)
2021-06-29 16:06:09 -04:00
Mark Johnston 4647d115ff ipfw: Update the pfil mbuf pointer in ipfw_check_frame()
ipfw_chk() might call m_pullup() and thus can change the mbuf chain
head.  In this case, the new chain head has to be returned to the pfil
hook caller, otherwise the pfil hook caller is left with a dangling
pointer.

Note that this affects only the link-layer hooks installed when the
net.link.ether.ipfw sysctl is set to 1.

Approved by:	so
Security:	EN-21:21.ipfw
PR:		256439, 254015, 255069, 255104
Fixes:		f355cb3e6
Reviewed by:	ae
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit bc6a2267ff)
(cherry picked from commit ed1acef3fe)
2021-06-29 13:09:43 -04:00
Alexander V. Chernikov 78f91c1fbf Fix vlan creation for the older ifconfig(8) binaries.
Approved by:	so
Security:	EN-21:20.vlan
Reported by:	allanjude
MFC after:	immediately

(cherry picked from commit afbb64f1d8)
(cherry picked from commit 9abc85d17d)
2021-06-29 13:09:25 -04:00
Mariusz Zaborski ba5ed8109c libcasper: fix descriptors numbers
Casper services expect that the first 3 descriptors (stdin/stdout/stderr)
will point to /dev/null. Which Casper will ensure later. The Casper
services are forked from the original process. If the initial process
closes one of those descriptors, Casper may reuse one of them for it on
purpose. If this is the case, then renumarate the descriptors used by
Casper to higher numbers. This is done already after the fork, so it
doesn't break the parent process.

Approved by:	so
Security:	EN-21:19.libcasper
PR:		255339
Reported by:	Borja Marcos <borjam (at) sarenet.es>
Tested by:	jkim@

(cherry picked from commit aa310ebfba)
(cherry picked from commit 934e10b4a3)
2021-06-29 13:09:02 -04:00
Dimitry Andric dac086497e Add C++ headers <barrier> <concepts> <execution> <latch> <numbers> <semaphore>
I missed adding these to the libc++ Makefile, when importing
llvm-project 11.0.0-rc1, even though they were supplied by upstream.

While here, update OptionalObsoleteFiles.inc to add these new headers,
and cleanup old cruft.

Approved by:	so
Security:	EN-21:18.libc++
Reported by:	yuri
Submitted by:	jkim (Makefile diff)
PR:		255374
MFC after:	3 days

(cherry picked from commit 95aa617e4b)
(cherry picked from commit 70e13c4cff)
2021-06-29 13:08:58 -04:00
Mark Johnston b74cdf1ece Add UPDATING entries and bump version
Approved by:	so
2021-06-01 16:28:18 -04:00
Mark Johnston 8acc450613 libradius: Fix attribute length validation in rad_get_attr(3)
The length of the attribute header needs to be excluded when comparing
the attribute length against the length of the packet.  Otherwise,
validation may incorrectly fail when fetching the final attribute in a
message.

Approved by:	so
Security:	FreeBSD-EN-21:17.libradius
Fixes:		8d5c78130 ("libradius: Fix input validation bugs")
Reported by:	Peter Eriksson
Tested by:	Peter Eriksson
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6bb5699d2b)
(cherry picked from commit f997253234)
2021-06-01 16:26:32 -04:00
Mark Johnston 8023e729a5 Add UPDATING entries and bump version
Approved by:	so
2021-05-26 16:36:52 -04:00
Mark Johnston 7d900abe62 libradius: Fix input validation bugs
Approved by:	so
Security:	FreeBSD-SA-21:12.libradius
Security:	CVE-2021-29629
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8d5c781306)
(cherry picked from commit bec0d2c9c8)
2021-05-26 16:36:29 -04:00
Mark Johnston 312510880e bc: Fix stack handling in the "P" command implementation
Approved by:	so
Security:	EN-21:16.bc
Submitted by:	se
2021-05-26 16:32:40 -04:00
Ka Ho Ng 61acb3179a virtio_pci_legacy: Allow memory space for configuration
For guests running under some kind of VMMs, configuration structure is
available in memory space but not I/O space.

Approved by:	so
Security:	EN-21:15.virtio
Reported by:	Yuan Rui <[email protected]>
Reviewed by:	rpokala, bryanv, jhb
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D28818

(cherry picked from commit cf5d111240)
(cherry picked from commit 2e107638ea)
2021-05-26 16:32:40 -04:00
Ka Ho Ng 6fe25201ea virtio_pci_legacy: Use the table BAR and PBA BAR from MSI-X cap
The MSI-X resource shouldn't be assumed to be always on BAR1.
The Virtio v1.1 Spec did not specify that MSI-X table and PBA BAR has to
be BAR1 either.

Approved by:	so
Security:	EN-21:15.virtio
Reported by:	Yuan Rui <[email protected]>
Reviewed by:	bryanv, jhb
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D28817

(cherry picked from commit faf9a4e914)
(cherry picked from commit 98740ead97)
2021-05-26 16:32:40 -04:00
Konstantin Belousov f32130a195 amd64/linux*: add required header to get the constant value
Otherwise asm silently interpret it as the external global symbol.

Approved by:	so
Security:	FreeBSD-SA-21:11.smap
Security:	CVE-2021-29628
Reported by:	bz
Sponsored by:	The FreeBSD Foundation
Fixes:	91aae953cb

(cherry picked from commit a59f028537)
(cherry picked from commit 876ffe2879)
2021-05-26 15:31:50 -04:00
Konstantin Belousov c690965773 amd64: clear PSL.AC in the right frame
If copyin family of routines fault, kernel does clear PSL.AC on the
fault entry, but the AC flag of the faulted frame is kept intact.  Since
onfault handler is effectively jump, AC survives until syscall exit.

Approved by:	so
Security:	FreeBSD-SA-21:11.smap
Security:	CVE-2021-29628
Reported by:	m00nbsd, via Sony
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
admbugs:	975

(cherry picked from commit 91aae953cb)
(cherry picked from commit 6bbde34ae6)
2021-05-26 15:31:22 -04:00
Mark Johnston 22b58630d6 divert: Fix mbuf ownership confusion in div_output()
div_output_outbound() and div_output_inbound() relied on the caller to
free the mbuf if an error occurred.  However, this is contrary to the
semantics of their callees, ip_output(), ip6_output() and
netisr_queue_src(), which always consume the mbuf.  So, if one of these
functions returned an error, that would get propagated up to
div_output(), resulting in a double free.

Fix the problem by making div_output_outbound() and div_output_inbound()
responsible for freeing the mbuf in all cases.

Approved by:	so
Security:	EN-21:12.divert
Reported by:	Michael Schmiedgen <[email protected]>
Tested by:	Michael Schmiedgen
Reviewed by:	donner
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30129

(cherry picked from commit a1fadf7de2)
(cherry picked from commit eafeee082c)
2021-05-26 15:30:51 -04:00
Alexander Motin b62d492067 pms(4): Limit maximum I/O size to 256KB instead of 1MB.
There is a weird limit of AGTIAPI_MAX_DMA_SEGS (128) S/G segments per
I/O since the initial driver import.  I don't know why it was added,
can only guess some hardware limitation, but in worst case it means
maximum I/O size of 508KB.  Respect it to be safe, rounding to 256KB.

Approved by:	so
Security:	EN-21:14.pms
MFC after:	1 week
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 3e34783420)
(cherry picked from commit 6514cb18d9)
2021-05-26 15:30:23 -04:00
Alexander Motin fc7402d50d pms(4): Do not return CAM_REQ_CMP on errors.
It is a direct request for data corruptions, one report of which we
have received.  I am very surprised that only one.

Approved by:	so
Security:	EN-21:14.pms
MFC after:	1 week
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 8434a65ce4)
(cherry picked from commit 4bc708e1e8)
2021-05-26 15:30:13 -04:00
Alexander Motin a8a91efa74 mpt(4): Remove incorrect S/G segments limits.
First, two of those four checks are unreachable.
Second, I don't believe there should be ">=" instead of ">".
Third, bus_dma(9) already returns the same EFBIG if ">".

This fixes false I/O errors in worst S/G cases with maxphys >= 2MB.

Approved by:	so
Security:	EN-21:13.mpt
MFC after:	1 week

(cherry picked from commit 0f29396e49)
(cherry picked from commit f0077b4c1d)
2021-05-26 15:29:54 -04:00
Glen Barber ea31abc261 13.0: update to RELEASE
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-04-08 20:14:30 -04:00
Glen Barber 5003c6014c 13.0/UPDATING: anticipate 13.0-RELEASE date
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-04-08 20:13:47 -04:00
Glen Barber df7114e92e 13.0: set static __FreeBSD_version
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-04-08 20:12:37 -04:00
Mark Johnston 273977acb0 Add UPDATING entries and bump version
Approved by:	re (implicit, so)
Approved by:	so
2021-04-06 15:19:09 -04:00
Mark Johnston 4710439ec5 mount: Disallow mounting over a jail root
Discussed with:	jamie
Approved by:	re (so, implicit)
Approved by:	so
Security:	CVE-2020-25584
Security:	FreeBSD-SA-21:10.jail_mount

(cherry picked from commit 2425f5e912)
(cherry picked from commit 3ae17faa37)
2021-04-06 15:18:59 -04:00
Mark Johnston 724bc23da1 vm_fault: Shoot down multiply mapped COW source page mappings
Reviewed by:	kib, rlibby
Discussed with:	alc
Approved by:	re (so, implicit)
Approved by:	so
Security:	CVE-2021-29626
Security:	FreeBSD-SA-21:08.vm

(cherry picked from commit 982693bb72)
(cherry picked from commit 2e08308d62)
2021-04-06 15:18:49 -04:00
Glen Barber f8a134d0ef 13.0: update to RC5
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-04-01 20:26:03 -04:00
Alexander V. Chernikov 0e7f02a1a9 Zero struct weightened_nhop fields in nhgrp_get_addition_group().
`struct weightened_nhop` has spare 32bit between the fields due to
 the alignment (on amd64).
Not zeroing these spare bits results in duplicating nhop groups
 in the kernel due to the way how comparison works.

Approved by:	re (gjb)

(cherry picked from commit 6f43c72b47)
2021-03-31 20:00:10 +00:00
Alexander V. Chernikov b7fbdb5042 Fix nexhtop group index array scaling.
The current code has the limit of 127 nexthop groups due to the
 wrongly-checked bitmask_copy() return value.

PR: 254303
Reported by:	Aleks <a.ivanov at veesp.com>
Approved by:	re (gjb)

(cherry picked from commit 923e7f7e12)
2021-03-31 20:00:10 +00:00
Jonathan T. Looney 40d278253d Fetch the sigfastblock value in syscalls that wait for signals
We have seen several cases of processes which have become "stuck" in
kern_sigsuspend(). When this occurs, the kernel's td_sigblock_val
is set to 0x10 (one block outstanding) and the userspace copy of the
word is set to 0 (unblocked). Because the kernel's cached value
shows that signals are blocked, kern_sigsuspend() blocks almost all
signals, which means the process hangs indefinitely in sigsuspend().

It is not entirely clear what is causing this condition to occur.
However, it seems to make sense to add some protection against this
case by fetching the latest sigfastblock value from userspace for
syscalls which will sleep waiting for signals. Here, the change is
applied to kern_sigsuspend() and kern_sigtimedwait().

Approved by:	re (gjb)

(cherry picked from commit dbec10e088)
(cherry picked from commit a25c17022e)
2021-03-31 19:55:24 +00:00
Robert Watson 6605a2a163 Teach DTrace that unaligned accesses are OK on aarch64, not just x86.
Reviewed by:	andrew
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D29369

(cherry picked from commit fb581531c1)
(cherry picked from commit ba08ba5226)
2021-03-31 12:05:26 -04:00
Robert Watson 7745d71597 Tune DTrace 'aframes' for the FBT and profile providers on arm64.
In both cases, too few frames were trimmed, leading to exception handling
or DTrace internals being exposed in stack traces exposed by D's stack()
primitive.

Reviewed by:	emaste, andrew
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D29356

(cherry picked from commit 599fb1d198)
(cherry picked from commit fcc700abe4)
2021-03-31 12:03:53 -04:00
Ed Maste 42d99e4efa arm64: implement COMPAT_FREEBSD32 fill/set dbregs/fpregs
On FreeBSD/arm fill_fpregs, fill_dbregs are stubs that zero the reg
struct and return success. set_fpregs and set_dbregs do nothing and
return success.

Provide the same implementation for arm64 COMPAT_FREEBSD32.

Reviewed by:	andrew
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29314

(cherry picked from commit 5be27cbf16)
(cherry picked from commit db50c81234)
2021-03-31 12:01:54 -04:00
Ed Maste 407e5a8d68 mn: report that this driver is removed in 14, not 13
(cherry picked from commit a66e75d9e2)

mn: bump deprecation version to 14 in man page as well

Fixes: 66e75d9e2ddd ("mn: report that this driver is removed in 14, not 13")

(cherry picked from commit 6acecf247f)

Approved by:	re (gjb)
2021-03-31 12:00:57 -04:00
Glen Barber 2e70fcbb15 13.0: update to RC4
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-03-28 19:51:40 -04:00
Alexander V. Chernikov 411cbdb1f2 Plug nexthop group refcount leak.
In case with batch route delete via rib_walk_del(), when
 some paths from the multipath route gets deleted, old
 multipath group were not freed.

PR:    254496
Reported by:   Zhenlei Huang <[email protected]>
Approved by:	re (gjb)

(cherry picked from commit 47c00a9835)
2021-03-28 20:40:48 +00:00
Alexander V. Chernikov 3765afa4da Fix panic when destroying interface with ECMP routes.
Reported by:	Zhenlei Huang <zlei.huang at gmail.com>
PR:		254496
Approved by:	re (gjb)

(cherry picked from commit af85312e8a)
2021-03-28 20:40:48 +00:00
Alexander V. Chernikov 589d5d28a8 Fix kassert panic when inserting multipath routes from multiple threads.
Reported by:	Marco Zec <zec at fer.hr>
Approved by:	re (gjb)

(cherry picked from commit 42f997d9b7)
2021-03-28 20:40:48 +00:00
Alexander V. Chernikov 6f4f8a441a Flush remaining routes from the routing table during VNET shutdown.
Summary:
This fixes rtentry leak for the cloned interfaces created inside the
 VNET.

Loopback teardown order is `SI_SUB_INIT_IF`, which happens after `SI_SUB_PROTO_DOMAIN` (route table teardown).
Thus, any route table operations are too late to schedule.
As the intent of the vnet teardown procedures to minimise the amount of effort by doing global cleanups instead of per-interface ones, address this by adding a relatively light-weight routing table cleanup function, `rib_flush_routes()`.
It removes all remaining routes from the routing table and schedules the deletion, which will happen later, when `rtables_destroy()` waits for the current epoch to finish.

Test Plan:
```
set_skip:set_skip_group_lo  ->  passed  [0.053s]
tail -n 200 /var/log/messages | grep rtentry
```

PR:		253998
Reported by:	rashey at superbox.pl
Reviewed By:	kp
Approved by:	re (gjb)
Differential Revision: https://reviews.freebsd.org/D29116

(cherry picked from commit 8aafa7a027)
2021-03-28 20:40:48 +00:00
Alexander V. Chernikov 367fcd5bce Fix blackhole/reject routes.
Traditionally *BSD routing stack required to supply some
 interface data for blackhole/reject routes. This lead to
 varieties of hacks in routing daemons when inserting such routes.
With the recent routeing stack changes, gateway sockaddr without
 RTF_GATEWAY started to be treated differently, purely as link
 identifier.

This change broke net/bird, which installs blackhole routes with
 127.0.0.1 gateway without RTF_GATEWAY flags.

Fix this by automatically constructing necessary gateway data at
 rtsock level if RTF_REJECT/RTF_BLACKHOLE is set.

Reported by:	Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Reviewed by:	donner
Approved by:	re (gjb)

(cherry picked from commit 3489286a5f)
2021-03-28 20:40:48 +00:00
Emmanuel Vadot d6616e3dba release: amd64: Fix ISO/USB hybrid image
Recent mkimg changes forces to have partitions given in explicit order.
This is so we can have the first partition starting at a specific offset
and the next ones starting after without having to specify an offset.
Switch the partition in the mkisoimage.sh script so the first one created
is the isoboot one.

Approved by:	re(gjb)
PR:    254490
Reported by:	Michael Dexter <[email protected]
Tested by:	Vincent Milum Jr <[email protected]>
MFC after:	Right now

(cherry picked from commit 90d2f7c413)
(cherry picked from commit 08639983e0)
2021-03-28 20:54:28 +02:00
Glen Barber b56440b343 Makefile.inc1: unbreak bootstrap when kbdcontrol does not exist
Approved by:		re (cperciva)
Submitted by:		Evgeniy Khramtsov
Reviewed by:		arichardson
Sponsored by:		Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 50179c5ec7)
(cherry picked from commit 1048c56784)
2021-03-28 14:27:29 -04:00
Mark Johnston af6611e5ad accept_filter: Fix filter parameter handling
For filters which implement accf_create, the setsockopt(2) handler
caches the filter name in the socket, but it also incorrectly frees the
buffer containing the copy, leaving a dangling pointer.  Note that no
accept filters provided in the base system are susceptible to this, as
they don't implement accf_create.

Approved by:	re (gjb)
Reported by:	Alexey Kulaev <[email protected]>
Discussed with:	emaste
Security:	kernel use-after-free
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 653a437c04)
(cherry picked from commit c7d10e7ec8)
2021-03-28 11:03:37 -04:00
Mark Johnston fa6d101e5f pf: Handle unmapped mbufs when computing checksums
Approved by:	re (cperciva)
PR:		254419
Reviewed by:	gallatin, kp
Tested by:	Igor A. Valkov <[email protected]>
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29378

(cherry picked from commit b93a796b06)
(cherry picked from commit 5fcab6fbcf8b99d1420e681731a07670c38defe3)
2021-03-26 12:33:12 -04:00
Gordon Tetlow c9b4e5e9ae Add UPDATING entry for OpenSSL advisory and bump version number.
Approved by:	re (implicit)
Approved by:	so
2021-03-25 23:38:52 +00:00
Mark Johnston 72280d7e57 rtsold: Fix validation of RDNSS options
The header specifies the size of the option in multiples of eight bytes.
The option consists of an eight-byte header followed by one or more IPv6
addresses, so the option is invalid if the size is not equal to 1+2n for
some n>0.  Check this.

The bug can cause random stack data to be formatted as an IPv6 address
and passed to resolvconf(8), but a host able to trigger the bug may also
specify arbitrary addresses this way.

Approved by:	re (cperciva)
Reported by:	Q C <[email protected]>
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1af332a7d8)
(cherry picked from commit e4bdf7ac2a)
2021-03-25 14:37:45 -04:00
Jung-uk Kim 1f84105d7a OpenSSL: Regen manual pages for 1.1.1k
(cherry picked from commit 7595394130)

Approved by:	re (implicit)
2021-03-25 12:26:08 -04:00
Jung-uk Kim 7d3f5a19f4 OpenSSL: Merge OpenSSL 1.1.1k
Merge commit '94fa08a4bcdfbb3434b025d67d014af3b18e5380'

(cherry picked from commit b6c1fdcdf5)

Approved by:	re (implicit)
2021-03-25 12:25:06 -04:00
Lawrence Stewart 2a878f01f2 random(9): Restore historical [0,2^31-1] output range and related man documention.
Commit SVN r364219 / Git 8a0edc914f changed random(9) to be a shim around
prng32(9) and inadvertently caused random(9) to begin returning numbers in the
range [0,2^32-1] instead of [0,2^31-1], where the latter has been the documented
range for decades.

The increased output range has been identified as the source of numerous bugs in
code written against the historical output range e.g. ipfw "prob" rules and
stats(3) are known to be affected, and a non-exhaustive audit of the tree
identified other random(9) consumers which are also likely affected.

As random(9) is deprecated and slated for eventual removal in 14.0, consumers
should gradually be audited and migrated to prng(9).

Submitted by:		Loic Prylli <[email protected]>
Obtained from:		Netflix
Reviewed by:		cem, delphij, imp
MFC after:		1 day
MFC to:			stable/13, releng/13.0
Differential Revision:	https://reviews.freebsd.org/D29385
Approved by:		re (delphij)

(cherry picked from commit dbbf3e3f37)
2021-03-25 18:00:55 +11:00
Dag-Erling Smørgrav 4f5b454509 MFC: Fix post-start check when unbound.conf has moved.
On behalf of:	des
Reported by:	phk@
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Approved by:	re (cperciva)

(cherry picked from commit 409388cfac)
(cherry picked from commit c6aa83342e)
2021-03-23 21:48:42 -04:00
Dag-Erling Smørgrav e011488bae MFC: Fix local-unbound setup for some IPv6 deployments.
On behalf of:	des
PR:		250984
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Approved by:	re (cperciva)

(cherry picked from commit e5f02c140b)
(cherry picked from commit 34e12e9a17)
2021-03-23 21:47:57 -04:00
Alex Richardson f979a90f42 AArch64: Don't set flush-subnormals-to-zero flag on startup
This flag has been set on startup since 65618fdda0.
However, This causes some of the math-related tests to fail as they report
zero instead of a tiny number. This fixes at least
/usr/tests/lib/msun/ldexp_test and possibly others.
Additionally, setting this flag prevents printf() from printing subnormal
numbers in decimal form.
See also https://www.openwall.com/lists/musl/2021/02/26/1

PR:		253847
Reviewed By:	mmel
Approved by:	re (gjb)
Differential Revision: https://reviews.freebsd.org/D28938

(cherry picked from commit 0e4ff0acbe)
(cherry picked from commit d37fb0e378)
2021-03-23 20:07:34 -04:00
Vincenzo Maffione 4ec92bce4e netmap: fix issues in nm_os_extmem_create()
- Call vm_object_reference() before vm_map_lookup_done().
- Use vm_mmap_to_errno() to convert vm_map_* return values to errno.
- Fix memory leak of e->obj.

Approved by:	re (gjb)
Reported by:	markj
Reviewed by:	markj
MFC after:	1 week

(cherry picked from commit ee7ffaa2e6)
(cherry picked from commit 3e4127f8f2)
2021-03-23 22:05:01 +00:00
Vincenzo Maffione f7e3976ed0 netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET
The netmap_ioctl() function has a reference counting bug in case of
NETMAP_REQ_PORT_INFO_GET command. When `hdr->nr_name[0] == '\0'`,
the function does not decrease the refcount of "nmd", which is
increased by netmap_mem_find(), causing a refcount leak.

Approved by:	re (gjb)
Reported by:	Xiyu Yang <[email protected]>
Submitted by:	Carl Smith <[email protected]>
MFC after: 3 days
PR:	254311

(cherry picked from commit 0ab5902e8a)
(cherry picked from commit 120a4bd4e9)
2021-03-23 22:04:29 +00:00
Brandon Bergren a9c7d90862 [PowerPC] [PowerPCSPE] Fix multiple issues in fpsetmask().
Building R on powerpc64 exposed a problem in fpsetmask() whereby we
were not properly clamping the provided mask to the valid range.

This same issue affects powerpc and powerpcspe.

Properly limit the range of bits that can be set via fpsetmask().

While here, use the correct fp_except_t type instead of fp_rnd_t.

Reported by:	pkubaj, jhibbits (in IRC)
Sponsored by:	Tag1 Consulting, Inc.
Approved by:	re (gjb) (Post-RC3 outstanding request approved for RC4)

(cherry picked from commit 384ee7cc6e)
(cherry picked from commit 8b96d6ac04)
2021-03-23 16:59:28 -05:00
Brandon Bergren 064f09616c [PowerPC64] Fix multiple issues in fpsetmask().
Building R exposed a problem in fpsetmask() whereby we were not properly
clamping the provided mask to the valid range.

R initilizes the mask by calling fpsetmask(~0) on FreeBSD. Since we
recently enabled precise exceptions, this was causing an immediate
SIGFPE because we were attempting to set invalid bits in the fpscr.

Properly limit the range of bits that can be set via fpsetmask().

While here, use the correct fp_except_t type instead of fp_rnd_t.

Reported by:	pkubaj (in IRC)
Sponsored by:	Tag1 Consulting, Inc.
Approved by:	re (gjb) (Post-RC3 outstanding request approved for RC4)

(cherry picked from commit dd95b39235)
(cherry picked from commit a79735386c)
2021-03-23 16:50:14 -05:00
Nathan Whitehorn 3ef46634cd Fix scripted installs on EFI systems after default mounting of the ESP.
Because the ESP mount point (/boot/efi) is in mtree, tar will attempt to
extract a directory at that point post-mount when the system is installed.
Normally, this is fine, since tar can happily set whatever properties it
wants. For FAT32 file systems, however, like the ESP, tar will attempt to
set mtime on the root directory, which FAT does not support, and tar will
interpret this as a fatal error, breaking the install (see
https://github.com/libarchive/libarchive/issues/1516). This issue would
also break scripted installs on bare-metal POWER8, POWER9, and PS3
systems, as well as some ARM systems.

This patch solves the problem in two ways:
- If stdout is a TTY, use the distextract stage instead of tar, as in
  interactive installs. distextract solves this problem internally and
  provides a nicer UI to boot, but requires a TTY.
- If stdout is not a TTY, use tar but, as a stopgap for 13.0, exclude
  boot/efi from tarball extraction and then add it by hand. This is a
  hack, and better solutions (as in the libarchive ticket above) will
  obsolete it, but it solves the most common case, leaving only
  unattended TTY-less installs on a few tier-2 platforms broken.

In addition, fix a bug with fstab generation uncovered once the tar issue
is fixed that umount(8) can depend on the ordering of lines in fstab in a
way that mount(8) does not. The partition editor now writes out fstab in
mount order, making sure umount (run at the end of scripted, but not
interactive, installs) succeeds.

PR:		254395
Approved by:	re (gjb)
Reviewed by:	gjb, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D29380

(cherry picked from commit c2f16c595e)
(cherry picked from commit 4601382e13)
2021-03-23 15:22:20 -04:00
Glen Barber 8f731a397a 13.0 release: update to RC3
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Approved by:	re (implicit)
2021-03-18 20:03:14 -04:00
Mariusz Zaborski c145b79546 zfs: bring back possibility to rewind the checkpoint from
Add parsing of the rewind options.

When I was upstreaming the change [1], I omitted the part where we
detect that the pool should be rewind. When the FreeBSD repo has
synced with the OpenZFS, this part of the code was removed.

[1] FreeBSD repo: 277f38abff
[2] OpenZFS repo: f2c027bd6a

Originally reviewed by:		tsoome, allanjude
Originally reviewed by:		kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <[email protected]>

PR:		254152
Approved by:	re(gjb)
Reported by:	Zhenlei Huang <zlei.huang at gmail.com>
Obtained from:	https://github.com/openzfs/zfs/pull/11730

(cherry picked from commit 653ed678c7)
(cherry picked from commit 6bbca5ca3a)
2021-03-19 00:02:57 +01:00
Michael Tuexen 11660fa28f vtnet: fix TSO for TCP/IPv6
The decision whether a TCP packet is sent over IPv4 or IPv6 was
based on ethertype, which works correctly. In D27926 the criteria
was changed to checking if the CSUM_IP_TSO flag is set in the
csum-flags and then considering it to be TCP/IPv4.
However, the TCP stack sets the flag to CSUM_TSO for IPv4 and IPv6,
where CSUM_TSO is defined as CSUM_IP_TSO|CSUM_IP6_TSO.
Therefore TCP/IPv6 packets gets mis-classified as TCP/IPv4,
which breaks TSO for TCP/IPv6.
This patch bases the check again on the ethertype.
This fix is instantly MFCed.

Approved by:		re(gjb)
PR:			254366
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D29331

(cherry picked from commit d4697a6b56)
(cherry picked from commit 6064ea8172)
2021-03-18 21:35:49 +01:00
Mateusz Guzik faa41af1fe vfs: fix vnlru marker handling for filtered/unfiltered cases
The global list has a marker with an invariant that free vnodes are
placed somewhere past that. A caller which performs filtering (like ZFS)
can move said marker all the way to the end, across free vnodes which
don't match. Then a caller which does not perform filtering will fail to
find them. This makes vn_alloc_hard sleep for 1 second instead of
reclaiming, resulting in significant stalls.

Fix the problem by requiring an explicit marker by callers which do
filtering.

As a temporary measure extend vnlru_free to restart if it fails to
reclaim anything.

Big thanks go to the reporter for testing several iterations of the
patch.

Reported by:	Yamagi <lists yamagi.org>
Tested by:	Yamagi <lists yamagi.org>
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29324
Approved by:	re (gjb)

(cherry picked from commit e9272225e6)
2021-03-18 15:36:22 +00:00
Scott Long 4c6c8f51fd base: remove if_wg(4) and associated utilities, manpage
After length decisions, we've decided that the if_wg(4) driver and
   related work is not yet ready to live in the tree.  This driver has
   larger security implications than many, and thus will be held to
   more scrutiny than other drivers.

Requested by: secteam
Approved by: re
2021-03-18 07:34:07 +00:00
Andrew Gierth cb370b1971 service(8): use an environment more consistent with init(8)
init(8) sets the "daemon" login class without specifying a pw
entry (so no substitutions are done on the variables). service(8)'s
use of env -L had the effect of specifying root's pw entry, with two
effects: getpwnam and getpwuid are being called, which may not be
entirely safe depending on what nsswitch is up to and what stage of
boot we are at, and substitutions would have been done.

Fix by teaching env(8) to allow -L -/classname to set the class
environment with no pw entry at all specified, and use it in
service(8).

PR:		253959
Approved by:	re (gjb)

(cherry picked from commit 55deb0a5f0)
(cherry picked from commit 0c1a5eaae8)
(cherry picked from commit 872ec7e5b6)
2021-03-16 19:11:23 -05:00
Edward Tomasz Napierala 56dd03e0f2 linux(4): make getcwd(2) return ERANGE instead of ENOMEM
For native FreeBSD binaries, the return value from __getcwd(2)
doesn't really matter, as the libc wrapper takes over and returns
the proper errno.

Approved by:	re (gjb)
PR:		kern/254120
Reported By:	Alex S <[email protected]>
Reviewed By:	kib
Sponsored By:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29217

(cherry picked from commit 0dfbdd9fc2)
(cherry picked from commit ab1a91d958)
2021-03-16 18:37:57 +00:00
Edward Tomasz Napierala 1aa6884953 development(7): update to reflect Git transition
Approved by:	re (gjb)
Reviewed By:	debdrup, imp (earlier version)
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D28939

(cherry picked from commit d28cbb7944)
(cherry picked from commit d7ef665e10)
2021-03-16 18:37:50 +00:00
Kyle Evans 1a15924593 x86: tsc: deprioritize TSC on VirtualBox
Misbehavior has been observed with TSC under VirtualBox, where threads
doing small sleeps (~1 second) may miss their wake up and hang around
in a sleep state indefinitely.  Switching back to ACPI-fast decidedly
fixes it, so stop using TSC on VirtualBox at least for the time being.

This partially reverts 84eaf2ccc6, applying it only to VirtualBox and
increasing the quality to 0. Negative qualities can never be chosen and
cannot be chosen with the tunable recently added. If we do not have a
timecounter with a higher quality than 0, then TSC does at least leave
the system mostly usable.

PR:		253087
Approved by:	re (gjb)

(cherry picked from commit 8cc15b0dfc)
(cherry picked from commit ec24f78e5b)
2021-03-14 14:44:04 -05:00
Mark Johnston 45910f6638 vm_reserv: Fix list locking in vm_reserv_reclaim_contig()
The per-domain partpop queue is locked by the combination of the
per-domain lock and individual reservation mutexes.
vm_reserv_reclaim_contig() scans the queue looking for partially
populated reservations that can be reclaimed in order to satisfy the
caller's allocation.

During the scan, we drop the per-domain lock.  At this point, the rvn
pointer may be invalidated.  Take care to load rvn after re-acquiring
the per-domain lock.

While here, simplify the condition used to check whether a reservation
was dequeued while the per-domain lock was dropped.

Approved by:	re (gjb)
Reviewed by:	alc, kib
Reported by:	gallatin
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29203

(cherry picked from commit 968079f253)
(cherry picked from commit cec3990d34)
2021-03-14 12:39:23 -04:00
Cyprien Laplace e6e8762dff gic_v3: add message based interrupts support
Pull Request:	https://github.com/freebsd/freebsd-src/pull/451

(cherry picked from commit 35ebd8d33a)
(cherry picked from commit acd69b0704)

Approved by:	re (gjb)
2021-03-14 12:26:06 -04:00
Cyprien Laplace 9ac43bb747 gic_v3: Use 64-bit writes to GICD_IROUTERn
While 32-bit accesses to GICD_IROUTERn are allowed,
this is a 64-bit register.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/451

(cherry picked from commit 46ca0b903c)
(cherry picked from commit 40f283b038)

Approved by:	re (gjb)
2021-03-14 12:25:25 -04:00
Glen Barber 13c22f7495 update to 13.0-RC2
While here, switch the pkg(8) repo to use release_0 for populating
the dvd1.iso packages.

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-03-11 19:03:52 -05:00
John Baldwin 290e4d98ab Add ObsoleteFiles.inc entries for various OCF headers removed in 13.
Approved by:	re (gjb)

(cherry picked from commit ef74bfc6fe)
(cherry picked from commit da55db3264)
2021-03-11 15:37:52 -08:00
John Baldwin 3b9e12f66e Correct the name of the structure used for TCP socket options.
The structure was renamed while refactoring Netflix's KTLS changes for
upstreaming, but the original name remained in tcp.4 and was
subsequently copied to ktls.4.

PR:		254141
Reported by:	asomers
Approved by:	re (gjb)

(cherry picked from commit c5a365623f)
(cherry picked from commit 0fc5395122)
2021-03-11 15:37:45 -08:00
John Baldwin 003e38a01c Remove the usr/tests/usr.bin/yacc/yacc directory when removing yacc.
Approved by:	re (gjb)

(cherry picked from commit e6cfd2939a)
(cherry picked from commit 6a2ab3769a)
2021-03-11 15:37:29 -08:00
Alexander V. Chernikov d4803b958c Fix 'in6_purgeaddr: err=65, destination address delete failed' message.
P2P ifa may require 2 routes: one is the loopback route, another is
 the "prefix" route towards its destination.

Current code marks loopback routes existence with IFA_RTSELF and
 "prefix" p2p routes with IFA_ROUTE.

For historic reasons, we fill in ifa_dstaddr for loopback interfaces.
To avoid installing the same route twice, we preemptively set
 IFA_RTSELF when adding "prefix" route for loopback.
However, the teardown part doesn't have this hack, so we try to
 remove the same route twice.

Fix this by checking if ifa_dstaddr is different from the ifa_addr
 and moving this logic into a separate function.

Reviewed By: kp
Approved by:	re(gjb)
Differential Revision: https://reviews.freebsd.org/D29121

(cherry picked from commit 83cedad139)
2021-03-11 21:38:01 +00:00
Nathan Whitehorn 3dbc2213da Mount the EFI system partition (ESP) on newly-installed systems and VM
images.

Per hier(7), the ESP will be mounted at /boot/efi. On UFS systems,
any existing ESP will be reused and mounted there; otherwise, a new one
will be made. On ZFS systems, space for an ESP is allocated on all disks
in the root pool, but only the partition actually used to boot is set up
and mounted.

This makes future upgrades of the EFI loader easier (upgrade scripts can
just change /boot/efi) and also greatly simplifies the parts of the
installer involved in initialization of the ESP. It also makes the
installer's behavior correspond to the documentation in hier(7).

Reviewed by:		imp, tsoome, bdragon
Approved by:		re (gjb)
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D28897

(cherry picked from commit 0b7472b3d8)
(cherry picked from commit 2c26d77d98)
(cherry picked from commit e77cf2a4ab)
(cherry picked from commit e70eb40271)
(cherry picked from commit 611d83116a)
2021-03-11 14:39:57 -05:00
Kyle Evans 7a1f6858da jail(8): reset to root cpuset before attaching to run commands
Recent changes have made it such that attaching to a jail will augment
the attaching process' cpu mask with the jail's cpuset. While this is
convenient for allowing the administrator to cpuset arbitrary programs
that will attach to a jail, this is decidedly not convenient for
executing long-running daemons during jail creation.

This change inserts a reset of the process cpuset to the root cpuset
between the fork and attach to execute a command. This allows commands
executed to have the widest mask possible, and the administrator can
cpuset(1) it back down inside the jail as needed.

With this applied, one should be able to change a jail's cpuset at
exec.poststart in addition to exec.created.  The former was made
difficult if jail(8) itself was running with a constrained set, as then
some processes may have been spawned inside the jail with a non-root
set.  The latter is the preferred option so that processes starting in
the jail are constrained appropriately up front.

Note that all system commands are still run with the process' initial
cpuset applied.

PR:		253724
Approved by:	re (gjb)

(cherry picked from commit 466df976ba)
(cherry picked from commit bdd61b6914)
2021-03-11 13:24:28 -06:00
Gordon Bergling 2b1bcf70b4 wg(4): Fix an example in the manual page
The example in the manual page of wg(4) for connecting to a
peer was missing the 'public-key' ifconfig(8) keyword and for the
addressed peer the port must be specified.

PR:	253866
Reported by:	Sergey Akhmatov <sergey at akhmatov dot ru>
Approved by:	re (gjb)
Reviewed by:	debdrup
Differential Revision:	https://reviews.freebsd.org/D29115

(cherry picked from commit f7bfe31019)
2021-03-11 19:02:51 +01:00
Evgeniy Khramtsov 1690984a83 security(7): mention new W^X sysctls in the manual page
Reviewed by:	emaste, gbe
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D28986

(cherry picked from commit 907023b454)
2021-03-11 19:00:55 +01:00
Mark Johnston 11d8457138 wg: Avoid leaking mbufs when the input handshake queue is full
Approved by:	re
Reviewed by:	grehan
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29011

(cherry picked from commit a11009dccb)
(cherry picked from commit 47495bf648)
2021-03-11 10:58:35 -05:00
Emmanuel Vadot e9bdfe2dd4 backlight(8): Add note that with option it print the current brightness.
MFC after:    3 days
PR: 	      253737
Approved by:  re (gjb)

(cherry picked from commit 1df30489a8)
(cherry picked from commit f21c0366f5)
2021-03-11 09:49:31 +01:00
David Schlachter cb603e3ea2 backlight: Fix incr/decr with percent value of 0
This now does nothing instead of incr/decr by 10%

MFC After:    3 days
PR: 	      253736
Approved by:  re (gjb)

(cherry picked from commit 3b005d51bd)
(cherry picked from commit 9ba393f2ca)
2021-03-11 09:49:03 +01:00
Alexander V. Chernikov 2d227a6ec3 Fix dst/netmask handling in routing socket code.
Traditionally routing socket code did almost zero checks on
 the input message except for the most basic size checks.

This resulted in the unclear KPI boundary for the routing system code
 (`rtrequest*` and now `rib_action()`) w.r.t message validness.

Multiple potential problems and nuances exists:
* Host bits in RTAX_DST sockaddr. Existing applications do send prefixes
 with hostbits uncleared. Even `route(8)` does this, as they hope the kernel
 would do the job of fixing it. Code inside `rib_action()` needs to handle
 it on its own (see `rt_maskedcopy()` ugly hack).
* There are multiple way of adding the host route: it can be DST without
 netmask or DST with /32(/128) netmask. Also, RTF_HOST has to be set correspondingly.
 Currently, these 2 options create 2 DIFFERENT routes in the kernel.
* no sockaddr length/content checking for the "secondary" fields exists: nothing
 stops rtsock application to send sockaddr_in with length of 25 (instead of 16).
 Kernel will accept it, install to RIB as is and propagate to all rtsock consumers,
 potentially triggering bugs in their code. Same goes for sin_port, sin_zero, etc.

The goal of this change is to make rtsock verify all sockaddr and prefix consistency.
Said differently, `rib_action()` or internals should NOT require to change any of the
 sockaddrs supplied by `rt_addrinfo` structure due to incorrectness.

To be more specific, this change implements the following:
* sockaddr cleanup/validation check is added immediately after getting sockaddrs from rtm.
* Per-family dst/netmask checks clears host bits in dst and zeros all dst/netmask "secondary" fields.
* The same netmask checking code converts /32(/128) netmasks to "host" route case
 (NULL netmask, RTF_HOST), removing the dualism.
* Instead of allowing ANY "known" sockaddr families (0<..<AF_MAX), allow only actually
 supported ones (inet, inet6, link).
* Automatically convert `sockaddr_sdl` (AF_LINK) gateways to
  `sockaddr_sdl_short`.

Reported by:	Guy Yur <guyyur at gmail.com>
Reviewed By:	donner
Approved by:	re(gjb)
Differential Revision: https://reviews.freebsd.org/D28668

(cherry picked from commit e1bdecd9f6)
2021-03-11 08:25:01 +00:00
Alexander V. Chernikov 19fdc20297 Fix dpdk/ldradix fib lookup algorithm preference calculation.
The current preference number were copied from IPv4 code,
 assuming 500k routes to be the full-view. Adjust with the current
 reality (100k full-view).

Reported by:	Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Approved by:	re(gjb)

(cherry picked from commit 8a25d3f6ce)
2021-03-11 08:24:44 +00:00
Alexander V. Chernikov dba80ca2cf Make in_localip_more() fib-aware.
It fixes loopback route installation for the interfaces
 in the different fibs using the same prefix.

Reviewed By:	donner
PR:		189088
Approved by:	re(gjb)
Differential Revision: https://reviews.freebsd.org/D28673

(cherry picked from commit f676416759)
2021-03-11 08:23:07 +00:00
Eric Joyner 3af5680fe2 ice(4): Update to version 0.28.1-k
This updates the driver to align with the version included in
the "Intel Ethernet Adapter Complete Driver Pack", version 25.6.

There are no major functional changes; this mostly contains
bug fixes and changes to prepare for new features. This version
of the driver uses the previously committed ice_ddp package
1.3.19.0.

Signed-off-by: Eric Joyner <[email protected]>

Tested by:	[email protected]
Approved by:	re (gjb)
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D28640

(cherry picked from commit d08b8680e1)
(cherry picked from commit 1da549169d)
2021-03-10 17:07:53 -08:00
Eric Joyner 6db19df195 ice_ddp: Update package file to 1.3.19.0
This package is intended to be used with ice(4) version 0.28.1-k.
That update will happen in a forthcoming commit.

Signed-off-by: Eric Joyner <[email protected]>
Approved by: re (gjb)
Sponsored by: Intel Corporation

(cherry picked from commit a7ac518bff)
(cherry picked from commit a02640c79e)
2021-03-10 17:07:35 -08:00
Krzysztof Galazka f9c8aed244 ixl(4): Add ability to control link state on ifconfig down
Add sysctl link_active_on_if_down, which allows user to control
if interface is kept in active state when it is brought
down with ifconfig. Set it to enabled by default to preserve
backwards compatibility.

Reviewed by:	erj
Tested by:	[email protected]
Approved by:	re (gjb)
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D28028

(cherry picked from commit 21802a127d)
(cherry picked from commit 2b94bda05a)
2021-03-10 17:07:26 -08:00
Krzysztof Galazka 995755b959 ixl(4): Report RX errors as sum of all RX error counters
HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

There is no HW counter for frames with invalid L3/L4 checksums
so add a SW one.

Also add a "rx_errors" sysctl with a copy of netstat IERRORS
counter value to make it easier accessible from scripts.

Reviewed By:	erj
Tested By:	[email protected]
Approved by:	re (gjb)
Sponsored By:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D27639

(cherry picked from commit 9f99061ef9)
(cherry picked from commit b149f7c23d)
2021-03-10 17:07:13 -08:00
Piotr Pietruszewski adc22165c0 ix(4): Report RX errors as sum of all RX error counters
HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

Also, add new "rx_errs" sysctl in the dev.ix.N.mac_stats tree. This is
to provide an another way to display the sum of RX errors.

Signed-off-by: Piotr Pietruszewski <[email protected]>

Reviewed By: erj
Tested By: [email protected]
Approved by: re (gjb)
Sponsored By: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D27191

(cherry picked from commit afb1aa4e6d)
(cherry picked from commit 8fa11f8922)
2021-03-10 17:07:03 -08:00
Krzysztof Galazka c637a66be4 ixl(4): Fix VLAN HW filtering
X700 family of controllers has limited number of available VLAN
HW filters. Driver did not handle properly a case when user
assigned more VLANs to the interface which had all filters
already in use. Fix that by disabling HW filtering when
it is impossible to create filters for all requested VLANs.
Keep track of registered VLANs using bitstring to be able
to re-enable HW filtering when number of requested VLANs
drops below the limit.

Also switch all allocations to use M_IXL malloc type
to ease detecting memory leaks in the driver.

Reviewed by:	erj
Tested by:	[email protected]
Approved by:	re (gjb)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28137

(cherry picked from commit 7d4dceec10)
(cherry picked from commit 7e166d608e)
2021-03-10 17:06:15 -08:00
Dimitry Andric 64b30c3671 Add a few missed files to libclang_rt.profile-<arch>.a
Otherwise, programs compiled with -fprofile-instr-generate will
encounter undefined symbol errors during linking, for example
__llvm_profile_counter_bias, lprofSetRuntimeCounterRelocation and a few
others were missing from the profile library.

Approved by:	re (gjb)
Reported by:	[email protected]
PR:		254001

(cherry picked from commit 772c631af8)
(cherry picked from commit 3f684107ef)
2021-03-09 21:57:51 +01:00
Oleksandr Tymoshenko fd7d1ec21a armv8crypto: fix AES-XTS regression introduced by ed9b7f44
Initialization of the XTS key schedule was accidentally dropped
when adding AES-GCM support so all-zero schedule was used instead.
This rendered previously created GELI partitions unusable.
This change restores proper XTS key schedule initialization.

Reported by:	Peter Jeremy <[email protected]>
MFC after:	immediately
Approved by:	re (gjb)

(cherry picked from commit 748be78e60)
2021-03-09 11:27:11 -08:00
Toomas Soome 1ceb3c6c3b loader: cursor off should restore display content
When drawing cursor, we should store original display
content because there may be image data we would like to restore
when the cursor is removed.

PR:		254054
Reported by:	Jose Luis Duran
Approved by:	re (gjb)

(cherry picked from commit d708f23ebb)
2021-03-09 16:30:47 +02:00
Konstantin Belousov 677a7288ad atomic(9): note that atomic_interrupt_fence first appeared in 13.0
Approved by:	re (gjb)

(cherry picked from commit f5e930b369)
(cherry picked from commit 8fb8f26ab4)
2021-03-09 07:54:45 +02:00
Konstantin Belousov 5235fb3137 Use atomic_interrupt_fence() instead of bare __compiler_membar()
Approved by:	re (gjb)

(cherry picked from commit b5449c92b4)
(cherry picked from commit c10e0a4656)
2021-03-09 07:54:41 +02:00
Mateusz Guzik 04b20818b9 kcsan: add atomic_interrupt_fence
Approved by:	re (gjb)

(cherry picked from commit 2c1c1255e4)
(cherry picked from commit a552da13fc)
2021-03-09 07:54:37 +02:00
Konstantin Belousov f279cbcbdf atomic: add atomic_interrupt_fence()
Approved by:	re (gjb)

(cherry picked from commit e2494f7561)
2021-03-09 07:54:33 +02:00
Alexander Motin 84e5f9455a Do not exit ctl_be_block_worker() prematurely.
Return while there are any I/Os in a queue may result in them stuck
indefinitely, since there is only one taskqueue task for all of them.
I think I've reproduced this by switching ha_role to secondary under
heavy load.

Approved by:	re (delphij)

(cherry picked from commit 6ed39db257)
(cherry picked from commit a3d416f3da)
2021-03-08 22:15:38 -05:00
Warner Losh c7ea14ed61 Move back the isa non-PNP driver deadline to FreeBSD 14.
Approved by: re@ (gjb)

(cherry picked from commit 6ffdaa5f2d)
(cherry picked from commit 832d0719d6)
2021-03-08 16:56:37 -07:00
Mitchell Horne 03572a87a8 riscv: fix errors in some atomic type aliases
This appears to be a copy-and-paste error that has simply been
overlooked. The tree contains only two calls to any of the affected
variants, but recent additions to the test suite started exercising the
call to atomic_clear_rel_int() in ng_leave_write(), reliably causing
panics.

Apparently, the issue was inherited from the arm64 atomic header. That
instance was addressed in c90baf6817, but the fix did not make its way
to RISC-V.

Note that the particular test case ng_macfilter_test:main still appears
to fail on this platform, but this change reduces the panic to a
timeout.

PR:		253237
Reported by:	Jenkins, arichardson
Reviewed by:	kp, arichardson
Approved by:	re (gjb)

(cherry picked from commit 0d3b3beeb2)
(cherry picked from commit cc24f5bc6f)
2021-03-08 19:04:25 -04:00
Stefan Eßer 02a8fe639a bc: Vendor import new version 3.3.3
(cherry picked from commit 028616d0dd)

Make length(0) and length(0.0) return 1 for compatibility with GNU bc
and the traditional FreeBSD bc.

Fix a potential division by zero error in a non-standard (extended)
math library function.

(cherry picked from commit f165641df4)

Approved by:   re
2021-03-08 23:46:47 +01:00
Stefan Eßer 456d115263 Upgrade to version 3.3.0
This update changes the behavior of "-e" or "-f" in BC_ENV_ARGS:

Use of these options on the command line makes bc exit after executing
the given commands. These options will not cause bc to exit when
passed via the environment (but EOF in STDIN or -e or -f on the
command line will make bc exit as before).

The same applies to DC_ENV_ARGS with regard to the dc program.

(cherry picked from commit 9a995fe186)

Approved by:   re
2021-03-08 23:46:14 +01:00
Jessica Clarke a239b47cc9 if_vtbe: Add missing includes to fix build
PR:		254137
Reported by:	Mina Galić <[email protected]>
Fixes:		f8bc74e2f4 ("tap: add support for virtio-net offloads")
Approved by:	re (gjb)

(cherry picked from commit f2f8405cf6)
(cherry picked from commit e3394851b5)
2021-03-08 21:33:27 +00:00
Richard Scheffenegger bb60a68985 tcp: remove incorrect reset of SACK variable in PRR
tcp: Add prr_out in preparation for PRR/nonSACK and LRD

Reviewed by:   #transport, rrs, tuexen, kbowling
Approved by:   #re (gjb)
PR:            253848
MFC after:     3 days
Sponsored by:  NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29083
Differential Revision: https://reviews.freebsd.org/D29058

(cherry picked from commit 4a8f3aad37)
(cherry picked from commit d90bba73a2)

(cherry picked from commit e53138694a)
(cherry picked from commit 71cc98ba73)
2021-03-08 15:17:12 +01:00
Michael Tuexen fb6ac317c0 rack: unbreak TCP fast open for the client side
Allow sending user data on the SYN segment.

Reviewed by:		rrs
Approved by:		re (gjb)
Differential Revision:	https://reviews.freebsd.org/D29082
Sponsored by:		Netflix, Inc.

(cherry picked from commit 705d06b289)
(cherry picked from commit 873f837601)
2021-03-08 13:46:26 +01:00
Martin Matuska eed4d02d7f zfs: cancel TRIM or initialize on FAULTED non-writeable vdevs
From the openzfs commit message:
  When a device which is actively trimming or initializing becomes
  FAULTED, and therefore no longer writable, cancel the active
  TRIM or initialization.  When the device is merely taken offline
  with `zpool offline` then stop the operation but do not cancel it.
  When the device is brought back online the operation will be
  resumed if possible.

Obtained from:	openzfs/zfs@bedbc13daa
Approved by:	re (delphij)

(cherry picked from commit dc2743434f)
2021-03-06 21:23:23 +01:00
Martin Matuska d2faf2e6b2 zfs: fix assert in FreeBSD-specific dmu_read_pages
From the openzfs 2e160dee9 commit message:
  The function has three similar pieces of code: for read-behind pages,
  requested pages and read-ahead pages.  All three pieces had an
  assert to ensure that the page is not mapped.  Later the assert was
  relaxed to require that the page is not mapped for writing.  But that
  was done in two places out of three.  This change fixes the third piece,
  read-ahead.

Obtained from:	openzfs/zfs@2e160dee97
Approved by:	re (delphij)

(cherry picked from commit 19049a2b2b)
2021-03-06 21:23:22 +01:00
Martin Matuska e33a2b2905 zfs: fix vdev_rebuild_thread deadlock
From the openzfs 8e43fa12c commit message:
  The metaslab_disable() call may block waiting for a txg sync.
  Therefore it's important that vdev_rebuild_thread release the
  SCL_CONFIG read lock it is holding before this call.  Failure
  to do so can result in the txg_sync thread getting blocked
  waiting for this lock which results in a deadlock.

Obtained from:	openzfs/zfs@8e43fa12c5
Approved by:	re (delphij)

(cherry picked from commit c706906314)
2021-03-06 21:23:22 +01:00
Martin Matuska 2fa2d50ead zfs: fix overly broad locking in spa_vdev_config_exit()
Resolves a deadlock which can occur when the ZED or zpool
command attaches a new device.

From the openzfs 75a089ed3 commit message:
  Calling vdev_free() only requires the we acquire the spa config
  SCL_STATE_ALL locks, not the SCL_ALL locks.  In particular, we need
  need to avoid taking the SCL_CONFIG lock (included in SCL_ALL) as a
  writer since this can lead to a deadlock.  The txg_sync_thread() may
  block in spa_txg_history_init_io() when taking the SCL_CONFIG lock
  as a reading when it detects there's a pending writer.

Obtained from:	openzfs/zfs@75a089ed34
Approved by:	re (delphij)

(cherry picked from commit f08e17c8a2)
2021-03-06 21:23:22 +01:00
Ed Maste 8d25741b63 growfs: allow operation on RW-mounted filesystems
growfs supports growing mounted filesystems (writes are temporarily
suspended while the grow happens).  Drop the check for fs_clean == 0
to restore this case.  Leave fs_flags check for FS_UNCLEAN or
FS_NEEDSFSCK which represent the state of the filesystem when it was
mounted, and fsck should be run first if they are set.

PR:		253754
Reviewed by:	mckusick
Approved by:	re (gjb)
Fixes:		6eb925f845 ("Filesystem utilities that modify the...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29021

(cherry picked from commit 0dcde5cc12)
(cherry picked from commit b5920128c7)
2021-03-06 14:46:31 -05:00
Toomas Soome bafab32168 loader_4th: brand image is aligned right
With screen border removed, I forgot to update forth brand image
coordinates to avoid image alignment.

(cherry picked from commit 6a3095aa6d)

Approved by:    re (delphij)
2021-03-06 11:37:16 +02:00
Peter Grehan 9705c012c1 Import wireguard fixes from pfSense 2.5
Merge the following fixes from https://github.com/pfsense/FreeBSD-src
 1940e7d3  Save	address	of ingress packets to allow wg to work on HA
 8f5531f1  Fix connection to IPv6 endpoint
 825ed9ee  Fix tcpdump for wg IPv6 rx tunnel traffic
 2ec232d3  Fix issue with replying to INITIATION messages in server mode
 ec77593a  Return immediately in wg_init if in DETACH'd state
 0f0dde6f  Remove unnecessary wg debug printf on transmit
 2766dc94  Detect and fix case in wg_init() where sockets weren't cleaned up
 b62cc7ac  Close the UDP tunnel sockets when the interface has been stopped

Approved by:	re (kib)
Obtained from:	pfSense 2.5
Relnotes:	yes
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 96aabea8bd)
2021-03-06 14:12:29 +10:00
Xin LI 85ec7f28cb arcmsr(4): Fixed no action of hot plugging device on type_F adapter.
Many thanks to Areca for continuing to support FreeBSD.

Submitted by:	黃清隆 <ching2048 areca com tw>
Approved by:	re (gjb)

(cherry picked from commit 5842073a9b)
(cherry picked from commit e298c1c3c2)
2021-03-05 20:59:21 -08:00
Toomas Soome acd98bcb28 loader: use display pixel density for font autoselection
Calculate font size from 16 density independent pixels (dp) by using:
size = 16 * ppi/160 * display_factor

We are specifying font size 16dp, and assuming 1dp = 160ppi.
Also apply scaling factor 2 (display_factor).

(cherry picked from commit becaac3972)

Approved by:    re (gjb)
2021-03-05 15:56:58 +02:00
Glen Barber 60e8939aa8 update to RC1
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-03-04 19:52:07 -05:00
Edward Tomasz Napierala fdd7609f10 linux: fix handling of flags for 32 bit send(2) syscall
Previously the flags were passed as-is, which could resulted
in spurious EAGAIN returned for non-blocking sockets, which
broke some Steam games.

Approved by:	re (gjb)
PR:		248065
Reported By:	Alex S <[email protected]>
Tested By:	Alex S <[email protected]>
Reviewed By:	emaste
MFC After:	3 days
Sponsored By:	The FreeBSD Foundation

(cherry picked from commit f6e8256a96)
(cherry picked from commit 9d930fb090)
2021-03-04 23:29:22 +00:00
Edward Tomasz Napierala 9d39df7bd9 Don't check compat.linux.emul_path before loading linux(4)
Fix e40787f900 to make libexec/rc/rc.d/linux retrieve the sysctl
after loading the kernel module which provides it, not before.

Approved by:	re (gjb)
Reported By:	jkim
Sponsored By:	The FreeBSD Foundation

(cherry picked from commit 07cac176fb)
(cherry picked from commit 5dc2e1bcf4)
2021-03-04 23:29:15 +00:00
Edward Tomasz Napierala f122a87192 Use compat.linux.emul_path instead of hardcoded path in /etc/rc.d/linux
In /etc/rc.d/linux the mounting paths of procfs, sysfs and devfs
are hardcoded to "/compat/linux".  Switching to the content of
compat.linux.emul_path sysctl would allow to switch linuxulator
to different place.

Approved by:	re (gjb)
Submitted by:	freebsdnewbie_freenet.de
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27807

(cherry picked from commit e40787f900)
(cherry picked from commit 1b2802ed4e)
2021-03-04 23:29:08 +00:00
Edward Tomasz Napierala 9bf608d00a libc: fix buffer overrun in getrpcport(3)
Approved by:	re (gjb)
Reviewed By:	markj
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27332

(cherry picked from commit 5299d64b2b)
(cherry picked from commit a3576b6207)
2021-03-04 23:29:00 +00:00
Konstantin Belousov ac94eec58a O_RELATIVE_BENEATH: return ENOTCAPABLE instead of EINVAL for abs path
Approved by:	re (gjb)

(cherry picked from commit 28cd3a673e)
2021-03-04 22:08:07 +02:00
Konstantin Belousov 8ae87de4df nameicap_check_dotdot: trim tracker on check
Approved by:	 re (gjb)

(cherry picked from commit 49c98a4bf3)
2021-03-04 22:08:02 +02:00
Konstantin Belousov bd7a41bed0 Add nameicap_cleanup_from(), to clean tracker list starting from some element
Approved by:	re (gjb)

(cherry picked from commit e8a2862aa0)
2021-03-04 22:07:58 +02:00
Konstantin Belousov 4a5108cdc9 nameicap_tracker_add: avoid duplicates in the tracker list
Approved by:	re (gjb)

(cherry picked from commit 2388ad7c29)
2021-03-04 22:07:54 +02:00
Konstantin Belousov cea301aee3 Do not call nameicap_tracker_add() for dotdot case.
Approved by:	re (gjb)

(cherry picked from commit 59e7494281)
2021-03-04 22:07:50 +02:00
Konstantin Belousov 22c1852a04 open(2): Remove O_BENEATH and AT_BENEATH
Approved by:	re (gjb)

(cherry picked from commit 20e91ca36a)
2021-03-04 22:07:46 +02:00
Konstantin Belousov 9f1e0822cd fhlink(2): the syscalls do not take flag
Approved by:	re (gjb)

(cherry picked from commit 600756afb5)
2021-03-04 22:07:42 +02:00
Konstantin Belousov 3bde9c57df FFS extattr: fix handling of the tail
Approved by:	re (gjb)

(cherry picked from commit 8742817ba6)
2021-03-04 22:07:33 +02:00
Mark Johnston 065b9549d3 sendfile: Use the pager size to determine the file extent when possible
Previously sendfile would issue a VOP_GETATTR and use the returned size,
i.e., the file size.  When paging in file data, sendfile_swapin() will
use the pager to determine whether it needs to zero-fill, most often
because of a hole in a sparse file.  An attempt to page in beyond the
end of a file is treated this way, and occurs when the requested page is
past the end of the pager.  In other words, both the file size and pager
size were used interchangeably.

With ZFS, updates to the pager and file sizes are not synchronized by
the exclusive vnode lock, at least partially due to its use of
MNTK_SHARED_WRITES.  In particular, the pager size is updated after the
file size, so in the presence of a writer concurrently extending the
file, sendfile could incorrectly instantiate "holes" in the page cache
pages backing the file, which manifests as data corruption when reading
the file back from the page cache.  The on-disk copy is unaffected.

Fix this by consistently using the pager size when available.

Approved by:	re (gjb)
Reported by:	dumbbell
Reviewed by:	chs, kib
Tested by:	dumbbell, pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28811

(cherry picked from commit faa998f6ff)
(cherry picked from commit 095558ac89)
2021-03-04 09:09:36 -05:00
Richard Scheffenegger b8ffda0a37 tcp: various improvements and fixes to PRR
- Ensure cwnd doesn't shrink to zero with PRR
- use accurate rfc6675_pipe when enabled
- Address two incorrect calculations and enhance readability
- address second instance of cwnd potentially becoming zero
- fix sublte bug due to implicit int to uint typecase in max()
- fix bug due to typo in hand-coded CEILING() function by using howmany() macro
- use int instead of long, and add a missing long typecast
- replace if conditionals with easier to read imax/imin (as in pseudocode)
- Avoid accounting left-edge twice in partial ACK.
- Include new data sent in PRR calculation
- Improve PRR initial transmission timing
- Fix prr_out when pipe < ssthresh

Reviewed By:    #transport, kbowling, tuexen
Reported by:    Liang Tian
Approved by:    re (gjb)
MFC after:      3 days
Sponsored by:   NetApp, Inc.
Differential Revision:  https://reviews.freebsd.org/D28780
Differential Revision:  https://reviews.freebsd.org/D28816
Differential Revision:  https://reviews.freebsd.org/D28813
Differential Revision:  https://reviews.freebsd.org/D28819
Differential Revision:  https://reviews.freebsd.org/D28941
Differential Revision:  https://reviews.freebsd.org/D28953
Differential Revision:  https://reviews.freebsd.org/D28998

(cherry picked from commit 853fd7a2e3)
(cherry picked from commit c3aa4ba5df)

(cherry picked from commit a8e431e153)
(cherry picked from commit 32ed0ef06b)

(cherry picked from commit 48396dc779)
(cherry picked from commit ffbf1b809e)

(cherry picked from commit 31d7a27c6e)
(cherry picked from commit 25fb4c363b)

(cherry picked from commit 9e83a6a556)
(cherry picked from commit 9596751563)

(cherry picked from commit e9071000c9)
(cherry picked from commit 2b43cd2ea2)

(cherry picked from commit 0b0f8b359d)
(cherry picked from commit 05e742af6f)
2021-03-04 12:56:35 +01:00
Michael Tuexen 43a2f41379 RACK: fix an issue triggered by using the CDG CC module
Obtained from:		rrs@
Approved by:		re (gjb)
PR:			238741
Sponsored by:		Netlix, Inc.

(cherry picked from commit 99adf23006)
(cherry picked from commit ae608d4ee7)
2021-03-04 12:00:34 +01:00
Kyle Evans 5fdc5c5dba jail: allow root to implicitly widen its cpuset to attach
The default behavior for attaching processes to jails is that the jail's
cpuset augments the attaching processes, so that it cannot be used to
escalate a user's ability to take advantage of more CPUs than the
administrator wanted them to.

This is problematic when root needs to manage jails that have disjoint
sets with whatever process is attaching, as this would otherwise result
in a deadlock. Therefore, if we did not have an appropriate common
subset of cpus/domains for our new policy, we now allow the process to
simply take on the jail set *if* it has the privilege to widen its mask
anyways.

With the new logic, root can still usefully cpuset a process that
attaches to a jail with the desire of maintaining the set it was given
pre-attachment while still retaining the ability to manage child jails
without jumping through hoops.

A test has been added to demonstrate the issue; cpuset of a process
down to just the first CPU and attempting to attach to a jail without
access to any of the same CPUs previously resulted in EDEADLK and now
results in taking on the jail's mask for privileged users.

PR:		253724
Approved by:	re (gjb)

(cherry picked from commit 60c4ec806d)
(cherry picked from commit c4ccb6d1be)
2021-03-03 20:41:48 -06:00
Thomas Skibo 661e2b8e14 ddb: fix show devmap output on 32-bit arm
The output has been broken since 1b6dd6d772. Casting to uintmax_t
before the call to printf is necessary to ensure that 32-bit addresses
are interpreted correctly.

PR:		243236
Approved by:	re (gjb)

(cherry picked from commit 9976b42b69)
(cherry picked from commit 0a223cf980)
2021-03-03 17:54:45 -04:00
Elliott Mitchell d2d99e6757 armv8crypto: add missing newline
The missing newline mildly garbles boot-time messages and this can be
troublesome if you need those.

Reported by:	Mike Karels ([email protected])
Reviewed by:	gonzo
Approved by:	re (gjb)

(cherry picked from commit 530d38441d)
(cherry picked from commit 0ae6762399)
2021-03-03 17:54:22 -04:00
Rick Macklem 3664067ea9 nfsclient: fix panic in cache_enter_time()
Juraj Lutter (otis@) reported a panic "dvp != vp not true" in
cache_enter_time() called from the NFS client's nfsrpc_readdirplus()
function.
This is specific to an NFSv3 mount with the "rdirplus" mount
option. Unlike NFSv4, NFSv3 replies to ReaddirPlus
includes entries for the current directory.

This trivial patch avoids doing a cache_enter_time()
call for the current directory to avoid the panic.

Approved by:	re (gjb)

(cherry picked from commit 3fe2c68ba2)
2021-03-03 08:27:06 -08:00
Rick Macklem 2d379aed1e copy_file_range(2): Fix for small values of input file offset and len
r366302 broke copy_file_range(2) for small values of
input file offset and len.

It was possible for rem to be greater than len and then
"len - rem" was a large value, since both variables are
unsigned.

Approved by:	re (gjb)

(cherry picked from commit a5f9fe2bab)
2021-03-03 07:40:39 -08:00
Mark Johnston 20f9e2a723 rmlock: Add a required compiler membar to the rlock slow path
The tracker flags need to be loaded only after the tracker is removed
from its per-CPU queue.  Otherwise, readers may fail to synchronize with
pending writers attempting to propagate priority to active readers, and
readers and writers deadlock on each other.  This was observed in a
stable/12-based armv7 kernel where the compiler had reordered the load
of rmp_flags to before the stores updating the queue.

Approved by:	re (gjb)
Reviewed by:	rlibby, scottl
Discussed with:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D28821

(cherry picked from commit 1d44514fcd)
(cherry picked from commit c29d3ecdc8)
2021-03-02 20:16:54 -05:00
Chris Rees 945184b92f Create dhclient pid directory if it doesn't exist
- Upgrading from older FreeBSD versions can result in errors

 - /var/run can be a tmpfs, and this should be handled correctly

Approved by:	re (gjb)
Approved by:	markj
Differential:	https://reviews.freebsd.org/D28843
MFC after:	2 weeks

(cherry picked from commit ce94bedf47)
2021-03-02 19:16:06 +00:00
Michael Tuexen 6f930137ca sctp: several fixes and improvements
Approved by:	re (gjb)

sctp: improve consistency

No functional change intended.

(cherry picked from commit 7a051c0a78)
(cherry picked from commit 459f1b9065)

sctp: fix PR-SCTP stats when adding addtional streams

(cherry picked from commit 0f7573ffd6)
(cherry picked from commit 21398f02b0)

sctp: fix a locking issue for old unordered data

Thanks to Anatoly Korniltsev for reporting the issue for the
userland stack.

(cherry picked from commit 8dc6a1edca)
(cherry picked from commit 3fa95c0fe6)

sctp: improve input validation

Improve the handling of INIT chunks in specific szenarios and
report and appropriate error cause.
Thanks to Anatoly Korniltsev for reporting the issue for the
userland stack.

(cherry picked from commit af885c57d6)
(cherry picked from commit 16b5389750)

sctp: small cleanup, no functional change intended.

(cherry picked from commit bdd4630c9a)
(cherry picked from commit 5573b94fa6)

sctp: clear a pointer to a net which will be removed

(cherry picked from commit 5ac839029d)
(cherry picked from commit 04c13928d9)

sctp: improve computation of an alternate net

Espeially handle the case where the net passed in is about to
be deleted and therefore not in the list of nets anymore.

Reported by:	[email protected]

(cherry picked from commit b963ce4588)
(cherry picked from commit 8cf046aff9)

sctp: avoid integer overflow when starting the HB timer

Reported by:	[email protected]

(cherry picked from commit 70e95f0b69)
(cherry picked from commit f7c20120c1)
2021-03-02 16:57:23 +01:00
Michael Tuexen 2751e264df tcp: improve behaviour when using TCP_NOOPT
Use ISS for SEG.SEQ when sending a SYN-ACK segment in response to
an SYN segment received in the SYN-SENT state on a socket having
the IPPROTO_TCP level socket option TCP_NOOPT enabled.

Approved by:		re (gjb)
Reviewed by:		rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D28656

(cherry picked from commit ed782b9f5a)
(cherry picked from commit e949dcc283)
2021-03-02 16:17:25 +01:00
Konstantin Belousov 811deba9df Remove __NO_TLS.
Approved by:	re (gjb)

(cherry picked from commit 3ae8d83d04)
2021-03-02 17:18:56 +02:00
John Baldwin 91a611e521 mips: Don't set __NO_TLS to disable some uses of TLS.
Approved by:	re (gjb)

(cherry picked from commit 24fd63e097)
2021-03-02 17:18:56 +02:00
John Baldwin 229f1e4b14 riscv: Don't set __NO_TLS to disable some uses of TLS.
Approved by:	re (gjb)

(cherry picked from commit dd176fd7e7)
2021-03-02 17:18:56 +02:00
Michael Tuexen 59b8f72a21 libsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG
TCP_FASTOPEN_MIN_COOKIE_LEN was incorrectly registered as a name of
a IPPROTO_TCP level socket option, which overwrote TCP_NOPUSH.
TCP_FASTOPEN_PSK_LEN was incorrectly registered as a name of an
IPPROTO_TCP level socket option, which overwrote TCP_MD5SIG.

Approved by:	re (gjb)
Sponsored by:	Netflix, Inc.

(cherry picked from commit f25266bee7)
(cherry picked from commit 2a9b68d5e1)
2021-03-02 15:55:22 +01:00
Emmanuel Vadot 856af5ff74 mkimg: Add support for offset if the source is an image
This allow us to create image with the following format:
mkimg -v -o sdcard -s gpt -p efi:=esp_aarch64.img:1M -p freebsd-ufs::1G

Which will add a efi partition at a 1M offset on the image with its content
coming from the esp_aarch64.img file.

MFC after:	3 days
Approved by:	re (gjb)
(cherry picked from commit 8f3c71c85e)
(cherry picked from commit 6f6c648004)
2021-03-02 15:21:08 +01:00
Emmanuel Vadot f3054d18bf mkimg: We always want the last block of the last inserted partition
Even with an absolute offset we want to know the last block the partition
otherwise we endup with an image the size of the metadata.
This allow to create image with the ESP placed at a specific position which
is useful on arm/arm64 where u-boot have always a hard time to read the ESP
if it's not aligned on 512k.
mkimg -v -o sdcard -s gpt -p efi::54M:1M -p freebsd-ufs::1G
now works.

MFC after:	3 days
Approved by:	re (gjb)
(cherry picked from commit 3b6268bb9e)
(cherry picked from commit 9c5f4f8e4e)
2021-03-02 15:20:53 +01:00
Brett Mastbergen 90cf334642 pwm_backlight: Add MODULE_DEPEND on backlight
Make the pwm_backlight module depend on backlight, so it
has access to the backlight interface symbols.  Otherwise you'll
get an error like:

link_elf: symbol backlight_get_info_desc undefined

Approved by:	re (gjb)
Signed-off-by: Brett Mastbergen <[email protected]>
MFC after:	3 days
PR: 		253765
(cherry picked from commit 43d4dfac96)
(cherry picked from commit 135fa1610f)
2021-03-02 15:19:51 +01:00
Warner Losh c0708f6835 efibootmgr: Check for efi supported after parsing args
Move the check for efi variables being supported to after parsing the args. This
allows '-h' to produce both as a normal user as well as on all systems.

Approved by: re@ (gjb)

(cherry picked from commit 7fe2f504f8)
(cherry picked from commit b8b867a10f)
2021-03-01 11:59:49 -07:00
Jessica Clarke f495e9ed95 uefi: Add riscv to historical details
Approved by: re@ (gjb)
(cherry picked from commit 963cf6cb0f)
(cherry picked from commit 44f483e0fa)
2021-03-01 11:59:44 -07:00
Warner Losh de3e66f4bb Restore missing word
"in" got dropped when I shuffled things around.

Noticed by: rpokala@
MFC After: 3 days
Approved by: re@ (gjb)
(cherry picked from commit f11e9f325a)
(cherry picked from commit 1df1b4190b)
2021-03-01 11:59:41 -07:00
Warner Losh abe709deef uefi: add historical details
Add details about when armv6 and armv7 support was added.
Approved by: re@ (gjb)
(cherry picked from commit 8c09ecb2e2)
(cherry picked from commit f88db54fd8)
2021-03-01 11:59:38 -07:00
Warner Losh 3e95150e8c Remove incorrect statement about EFI environment variables being unsupported.
Our uefi support has included environment variable support for several years
now. Remove the bogus blanket statement saying we don't support them.

MFC After: 3 days
Approved by: re@ (gjb)
(cherry picked from commit ab77cc9e7b)
(cherry picked from commit 78050d4966)
2021-03-01 11:59:34 -07:00
Warner Losh eb62c494bf uart: only use MSI on devices that advertise 1 MSI vector
This updates r311987/fb1d9b7f4113d which allowed any number of vectors to be
used. Since we're just attaching one instance, the meaning of more than one
vector is not clear and seems to cause problems. Fall back to old methods for
these cards.

PR: 235016
Submitted by: David Cross
Approved by: re@ (gjb)
(cherry picked from commit 955b6109bb)
(cherry picked from commit ef1f205608)
2021-03-01 11:59:30 -07:00
Warner Losh 963c8fa8b2 boot: remove gptboot.efifat, it never should have been
conical hat reduction: Make sure we also remove gotboot.efifat. It was created,
briefly, and shouldn't have existed in the first place. Kill it at the same
place we kill boot1.efifat.

Pointy Hat to: imp@
Approved by: re@ (gjb)
(cherry picked from commit 8cd1b2b1a7)
(cherry picked from commit dd9b24be14)
2021-03-01 11:59:26 -07:00
Warner Losh 5eabef5a82 Giant: move back Giant removal until 14
Update the Giant Lock warning message to FreeBSD 14. It's growing increasling
clear that this won't be done before 13.0.

MFC: Insta (re@'s request)
Approved by: re@ (gjb)
(cherry picked from commit 00065c7630)
(cherry picked from commit d2fb8eb147)
2021-03-01 11:59:18 -07:00
Warner Losh 5a1ecfa5a9 hid: bump HID_ITEM_MAXUSAGES to 8
My YOGA requires a minimum of 7 to parse w/o an error. Since the memory savings
are trivial and the yoga a popular system, bump the default up to 8. There's no
API/ABI issues in doing this. This hid_item struct isn't exported to userland
and the one libusbhid has is different and only shares a name...

MFC After: 3 days
Reviewed by: wulf@
Differential Revision: https://reviews.freebsd.org/D28543
Approved by: re@ (gjb)
(cherry picked from commit db2f512381)
(cherry picked from commit 0dc5c9467b)
2021-03-01 11:59:13 -07:00
Warner Losh 84c6bae8db acpi: limit the AMDI0020/AMDI0010 workaround to an option
It appears that production versions of EPYC firmware get the _STA method right
for these nodes. In fact, this workaround breaks on production hardware by
including too many uart nodes. This work around was for pre-release hardware
that wound up not having a large deployment. Move this work around to a kernel
option since the machines that needed it have been powered off and are difficult
to resurrect. Should there be a more significant deployment than is understood,
we can restrict it based on smbios strings.

Discussed with: mmacy@, seanc@, jhb@
MFC After: 3 days
Approved by: re@ (gjb)
(cherry picked from commit 35af933173)
(cherry picked from commit a60c5de933)
2021-03-01 11:58:52 -07:00
Kristof Provost a7926435c1 pf: Fix incorrect fragment handling
A sequence of overlapping IPv4 fragments could crash the kernel in
pf due to an assertion.

Approved by:    re (gjb)
Reported by:	Alexander Bluhm
Obtained from:	OpenBSD
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5f1b1f184b)
(cherry picked from commit 86ebf4d3e1)
2021-03-01 08:04:47 +01:00
Mark Johnston 113bd64cdf pmap: Fix largemap restart checks in the kernel_maps sysctl handler
The purpose of these checks is to ensure that the address of the
next-level page table page is valid, since nothing is synchronizing with
a concurrent update of the large map and large map PTPs are freed to the
system.  However, if PG_PS is set, there is no next level.

Approved by:	re (gjb)
Reported by:	rpokala
Reviewed by:	kib
Tested by:	rpokala
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28922

(cherry picked from commit aac25e2225)
(cherry picked from commit 5966aae9c7)
2021-02-28 19:32:58 -05:00
Mark Johnston 18b6283014 iflib: Avoid double counting in rxeof
iflib_rxeof() was counting everything twice.  This was introduced when
pfil hooks were added to the iflib receive path.  We want to count rx
packets/bytes before the pfil hooks are executed, so remove the counter
adjustments that are executed after.

Approved by:	re (gjb)
PR:		253583
Reviewed by:	gallatin, erj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28900

(cherry picked from commit b6999635b1)
(cherry picked from commit 76294b65df)
2021-02-28 15:51:21 -05:00
Jung-uk Kim 310ae6a0df OpenSSL: Regen manual page for the previous commit
This is regen for 9b2f020c14.

Approved by:	re (gjb)

(cherry picked from commit 351d06eeb5)
(cherry picked from commit cdba1277dd)
2021-02-26 13:35:20 -08:00
Oleksandr Tymoshenko 9745047839 Handle partial data re-sending on ktls/sendfile on FreeBSD
Add a handler for EBUSY sendfile error in addition to
EAGAIN. With EBUSY returned the data still can be partially
sent and user code has to be notified about it, otherwise it
may try to send data multiple times.

PR:		251969
Approved by:	re (gjb)
Obtained from:	OpenSSL (dfcfd17f2818cf520ce6381aed9ec3d2fc12170d)
Sponsored by:	Netflix (merging to FreeBSD)

(cherry picked from commit 9b2f020c14)
(cherry picked from commit 63241a0764)
2021-02-26 13:35:05 -08:00
Glen Barber e32bc25362 update to BETA4
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-02-25 21:18:11 -05:00
Robert Watson 97bfffafda Reimplement FreeBSD/arm64 dtrace_gethrtime() to use the system timer.
dtrace_gethrtime() is the high-resolution nanosecond timestemp used
for the DTrace 'timestamp' built-in variable.  The new implementation
uses the EL0 cycle counter and frequency registers in ARMv8-A.  This
replaces a previous implementation that relied on an
instrumentation-safe implementation of getnanotime(), which provided
only timer resolution.

Approved by:	re (gjb)
Reviewed by:	andrew, bsdimp (older version)
Useful comments appreciated:	jrtc27, emaste
Differential Revision:	https://reviews.freebsd.org/D28723
2021-02-25 22:31:52 +00:00
Alexander V. Chernikov 52d4c9e2fa Fix crash with rtadv-originated multipath IPv6 routes.
PR:		253800
Reported by:	Frederic Denis <freebsdml at hecian.net>
Approved by:	re(gjb)

(cherry picked from commit 7dfdd039a3)
2021-02-25 21:55:58 +00:00
Alexander V. Chernikov 5dde6e460a Fix nd6 rib_action() handling.
rib_action() guarantees valid rc filling IFF it returns without error.
Check rib_action() return code instead of checking rc fields.

PR:		253800
Reported by:	Frederic Denis <[email protected]>
Approved by:	re(gjb)

(cherry picked from commit ea10694336)
2021-02-25 21:55:52 +00:00
Mitchell Horne f1847ed16e arm64: extend struct db_reg to include watchpoint registers
The motivation is to provide access to these registers from userspace
via ptrace(2) requests PT_GETDBREGS and PT_SETDBREGS.

This change breaks the ABI of these particular requests, but is
justified by the fact that the intended consumers (debuggers) have not
been taught to use them yet. Making this change now enables active
upstream work on lldb to begin using this interface, and take advantage
of the hardware debugging registers available on the platform.

PR:		252860
Reported by:	Michał Górny ([email protected])
Reviewed by:	andrew, markj (earlier version)
Tested by:	Michał Górny ([email protected])
Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit f2583be110)
(cherry picked from commit 4786c8582c)
2021-02-25 17:31:31 -04:00
Mitchell Horne 8f686c0f29 arm64: handle watchpoint exceptions from EL0
This is a prerequisite to allowing the use of hardware watchpoints for
userspace debuggers.

This is also a slight departure from the x86 behaviour, since `si_addr`
returns the data address that triggered the watchpoint, not the
address of the instruction that was executed. Otherwise, there is no
straightforward way for the application to determine which watchpoint
was triggered. Make a note of this in the siginfo(3) man page.

Reviewed by:	jhb, markj (earlier version)
Tested by:	Michał Górny ([email protected])
Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit bd012c7159)
(cherry picked from commit 9372df63ad)
2021-02-25 17:31:17 -04:00
Mitchell Horne ce9bc83f91 arm64: validate breakpoint registers
In particular, we want to disallow setting breakpoints on kernel
addresses from userspace. The control register fields are validated or
ignored as appropriate.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit de2b942280)
(cherry picked from commit 8837e9c540)
2021-02-25 17:30:45 -04:00
Kirk McKusick f3a1daebaf Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash
PR:	253158
Approved by:	re (delphij, gjb)

(cherry picked from commit 8563de2f27)
(cherry picked from commit c31480a1f6)
2021-02-25 22:51:10 +02:00
Konstantin Belousov 6e3f19537a Call softdep_prealloc() before taking ffs_lock_ea(), if unlock is committing
Approved by:	re (delphij, gjb)

(cherry picked from commit 6f30ac9995)
2021-02-25 22:50:57 +02:00
Konstantin Belousov b287d46c38 ffs_close_ea: do not relock vnode under lock_ea
Approved by:	re (delphij, gjb)

(cherry picked from commit 5e198e7646)
2021-02-25 22:50:52 +02:00
Konstantin Belousov 16961e5e3f ffs_vnops.c: style
Approved by:	re (delphij, gjb)

(cherry picked from commit c6d68ca842)
2021-02-25 22:50:47 +02:00
Konstantin Belousov 9bef28f294 ffs: do not call softdep_prealloc() from UFS_BALLOC()
Approved by:	re (delphij, gjb)

(cherry picked from commit 4983146279)
2021-02-25 22:50:42 +02:00
Konstantin Belousov 298fde182f ffs_reallocblks: change the guard for softdep_prealloc() call to DOINGSUJ()
Approved by:	re (delphij, gjb)

(cherry picked from commit cc9958bf22)
2021-02-25 22:50:37 +02:00
Konstantin Belousov d1015ac544 fifo: minor comment and assert improvements.
Approved by:	re (delphij, gjb)

(cherry picked from commit adf28ab456)
2021-02-25 22:50:32 +02:00
Konstantin Belousov eed0fd5903 ffs_unlock: assert that IN_ENDOFF is not leaked past locked scope
Approved by:	re (delphij, gjb)

(cherry picked from commit 26af9f72f7)
2021-02-25 22:50:27 +02:00
Konstantin Belousov eadca59970 ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage
Approved by:	re (delphij, gjb)

(cherry picked from commit 28703d2713)
2021-02-25 22:50:22 +02:00
Konstantin Belousov 28d0541398 softdep_request_cleanup: wait for softdep_request_clean_flush() to pass
Approved by:	re (delphij, gjb)

(cherry picked from commit 2011b44fa3)
2021-02-25 22:50:12 +02:00
Konstantin Belousov f8272ff1d2 ufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it.
Approved by:	re (delphij, gjb)

(cherry picked from commit 013168db8c)
2021-02-25 22:50:00 +02:00
Konstantin Belousov 2e4940262c Stop ignoring ERELOOKUP from VOP_INACTIVE()
Approved by:	re (delphij, gjb)

(cherry picked from commit b59a8e63d6)
2021-02-25 22:49:49 +02:00
Konstantin Belousov 8ef69a7e8f ufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP
Approved by:	re (delphij, gjb)

(cherry picked from commit 6aed2435c8)
2021-02-25 22:49:41 +02:00
Konstantin Belousov f889959e0a ffs softdep: remove will_direnter argument of softdep_prelink()
Approved by:	re (delphij, gjb)

(cherry picked from commit ede40b0675)
2021-02-25 22:49:35 +02:00
Konstantin Belousov bccb8dda0e ufs_direnter: directory truncation does not need special case for rename
Approved by:	re (delphij, gjb)

(cherry picked from commit 06f2918ab8)
2021-02-25 22:49:29 +02:00
Konstantin Belousov 9fc9a50119 ufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there
Approved by:	re (delphij, gjb)

(cherry picked from commit 038fe6e089)
2021-02-25 22:49:24 +02:00
Konstantin Belousov b62d17802d ufs_direnter: move directory truncation to ffs_vput_pair().
Approved by:	re (delphij, gjb)

(cherry picked from commit 74a3652f83)
2021-02-25 22:49:09 +02:00
Konstantin Belousov 0c3cdbf429 ffs_vput_pair(): try harder to recover from the vnode reclaim
Approved by:	re (delphij, gjb)

(cherry picked from commit 30bfb2fa0f)
2021-02-25 22:49:04 +02:00
Konstantin Belousov b3162f7d99 FFS: implement special VOP_VPUT_PAIR().
Approved by:	re (delphij, gjb)

(cherry picked from commit f2c9d038bd)
2021-02-25 22:48:58 +02:00
Konstantin Belousov 2b2c2c7128 nfsserver: use VOP_VPUT_PAIR().
Approved by:	re (delphij, gjb)

(cherry picked from commit 4a21bcb241)
2021-02-25 22:48:52 +02:00
Konstantin Belousov 56119250bb ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE.
Approved by:	re (delphij, gjb)

(cherry picked from commit be44e98637)
2021-02-25 22:48:47 +02:00
Konstantin Belousov 02c163e49b Use VOP_VPUT_PAIR() for eligible VFS syscalls.
Approved by:	re (delphij, gjb)

(cherry picked from commit 3b2aa36024)
2021-02-25 22:48:42 +02:00
Konstantin Belousov b4cc32336d nullfs: provide special bypass for VOP_VPUT_PAIR
Approved by:	re (delphij, gjb)

(cherry picked from commit e4aaf35ab5)
2021-02-25 22:48:37 +02:00
Konstantin Belousov 984c11f5aa Add VOP_VPUT_PAIR() with trivial default implementation.
Approved by:	re (delphij, gjb)

(cherry picked from commit 49c117c193)
2021-02-25 22:48:32 +02:00
Konstantin Belousov c200745702 vn_open(): If the vnode is reclaimed during open(2), do not return error.
Approved by:	re (delphij, gjb)

(cherry picked from commit ee965dfa64)
2021-02-25 22:48:28 +02:00
Konstantin Belousov 9ab31d3d60 ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory
Approved by:	re (delphij, gjb)

(cherry picked from commit 08c2dc2841)
2021-02-25 22:48:23 +02:00
Konstantin Belousov 57582311c3 ffs_syncvnode: only clear IN_NEEDSYNC after successfull sync
Approved by:	re (delphij, gjb)

(cherry picked from commit 1de1e2bfbf)
2021-02-25 22:48:18 +02:00
Konstantin Belousov 6a61e5e0a1 Merge ufs_fhtovp() into ffs_inotovp().
Approved by:	re (delphij, gjb)

(cherry picked from commit 89fd61d955)
2021-02-25 22:48:13 +02:00
Konstantin Belousov fc54784b47 ffs_inotovp(): interface to convert (ino, gen) into alive vnode
Approved by:	re (delphij, gjb)

(cherry picked from commit 5952c86c78)
2021-02-25 22:47:47 +02:00
Konstantin Belousov 8ecc621480 ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf()
Approved by:	re (delphij, gjb)

(cherry picked from commit f16c26b1c0)
2021-02-25 22:47:42 +02:00
Konstantin Belousov b95a453656 ffs: call ufsdirhash_dirtrunc() right after setting directory size
Approved by:	re (delphij, gjb)

(cherry picked from commit e94f2f1be3)
2021-02-25 22:47:36 +02:00
Konstantin Belousov 041d9a1e05 buf SU hooks: track buf_start() calls with B_IOSTARTED flag
Approved by:	re (delphij, gjb)

(cherry picked from commit bf0db19339)
2021-02-25 22:47:01 +02:00
Allan Jude 1eb60112b2 Use iflib_if_init_locked() during media change instead of iflib_init_locked().
iflib_init_locked() assumes that iflib_stop() has been called, however,
it is not called for media changes.
iflib_if_init_locked() calls stop then init, so fixes the problem.

PR:	253473
Sponsored by:	Juniper Networks, Inc., Klara, Inc.
Approved by:	re (gjb)

(cherry picked from commit 922cf8ac43)
2021-02-25 20:41:10 +00:00
Alexander Motin d6cb4c5669 cxgb(4): Rework my commit 9dc7c250.
The previous implementation was reported to try to coalesce packets
in situations when it should not, that resulted in assertion later.
This implementation better checks the first packet of the chain for
the coallescing elligibility.

Approved by:	re (gjb@)

(cherry picked from commit d510bf133d)
(cherry picked from commit 1f3cff343b)
2021-02-25 12:02:34 -05:00
Martin Matuska 3d66df7026 zfs: restore FreeBSD resource usage accounting
With the switch to OpenZFS 2.0 the platform-dependent resource
usage accounting code got missing.

Patch author:	Ryan Moeller <[email protected]>

Obtained from:	openzfs/zfs@64e0fe14ff
Approved by:	re (gjb)

(cherry picked from commit 2126962573)
2021-02-25 17:20:53 +01:00
Martin Matuska 442719c0c6 zfs: disable use of hardware crypto offload drivers
From openzfs-master e7adccf7f commit message:
  First, the crypto request completion handler contains a bug in that it
  fails to reset fs_done correctly after the request is completed.  This
  is only a problem for asynchronous drivers.  Second, some hardware
  drivers have input constraints which ZFS does not satisfy.  For
  instance, ccp(4) apparently requires the AAD length for AES-GCM to be a
  multiple of the cipher block size, and with qat(4) the AES-GCM AAD
  length may not be longer than 240 bytes.  FreeBSD's generic crypto
  framework doesn't have a mechanism to automatically fall back to a
  software implementation if a hardware driver cannot process a request,
  and ZFS does not tolerate such errors.

Patch Author:	Mark Johnston <[email protected]>

Obtained from:	openzfs/zfs@e7adccf7f5
PR:		252981, 253595
Approved by:	re (gjb)

(cherry picked from commit 940415f20a)
2021-02-25 17:20:20 +01:00
Martin Matuska ee0b7e05e7 zfs: fix panic if scrubbing after removing a slog device
From openzfs-master 11f2e9a4 commit message:
  vdev_ops: don't try to call vdev_op_hold or vdev_op_rele when NULL

  This prevents a panic after a SLOG add/removal on the root pool followed
  by a zpool scrub.

  When a SLOG is removed, a hole takes its place - the vdev_ops for a hole
  is vdev_hole_ops, which defines the handler functions of vdev_op_hold
  and vdev_op_rele as NULL.

Patch Author: Patrick Mooney <[email protected]>

Obtained from:	openzfs/zfs@11f2e9a491
PR:		252396
Approved by:	re (gjb)

(cherry picked from commit 64649f0285)
2021-02-25 17:19:49 +01:00
Toomas Soome e680f3c0bd loader: autoload_font will hung loader when there is no local console
If we start with console set to comconsole, the local
console (vidconsole, efi) is never initialized and attempt to
use the data can render the loader hung.

(cherry picked from commit 61c50cbc09)

Reported by:	Kamigishi Rei
Approved by:	re (gjb)
2021-02-25 18:05:24 +02:00
Mark Johnston 5ad3a9988c vm_kern: Avoid sign extension in the KVA_QUANTUM definition
Otherwise, on a powerpc64 NUMA system with hashed page tables, the
first-level superpage reservation size is large enough that the value of
the kernel KVA arena import quantum, KVA_NUMA_IMPORT_QUANTUM, is
negative and gets sign-extended when passed to vmem_set_import().  This
results in a boot-time hang on such platforms.

Approved by:	re (gjb)
Reported by:	bdragon

(cherry picked from commit 23e875fd97)
(cherry picked from commit 0486986ad8)
2021-02-25 10:54:17 -05:00
Toomas Soome 8305d6906f loader: unload command should reset tg_kernel_supported in gfx_state
While loading kernel, we check if vt/vbe backend support is included in
kernel and set the tg_kernel_supported flag in gfx_state. unload
command needs to reset this flag to allow next load to perform
this check with new kernel.

(cherry picked from commit 9b388ac303)

Reported by: jhb
Approved by: re (gjb)
2021-02-23 09:42:26 +02:00
Dimitry Andric 6daafec208 Fix loader detection of vbefb support on !amd64
On i386, after 6c7a932d0b, the vbefb vt
driver was no longer detected by the loader, if any kernel module was
loaded after the kernel itself.

This was caused by the parse_vt_drv_set() function being called multiple
times, resetting the detection flag. (It was called multiple times,
becuase i386 .ko files are shared objects like the kernel proper, while
this is not the case on amd64.)

Fix this by skipping the set_vt_drv_set lookup if vbefb was already
detected.

(cherry picked from commit 6e26189be4)

Reviewed by:	tsoome
Approved by:	re (gjb)
2021-02-23 09:41:55 +02:00
Toomas Soome ce132d4aab loader: start kernel in text mode when there is no vbefb vt driver
If kernel is built without VT vbefb driver, make sure
we start kernel in text mode.

(cherry picked from commit 6c7a932d0b)

Approved by: re (gjb)
2021-02-23 09:41:09 +02:00
Toomas Soome b3e8229935 loader_lua: consider userboot console as serial
We use ascii box chars with serial console because we do not know
if terminal can draw unixode box chars. Same problem is about userboot
console.

(cherry picked from commit 5d8c062fe3)

Approved by: re (gjb)
2021-02-23 09:39:18 +02:00
Mark Johnston 035021b98a Add UPDATING entries and bump version
Approved by:	re (implicit, so)
Approved by:	so
2021-02-23 20:42:47 -05:00
Mark Johnston f82cffcf2f pam_login_access: Fix negative entry matching logic
PR:		252194
Approved by:	re (implicit, so)
Approved by:	so
Security:	CVE-2020-25580
Security:	FreeBSD-SA-21:03.pam_login_access

(cherry picked from commit 6ab923cbca)
(cherry picked from commit 8cf559d6b9)
2021-02-23 20:42:42 -05:00
Roger Pau Monné ce9af53d08 xen-blkback: fix leak of grant maps on ring setup failure
Multi page rings are mapped using a single hypercall that gets passed
an array of grants to map. One of the grants in the array failing to
map would lead to the failure of the whole ring setup operation, but
there was no cleanup of the rest of the grant maps in the array that
could have likely been created as a result of the hypercall.

Add proper cleanup on the failure path during ring setup to unmap any
grants that could have been created.

This is part of XSA-361.

Approved by:	re (implicit, so)
Approved by:	so
Security:	CVE-2021-26932
Security:	FreeBSD-SA-21:06.xen
Security:	XSA-361
Sponsored by:	Citrix Systems R&D

(cherry picked from commit 808d4aad10)
(cherry picked from commit ab3e1bd3c2)
2021-02-23 20:42:35 -05:00
Konstantin Belousov 4b737a9c58 pgcache read: protect against reads past end of the vm object size
PR:	253158
Approved by:	re (gjb)

(cherry picked from commit c61fae1475)
2021-02-23 13:21:00 +02:00
Alexander Motin d7296b8939 cxgbe(4): Save proper zone index on low memory in refill_fl().
When refill_fl() fails to allocate large (9/16KB) mbuf cluster, it
falls back to safe (4KB) ones.  But it still saved into sd->zidx
the original fl->zidx instead of fl->safe_zidx.  It caused problems
with the later use of that cluster, including memory and/or data
corruption.

While there, make refill_fl() to use the safe zone for all following
clusters for the call, since it is unlikely that large succeed.

Approved by:	re@ (gjb@)
Sponsored by:	iXsystems, Inc.
Reviewed by:	np, jhb
Differential Revision:	https://reviews.freebsd.org/D28716

(cherry picked from commit 294e62bebf)
(cherry picked from commit c930816b76)
2021-02-22 16:46:10 -08:00
Mark Johnston ae093a0614 libdtrace: Stop relying on lex compatibility
It does not appear to be required, and as of commit 6b7e592c21
("lex: Do not let input() return 0 when end-of-file is reached") it
causes input to return 0 instead of EOF when end-of-input is reached.

Approved by:	re (gjb)
PR:		253440
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8ba333e02e)
(cherry picked from commit af80731179)
2021-02-22 16:59:36 -05:00
Jung-uk Kim 4e3fa977a1 lex: Do not let input() return 0 when end-of-file is reached
Importing flex 2.6.4 has introduced a regression: input() now returns 0
instead of EOF to indicate that the end of input was reached, just like
traditional AT&T and POSIX lex.  Note the behavior contradicts flex(1).
See "INCOMPATIBILITIES WITH LEX AND POSIX" section for information.
This incompatibility traces back to the original version and documented
in its manual page by the Vern Paxson.

Apparently, it has been reported in a few places, e.g.,

https://github.com/westes/flex/issues/448
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415

Unfortunately, this also breaks the scanner used by libdtrace and
dtrace is unable to resolve some probe argument types as a result.  See
PR253440 for more information.

Note the regression was introduced by the following upstream commit
without any explanation or documentation change:

https://github.com/westes/flex/commit/f863c9490e6912ffcaeb12965fb3a567a10745ff

Now we restore the traditional flex behavior unless lex-compatibility
mode is set with "-l" option because I believe the author originally
wanted to make it more lex and POSIX compatible.

PR:		253440
Reported by:	markj
Approved by:	re (gjb)

(cherry picked from commit 6b7e592c21)
2021-02-22 16:28:53 -05:00
Gordon Bergling dd250d3def ktls(4): Mention WITH_OPENSSL_KTLS in the ktls(4) manual page
Since we ship a ktls(4) enabled OpenSSL version, mention
the src.conf(5) option WITH_OPENSSL_KTLS in the manual page.

Approved by:	re (gjb)
Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D28435

(cherry picked from commit 6c34d8ce11)
2021-02-22 20:21:46 +01:00
Jamie Gritton f3f042d850 MFS jail: Change both root and working directories in jail_attach(2)
jail_attach(2) performs an internal chroot operation, leaving it up to
the calling process to assure the working directory is inside the jail.

Add a matching internal chdir operation to the jail's root.  Also
ignore kern.chroot_allow_open_directories, and always disallow the
operation if there are any directory descriptors open.

Reported by:    mjg
Approved by:    re (gjb), markj, kib

(cherry picked from commit d4380c0cdd)
(cherry picked from commit 5dbb407145)
2021-02-22 10:25:23 -08:00
Kyle Evans 5d07525b81 pkg(7): address minor nits (mostly clang-analyze complaints)
- One (1) spurious whitespace.
- One (1) occurrence of "random(3) bad, arc4random(3)" good.
- Three (3) writes that will never be seen.

The latter two points are complaints from clang-analyze. Switching to
arc4random(3) is decidedly a good idea because we weren't doing any kind
of PRNG seeding anyways. The discarded assignments are arguably good
for future-proofing, but it's better to improve the S/N ratio from
clang-analyze.

Approved by:	re (gjb)

(cherry picked from commit b2c4ca8d28)
(cherry picked from commit 9ec09b04df)
2021-02-22 10:30:26 -06:00
Michal Krawczyk 5de955fe43 MFC 1c808fcd85: Allocate BAR for ENA MSIx vector table
In the new ENA-based instances like c6gn, the vector table moved to a
new PCIe bar - BAR1. Previously it was always located on the BAR0, so
the resources were already allocated together with the registers.

As the FreeBSD isn't doing any resource allocation behind the scenes,
the driver is responsible to allocate them explicitly, before other
parts of the OS (like the PCI code allocating MSIx) will be able to
access them.

To determine dynamically BAR on which the MSIx vector table is present
the pci_msix_table_bar() is being used and the new BAR is allocated if
needed.

Approved by: re (gjb)
Submitted by: Michal Krawczyk <[email protected]>
Obtained from: Semihalf
Sponsored by: Amazon, Inc

(cherry picked from commit 1c808fcd85)
(cherry picked from commit e540e45097)
2021-02-22 17:29:40 +01:00
Emmanuel Vadot 1d0d443daa arm64: rpi4: gpio: Add brcm,bcm2711-gpio compatible
Looks like we never enabled the main gpio controller on the RPI4 board.
Now gpio are usable.

Approved by:	re (gjb)
MFC after:	3 days

(cherry picked from commit 2551d92850)
(cherry picked from commit 796faf365c)
2021-02-21 22:03:14 +01:00
Emmanuel Vadot 07efb4cef7 arm64: rpi4: firmware: Attach at BUS_PASS_BUS + BUS_PASS_ORDER_LATE
The node have now a compatible with simple-mfd so we need to attach
at the same pass so the specific driver will be used.

Approved by:	re (gjb)
MFC after:	3 days
PR:		252971

(cherry picked from commit 1cf2823631)
(cherry picked from commit 944f431655)
2021-02-21 22:02:47 +01:00
Alan Somers 26b11d047d libpmc: fix linking with C programs
Revision r334749 Added some C++ code to libpmc.  It didn't change the ABI,
but it did introduce a dependency on libc++.  Nobody noticed because every
program that in the base system that uses libpmc is also C++.

Approved by:	re (gjb)
Reported-by:	Dom Dwyer <[email protected]>
Reviewed By:	vangyzen
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D28550

(cherry picked from commit 04e34c0202)
2021-02-21 13:42:51 -07:00
Kristof Provost a310973472 pf: Fix osfp configuration
pf_rule_to_krule() incorrectly converted the rule osfp configuration to
the krule structure.

Approved by:    re (kib)
Reported by:	delphij@
MFC after:	3 days

(cherry picked from commit 2ed689a674)
(cherry picked from commit 9823eb6909)
2021-02-21 17:31:27 +01:00
Jamie Gritton 9f00cb5fa8 MFS jail: Handle a possible race between jail_remove(2) and fork(2)
jail_remove(2) includes a loop that sends SIGKILL to all processes
in a jail, but skips processes in PRS_NEW state.  Thus it is possible
the a process in mid-fork(2) during jail removal can survive the jail
being removed.

Add a prison flag PR_REMOVE, which is checked before the new process
returns.  If the jail is being removed, the process will then exit.
Also check this flag in jail_attach(2) which has a similar issue.

Approved by:    re (gjb)
Reported by:    trasz
Approved by:    kib

(cherry picked from commit cc7b730653)
(cherry picked from commit 894360bacd)
2021-02-19 13:53:07 -08:00
Konstantin Belousov 889cf2bf73 ffs_vnops.c: Move opt_*.h includes to the top.
Approved by:	re (gjb)

(cherry picked from commit 0281f88e5d)
2021-02-19 22:56:13 +02:00
Glen Barber 150b4388d3 update to 13.0-BETA3
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-02-18 19:00:40 -05:00
Toomas Soome eb7d18ff0a loader: do not autoselect smaller font than 8x16 with high res display
The VT screen buffer size is calculated based on our default
built in (8x16) font.

With high-resolution display, we want to use at least 8x16 font,
or we will have large unused areas on screen.

(cherry picked from commit a26f735858)

Approved by: re (gjb)
2021-02-18 10:25:16 +02:00
Toomas Soome d560d01b02 loader: remove BORDER_PIXELS
BORDER_PIXELS is left over from picking up the source from illumos
port. Since FreeBSD VT does not use border in terminal size
calculation, there is no reason why should loader use it.

(cherry picked from commit 96bef2053a)

Approved by: re (gjb)
2021-02-18 10:23:57 +02:00
Toomas Soome 03c31d3ca3 vt: terminal size can grow too big with small font
vt is using static buffers for on screen data, the buffer size is
calculated based on maximum supported screen size and 8x16 font.

When using hi-res graphics and very smaller than 8x16 font, we
need to be careful not to overflow static buffers in vt.

Testing: I did test by building smaller buffers than vt currently is using,
royger was testing on actual 4k capable hardware.

Tested by: royger

(cherry picked from commit 32bf05ad89)
Approved by: re(gjb)
2021-02-18 10:22:43 +02:00
Alfredo Dal'Ava Junior c3942b4284 [POWERPC64LE] add mrsas to GENERIC64LE
Approved by:	re (gjb)
Reviewed by:	bdragon
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28475

(cherry picked from commit eaffd270d8)
(cherry picked from commit 928cbdbe39)
2021-02-18 21:50:19 +00:00
Alfredo Dal'Ava Junior f49177221a mrsas: update man page
update mrsas(4) since big-endian is supported since
e34a057ca6

Approved by:	re (gjb)
Reviewed by:    bdragon, gbe
Sponsored by:   Eldorado Research Institute (eldorado.org.br)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D28475

(cherry picked from commit 20e1817f9a)
(cherry picked from commit 467f2b64db)
2021-02-18 21:50:08 +00:00
Hans Petter Selasky 0abf8ecb11 MFC 12148d4300:
Fix for locking order reversal in USB audio driver, when using mmap().

Locking the second lock which causes the LOR, can be skipped because
the code updating the shared variables is always executing from the
same USB thread.

lock order reversal:
  1st 0xfffff80005cc3840 pcm7:play:dsp7.p0 (pcm play channel, sleep mutex)
@ usb_transfer.c:2342
  2nd 0xfffff80005cc3860 pcm7:record:dsp7.r0 (pcm record channel, sleep mutex)
@ uaudio.c:2317

lock order pcm record channel -> pcm play channel established at:
witness_checkorder+0x461
__mtx_lock_flags+0x98
dsp_mmap_single+0x151
vm_mmap_cdev+0x65
devfs_mmap_f+0x143
kern_mmap_req+0x594
sys_mmap+0x46
amd64_syscall+0x12e
fast_syscall_common+0xf8

lock order pcm play channel -> pcm record channel attempted at:
witness_checkorder+0xd82
__mtx_lock_flags+0x98
uaudio_chan_play_callback+0xeb
usbd_callback_wrapper+0x7ec
usb_command_wrapper+0x7e
usb_callback_proc+0x8e
usb_process+0xf3
fork_exit+0x80
fork_trampoline+0xe

Approved by:	re (gjb)
Found by:	Stefan Ehmann <[email protected]>
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 12148d4300)
2021-02-18 10:19:43 +01:00
Martin Matuska 0be7053c91 zfs: Avoid updating the L2ARC device header unnecessarily
From openzfs-master 0ae184a6b commit message:
  If we do not write any buffers to the cache device and the evict hand
  has not advanced do not update the cache device header.

Cherry-picked from openzfs 0ae184a6ba
Patch Author:   George Amanakis <[email protected]>

Approved by:		re (gjb)
Reviewed by:            delphij
Differential Revision:  https://reviews.freebsd.org/D28682

(cherry picked from commit 5dce03847f)
(cherry picked from commit edb9049c3a)
2021-02-18 10:01:16 +01:00
Martin Matuska 223debfb95 zfs: fix RAIDZ2/3 not healing parity with 2+ bad disks
From openzfs-master 62d4287f2 commit message:
  When scrubbing, (non-sequential) resilvering, or correcting a checksum
  error using RAIDZ parity, ZFS should heal any incorrect RAIDZ parity by
  overwriting it.  For example, if P disks are silently corrupted (P being
  the number of failures tolerated; e.g. RAIDZ2 has P=2), `zpool scrub`
  should detect and heal all the bad state on these disks, including
  parity.  This way if there is a subsequent failure we are fully
  protected.

  With RAIDZ2 or RAIDZ3, a block can have silent damage to a parity
  sector, and also damage (silent or known) to a data sector.  In this
  case the parity should be healed but it is not.

Cherry-picked from openzfs 62d4287f27
Patch Author:	Matthew Ahrens <[email protected]>

Approved by:		re (gjb)
Reviewed by:		delphij
Differential Revision:	https://reviews.freebsd.org/D28681

(cherry picked from commit f15e18a642)
(cherry picked from commit 6f21b7996a)
2021-02-18 09:59:38 +01:00
Jung-uk Kim ba4d5b4d59 OpenSSL: Regen assembly files for OpenSSL 1.1.1j
(cherry picked from commit 3396647c8d)
(cherry picked from commit 7973db046c)

Approved by:	re (gjb)
2021-02-17 19:16:20 -05:00
Jung-uk Kim f7e7c4d406 OpenSSL: Remove obsolete include directory
This directory was deprecated since OpenSSL 1.1.1e.

https://github.com/openssl/openssl/pull/9681

(cherry picked from commit b840816061)
(cherry picked from commit 36c368d91c)

Approved by:	re (gjb)
2021-02-17 19:15:49 -05:00
Jung-uk Kim 28025add11 OpenSSL: Regen manual pages for OpenSSL 1.1.1j.
(cherry picked from commit e25db73fea)
(cherry picked from commit e8cbe40ac3)

Approved by:	re (gjb)
2021-02-17 19:15:19 -05:00
Jung-uk Kim e57523de19 OpenSSL: Merge OpenSSL 1.1.1j
(cherry picked from commit 88e852c0b5)
(cherry picked from commit a4f76f79ff)

Approved by:	re (gjb)
2021-02-17 19:14:19 -05:00
Kyle Evans 726e20f450 fmtree: add a deprecation notice to the manpage
Note that this mtree(8) is actually installed as fmtree(8), while
mtree(8) is located in ^/contrib/mtree -- thus, the reference to
mtree(8) makes a lot more sense in the context in which folks would
actually notice it. Shout-out to Ravi for pointing out that this may
not be an obvious fact.

Approved by:	re (gjb)
Relnotes:	yes

(cherry picked from commit 6fea22cebe)
(cherry picked from commit be4b3e7a5b)
2021-02-17 10:53:25 -06:00
Kristof Provost 23f8fe51af Widen ifnet_detach_sxlock coverage
Widen the ifnet_detach_sxlock to cover the entire vnet sysuninit code.
This ensures that we can't end up having the vnet_sysuninit free the UDP
pcb while the detach code is running and trying to purge the UDP pcb.

Approved by:    re (gjb)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28530

(cherry picked from commit 6d2a10d96f)
(cherry picked from commit 0553021116)
2021-02-17 17:49:28 +01:00
Kristof Provost 00abeecb4a pf: Slightly relax pf_rule_addr validation
Ensure we don't reject no-route / urpf-failed addresses.

PR:		253479
Approved by:    re (gjb)
Reported by:	michal AT microwave.sk
Revied by:	donner@
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D28650

(cherry picked from commit 5e42cb139f)
(cherry picked from commit f9a66bb91a)
2021-02-17 17:48:58 +01:00
Andrey V. Elsukov 6666b1d45a [udp6] fix possible panic due to lack of locking.
The lookup for a IPv6 multicast addresses corresponding to
the destination address in the datagram is protected by the
NET_EPOCH section. Access to each PCB is protected by INP_RLOCK
during comparing. But access to socket's so_options field is
not protected. And in some cases it is possible, that PCB
pointer is still valid, but inp_socket is not. The patch wides
lock holding to protect access to inp_socket. It copies locking
strategy from IPv4 UDP handling.

PR:	232192
Approved by:	re (gjb)
Obtained from:	Yandex LLC
Sponsored by:	Yandex LLC
Differential Revision:	https://reviews.freebsd.org/D28232

(cherry picked from commit 3c782d9c91)
(cherry picked from commit 8cb4c36316)
2021-02-17 01:03:08 +03:00
Michael Chiu f28545524c ifconfig: fix incorrect wg allowed-ips netmask
Currently when peer information is displayed with `ifconfig wgN peer ..`
or `ifconfig wgN peer-list`, the netmask of the first `allowed-ips` will
be used as the netmask of all CIDR in `allowed-ips`.  For example, if
the list is `192.168.1.0/24, 172.16.0.0/16`, it will display as
`192.168.1.0/24, 172.16.0.0/24`. While this does not affect the actual
functionality, it is very confusing.

Submitted by:   Michael Chiu <nyan -at- myuji.xyz>
Reviewed by:	grehan
Differential Revision: https://reviews.freebsd.org/D28655
Approved by:    re (gjb)

(cherry picked from commit be2003ccfa)
2021-02-17 05:11:45 +08:00
Glen Barber 4689ab1eab release: fix overriding UNAME_r
release.sh: fix OSVERSION and UNAME_r overrides

Add PBUILD_FLAGS and UNAME_r overrides to extra_chroot_setup()
to fix building ports for 14-CURRENT builds on 13.x.

Approved by:	re (kib)
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit c511a5ab53)
(cherry picked from commit 6462113b70)
(cherry picked from commit cc11afa865)
2021-02-16 13:12:07 -05:00
Mark Johnston f560a8b1a4 mca: Handle inconsistent CMCI capability reporting
A BIOS bug may apparently cause the BSP to report that it does not
implement CMCI, with some APs reporting that they do.  In this scenario,
avoid a NULL pointer dereference that occurs in cmci_monitor() because
cmc_state was not allocated by the BSP.

Approved by:	re (gjb)
PR:		253272
Reported by:	asomers, mmacy
Reviewed by:	kib (previous version)

(cherry picked from commit b577047027)
(cherry picked from commit 8eebd9592e)
2021-02-16 12:07:43 -05:00
Richard Scheffenegger 1e76911d62 Adding PRR sysctls to tcp(4) man page
Documenting the newly added, and enabled by default,
Proportional Rate Reduction algorithm's governing sysctls.

Reviewed by:	kbowling, rgrimes
Approved by:	re(gjb)
MFC after:	3 days
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D28568

(cherry picked from commit a78fee8182)
2021-02-15 22:56:39 +01:00
Alexander V. Chernikov 2f4f3e2512 Fix ifa refcount leak during route addition.
Reported by:	rstone
Reviewed by:	rstone
Approved by:	re(gjb)

(cherry picked from commit 11304949de)
2021-02-15 20:41:05 +00:00
Randall Stewart b3cfe07d74 When we are about to send down to the driver layer
we need to make sure that the m_nextpkt field is NULL
else the lower layers may do unwanted things.

Approved by:	re(gjb)
Reviewed By:  gallatin, melifaro
Differential Revision: https://reviews.freebsd.org/D28377

(cherry picked from commit 538a81520b)
2021-02-15 20:39:11 +00:00
Michal Meloun 15e64578cb dwmmc: Multiple busdma fixes.
- limit maximum segment size to 2048 bytes.  Although dwmmc supports a buffer
  fragment with a maximum length of 4095 bytes, use the nearest lower power
  of two as the maximum fragment size. Otherwise, busdma create excessive
  buffer fragments.
- fix off by one error in computation of the maximum data transfer length.
- in addition, reserve two DMA descriptors that can be used by busdma
  bouncing. The beginning or end of the buffer can be misaligned.
- Don’t ignore errors passed to bus_dmamap_load() callback function.
- In theory, a DMA engine may be running at time when next dma descriptor is
  constructed. Create a full DMA descriptor before OWN bit is set.

Approved by:	re (gjb)

(cherry picked from commit 8727c174b0)
(cherry picked from commit e8dfdf40be)
2021-02-13 13:27:48 +01:00
Michal Meloun 72d3aeb1b2 arm32: Align arguments of sync_icache() syscall to cacheline size.
Otherwise, we may miss synchronization of the last cacheline.

Approved by:    re (gjb)

(cherry picked from commit ec090f4a67)
(cherry picked from commit 6930f97474)
2021-02-13 13:27:43 +01:00
Michal Meloun f63b87ec3e arm64: Initialize VFP control register.
The RW fields in this register reset to architecturally unknown values,
so initialize these to the proper rounding and denormal mode.

Approved by:	re (gjb)

(cherry picked from commit 65618fdda0)
(cherry picked from commit 214ef32001)
2021-02-13 13:27:36 +01:00
Mark Johnston 678abec026 vm: Honour the "noreuse" flag to vm_page_unwire_managed()
This flag indicates that the page should be enqueued near the head of
the inactive queue, skipping the LRU queue.  It is used when unwiring
pages from the buffer cache following direct I/O or after I/O when
POSIX_FADV_NOREUSE or _DONTNEED advice was specified, or when
sendfile(SF_NOCACHE) completes.  For the direct I/O and sendfile cases
we only enqueue the page if we decide not to free it, typically because
it's mapped.

Pass "noreuse" through to vm_page_release_toq() so that we actually
honour the desired LRU policy for these scenarios.

Approved by:	re (kib)
Reported by:	bdrewery
Reviewed by:	alc, kib
Differential Revision:	https://reviews.freebsd.org/D28555

(cherry picked from commit 5c18744ea9)
(cherry picked from commit a73aaaeb57)
2021-02-12 20:31:22 -05:00
Glen Barber 6461715f1a update releng/13.0 to BETA2
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-02-11 19:01:40 -05:00
Alexander V. Chernikov 4a3d252cf3 Turn off forgotten multipath debug messages
Approved by:	re(gjb)
Reported by:	mike tancsa<mike at sentex.net>

(cherry picked from commit adc4ea97bd)
(cherry picked from commit 980ce11f30)
2021-02-11 23:10:31 +00:00
Mark Johnston 46d3e8cd88 armv8crypto: Fix some edge cases in the AES-GCM implementation
- We were only hashing up to the first 16 bytes of the AAD.
- When computing the digest during decryption, handle the case where
  len == trailer, i.e., len < AES_BLOCK_LEN, properly.

While here:

- trailer is always smaller than AES_BLOCK_LEN, so remove a pair of
  unnecessary modulus operations.
- Replace some byte-by-byte loops with memcpy() and memset() calls.
  In particular, zero the full block before copying a partial block into
  it since we do that elsewhere and it means that the memset() length is
  known at compile time.

Approved by:	re (gjb)
Reviewed by:	jhb
Sponsored by:	Ampere Computing
Submitted by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D28501

(cherry picked from commit 0dc7076037)
(cherry picked from commit 860e0c7fb8)
2021-02-11 11:47:37 -05:00
Kyle Evans dc57f21252 grep: fix -A handling in conjunction with -m match limitation
The basic issue here is that grep, when given -m 1, would stop all
line processing once it hit the match count and exit immediately.  The
problem with exiting immediately is that -A processing only happens when
subsequent lines are processed and do not match.

The fix here is relatively easy; when bsdgrep matches a line, it resets
the 'tail' of the matching context to the value supplied to -A and
dumps anything that's been queued up for -B. After the current line has
been printed and tail is reset, we check our mcount and do what's
needed. Therefore, at the time that we decide we're doing nothing, we
know that 'tail' of the context is correct and we can simply continue
on if there's still more to pick up.

With this change, we still bail out immediately if there's been no -A
flag. If -A was supplied, we signal that we should continue on. However,
subsequent lines will not even bothere to try and process the line.  We
have reached the match count, so even if the next line would match then
we must process it if it hadn't. Thus, the loop in procfile() can
short-circuit and just process the line as a non-match until
procmatches() indicates that it's safe to stop.

A test has been added to reflect both that we should be picking up the
next line and that the next line should be considered a non-match even
if it should have been.

PR:		253350
Approved by:	re (gjb)

(cherry picked from commit 3e2d96ac97)
(cherry picked from commit 08f25b50db)
2021-02-11 09:12:17 -06:00
Kyle Evans f28ccd8d95 grep: fix null pattern and empty pattern file behavior
The null pattern semantics were terrible because I tried to match gnugrep,
but I got it wrong.  Let's unwind that:

- The null pattern should match every line if neither -w nor -x.
- The null pattern should match empty lines if -x.
- The null pattern should not match any lines if -w.

The first two will stop processing (shortcut) even if additional patterns
are specified. In any other case, we will continue processing other
patterns.  If no other patterns are specified beside a null pattern, then
we match if neither -w nor -x or set and do not match if either of those
are specified.

The justification for -w is that it should match on a whole word, but the
null pattern does not have a whole word to match on.

Empty pattern files should never match anything, and more importantly, -v
should cause everything to be written.

PR:		253209
Approved by:	re (gjb)

(cherry picked from commit f823c6dc73)
(cherry picked from commit 574d0dfae5)
2021-02-11 09:12:10 -06:00
Ed Maste 0b54d27647 Enable pvscsi and vmx in arm64 GENERIC
FreeBSD pvscsi and vmx work with VMware ESXi Arm "Fling"; provide these
in GENERIC for a convenient out-of-the-box experience.

PR:		253202
Reported by:	Vincent Milum Jr
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 375d797b81)
(cherry picked from commit 87eac76083)
2021-02-10 12:10:45 -05:00
Ed Maste bfb217a826 Correct description for kern.proc.proc_td
kern.proc.proc_td returns the process table with an entry for each
thread.  Previously the description included "no threads", presumably
a cut-and-pasteo in 2648efa621.

Description suggested by PauAmma.

PR:		253146
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit edc374e7c4)
(cherry picked from commit dbe043d42c)
2021-02-10 12:10:01 -05:00
Ed Maste abfcf9a17d readelf: decode LA48 and ASG_DISABLE feature flags
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e79b51e2b2)
(cherry picked from commit 5e9e7ad9a2)
2021-02-10 12:08:51 -05:00
Brandon Bergren c48cbd0254 powerpc64: Fix boot on virtual-mode OF (PowerMac G5)
In 78599c32ef, CFI endproc decoration was
added to locore64.S. However, it missed the subtle detail that
__restartkernel_virtual() falls through to __restartkernel(). This was
causing boot failure on PowerMac G5, as it tried to execute the
epilogue as code.

Fix this by branching to __restartkernel() instead of intentionally
running off the end of the function.

While here, add some additional notes on how the virtual mode restart
works.

Approved by:	re (gjb)

(cherry picked from commit d26f2a50ff)
(cherry picked from commit 187492ef63)
2021-02-09 21:42:44 -06:00
Stefan Eßer c41fef90a7 bc: Correct mis-merge of contrib/bc on upgrade to version 3.2.6
Revert "bc: Vendor import of Gavin Howard's bc version 3.2.6"
This reverts commit 601ac82194.

Vendor import of Gavin Howard's bc version 3.2.6
(cherry picked from commit 47a52dc4d4)

The files README.md and .gitignore had been lost and are restored
by this commit.

A lot of files used for fuzzing had been moved to a new place and
still existed in their previous location. Delete the now obsolete
files from the old location.

Approved by:   re
2021-02-09 22:24:12 +01:00
Antonio Russo 7100be11ec Set file mode during zfs_write
Apply https://github.com/openzfs/zfs/pull/11576

Direct commit from upstream openzfs. Full commit message below:

Set file mode during zfs_write

3d40b65 refactored zfs_vnops.c, which shared much code verbatim between
Linux and BSD.  After a successful write, the suid/sgid bits are reset,
and the mode to be written is stored in newmode.  On Linux, this was
propagated to both the in-memory inode and znode, which is then updated
with sa_update.

3d40b65 accidentally removed the initialization of newmode, which
happened to occur on the same line as the inode update (which has been
moved out of the function).

The uninitialized newmode can be saved to disk, leading to a crash on
stat() of that file, in addition to a merely incorrect file mode.

Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Antonio Russo <[email protected]>
Closes #11474
Closes #11576

Approved by:	re (gdb)
Obtained from:	openzfs/zfs@f8ce8aed0
Sponsored by:	iXsystems, Inc.

(cherry picked from commit e9d419a053)
(cherry picked from commit 618dee6023)
2021-02-09 13:13:25 -05:00
John Baldwin f69cd089cc serf: Fix the default return value of the BIO control method.
OpenSSL BIO classes provide an abstraction for dealing with I/O.
OpenSSL provides BIO classes for commonly used I/O primitives backed
by file descriptors, sockets, etc. as well as permitting consumers
of OpenSSL to define custom BIO classes.

One of the methods BIO classes implement is a control method invoked
by BIO_ctrl() for various ancilliary tasks somewhat analgous to
fcntl() and ioctl() on file descriptors.  According to the BIO_ctrl(3)
manual page, control methods should return 0 for unknown control
requests.

KTLS support in OpenSSL adds new control requests.  Two of those new
requests are queries to determine if KTLS is enabled for either
reading or writing.  These control reuquest return 1 if KTLS is
enabled and 0 if it is not.

serf includes two custom BIO classes for wrapping I/O requests from
files and from a buffer in memory.  These BIO classes both use a
custom control method.  However, this custom control method was
returning 1 for unknown or unsupported control requests instead of 0.
As a result, OpenSSL with KTLS believed that these BIOs were using
KTLS and were thus adding headers and doing encryption/decryption in
the BIO.  Correcting the return value removes this confusion.

PR:		253135
Reported by:	Guido Falsi <[email protected]>
Approved by:	re (gjb)
Sponsored by:	Netflix

(cherry picked from commit cb7cc72c54)
(cherry picked from commit b122886de2)
2021-02-09 09:35:21 -08:00
John Baldwin 1f0bc379eb Fix ldd to work with more ELF files.
- Use libelf to parse ELF data structures and remove code duplication
  for ELF32.

- Don't require the OSABI field to be set to the FreeBSD OSABI for
  shared libraries.  Both AArch64 and RISC-V leave it set to "none"
  and instead depend on the ABI tag note.  For ldd, this means falling
  back to walking the notes in PT_NOTE segments to find the ABI tag
  note to determine if an ELF shared library without OSABI set in the
  header file is a FreeBSD shared library.

Approved by:	re (gjb)

(cherry picked from commit 9d4104b214)
(cherry picked from commit fa3b2ad265)
2021-02-09 09:32:31 -08:00
David Chisnall 07eed38ae2 rtld: Fix null-pointer dereference
Approved by:	re (gjb)

(cherry picked from commit 43d44842ae)
2021-02-09 17:05:44 +02:00
Piotr Kubaj 45c95531c0 powerpc64le: readd COMPAT_FREEBSD11 and COMPAT_FREEBSD12
lang/rust needs COMPAT_FREEBSD11 to build, even though powerpc64le itself is
supported only since 13.0.
I also corrected a comment, because if we ever have lib32 for powerpc64le,
it will be for powerpcle.

Reviewed by:	bdragon (on IRC)
Approved by:	gjb (re)

(cherry picked from commit 8b804ee616)
2021-02-09 02:54:56 +01:00
Peter Grehan 82874dcb36 Always clamp curve25519 keys prior to use.
Approved by:	re (gjb)

(cherry picked from commit 6136a10e35)
2021-02-09 09:36:13 +10:00
Hans Petter Selasky 8cb8d8d998 MFC 093e723190:
Add missing decrement of active ratelimit connections.

Approved by:	re (gjb)
Reviewed by:	rrs@
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 093e723190)
2021-02-08 16:08:42 +01:00
Hans Petter Selasky 20204c4681 MFC 85d8d30f9f:
Don't allow allocating a new send tag on an INP which is being torn down.
This fixes a potential send tag leak.

Approved by:	re (gjb)
Reviewed by:	rrs@
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 85d8d30f9f)
2021-02-08 16:08:28 +01:00
Glen Barber 07e8f560fb release: disable the 'reldoc' target after the ASCIIDoctor switch
The 'reldoc' target includes release-related documentation on
installation medium.  Since the switch from XML to ASCIIDoctor,
the file locations have moved, and it will take some time to sort
out how this target should work now.

Approved by:	re (kib)
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 7b1d1a1658)
(cherry picked from commit 606bf913f9)
2021-02-07 22:32:11 -05:00
Konstantin Belousov 741627c88b amd64 GENERIC: compile in mlx5en(4)
Approved by:	re (gjb)

(cherry picked from commit 5832a3e398)
2021-02-08 05:28:08 +02:00
Konstantin Belousov bb79ec97e5 cpucontrol(8): Fix display.
Approved by:	re (gjb)

(cherry picked from commit 856789c123)
2021-02-08 05:28:03 +02:00
John Baldwin 9fb4377f41 Regenerate src.conf(5).
Approved by:	re (gjb)

(cherry picked from commit ab53734306)
2021-02-05 17:58:26 -08:00
John Baldwin b494fc41b7 Disable MK_OPENSSL_KTLS for stable/13.
Due to the pending release of 13.0 and the recent bug in serf exposed
by the KTLS changes, disable OpenSSL's KTLS by default.  This keeps
crypto/openssl in sync with main while lowering the risk of introducing
instability into 13.0.

Approved by:	re (gjb)
Discussed with:	gjb (re), jkim, emaste (secteam)

(cherry picked from commit 3cf25a7802)
2021-02-05 17:58:16 -08:00
Jung-uk Kim 25a4522f88 OpenSSL: Regenerate manual pages.
Approved by:	re (gjb)

(cherry picked from commit bb8acd558e)
(cherry picked from commit 3e09120f79)
2021-02-05 17:58:11 -08:00
John Baldwin afdbccbf40 OpenSSL: Support for kernel TLS offload (KTLS)
This merges upstream patches from OpenSSL's master branch to add
KTLS infrastructure for TLS 1.0-1.3 including both RX and TX
offload and SSL_sendfile support on both Linux and FreeBSD.

Note that TLS 1.3 only supports TX offload.

A new WITH/WITHOUT_OPENSSL_KTLS determines if OpenSSL is built with
KTLS support.  It defaults to enabled on amd64 and disabled on all
other architectures.

Approved by:	re (gjb)
Sponsored by:	Netflix

(cherry picked from commit aa906e2a49)
(cherry picked from commit c1c52cd57e)
2021-02-05 17:57:55 -08:00
John Baldwin e45bb3902e Bump shared library versions after ncurses bump in 13.
A few shared libraries in the base system link against ncurses.  An
upgrade from a 12.x host to 13 results in ABI breakage for existing
binaries since the newer versions of these libraries link against the
newer ncurses while the binary itself links against the older ncurses.
For example, dialog4ports built on 12.x sometimes crashes on 13 since
it depends on libdialog which links against ncurses internally.

Approved by:	re (gjb)

(cherry picked from commit 0b7f1af804)
(cherry picked from commit 6e1fe6d26e)
2021-02-05 17:18:07 -08:00
Alfredo Dal'Ava Junior b94f25eb62 mrsas: unbreak i386 build
Fix build regression introduced by
e34a057ca6

Approved by:	re (gjb)
Reviewed by:	jhibbits
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D28494

(cherry picked from commit 59fffbcf46)
(cherry picked from commit 6bf9668d9d)
2021-02-05 19:07:28 -03:00
Glen Barber 638e531019 Branch releng/13.0
Update releng/13.0 to BETA1 in preparation for the first BETA
builds.

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-02-04 19:01:10 -05:00
1641 changed files with 20084 additions and 61334 deletions

No files matched your search

+11 -5
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
+82
View File
@@ -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
+206
View File
@@ -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 */
-2
View File
@@ -129,8 +129,6 @@ SRCS+= dis_tables.c
DSRCS+= regs_x86.d
.endif
LFLAGS+=-l
YFLAGS+=-d
LIBADD= ctf elf proc pthread rtld_db
+1
View File
@@ -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 \
+1 -1
View File
@@ -29,7 +29,7 @@
#
.POSIX:
VERSION = 3.2.6
VERSION = 3.3.3
SRC = %%SRC%%
OBJ = %%OBJ%%
+46
View File
@@ -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.
+1 -1
View File
@@ -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
+1 -6
View File
@@ -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")
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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;
+7 -3
View File
@@ -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__)
+1
View File
@@ -356,6 +356,7 @@ typedef struct BcVm {
uint16_t line_len;
bool no_exit_exprs;
bool exit_exprs;
bool eof;
#endif // !BC_ENABLE_LIBRARY
+5 -5
View File
@@ -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
+41 -33
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+38 -30
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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
View File
@@ -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
+40 -32
View File
@@ -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**
+1 -1
View File
@@ -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
View File
@@ -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***)**
+16
View File
@@ -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.
+32 -23
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+31 -22
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
+32 -23
View File
@@ -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
View File
@@ -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
View File
@@ -1 +1 @@
.TH "BCL" "3" "January 2021" "Gavin D. Howard" "Libraries Manual"
.TH "BCL" "3" "March 2021" "Gavin D. Howard" "Libraries Manual"
+1 -1
View File
@@ -1 +1 @@
.TH "DC" "1" "January 2021" "Gavin D. Howard" "General Commands Manual"
.TH "DC" "1" "March 2021" "Gavin D. Howard" "General Commands Manual"
+1 -1
View File
@@ -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
+3 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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) {
+2
View File
@@ -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
View File
@@ -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);
+3
View File
@@ -1,4 +1,7 @@
length(0)
length(0.0000)
length(0.00000000)
length(0.00000000000)
length(1)
length(12)
length(123)
+4 -1
View File
@@ -1,4 +1,7 @@
0
1
4
8
11
1
2
3
+6
View File
@@ -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)
+6
View File
@@ -84,6 +84,12 @@
-3.00000000000000000000
16.00000000000000000000
-16.00000000000000000000
0
0
0
0
0
0
2.00000000000000000000
5.00000000000000000000
-5.00000000000000000000
+7 -2
View File
@@ -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