aboutsummaryrefslogtreecommitdiffstats
path: root/manuals
diff options
context:
space:
mode:
authorGavin Howard <gavin@yzena.com>2021-07-01 23:17:21 -0600
committerGavin Howard <gavin@yzena.com>2021-07-01 23:20:24 -0600
commit8746e589abeb0c48a803fe09bd2222bcd757a71c (patch)
tree9f044991fbc55389d51a5ebf80b593827ff9a10a /manuals
parent89f4f7cfa71ed738f5d9b34bf67420664f11333e (diff)
downloadplatform_external_bc-8746e589abeb0c48a803fe09bd2222bcd757a71c.tar.gz
platform_external_bc-8746e589abeb0c48a803fe09bd2222bcd757a71c.tar.bz2
platform_external_bc-8746e589abeb0c48a803fe09bd2222bcd757a71c.zip
Improve the manuals regarding environment variables and defaults
Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'manuals')
-rw-r--r--manuals/bc.1.md.in98
-rw-r--r--manuals/bc/A.1137
-rw-r--r--manuals/bc/A.1.md124
-rw-r--r--manuals/bc/E.1137
-rw-r--r--manuals/bc/E.1.md124
-rw-r--r--manuals/bc/EH.1115
-rw-r--r--manuals/bc/EH.1.md106
-rw-r--r--manuals/bc/EHN.1115
-rw-r--r--manuals/bc/EHN.1.md106
-rw-r--r--manuals/bc/EN.1137
-rw-r--r--manuals/bc/EN.1.md124
-rw-r--r--manuals/bc/H.1117
-rw-r--r--manuals/bc/H.1.md107
-rw-r--r--manuals/bc/HN.1117
-rw-r--r--manuals/bc/HN.1.md107
-rw-r--r--manuals/bc/N.1137
-rw-r--r--manuals/bc/N.1.md124
-rw-r--r--manuals/dc.1.md.in85
-rw-r--r--manuals/dc/A.1139
-rw-r--r--manuals/dc/A.1.md131
-rw-r--r--manuals/dc/E.1139
-rw-r--r--manuals/dc/E.1.md131
-rw-r--r--manuals/dc/EH.1117
-rw-r--r--manuals/dc/EH.1.md113
-rw-r--r--manuals/dc/EHN.1115
-rw-r--r--manuals/dc/EHN.1.md111
-rw-r--r--manuals/dc/EN.1137
-rw-r--r--manuals/dc/EN.1.md129
-rw-r--r--manuals/dc/H.1117
-rw-r--r--manuals/dc/H.1.md113
-rw-r--r--manuals/dc/HN.1115
-rw-r--r--manuals/dc/HN.1.md111
-rw-r--r--manuals/dc/N.1137
-rw-r--r--manuals/dc/N.1.md129
34 files changed, 3566 insertions, 535 deletions
diff --git a/manuals/bc.1.md.in b/manuals/bc.1.md.in
index bb710680..8dbdeb82 100644
--- a/manuals/bc.1.md.in
+++ b/manuals/bc.1.md.in
@@ -1676,8 +1676,12 @@ bc(1) recognizes the following environment variables:
value activates the copyright banner when bc(1) is in interactive mode,
while zero deactivates it.
- This overrides the default, which can be queried with the **-h** or
- **-\-help** options.
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
@@ -1685,8 +1689,12 @@ bc(1) recognizes the following environment variables:
value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
bc(1) exit.
- This overrides the default, which can be queried with the **-h** or
- **-\-help** options.
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
**BC_TTY_MODE**
@@ -1694,17 +1702,26 @@ bc(1) recognizes the following environment variables:
value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
available, and zero makes bc(1) not use TTY mode.
- This overrides the default, which can be queried with the **-h** or
- **-\-help** options.
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
**BC_PROMPT**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
- section) is available, and zero makes bc(1) not use a prompt.
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
- This overrides the default, which can be queried with the **-h** or
- **-\-help** options.
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
# EXIT STATUS
@@ -1799,33 +1816,54 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input. It is also required to enable special handling for
-**SIGINT** signals.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
-{{ A E N EN }}
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section).
-{{ end }}
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode, subject to the **BC_PROMPT** environment
-variable (see the **ENVIRONMENT VARIABLES** section), the **-P** command-line
-option, and the **-\-no-prompt** command-line option (see the **OPTIONS**
-section).
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+{{ A E N EN }}
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+{{ end }}
+
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
@@ -1854,9 +1892,17 @@ default handler for all other signals.
{{ A E N EN }}
# COMMAND LINE HISTORY
-bc(1) supports interactive command-line editing. If bc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+bc(1) supports interactive command-line editing.
+
+If bc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**BC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
+
+If history is enabled, previous lines can be recalled and edited with the arrow
+keys.
**Note**: tabs are converted to 8 spaces.
{{ end }}
diff --git a/manuals/bc/A.1 b/manuals/bc/A.1
index c6905884..97365482 100644
--- a/manuals/bc/A.1
+++ b/manuals/bc/A.1
@@ -282,6 +282,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1878,6 +1895,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1969,29 +2045,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -2017,9 +2122,19 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause bc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
bc(1) supports interactive command-line editing.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If bc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]BC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If history is enabled, previous lines can be recalled and edited with
+the arrow keys.
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH LOCALES
diff --git a/manuals/bc/A.1.md b/manuals/bc/A.1.md
index 329fd569..b15fb1c0 100644
--- a/manuals/bc/A.1.md
+++ b/manuals/bc/A.1.md
@@ -227,6 +227,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -1568,6 +1584,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1650,27 +1719,52 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
@@ -1693,9 +1787,17 @@ exit.
# COMMAND LINE HISTORY
-bc(1) supports interactive command-line editing. If bc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+bc(1) supports interactive command-line editing.
+
+If bc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**BC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
+
+If history is enabled, previous lines can be recalled and edited with the arrow
+keys.
**Note**: tabs are converted to 8 spaces.
diff --git a/manuals/bc/E.1 b/manuals/bc/E.1
index 3d009642..c4af22cb 100644
--- a/manuals/bc/E.1
+++ b/manuals/bc/E.1
@@ -259,6 +259,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1144,6 +1161,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1233,29 +1309,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1281,9 +1386,19 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause bc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
bc(1) supports interactive command-line editing.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If bc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]BC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If history is enabled, previous lines can be recalled and edited with
+the arrow keys.
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH LOCALES
diff --git a/manuals/bc/E.1.md b/manuals/bc/E.1.md
index 22e3f3e7..66a14e4b 100644
--- a/manuals/bc/E.1.md
+++ b/manuals/bc/E.1.md
@@ -211,6 +211,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -949,6 +965,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1029,27 +1098,52 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
@@ -1072,9 +1166,17 @@ exit.
# COMMAND LINE HISTORY
-bc(1) supports interactive command-line editing. If bc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+bc(1) supports interactive command-line editing.
+
+If bc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**BC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
+
+If history is enabled, previous lines can be recalled and edited with the arrow
+keys.
**Note**: tabs are converted to 8 spaces.
diff --git a/manuals/bc/EH.1 b/manuals/bc/EH.1
index 080f345c..8943639c 100644
--- a/manuals/bc/EH.1
+++ b/manuals/bc/EH.1
@@ -51,6 +51,9 @@ Such differences will be noted in this document.
.PP
After parsing and handling options, this bc(1) reads any files given on
the command line and executes them before reading from \f[B]stdin\f[R].
+.PP
+This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
+(and especially) the GNU bc(1).
.SH OPTIONS
.PP
The following are the options that bc(1) accepts.
@@ -256,6 +259,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1141,6 +1161,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1230,24 +1309,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
+.PP
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
diff --git a/manuals/bc/EH.1.md b/manuals/bc/EH.1.md
index 96b6f962..438ffe86 100644
--- a/manuals/bc/EH.1.md
+++ b/manuals/bc/EH.1.md
@@ -46,6 +46,9 @@ Such differences will be noted in this document.
After parsing and handling options, this bc(1) reads any files given on the
command line and executes them before reading from **stdin**.
+This bc(1) is a drop-in replacement for *any* bc(1), including (and especially)
+the GNU bc(1).
+
# OPTIONS
The following are the options that bc(1) accepts.
@@ -208,6 +211,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -946,6 +965,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1026,24 +1098,46 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
diff --git a/manuals/bc/EHN.1 b/manuals/bc/EHN.1
index 85b5212b..cb061f60 100644
--- a/manuals/bc/EHN.1
+++ b/manuals/bc/EHN.1
@@ -51,6 +51,9 @@ Such differences will be noted in this document.
.PP
After parsing and handling options, this bc(1) reads any files given on
the command line and executes them before reading from \f[B]stdin\f[R].
+.PP
+This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
+(and especially) the GNU bc(1).
.SH OPTIONS
.PP
The following are the options that bc(1) accepts.
@@ -256,6 +259,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1141,6 +1161,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1230,24 +1309,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
+.PP
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
diff --git a/manuals/bc/EHN.1.md b/manuals/bc/EHN.1.md
index f2307ff3..1afc10be 100644
--- a/manuals/bc/EHN.1.md
+++ b/manuals/bc/EHN.1.md
@@ -46,6 +46,9 @@ Such differences will be noted in this document.
After parsing and handling options, this bc(1) reads any files given on the
command line and executes them before reading from **stdin**.
+This bc(1) is a drop-in replacement for *any* bc(1), including (and especially)
+the GNU bc(1).
+
# OPTIONS
The following are the options that bc(1) accepts.
@@ -208,6 +211,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -946,6 +965,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1026,24 +1098,46 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
diff --git a/manuals/bc/EN.1 b/manuals/bc/EN.1
index 0ddc3eaa..5a377465 100644
--- a/manuals/bc/EN.1
+++ b/manuals/bc/EN.1
@@ -259,6 +259,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1144,6 +1161,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1233,29 +1309,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1281,9 +1386,19 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause bc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
bc(1) supports interactive command-line editing.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If bc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]BC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If history is enabled, previous lines can be recalled and edited with
+the arrow keys.
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH SEE ALSO
diff --git a/manuals/bc/EN.1.md b/manuals/bc/EN.1.md
index 7fc55d74..db0b4afc 100644
--- a/manuals/bc/EN.1.md
+++ b/manuals/bc/EN.1.md
@@ -211,6 +211,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -949,6 +965,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1029,27 +1098,52 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
@@ -1072,9 +1166,17 @@ exit.
# COMMAND LINE HISTORY
-bc(1) supports interactive command-line editing. If bc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+bc(1) supports interactive command-line editing.
+
+If bc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**BC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
+
+If history is enabled, previous lines can be recalled and edited with the arrow
+keys.
**Note**: tabs are converted to 8 spaces.
diff --git a/manuals/bc/H.1 b/manuals/bc/H.1
index ed59ee05..d2fe6e75 100644
--- a/manuals/bc/H.1
+++ b/manuals/bc/H.1
@@ -51,6 +51,11 @@ Such differences will be noted in this document.
.PP
After parsing and handling options, this bc(1) reads any files given on
the command line and executes them before reading from \f[B]stdin\f[R].
+.PP
+This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
+(and especially) the GNU bc(1).
+It also has many extensions and extra features beyond other
+implementations.
.SH OPTIONS
.PP
The following are the options that bc(1) accepts.
@@ -277,6 +282,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1873,6 +1895,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1964,24 +2045,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-The prompt is enabled in TTY mode.
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
+.PP
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
diff --git a/manuals/bc/H.1.md b/manuals/bc/H.1.md
index 3abe4b6b..421e942f 100644
--- a/manuals/bc/H.1.md
+++ b/manuals/bc/H.1.md
@@ -46,6 +46,10 @@ Such differences will be noted in this document.
After parsing and handling options, this bc(1) reads any files given on the
command line and executes them before reading from **stdin**.
+This bc(1) is a drop-in replacement for *any* bc(1), including (and
+especially) the GNU bc(1). It also has many extensions and extra features beyond
+other implementations.
+
# OPTIONS
The following are the options that bc(1) accepts.
@@ -223,6 +227,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -1564,6 +1584,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1646,24 +1719,46 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
diff --git a/manuals/bc/HN.1 b/manuals/bc/HN.1
index 84f13791..8fc05160 100644
--- a/manuals/bc/HN.1
+++ b/manuals/bc/HN.1
@@ -51,6 +51,11 @@ Such differences will be noted in this document.
.PP
After parsing and handling options, this bc(1) reads any files given on
the command line and executes them before reading from \f[B]stdin\f[R].
+.PP
+This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
+(and especially) the GNU bc(1).
+It also has many extensions and extra features beyond other
+implementations.
.SH OPTIONS
.PP
The following are the options that bc(1) accepts.
@@ -277,6 +282,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1873,6 +1895,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1964,24 +2045,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-The prompt is enabled in TTY mode.
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
+.PP
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
diff --git a/manuals/bc/HN.1.md b/manuals/bc/HN.1.md
index 90e9257d..a27811e9 100644
--- a/manuals/bc/HN.1.md
+++ b/manuals/bc/HN.1.md
@@ -46,6 +46,10 @@ Such differences will be noted in this document.
After parsing and handling options, this bc(1) reads any files given on the
command line and executes them before reading from **stdin**.
+This bc(1) is a drop-in replacement for *any* bc(1), including (and
+especially) the GNU bc(1). It also has many extensions and extra features beyond
+other implementations.
+
# OPTIONS
The following are the options that bc(1) accepts.
@@ -223,6 +227,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -1564,6 +1584,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1646,24 +1719,46 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
diff --git a/manuals/bc/N.1 b/manuals/bc/N.1
index 9e613f7e..c5bec513 100644
--- a/manuals/bc/N.1
+++ b/manuals/bc/N.1
@@ -282,6 +282,23 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files or expressions are given by the \f[B]-f\f[R],
+\f[B]--file\f[R], \f[B]-e\f[R], or \f[B]--expression\f[R] options, then
+bc(1) read from \f[B]stdin\f[R].
+.PP
+However, there are a few caveats to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if the parse cannot complete.
+That means that starting a string without ending it or starting a
+function, \f[B]if\f[R] statement, or loop without ending it will also
+cause bc(1) to not execute.
+.PP
+Second, after an \f[B]if\f[R] statement, bc(1) doesn\[cq]t know if an
+\f[B]else\f[R] statement will follow, so it will not execute until it
+knows there will not be an \f[B]else\f[R] statement.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1878,6 +1895,65 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), bc(1) will output lines to that length,
including the backslash (\f[B]\[rs]\f[R]).
The default line length is \f[B]70\f[R].
+.TP
+\f[B]BC_BANNER\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value activates the copyright banner when bc(1) is in
+interactive mode, while zero deactivates it.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+does not print the banner when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes bc(1) exit.
+.RS
+.PP
+If bc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because bc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes bc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]BC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes bc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes bc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]BC_TTY_MODE\f[R]
+does, then the value of the \f[B]BC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]BC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
bc(1) returns the following exit statuses:
@@ -1969,29 +2045,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+bc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]BC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, bc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, bc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]BC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then bc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]BC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If bc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]BC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]BC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause bc(1) to stop execution of the
current input.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]BC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, bc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -2017,9 +2122,19 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause bc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
bc(1) supports interactive command-line editing.
-If bc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If bc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]BC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If history is enabled, previous lines can be recalled and edited with
+the arrow keys.
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH SEE ALSO
diff --git a/manuals/bc/N.1.md b/manuals/bc/N.1.md
index bafb6179..c88bc16c 100644
--- a/manuals/bc/N.1.md
+++ b/manuals/bc/N.1.md
@@ -227,6 +227,22 @@ The following are the options that bc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files or expressions are given by the **-f**, **-\-file**, **-e**, or
+**-\-expression** options, then bc(1) read from **stdin**.
+
+However, there are a few caveats to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+the parse cannot complete. That means that starting a string without ending it
+or starting a function, **if** statement, or loop without ending it will also
+cause bc(1) to not execute.
+
+Second, after an **if** statement, bc(1) doesn't know if an **else** statement
+will follow, so it will not execute until it knows there will not be an **else**
+statement.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -1568,6 +1584,59 @@ bc(1) recognizes the following environment variables:
lines to that length, including the backslash (**\\**). The default line
length is **70**.
+**BC_BANNER**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value activates the copyright banner when bc(1) is in interactive mode,
+ while zero deactivates it.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) does not print
+ the banner when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) reset on **SIGINT**, rather than exit, and zero makes
+ bc(1) exit.
+
+ If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because bc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes bc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**BC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes bc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes bc(1) not use a prompt. If this
+ environment variable does not exist and **BC_TTY_MODE** does, then the value
+ of the **BC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **BC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
bc(1) returns the following exit statuses:
@@ -1650,27 +1719,52 @@ turn it on in other cases.
In interactive mode, bc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. bc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **BC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, bc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **BC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then bc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **BC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If bc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **BC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **BC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause bc(1) to stop execution of the current input. If
-bc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+bc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**BC_SIGINT_RESET** environment variable, or its default, is non-zero, bc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If bc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If bc(1) is
@@ -1693,9 +1787,17 @@ exit.
# COMMAND LINE HISTORY
-bc(1) supports interactive command-line editing. If bc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+bc(1) supports interactive command-line editing.
+
+If bc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**BC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
+
+If history is enabled, previous lines can be recalled and edited with the arrow
+keys.
**Note**: tabs are converted to 8 spaces.
diff --git a/manuals/dc.1.md.in b/manuals/dc.1.md.in
index 6541277c..2c808c51 100644
--- a/manuals/dc.1.md.in
+++ b/manuals/dc.1.md.in
@@ -1129,8 +1129,12 @@ dc(1) recognizes the following environment variables:
value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
dc(1) exit.
- This overrides the default, which can be queried with the **-h** or
- **-\-help** options.
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
**DC_TTY_MODE**
@@ -1138,17 +1142,26 @@ dc(1) recognizes the following environment variables:
value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
available, and zero makes dc(1) not use TTY mode.
- This overrides the default, which can be queried with the **-h** or
- **-\-help** options.
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
**DC_PROMPT**
: If this environment variable exists and contains an integer, then a non-zero
value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
- section) is available, and zero makes dc(1) not use a prompt.
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
- This overrides the default, which can be queried with the **-h** or
- **-\-help** options.
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
# EXIT STATUS
@@ -1235,29 +1248,54 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
-{{ A E N EN }}
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
-{{ end }}
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+{{ A E N EN }}
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+{{ end }}
+
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
@@ -1286,9 +1324,14 @@ default handler for all other signals.
{{ A E N EN }}
# COMMAND LINE HISTORY
-dc(1) supports interactive command-line editing. If dc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+dc(1) supports interactive command-line editing.
+
+If dc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**DC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
**Note**: tabs are converted to 8 spaces.
{{ end }}
@@ -1297,7 +1340,7 @@ and edited with the arrow keys.
# LOCALES
This dc(1) ships with support for adding error messages for different locales
-and thus, supports **LC_MESSAGS**.
+and thus, supports **LC_MESSAGES**.
{{ end }}
# SEE ALSO
diff --git a/manuals/dc/A.1 b/manuals/dc/A.1
index 393923d3..1d03149d 100644
--- a/manuals/dc/A.1
+++ b/manuals/dc/A.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1059,8 +1064,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1222,6 +1228,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1301,29 +1352,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1349,15 +1429,22 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause dc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
dc(1) supports interactive command-line editing.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If dc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]DC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH LOCALES
.PP
This dc(1) ships with support for adding error messages for different
-locales and thus, supports \f[B]LC_MESSAGS\f[R].
+locales and thus, supports \f[B]LC_MESSAGES\f[R].
.SH SEE ALSO
.PP
bc(1)
diff --git a/manuals/dc/A.1.md b/manuals/dc/A.1.md
index 32baedd6..8345be3c 100644
--- a/manuals/dc/A.1.md
+++ b/manuals/dc/A.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -925,8 +933,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -1079,6 +1088,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -1153,27 +1202,52 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
@@ -1196,16 +1270,21 @@ exit.
# COMMAND LINE HISTORY
-dc(1) supports interactive command-line editing. If dc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+dc(1) supports interactive command-line editing.
+
+If dc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**DC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
**Note**: tabs are converted to 8 spaces.
# LOCALES
This dc(1) ships with support for adding error messages for different locales
-and thus, supports **LC_MESSAGS**.
+and thus, supports **LC_MESSAGES**.
# SEE ALSO
diff --git a/manuals/dc/E.1 b/manuals/dc/E.1
index a2468937..523dfc53 100644
--- a/manuals/dc/E.1
+++ b/manuals/dc/E.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -859,8 +864,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1017,6 +1023,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1094,29 +1145,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1142,15 +1222,22 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause dc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
dc(1) supports interactive command-line editing.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If dc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]DC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH LOCALES
.PP
This dc(1) ships with support for adding error messages for different
-locales and thus, supports \f[B]LC_MESSAGS\f[R].
+locales and thus, supports \f[B]LC_MESSAGES\f[R].
.SH SEE ALSO
.PP
bc(1)
diff --git a/manuals/dc/E.1.md b/manuals/dc/E.1.md
index ed37ca48..70e50f7d 100644
--- a/manuals/dc/E.1.md
+++ b/manuals/dc/E.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -765,8 +773,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -914,6 +923,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -986,27 +1035,52 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
@@ -1029,16 +1103,21 @@ exit.
# COMMAND LINE HISTORY
-dc(1) supports interactive command-line editing. If dc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+dc(1) supports interactive command-line editing.
+
+If dc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**DC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
**Note**: tabs are converted to 8 spaces.
# LOCALES
This dc(1) ships with support for adding error messages for different locales
-and thus, supports **LC_MESSAGS**.
+and thus, supports **LC_MESSAGES**.
# SEE ALSO
diff --git a/manuals/dc/EH.1 b/manuals/dc/EH.1
index 24d1d7cf..0fbcbbd4 100644
--- a/manuals/dc/EH.1
+++ b/manuals/dc/EH.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -859,8 +864,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1017,6 +1023,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1094,24 +1145,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
+.PP
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1135,7 +1214,7 @@ exit, and it uses the default handler for all other signals.
.SH LOCALES
.PP
This dc(1) ships with support for adding error messages for different
-locales and thus, supports \f[B]LC_MESSAGS\f[R].
+locales and thus, supports \f[B]LC_MESSAGES\f[R].
.SH SEE ALSO
.PP
bc(1)
diff --git a/manuals/dc/EH.1.md b/manuals/dc/EH.1.md
index d5ff123b..61aa995a 100644
--- a/manuals/dc/EH.1.md
+++ b/manuals/dc/EH.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -765,8 +773,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -914,6 +923,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -986,24 +1035,46 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
@@ -1025,7 +1096,7 @@ default handler for all other signals.
# LOCALES
This dc(1) ships with support for adding error messages for different locales
-and thus, supports **LC_MESSAGS**.
+and thus, supports **LC_MESSAGES**.
# SEE ALSO
diff --git a/manuals/dc/EHN.1 b/manuals/dc/EHN.1
index 547195b8..13aba658 100644
--- a/manuals/dc/EHN.1
+++ b/manuals/dc/EHN.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -859,8 +864,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1017,6 +1023,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1094,24 +1145,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
+.PP
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
diff --git a/manuals/dc/EHN.1.md b/manuals/dc/EHN.1.md
index dda7fb32..648f5d95 100644
--- a/manuals/dc/EHN.1.md
+++ b/manuals/dc/EHN.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -765,8 +773,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -914,6 +923,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -986,24 +1035,46 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
diff --git a/manuals/dc/EN.1 b/manuals/dc/EN.1
index d4c753f7..feea0a8e 100644
--- a/manuals/dc/EN.1
+++ b/manuals/dc/EN.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -859,8 +864,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1017,6 +1023,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1094,29 +1145,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1142,9 +1222,16 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause dc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
dc(1) supports interactive command-line editing.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If dc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]DC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH SEE ALSO
diff --git a/manuals/dc/EN.1.md b/manuals/dc/EN.1.md
index 1cfc9900..419038ad 100644
--- a/manuals/dc/EN.1.md
+++ b/manuals/dc/EN.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -765,8 +773,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -914,6 +923,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -986,27 +1035,52 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
@@ -1029,9 +1103,14 @@ exit.
# COMMAND LINE HISTORY
-dc(1) supports interactive command-line editing. If dc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+dc(1) supports interactive command-line editing.
+
+If dc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**DC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
**Note**: tabs are converted to 8 spaces.
diff --git a/manuals/dc/H.1 b/manuals/dc/H.1
index 9f1aa618..581775d7 100644
--- a/manuals/dc/H.1
+++ b/manuals/dc/H.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1059,8 +1064,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1222,6 +1228,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1301,24 +1352,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
+.PP
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1342,7 +1421,7 @@ exit, and it uses the default handler for all other signals.
.SH LOCALES
.PP
This dc(1) ships with support for adding error messages for different
-locales and thus, supports \f[B]LC_MESSAGS\f[R].
+locales and thus, supports \f[B]LC_MESSAGES\f[R].
.SH SEE ALSO
.PP
bc(1)
diff --git a/manuals/dc/H.1.md b/manuals/dc/H.1.md
index 52790faa..e3378847 100644
--- a/manuals/dc/H.1.md
+++ b/manuals/dc/H.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -925,8 +933,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -1079,6 +1088,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -1153,24 +1202,46 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
@@ -1192,7 +1263,7 @@ default handler for all other signals.
# LOCALES
This dc(1) ships with support for adding error messages for different locales
-and thus, supports **LC_MESSAGS**.
+and thus, supports **LC_MESSAGES**.
# SEE ALSO
diff --git a/manuals/dc/HN.1 b/manuals/dc/HN.1
index 448508c0..ab4e4185 100644
--- a/manuals/dc/HN.1
+++ b/manuals/dc/HN.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1059,8 +1064,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1222,6 +1228,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1301,24 +1352,52 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
+.PP
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
diff --git a/manuals/dc/HN.1.md b/manuals/dc/HN.1.md
index 84b1cb08..f0da5da6 100644
--- a/manuals/dc/HN.1.md
+++ b/manuals/dc/HN.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -925,8 +933,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -1079,6 +1088,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -1153,24 +1202,46 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
+
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
diff --git a/manuals/dc/N.1 b/manuals/dc/N.1
index 8f0e887c..ee23eaa1 100644
--- a/manuals/dc/N.1
+++ b/manuals/dc/N.1
@@ -46,20 +46,12 @@ of computations.
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]--file\f[R] arguments), then dc(1) reads from
-\f[B]stdin\f[R].
+If no files are given on the command-line, then dc(1) reads from
+\f[B]stdin\f[R] (see the \f[B]STDIN\f[R] section).
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]--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
-VARIABLES\f[R] section).
-Any expressions given on the command-line should be used to set up a
-standard environment.
+If a user wants to set up a standard environment, they can use
+\f[B]DC_ENV_ARGS\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
For example, if a user wants the \f[B]scale\f[R] always set to
\f[B]10\f[R], they can set \f[B]DC_ENV_ARGS\f[R] to \f[B]-e 10k\f[R],
and this dc(1) will always start with a \f[B]scale\f[R] of \f[B]10\f[R].
@@ -163,6 +155,19 @@ This is a \f[B]non-portable extension\f[R].
.RE
.PP
All long options are \f[B]non-portable extensions\f[R].
+.SH STDIN
+.PP
+If no files are given on the command-line and no files or expressions
+are given by the \f[B]-f\f[R], \f[B]--file\f[R], \f[B]-e\f[R], or
+\f[B]--expression\f[R] options, then dc(1) read from \f[B]stdin\f[R].
+.PP
+However, there is a caveat to this.
+.PP
+First, \f[B]stdin\f[R] is evaluated a line at a time.
+The only exception to this is if a string has been finished, but not
+ended.
+This means that, except for escaped brackets, all brackets must be
+balanced before dc(1) parses and executes.
.SH STDOUT
.PP
Any non-error output is written to \f[B]stdout\f[R].
@@ -1059,8 +1064,9 @@ of the register stack.
.PP
In non-extended register mode, a register name is just the single
character that follows any command that needs a register name.
-The only exception is a newline (\f[B]`\[rs]n'\f[R]); it is a parse
-error for a newline to be used as a register name.
+The only exceptions are: a newline (\f[B]`\[rs]n'\f[R]) and a left
+bracket (\f[B]`['\f[R]); it is a parse error for a newline or a left
+bracket to be used as a register name.
.SS Extended Register Mode
.PP
Unlike most other dc(1) implentations, this dc(1) provides nearly
@@ -1222,6 +1228,51 @@ greater than \f[B]1\f[R] and is less than \f[B]UINT16_MAX\f[R]
(\f[B]2\[ha]16-1\f[R]), dc(1) will output lines to that length,
including the backslash newline combo.
The default line length is \f[B]70\f[R].
+.TP
+\f[B]DC_SIGINT_RESET\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) reset on \f[B]SIGINT\f[R], rather than exit,
+and zero makes dc(1) exit.
+.RS
+.PP
+If dc(1) is not in interactive mode (see the \f[B]INTERACTIVE MODE\f[R]
+section), then this environment variable has no effect because dc(1)
+exits on \f[B]SIGINT\f[R] when not in interactive mode.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_TTY_MODE\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use TTY mode (see the \f[B]TTY MODE\f[R]
+section) when it is available, and zero makes dc(1) not use TTY mode.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable overrides the default, which can be queried
+with the \f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
+.TP
+\f[B]DC_PROMPT\f[R]
+If this environment variable exists and contains an integer, then a
+non-zero value makes dc(1) use a prompt when the TTY mode (see the
+\f[B]TTY MODE\f[R] section) is available, and zero makes dc(1) not use a
+prompt.
+If this environment variable does not exist and \f[B]DC_TTY_MODE\f[R]
+does, then the value of the \f[B]DC_TTY_MODE\f[R] environment variable
+is used.
+.RS
+.PP
+If TTY mode is \f[I]not\f[R] available, then this environment variable
+has no effect.
+.PP
+This environment variable or the \f[B]DC_TTY_MODE\f[R] environment
+variable override the default, which can be queried with the
+\f[B]-h\f[R] or \f[B]--help\f[R] options.
+.RE
.SH EXIT STATUS
.PP
dc(1) returns the following exit statuses:
@@ -1301,29 +1352,58 @@ and \f[B]--interactive\f[R] option can turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the
\f[B]RESET\f[R] section), and in normal execution, flushes
\f[B]stdout\f[R] as soon as execution is done for the current input.
+dc(1) may also reset on \f[B]SIGINT\f[R] instead of exit, depending on
+the contents or default for the \f[B]DC_SIGINT_RESET\f[R] environment
+variable.
.SH TTY MODE
.PP
If \f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
-connected to a TTY, dc(1) turns on \[lq]TTY mode.\[rq]
+connected to a TTY, dc(1) can turn on \[lq]TTY mode,\[rq] subject to
+some settings.
.PP
-TTY mode is required for history to be enabled (see the \f[B]COMMAND
-LINE HISTORY\f[R] section).
-It is also required to enable special handling for \f[B]SIGINT\f[R]
-signals.
+If there is the environment variable \f[B]DC_TTY_MODE\f[R] in the
+environment (see the \f[B]ENVIRONMENT VARIABLES\f[R] section), then if
+that environment variable contains a non-zero integer, then dc(1) will
+turn on TTY mode when \f[B]stdin\f[R], \f[B]stdout\f[R], and
+\f[B]stderr\f[R] are all connected to a TTY.
.PP
-The prompt is enabled in TTY mode.
+If the environment variable \f[B]DC_TTY_MODE\f[R] does \f[I]not\f[R]
+exist, the default setting is used.
+The default setting can be queried with the \f[B]-h\f[R] or
+\f[B]--help\f[R] options.
.PP
TTY mode is different from interactive mode because interactive mode is
required in the bc(1)
specification (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html),
and interactive mode requires only \f[B]stdin\f[R] and \f[B]stdout\f[R]
to be connected to a terminal.
+.SS Command-Line History
+.PP
+Command-line history can only be enabled if TTY mode can be, i.e., that
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to
+a TTY.
+See the \f[B]COMMAND LINE HISTORY\f[R] section for more information.
+.SS Prompt
+.PP
+If dc(1) can be in TTY mode, a prompt can be enabled.
+Like TTY mode itself, it can be turned on or off with an environment
+variable: \f[B]DC_PROMPT\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
+.PP
+If the environment variable \f[B]DC_PROMPT\f[R] is a non-zero integer,
+then command-line history is turned on when \f[B]stdin\f[R],
+\f[B]stdout\f[R], and \f[B]stderr\f[R] are connected to a TTY and the
+\f[B]-P\f[R] and \f[B]--no-prompt\f[R] options were not used.
+The read prompt will be turned on under the same conditions, except that
+the \f[B]-R\f[R] and \f[B]--no-read-prompt\f[R] options must also not be
+used.
.SH SIGNAL HANDLING
.PP
Sending a \f[B]SIGINT\f[R] will cause dc(1) to stop execution of the
current input.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), it will
-reset (see the \f[B]RESET\f[R] section).
+If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section) and/or the
+\f[B]DC_SIGINT_RESET\f[R] environment variable, or its default, is
+non-zero, dc(1) will reset (see the \f[B]RESET\f[R] section).
Otherwise, it will clean up and exit.
.PP
Note that \[lq]current input\[rq] can mean one of two things.
@@ -1349,9 +1429,16 @@ TTY mode, a \f[B]SIGHUP\f[R] will cause dc(1) to clean up and exit.
.SH COMMAND LINE HISTORY
.PP
dc(1) supports interactive command-line editing.
-If dc(1) is in TTY mode (see the \f[B]TTY MODE\f[R] section), history is
-enabled.
-Previous lines can be recalled and edited with the arrow keys.
+.PP
+If dc(1) can be in TTY mode (see the \f[B]TTY MODE\f[R] section),
+history can be enabled.
+This means that command-line history can only be enabled when
+\f[B]stdin\f[R], \f[B]stdout\f[R], and \f[B]stderr\f[R] are all
+connected to a TTY.
+.PP
+Like TTY mode itself, it can be turned on or off with the environment
+variable: \f[B]DC_TTY_MODE\f[R] (see the \f[B]ENVIRONMENT VARIABLES\f[R]
+section).
.PP
\f[B]Note\f[R]: tabs are converted to 8 spaces.
.SH SEE ALSO
diff --git a/manuals/dc/N.1.md b/manuals/dc/N.1.md
index 16dd5006..40d55c08 100644
--- a/manuals/dc/N.1.md
+++ b/manuals/dc/N.1.md
@@ -42,18 +42,14 @@ dc(1) is an arbitrary-precision calculator. It uses a stack (reverse Polish
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,
-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**)
-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
-command-line should be used to set up a standard environment. For example, if a
-user wants the **scale** always set to **10**, they can set **DC_ENV_ARGS** to
-**-e 10k**, and this dc(1) will always start with a **scale** of **10**.
+If no files are given on the command-line, then dc(1) reads from **stdin** (see
+the **STDIN** section). Otherwise, those files are processed, and dc(1) will
+then exit.
+
+If a user wants to set up a standard environment, they can use **DC_ENV_ARGS**
+(see the **ENVIRONMENT VARIABLES** section). For example, if a user wants the
+**scale** always set to **10**, they can set **DC_ENV_ARGS** to **-e 10k**, and
+this dc(1) will always start with a **scale** of **10**.
# OPTIONS
@@ -137,6 +133,18 @@ The following are the options that dc(1) accepts.
All long options are **non-portable extensions**.
+# STDIN
+
+If no files are given on the command-line and no files or expressions are given
+by the **-f**, **-\-file**, **-e**, or **-\-expression** options, then dc(1)
+read from **stdin**.
+
+However, there is a caveat to this.
+
+First, **stdin** is evaluated a line at a time. The only exception to this is if
+a string has been finished, but not ended. This means that, except for escaped
+brackets, all brackets must be balanced before dc(1) parses and executes.
+
# STDOUT
Any non-error output is written to **stdout**. In addition, if history (see the
@@ -925,8 +933,9 @@ the stack for the register. All registers, when first referenced, have one value
off of the register stack.
In non-extended register mode, a register name is just the single character that
-follows any command that needs a register name. The only exception is a newline
-(**'\\n'**); it is a parse error for a newline to be used as a register name.
+follows any command that needs a register name. The only exceptions are: a
+newline (**'\\n'**) and a left bracket (**'['**); it is a parse error for a
+newline or a left bracket to be used as a register name.
## Extended Register Mode
@@ -1079,6 +1088,46 @@ dc(1) recognizes the following environment variables:
lines to that length, including the backslash newline combo. The default
line length is **70**.
+**DC_SIGINT_RESET**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) reset on **SIGINT**, rather than exit, and zero makes
+ dc(1) exit.
+
+ If dc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),
+ then this environment variable has no effect because dc(1) exits on
+ **SIGINT** when not in interactive mode.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_TTY_MODE**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use TTY mode (see the **TTY MODE** section) when it is
+ available, and zero makes dc(1) not use TTY mode.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable overrides the default, which can be queried with
+ the **-h** or **-\-help** options.
+
+**DC_PROMPT**
+
+: If this environment variable exists and contains an integer, then a non-zero
+ value makes dc(1) use a prompt when the TTY mode (see the **TTY MODE**
+ section) is available, and zero makes dc(1) not use a prompt. If this
+ environment variable does not exist and **DC_TTY_MODE** does, then the value
+ of the **DC_TTY_MODE** environment variable is used.
+
+ If TTY mode is *not* available, then this environment variable has no
+ effect.
+
+ This environment variable or the **DC_TTY_MODE** environment variable
+ override the default, which can be queried with the **-h** or **-\-help**
+ options.
+
# EXIT STATUS
dc(1) returns the following exit statuses:
@@ -1153,27 +1202,52 @@ turn it on in other cases.
In interactive mode, dc(1) attempts to recover from errors (see the **RESET**
section), and in normal execution, flushes **stdout** as soon as execution is
-done for the current input.
+done for the current input. dc(1) may also reset on **SIGINT** instead of exit,
+depending on the contents or default for the **DC_SIGINT_RESET** environment
+variable.
# TTY MODE
-If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) turns
-on "TTY mode."
+If **stdin**, **stdout**, and **stderr** are all connected to a TTY, dc(1) can
+turn on "TTY mode," subject to some settings.
-TTY mode is required for history to be enabled (see the **COMMAND LINE HISTORY**
-section). It is also required to enable special handling for **SIGINT** signals.
+If there is the environment variable **DC_TTY_MODE** in the environment (see the
+**ENVIRONMENT VARIABLES** section), then if that environment variable contains a
+non-zero integer, then dc(1) will turn on TTY mode when **stdin**, **stdout**,
+and **stderr** are all connected to a TTY.
-The prompt is enabled in TTY mode.
+If the environment variable **DC_TTY_MODE** does *not* exist, the default
+setting is used. The default setting can be queried with the **-h** or
+**-\-help** options.
TTY mode is different from interactive mode because interactive mode is required
in the [bc(1) specification][1], and interactive mode requires only **stdin**
and **stdout** to be connected to a terminal.
+## Command-Line History
+
+Command-line history can only be enabled if TTY mode can be, i.e., that
+**stdin**, **stdout**, and **stderr** are connected to a TTY. See the **COMMAND
+LINE HISTORY** section for more information.
+
+## Prompt
+
+If dc(1) can be in TTY mode, a prompt can be enabled. Like TTY mode itself, it
+can be turned on or off with an environment variable: **DC_PROMPT** (see the
+**ENVIRONMENT VARIABLES** section).
+
+If the environment variable **DC_PROMPT** is a non-zero integer, then
+command-line history is turned on when **stdin**, **stdout**, and **stderr** are
+connected to a TTY and the **-P** and **-\-no-prompt** options were not used.
+The read prompt will be turned on under the same conditions, except that the
+**-R** and **-\-no-read-prompt** options must also not be used.
+
# SIGNAL HANDLING
Sending a **SIGINT** will cause dc(1) to stop execution of the current input. If
-dc(1) is in TTY mode (see the **TTY MODE** section), it will reset (see the
-**RESET** section). Otherwise, it will clean up and exit.
+dc(1) is in TTY mode (see the **TTY MODE** section) and/or the
+**DC_SIGINT_RESET** environment variable, or its default, is non-zero, dc(1)
+will reset (see the **RESET** section). Otherwise, it will clean up and exit.
Note that "current input" can mean one of two things. If dc(1) is processing
input from **stdin** in TTY mode, it will ask for more input. If dc(1) is
@@ -1196,9 +1270,14 @@ exit.
# COMMAND LINE HISTORY
-dc(1) supports interactive command-line editing. If dc(1) is in TTY mode (see
-the **TTY MODE** section), history is enabled. Previous lines can be recalled
-and edited with the arrow keys.
+dc(1) supports interactive command-line editing.
+
+If dc(1) can be in TTY mode (see the **TTY MODE** section), history can be
+enabled. This means that command-line history can only be enabled when
+**stdin**, **stdout**, and **stderr** are all connected to a TTY.
+
+Like TTY mode itself, it can be turned on or off with the environment variable:
+**DC_TTY_MODE** (see the **ENVIRONMENT VARIABLES** section).
**Note**: tabs are converted to 8 spaces.