Change the keyword redefinition infrastructure

This changes it to use a command-line option. This is best because if a
user encounters a problem; they *know* they are using my bc and can add
the command-line option.

This is also better because it allows the keyword to be used as variable
and array names as well as function names, without editing the script.

This has the double advantage that I can undo the change to the parser,
though I need to keep the one line change to the lexer.

The option is `-r` and `--redefine`, and they take an argument, which is
the keyword to redefine.

All docs and tests have been updated.

Signed-off-by: Gavin Howard <gavin@yzena.com>
computed_goto
Gavin Howard 1 year ago
parent e9f2581d6c
commit f4e36d5707
Signed by: gavin
GPG Key ID: C08038BDF280D33E
  1. 6
      Makefile.in
  2. 9
      configure.sh
  3. 3
      include/opt.h
  4. 4
      include/status.h
  5. 20
      include/vm.h
  6. 73
      manuals/bc.1.md.in
  7. 91
      manuals/bc/A.1
  8. 65
      manuals/bc/A.1.md
  9. 83
      manuals/bc/E.1
  10. 61
      manuals/bc/E.1.md
  11. 83
      manuals/bc/EH.1
  12. 61
      manuals/bc/EH.1.md
  13. 83
      manuals/bc/EHN.1
  14. 61
      manuals/bc/EHN.1.md
  15. 83
      manuals/bc/EN.1
  16. 61
      manuals/bc/EN.1.md
  17. 91
      manuals/bc/H.1
  18. 65
      manuals/bc/H.1.md
  19. 91
      manuals/bc/HN.1
  20. 65
      manuals/bc/HN.1.md
  21. 91
      manuals/bc/N.1
  22. 65
      manuals/bc/N.1.md
  23. 5
      manuals/build.md
  24. 36
      src/args.c
  25. 5
      src/bc_lex.c
  26. 42
      src/bc_parse.c
  27. 1
      src/data.c
  28. 15
      src/opt.c
  29. 5
      src/vm.c
  30. 13
      tests/other.sh

@ -140,7 +140,6 @@ BC_ENABLE_AFL = %%FUZZ%%
BC_ENABLE_MEMCHECK = %%MEMCHECK%%
BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%%
BC_DEFAULT_REDEFINE_KEYWORDS = %%BC_DEFAULT_REDEFINE_KEYWORDS%%
BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%%
DC_DEFAULT_SIGINT_RESET = %%DC_DEFAULT_SIGINT_RESET%%
BC_DEFAULT_TTY_MODE = %%BC_DEFAULT_TTY_MODE%%
@ -170,12 +169,11 @@ TEST_STARS = *******************************************************************
BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
BC_DEFS0_0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER)
BC_DEFS0_1 = -DBC_DEFAULT_REDEFINE_KEYWORDS=$(BC_DEFAULT_REDEFINE_KEYWORDS)
BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER)
BC_DEFS1 = -DBC_DEFAULT_SIGINT_RESET=$(BC_DEFAULT_SIGINT_RESET)
BC_DEFS2 = -DBC_DEFAULT_TTY_MODE=$(BC_DEFAULT_TTY_MODE)
BC_DEFS3 = -DBC_DEFAULT_PROMPT=$(BC_DEFAULT_PROMPT)
BC_DEFS = $(BC_DEFS0_0) $(BC_DEFS0_1) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3)
BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3)
DC_DEFS1 = -DDC_DEFAULT_SIGINT_RESET=$(DC_DEFAULT_SIGINT_RESET)
DC_DEFS2 = -DDC_DEFAULT_TTY_MODE=$(DC_DEFAULT_TTY_MODE)
DC_DEFS3 = -DDC_DEFAULT_PROMPT=$(DC_DEFAULT_PROMPT)

@ -264,11 +264,6 @@ usage() {
printf '| | banner when in | | |\n'
printf '| | interactive mode. | | |\n'
printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
printf '| bc.redefine_kws | Whether to allow the | 0 | BC_REDEFINE_KEYWORDS |\n'
printf '| | user to redefine bc | | |\n'
printf '| | keywords as function | | |\n'
printf '| | names. | | |\n'
printf '| --------------- | -------------------- | ------------ | -------------------- |\n'
printf '| bc.sigint_reset | Whether SIGINT will | 1 | BC_SIGINT_RESET |\n'
printf '| | reset bc, instead of | | |\n'
printf '| | exiting, when in | | |\n'
@ -553,7 +548,6 @@ set_default() {
case "$_set_default_name" in
bc.banner) bc_default_banner="$_set_default_on" ;;
bc.redefine_keywords) bc_default_redefine_keywords="$_set_default_on" ;;
bc.sigint_reset) bc_default_sigint_reset="$_set_default_on" ;;
dc.sigint_reset) dc_default_sigint_reset="$_set_default_on" ;;
bc.tty_mode) bc_default_tty_mode="$_set_default_on" ;;
@ -616,7 +610,6 @@ clean=1
# The empty strings are because they depend on TTY mode. If they are directly
# set, though, they will be integers. We test for empty strings later.
bc_default_banner=0
bc_default_redefine_keywords=0
bc_default_sigint_reset=1
dc_default_sigint_reset=1
bc_default_tty_mode=1
@ -1450,7 +1443,6 @@ printf '\n'
printf 'Setting Defaults\n'
printf '================\n'
printf 'bc.banner=%s\n' "$bc_default_banner"
printf 'bc.redefine_keywords=%s\n' "$bc_default_redefine_keywords"
printf 'bc.sigint_reset=%s\n' "$bc_default_sigint_reset"
printf 'dc.sigint_reset=%s\n' "$dc_default_sigint_reset"
printf 'bc.tty_mode=%s\n' "$bc_default_tty_mode"
@ -1584,7 +1576,6 @@ contents=$(replace "$contents" "GEN_EMU" "$GEN_EMU")
contents=$(replace "$contents" "BSD" "$bsd")
contents=$(replace "$contents" "BC_DEFAULT_BANNER" "$bc_default_banner")
contents=$(replace "$contents" "BC_DEFAULT_REDEFINE_KEYWORDS" "$bc_default_redefine_keywords")
contents=$(replace "$contents" "BC_DEFAULT_SIGINT_RESET" "$bc_default_sigint_reset")
contents=$(replace "$contents" "DC_DEFAULT_SIGINT_RESET" "$dc_default_sigint_reset")
contents=$(replace "$contents" "BC_DEFAULT_TTY_MODE" "$bc_default_tty_mode")

@ -75,6 +75,9 @@ typedef enum BcOptType {
/// An option that is bc-only.
BC_OPT_BC_ONLY,
/// An option that is bc-only that requires an argument.
BC_OPT_REQUIRED_BC_ONLY,
/// An option that is dc-only.
BC_OPT_DC_ONLY,

@ -220,10 +220,6 @@
#define BC_DEFAULT_BANNER (0)
#endif // BC_DEFAULT_BANNER
#ifndef BC_DEFAULT_REDEFINE_KEYWORDS
#define BC_DEFAULT_REDEFINE_KEYWORDS (0)
#endif // BC_DEFAULT_REDEFINE_KEYWORDS
#endif // BC_ENABLED
#ifndef BC_DEFAULT_SIGINT_RESET

@ -150,31 +150,28 @@
/// The flag for the global stacks option.
#define BC_FLAG_G (UINTMAX_C(1)<<4)
/// The flag for redefining keywords.
#define BC_FLAG_REDEFINE_KWS (UINTMAX_C(1)<<5)
#endif // BC_ENABLED
/// The flag for quiet, though this one is reversed; the option clears the flag.
#define BC_FLAG_Q (UINTMAX_C(1)<<6)
#define BC_FLAG_Q (UINTMAX_C(1)<<5)
/// The flag for interactive.
#define BC_FLAG_I (UINTMAX_C(1)<<7)
#define BC_FLAG_I (UINTMAX_C(1)<<6)
/// The flag for prompt. This is also reversed; the option clears the flag.
#define BC_FLAG_P (UINTMAX_C(1)<<8)
#define BC_FLAG_P (UINTMAX_C(1)<<7)
/// The flag for read prompt. This is also reversed; the option clears the flag.
#define BC_FLAG_R (UINTMAX_C(1)<<9)
#define BC_FLAG_R (UINTMAX_C(1)<<8)
/// The flag for stdin being a TTY.
#define BC_FLAG_TTYIN (UINTMAX_C(1)<<10)
#define BC_FLAG_TTYIN (UINTMAX_C(1)<<9)
/// The flag for TTY mode.
#define BC_FLAG_TTY (UINTMAX_C(1)<<11)
#define BC_FLAG_TTY (UINTMAX_C(1)<<10)
/// The flag for reset on SIGINT.
#define BC_FLAG_SIGINT (UINTMAX_C(1)<<12)
#define BC_FLAG_SIGINT (UINTMAX_C(1)<<11)
/// A convenience macro for getting the TTYIN flag.
#define BC_TTYIN (vm.flags & BC_FLAG_TTYIN)
@ -199,9 +196,6 @@
/// A convenience macro for getting the global stacks flag.
#define BC_G (vm.flags & BC_FLAG_G)
/// A convenience macro for getting the global redefine keywords flag.
#define BC_REDEFINE (vm.flags & BC_FLAG_REDEFINE_KWS)
#endif // BC_ENABLED
#if DC_ENABLED

@ -57,9 +57,13 @@ the GNU bc(1).
{{ end }}
**Note**: If running this bc(1) on *any* script meant for another bc(1) gives a
parse error, set the environment variable **BC_REDEFINE_KEYWORDS** to **1** (see
the **ENVIRONMENT VARIABLES** section) and try again. It should parse correctly.
If not, that is a bug and should be reported. See the **BUGS** section.
parse error, it is probably because a word this bc(1) reserves as a keyword is
used as the name of a function, variable, or array. To fix that, use the
command-line option **-r** *keyword*, where *keyword* is the keyword that is
used as a name in the script. For more information, see the **OPTIONS** section.
If parsing scripts meant for other bc(1) implementations still does not work,
that is a bug and should be reported. See the **BUGS** section.
# OPTIONS
@ -195,6 +199,48 @@ The following are the options that bc(1) accepts.
This is a **non-portable extension**.
**-r** *keyword*, **-\-redefine**=*keyword*
: Redefines *keyword* in order to allow it to be used as a function, variable,
or array name. This is useful when this bc(1) gives parse errors when
parsing scripts meant for other bc(1) implementations.
The keywords this bc(1) allows to be redefined are:
* **abs**
* **continue**
* **divmod**
* **else**
* **halt**
{{ A H N HN }}
* **irand**
{{ end }}
* **last**
* **limits**
* **maxibase**
* **maxobase**
{{ A H N HN }}
* **maxrand**
{{ end }}
* **maxscale**
* **modexp**
* **print**
{{ A H N HN }}
* **rand**
{{ end }}
* **read**
{{ A H N HN }}
* **seed**
{{ end }}
If any of those keywords are used as a function, variable, or array name in
a script, use this option with the keyword as the argument. If multiple are
used, use this option for all of them; it can be used multiple times.
It is a fatal error to redefine keywords mandated by the POSIX standard. It
is a fatal error to attempt to redefine words that this bc(1) does not
reserve as keywords.
**-R**, **-\-no-read-prompt**
: Disables the read prompt in TTY mode. (The read prompt is only enabled in
@ -1695,27 +1741,6 @@ bc(1) recognizes the following environment variables:
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_REDEFINE_KEYWORDS**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) allow the user to redefine keywords that do not exist in
the bc standard, while zero causes bc(1) to give parse errors if keywords
are not used as expected.
This has several consequences.
First, if a keyword is used before it is redefined, then the keyword acts
normally.
Second, redefining a keyword precludes any future use of that keyword during
the execution of bc(1), except as the function that redefined it.
Third, if an error occurs during the parsing of a function whose name is a
redefined keyword, the keyword remains redefined, so it cannot be recovered.
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
: If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),

@ -58,11 +58,16 @@ It also has many extensions and extra features beyond other
implementations.
.PP
\f[B]Note\f[R]: If running this bc(1) on \f[I]any\f[R] script meant for
another bc(1) gives a parse error, set the environment variable
\f[B]BC_REDEFINE_KEYWORDS\f[R] to \f[B]1\f[R] (see the \f[B]ENVIRONMENT
VARIABLES\f[R] section) and try again.
It should parse correctly.
If not, that is a bug and should be reported.
another bc(1) gives a parse error, it is probably because a word this
bc(1) reserves as a keyword is used as the name of a function, variable,
or array.
To fix that, use the command-line option \f[B]-r\f[R] \f[I]keyword\f[R],
where \f[I]keyword\f[R] is the keyword that is used as a name in the
script.
For more information, see the \f[B]OPTIONS\f[R] section.
.PP
If parsing scripts meant for other bc(1) implementations still does not
work, that is a bug and should be reported.
See the \f[B]BUGS\f[R] section.
.SH OPTIONS
.PP
@ -196,6 +201,59 @@ environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
This is a \f[B]non-portable extension\f[R].
.RE
.TP
\f[B]-r\f[R] \f[I]keyword\f[R], \f[B]--redefine\f[R]=\f[I]keyword\f[R]
Redefines \f[I]keyword\f[R] in order to allow it to be used as a
function, variable, or array name.
This is useful when this bc(1) gives parse errors when parsing scripts
meant for other bc(1) implementations.
.RS
.PP
The keywords this bc(1) allows to be redefined are:
.IP \[bu] 2
\f[B]abs\f[R]
.IP \[bu] 2
\f[B]continue\f[R]
.IP \[bu] 2
\f[B]divmod\f[R]
.IP \[bu] 2
\f[B]else\f[R]
.IP \[bu] 2
\f[B]halt\f[R]
.IP \[bu] 2
\f[B]irand\f[R]
.IP \[bu] 2
\f[B]last\f[R]
.IP \[bu] 2
\f[B]limits\f[R]
.IP \[bu] 2
\f[B]maxibase\f[R]
.IP \[bu] 2
\f[B]maxobase\f[R]
.IP \[bu] 2
\f[B]maxrand\f[R]
.IP \[bu] 2
\f[B]maxscale\f[R]
.IP \[bu] 2
\f[B]modexp\f[R]
.IP \[bu] 2
\f[B]print\f[R]
.IP \[bu] 2
\f[B]rand\f[R]
.IP \[bu] 2
\f[B]read\f[R]
.IP \[bu] 2
\f[B]seed\f[R]
.PP
If any of those keywords are used as a function, variable, or array name
in a script, use this option with the keyword as the argument.
If multiple are used, use this option for all of them; it can be used
multiple times.
.PP
It is a fatal error to redefine keywords mandated by the POSIX standard.
It is a fatal error to attempt to redefine words that this bc(1) does
not reserve as keywords.
.RE
.TP
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
Disables the read prompt in TTY mode.
(The read prompt is only enabled in TTY mode.
@ -1925,29 +1983,6 @@ 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_REDEFINE_KEYWORDS\f[R]
If this environment variable exists and contains an integer, then a
non-zero value makes bc(1) allow the user to redefine keywords that do
not exist in the bc standard, while zero causes bc(1) to give parse
errors if keywords are not used as expected.
.RS
.PP
This has several consequences.
.PP
First, if a keyword is used before it is redefined, then the keyword
acts normally.
.PP
Second, redefining a keyword precludes any future use of that keyword
during the execution of bc(1), except as the function that redefined it.
.PP
Third, if an error occurs during the parsing of a function whose name is
a redefined keyword, the keyword remains redefined, so it cannot be
recovered.
.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 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)

@ -51,9 +51,13 @@ especially) the GNU bc(1). It also has many extensions and extra features beyond
other implementations.
**Note**: If running this bc(1) on *any* script meant for another bc(1) gives a
parse error, set the environment variable **BC_REDEFINE_KEYWORDS** to **1** (see
the **ENVIRONMENT VARIABLES** section) and try again. It should parse correctly.
If not, that is a bug and should be reported. See the **BUGS** section.
parse error, it is probably because a word this bc(1) reserves as a keyword is
used as the name of a function, variable, or array. To fix that, use the
command-line option **-r** *keyword*, where *keyword* is the keyword that is
used as a name in the script. For more information, see the **OPTIONS** section.
If parsing scripts meant for other bc(1) implementations still does not work,
that is a bug and should be reported. See the **BUGS** section.
# OPTIONS
@ -158,6 +162,40 @@ The following are the options that bc(1) accepts.
This is a **non-portable extension**.
**-r** *keyword*, **-\-redefine**=*keyword*
: Redefines *keyword* in order to allow it to be used as a function, variable,
or array name. This is useful when this bc(1) gives parse errors when
parsing scripts meant for other bc(1) implementations.
The keywords this bc(1) allows to be redefined are:
* **abs**
* **continue**
* **divmod**
* **else**
* **halt**
* **irand**
* **last**
* **limits**
* **maxibase**
* **maxobase**
* **maxrand**
* **maxscale**
* **modexp**
* **print**
* **rand**
* **read**
* **seed**
If any of those keywords are used as a function, variable, or array name in
a script, use this option with the keyword as the argument. If multiple are
used, use this option for all of them; it can be used multiple times.
It is a fatal error to redefine keywords mandated by the POSIX standard. It
is a fatal error to attempt to redefine words that this bc(1) does not
reserve as keywords.
**-R**, **-\-no-read-prompt**
: Disables the read prompt in TTY mode. (The read prompt is only enabled in
@ -1609,27 +1647,6 @@ bc(1) recognizes the following environment variables:
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_REDEFINE_KEYWORDS**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) allow the user to redefine keywords that do not exist in
the bc standard, while zero causes bc(1) to give parse errors if keywords
are not used as expected.
This has several consequences.
First, if a keyword is used before it is redefined, then the keyword acts
normally.
Second, redefining a keyword precludes any future use of that keyword during
the execution of bc(1), except as the function that redefined it.
Third, if an error occurs during the parsing of a function whose name is a
redefined keyword, the keyword remains redefined, so it cannot be recovered.
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
: If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),

@ -56,11 +56,16 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
(and especially) the GNU bc(1).
.PP
\f[B]Note\f[R]: If running this bc(1) on \f[I]any\f[R] script meant for
another bc(1) gives a parse error, set the environment variable
\f[B]BC_REDEFINE_KEYWORDS\f[R] to \f[B]1\f[R] (see the \f[B]ENVIRONMENT
VARIABLES\f[R] section) and try again.
It should parse correctly.
If not, that is a bug and should be reported.
another bc(1) gives a parse error, it is probably because a word this
bc(1) reserves as a keyword is used as the name of a function, variable,
or array.
To fix that, use the command-line option \f[B]-r\f[R] \f[I]keyword\f[R],
where \f[I]keyword\f[R] is the keyword that is used as a name in the
script.
For more information, see the \f[B]OPTIONS\f[R] section.
.PP
If parsing scripts meant for other bc(1) implementations still does not
work, that is a bug and should be reported.
See the \f[B]BUGS\f[R] section.
.SH OPTIONS
.PP
@ -173,6 +178,51 @@ environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
This is a \f[B]non-portable extension\f[R].
.RE
.TP
\f[B]-r\f[R] \f[I]keyword\f[R], \f[B]--redefine\f[R]=\f[I]keyword\f[R]
Redefines \f[I]keyword\f[R] in order to allow it to be used as a
function, variable, or array name.
This is useful when this bc(1) gives parse errors when parsing scripts
meant for other bc(1) implementations.
.RS
.PP
The keywords this bc(1) allows to be redefined are:
.IP \[bu] 2
\f[B]abs\f[R]
.IP \[bu] 2
\f[B]continue\f[R]
.IP \[bu] 2
\f[B]divmod\f[R]
.IP \[bu] 2
\f[B]else\f[R]
.IP \[bu] 2
\f[B]halt\f[R]
.IP \[bu] 2
\f[B]last\f[R]
.IP \[bu] 2
\f[B]limits\f[R]
.IP \[bu] 2
\f[B]maxibase\f[R]
.IP \[bu] 2
\f[B]maxobase\f[R]
.IP \[bu] 2
\f[B]maxscale\f[R]
.IP \[bu] 2
\f[B]modexp\f[R]
.IP \[bu] 2
\f[B]print\f[R]
.IP \[bu] 2
\f[B]read\f[R]
.PP
If any of those keywords are used as a function, variable, or array name
in a script, use this option with the keyword as the argument.
If multiple are used, use this option for all of them; it can be used
multiple times.
.PP
It is a fatal error to redefine keywords mandated by the POSIX standard.
It is a fatal error to attempt to redefine words that this bc(1) does
not reserve as keywords.
.RE
.TP
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
Disables the read prompt in TTY mode.
(The read prompt is only enabled in TTY mode.
@ -1191,29 +1241,6 @@ 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_REDEFINE_KEYWORDS\f[R]
If this environment variable exists and contains an integer, then a
non-zero value makes bc(1) allow the user to redefine keywords that do
not exist in the bc standard, while zero causes bc(1) to give parse
errors if keywords are not used as expected.
.RS
.PP
This has several consequences.
.PP
First, if a keyword is used before it is redefined, then the keyword
acts normally.
.PP
Second, redefining a keyword precludes any future use of that keyword
during the execution of bc(1), except as the function that redefined it.
.PP
Third, if an error occurs during the parsing of a function whose name is
a redefined keyword, the keyword remains redefined, so it cannot be
recovered.
.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 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)

@ -50,9 +50,13 @@ This bc(1) is a drop-in replacement for *any* bc(1), including (and especially)
the GNU bc(1).
**Note**: If running this bc(1) on *any* script meant for another bc(1) gives a
parse error, set the environment variable **BC_REDEFINE_KEYWORDS** to **1** (see
the **ENVIRONMENT VARIABLES** section) and try again. It should parse correctly.
If not, that is a bug and should be reported. See the **BUGS** section.
parse error, it is probably because a word this bc(1) reserves as a keyword is
used as the name of a function, variable, or array. To fix that, use the
command-line option **-r** *keyword*, where *keyword* is the keyword that is
used as a name in the script. For more information, see the **OPTIONS** section.
If parsing scripts meant for other bc(1) implementations still does not work,
that is a bug and should be reported. See the **BUGS** section.
# OPTIONS
@ -142,6 +146,36 @@ The following are the options that bc(1) accepts.
This is a **non-portable extension**.
**-r** *keyword*, **-\-redefine**=*keyword*
: Redefines *keyword* in order to allow it to be used as a function, variable,
or array name. This is useful when this bc(1) gives parse errors when
parsing scripts meant for other bc(1) implementations.
The keywords this bc(1) allows to be redefined are:
* **abs**
* **continue**
* **divmod**
* **else**
* **halt**
* **last**
* **limits**
* **maxibase**
* **maxobase**
* **maxscale**
* **modexp**
* **print**
* **read**
If any of those keywords are used as a function, variable, or array name in
a script, use this option with the keyword as the argument. If multiple are
used, use this option for all of them; it can be used multiple times.
It is a fatal error to redefine keywords mandated by the POSIX standard. It
is a fatal error to attempt to redefine words that this bc(1) does not
reserve as keywords.
**-R**, **-\-no-read-prompt**
: Disables the read prompt in TTY mode. (The read prompt is only enabled in
@ -990,27 +1024,6 @@ bc(1) recognizes the following environment variables:
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_REDEFINE_KEYWORDS**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) allow the user to redefine keywords that do not exist in
the bc standard, while zero causes bc(1) to give parse errors if keywords
are not used as expected.
This has several consequences.
First, if a keyword is used before it is redefined, then the keyword acts
normally.
Second, redefining a keyword precludes any future use of that keyword during
the execution of bc(1), except as the function that redefined it.
Third, if an error occurs during the parsing of a function whose name is a
redefined keyword, the keyword remains redefined, so it cannot be recovered.
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
: If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),

@ -56,11 +56,16 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
(and especially) the GNU bc(1).
.PP
\f[B]Note\f[R]: If running this bc(1) on \f[I]any\f[R] script meant for
another bc(1) gives a parse error, set the environment variable
\f[B]BC_REDEFINE_KEYWORDS\f[R] to \f[B]1\f[R] (see the \f[B]ENVIRONMENT
VARIABLES\f[R] section) and try again.
It should parse correctly.
If not, that is a bug and should be reported.
another bc(1) gives a parse error, it is probably because a word this
bc(1) reserves as a keyword is used as the name of a function, variable,
or array.
To fix that, use the command-line option \f[B]-r\f[R] \f[I]keyword\f[R],
where \f[I]keyword\f[R] is the keyword that is used as a name in the
script.
For more information, see the \f[B]OPTIONS\f[R] section.
.PP
If parsing scripts meant for other bc(1) implementations still does not
work, that is a bug and should be reported.
See the \f[B]BUGS\f[R] section.
.SH OPTIONS
.PP
@ -173,6 +178,51 @@ environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
This is a \f[B]non-portable extension\f[R].
.RE
.TP
\f[B]-r\f[R] \f[I]keyword\f[R], \f[B]--redefine\f[R]=\f[I]keyword\f[R]
Redefines \f[I]keyword\f[R] in order to allow it to be used as a
function, variable, or array name.
This is useful when this bc(1) gives parse errors when parsing scripts
meant for other bc(1) implementations.
.RS
.PP
The keywords this bc(1) allows to be redefined are:
.IP \[bu] 2
\f[B]abs\f[R]
.IP \[bu] 2
\f[B]continue\f[R]
.IP \[bu] 2
\f[B]divmod\f[R]
.IP \[bu] 2
\f[B]else\f[R]
.IP \[bu] 2
\f[B]halt\f[R]
.IP \[bu] 2
\f[B]last\f[R]
.IP \[bu] 2
\f[B]limits\f[R]
.IP \[bu] 2
\f[B]maxibase\f[R]
.IP \[bu] 2
\f[B]maxobase\f[R]
.IP \[bu] 2
\f[B]maxscale\f[R]
.IP \[bu] 2
\f[B]modexp\f[R]
.IP \[bu] 2
\f[B]print\f[R]
.IP \[bu] 2
\f[B]read\f[R]
.PP
If any of those keywords are used as a function, variable, or array name
in a script, use this option with the keyword as the argument.
If multiple are used, use this option for all of them; it can be used
multiple times.
.PP
It is a fatal error to redefine keywords mandated by the POSIX standard.
It is a fatal error to attempt to redefine words that this bc(1) does
not reserve as keywords.
.RE
.TP
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
Disables the read prompt in TTY mode.
(The read prompt is only enabled in TTY mode.
@ -1191,29 +1241,6 @@ 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_REDEFINE_KEYWORDS\f[R]
If this environment variable exists and contains an integer, then a
non-zero value makes bc(1) allow the user to redefine keywords that do
not exist in the bc standard, while zero causes bc(1) to give parse
errors if keywords are not used as expected.
.RS
.PP
This has several consequences.
.PP
First, if a keyword is used before it is redefined, then the keyword
acts normally.
.PP
Second, redefining a keyword precludes any future use of that keyword
during the execution of bc(1), except as the function that redefined it.
.PP
Third, if an error occurs during the parsing of a function whose name is
a redefined keyword, the keyword remains redefined, so it cannot be
recovered.
.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 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)

@ -50,9 +50,13 @@ This bc(1) is a drop-in replacement for *any* bc(1), including (and especially)
the GNU bc(1).
**Note**: If running this bc(1) on *any* script meant for another bc(1) gives a
parse error, set the environment variable **BC_REDEFINE_KEYWORDS** to **1** (see
the **ENVIRONMENT VARIABLES** section) and try again. It should parse correctly.
If not, that is a bug and should be reported. See the **BUGS** section.
parse error, it is probably because a word this bc(1) reserves as a keyword is
used as the name of a function, variable, or array. To fix that, use the
command-line option **-r** *keyword*, where *keyword* is the keyword that is
used as a name in the script. For more information, see the **OPTIONS** section.
If parsing scripts meant for other bc(1) implementations still does not work,
that is a bug and should be reported. See the **BUGS** section.
# OPTIONS
@ -142,6 +146,36 @@ The following are the options that bc(1) accepts.
This is a **non-portable extension**.
**-r** *keyword*, **-\-redefine**=*keyword*
: Redefines *keyword* in order to allow it to be used as a function, variable,
or array name. This is useful when this bc(1) gives parse errors when
parsing scripts meant for other bc(1) implementations.
The keywords this bc(1) allows to be redefined are:
* **abs**
* **continue**
* **divmod**
* **else**
* **halt**
* **last**
* **limits**
* **maxibase**
* **maxobase**
* **maxscale**
* **modexp**
* **print**
* **read**
If any of those keywords are used as a function, variable, or array name in
a script, use this option with the keyword as the argument. If multiple are
used, use this option for all of them; it can be used multiple times.
It is a fatal error to redefine keywords mandated by the POSIX standard. It
is a fatal error to attempt to redefine words that this bc(1) does not
reserve as keywords.
**-R**, **-\-no-read-prompt**
: Disables the read prompt in TTY mode. (The read prompt is only enabled in
@ -990,27 +1024,6 @@ bc(1) recognizes the following environment variables:
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_REDEFINE_KEYWORDS**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) allow the user to redefine keywords that do not exist in
the bc standard, while zero causes bc(1) to give parse errors if keywords
are not used as expected.
This has several consequences.
First, if a keyword is used before it is redefined, then the keyword acts
normally.
Second, redefining a keyword precludes any future use of that keyword during
the execution of bc(1), except as the function that redefined it.
Third, if an error occurs during the parsing of a function whose name is a
redefined keyword, the keyword remains redefined, so it cannot be recovered.
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
: If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),

@ -56,11 +56,16 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
(and especially) the GNU bc(1).
.PP
\f[B]Note\f[R]: If running this bc(1) on \f[I]any\f[R] script meant for
another bc(1) gives a parse error, set the environment variable
\f[B]BC_REDEFINE_KEYWORDS\f[R] to \f[B]1\f[R] (see the \f[B]ENVIRONMENT
VARIABLES\f[R] section) and try again.
It should parse correctly.
If not, that is a bug and should be reported.
another bc(1) gives a parse error, it is probably because a word this
bc(1) reserves as a keyword is used as the name of a function, variable,
or array.
To fix that, use the command-line option \f[B]-r\f[R] \f[I]keyword\f[R],
where \f[I]keyword\f[R] is the keyword that is used as a name in the
script.
For more information, see the \f[B]OPTIONS\f[R] section.
.PP
If parsing scripts meant for other bc(1) implementations still does not
work, that is a bug and should be reported.
See the \f[B]BUGS\f[R] section.
.SH OPTIONS
.PP
@ -173,6 +178,51 @@ environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
This is a \f[B]non-portable extension\f[R].
.RE
.TP
\f[B]-r\f[R] \f[I]keyword\f[R], \f[B]--redefine\f[R]=\f[I]keyword\f[R]
Redefines \f[I]keyword\f[R] in order to allow it to be used as a
function, variable, or array name.
This is useful when this bc(1) gives parse errors when parsing scripts
meant for other bc(1) implementations.
.RS
.PP
The keywords this bc(1) allows to be redefined are:
.IP \[bu] 2
\f[B]abs\f[R]
.IP \[bu] 2
\f[B]continue\f[R]
.IP \[bu] 2
\f[B]divmod\f[R]
.IP \[bu] 2
\f[B]else\f[R]
.IP \[bu] 2
\f[B]halt\f[R]
.IP \[bu] 2
\f[B]last\f[R]
.IP \[bu] 2
\f[B]limits\f[R]
.IP \[bu] 2
\f[B]maxibase\f[R]
.IP \[bu] 2
\f[B]maxobase\f[R]
.IP \[bu] 2
\f[B]maxscale\f[R]
.IP \[bu] 2
\f[B]modexp\f[R]
.IP \[bu] 2
\f[B]print\f[R]
.IP \[bu] 2
\f[B]read\f[R]
.PP
If any of those keywords are used as a function, variable, or array name
in a script, use this option with the keyword as the argument.
If multiple are used, use this option for all of them; it can be used
multiple times.
.PP
It is a fatal error to redefine keywords mandated by the POSIX standard.
It is a fatal error to attempt to redefine words that this bc(1) does
not reserve as keywords.
.RE
.TP
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
Disables the read prompt in TTY mode.
(The read prompt is only enabled in TTY mode.
@ -1191,29 +1241,6 @@ 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_REDEFINE_KEYWORDS\f[R]
If this environment variable exists and contains an integer, then a
non-zero value makes bc(1) allow the user to redefine keywords that do
not exist in the bc standard, while zero causes bc(1) to give parse
errors if keywords are not used as expected.
.RS
.PP
This has several consequences.
.PP
First, if a keyword is used before it is redefined, then the keyword
acts normally.
.PP
Second, redefining a keyword precludes any future use of that keyword
during the execution of bc(1), except as the function that redefined it.
.PP
Third, if an error occurs during the parsing of a function whose name is
a redefined keyword, the keyword remains redefined, so it cannot be
recovered.
.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 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)

@ -50,9 +50,13 @@ This bc(1) is a drop-in replacement for *any* bc(1), including (and especially)
the GNU bc(1).
**Note**: If running this bc(1) on *any* script meant for another bc(1) gives a
parse error, set the environment variable **BC_REDEFINE_KEYWORDS** to **1** (see
the **ENVIRONMENT VARIABLES** section) and try again. It should parse correctly.
If not, that is a bug and should be reported. See the **BUGS** section.
parse error, it is probably because a word this bc(1) reserves as a keyword is
used as the name of a function, variable, or array. To fix that, use the
command-line option **-r** *keyword*, where *keyword* is the keyword that is
used as a name in the script. For more information, see the **OPTIONS** section.
If parsing scripts meant for other bc(1) implementations still does not work,
that is a bug and should be reported. See the **BUGS** section.
# OPTIONS
@ -142,6 +146,36 @@ The following are the options that bc(1) accepts.
This is a **non-portable extension**.
**-r** *keyword*, **-\-redefine**=*keyword*
: Redefines *keyword* in order to allow it to be used as a function, variable,
or array name. This is useful when this bc(1) gives parse errors when
parsing scripts meant for other bc(1) implementations.
The keywords this bc(1) allows to be redefined are:
* **abs**
* **continue**
* **divmod**
* **else**
* **halt**
* **last**
* **limits**
* **maxibase**
* **maxobase**
* **maxscale**
* **modexp**
* **print**
* **read**
If any of those keywords are used as a function, variable, or array name in
a script, use this option with the keyword as the argument. If multiple are
used, use this option for all of them; it can be used multiple times.
It is a fatal error to redefine keywords mandated by the POSIX standard. It
is a fatal error to attempt to redefine words that this bc(1) does not
reserve as keywords.
**-R**, **-\-no-read-prompt**
: Disables the read prompt in TTY mode. (The read prompt is only enabled in
@ -990,27 +1024,6 @@ bc(1) recognizes the following environment variables:
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_REDEFINE_KEYWORDS**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) allow the user to redefine keywords that do not exist in
the bc standard, while zero causes bc(1) to give parse errors if keywords
are not used as expected.
This has several consequences.
First, if a keyword is used before it is redefined, then the keyword acts
normally.
Second, redefining a keyword precludes any future use of that keyword during
the execution of bc(1), except as the function that redefined it.
Third, if an error occurs during the parsing of a function whose name is a
redefined keyword, the keyword remains redefined, so it cannot be recovered.
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
: If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),

@ -56,11 +56,16 @@ This bc(1) is a drop-in replacement for \f[I]any\f[R] bc(1), including
(and especially) the GNU bc(1).
.PP
\f[B]Note\f[R]: If running this bc(1) on \f[I]any\f[R] script meant for
another bc(1) gives a parse error, set the environment variable
\f[B]BC_REDEFINE_KEYWORDS\f[R] to \f[B]1\f[R] (see the \f[B]ENVIRONMENT
VARIABLES\f[R] section) and try again.
It should parse correctly.
If not, that is a bug and should be reported.
another bc(1) gives a parse error, it is probably because a word this
bc(1) reserves as a keyword is used as the name of a function, variable,
or array.
To fix that, use the command-line option \f[B]-r\f[R] \f[I]keyword\f[R],
where \f[I]keyword\f[R] is the keyword that is used as a name in the
script.
For more information, see the \f[B]OPTIONS\f[R] section.
.PP
If parsing scripts meant for other bc(1) implementations still does not
work, that is a bug and should be reported.
See the \f[B]BUGS\f[R] section.
.SH OPTIONS
.PP
@ -173,6 +178,51 @@ environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
This is a \f[B]non-portable extension\f[R].
.RE
.TP
\f[B]-r\f[R] \f[I]keyword\f[R], \f[B]--redefine\f[R]=\f[I]keyword\f[R]
Redefines \f[I]keyword\f[R] in order to allow it to be used as a
function, variable, or array name.
This is useful when this bc(1) gives parse errors when parsing scripts
meant for other bc(1) implementations.
.RS
.PP
The keywords this bc(1) allows to be redefined are:
.IP \[bu] 2
\f[B]abs\f[R]
.IP \[bu] 2
\f[B]continue\f[R]
.IP \[bu] 2
\f[B]divmod\f[R]
.IP \[bu] 2
\f[B]else\f[R]
.IP \[bu] 2
\f[B]halt\f[R]
.IP \[bu] 2
\f[B]last\f[R]
.IP \[bu] 2
\f[B]limits\f[R]
.IP \[bu] 2
\f[B]maxibase\f[R]
.IP \[bu] 2
\f[B]maxobase\f[R]
.IP \[bu] 2
\f[B]maxscale\f[R]
.IP \[bu] 2
\f[B]modexp\f[R]
.IP \[bu] 2
\f[B]print\f[R]
.IP \[bu] 2
\f[B]read\f[R]
.PP
If any of those keywords are used as a function, variable, or array name
in a script, use this option with the keyword as the argument.
If multiple are used, use this option for all of them; it can be used
multiple times.
.PP
It is a fatal error to redefine keywords mandated by the POSIX standard.
It is a fatal error to attempt to redefine words that this bc(1) does
not reserve as keywords.
.RE
.TP
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
Disables the read prompt in TTY mode.
(The read prompt is only enabled in TTY mode.
@ -1191,29 +1241,6 @@ 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_REDEFINE_KEYWORDS\f[R]
If this environment variable exists and contains an integer, then a
non-zero value makes bc(1) allow the user to redefine keywords that do
not exist in the bc standard, while zero causes bc(1) to give parse
errors if keywords are not used as expected.
.RS
.PP
This has several consequences.
.PP
First, if a keyword is used before it is redefined, then the keyword
acts normally.
.PP
Second, redefining a keyword precludes any future use of that keyword
during the execution of bc(1), except as the function that redefined it.
.PP
Third, if an error occurs during the parsing of a function whose name is
a redefined keyword, the keyword remains redefined, so it cannot be
recovered.
.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 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)

@ -50,9 +50,13 @@ This bc(1) is a drop-in replacement for *any* bc(1), including (and especially)
the GNU bc(1).
**Note**: If running this bc(1) on *any* script meant for another bc(1) gives a
parse error, set the environment variable **BC_REDEFINE_KEYWORDS** to **1** (see
the **ENVIRONMENT VARIABLES** section) and try again. It should parse correctly.
If not, that is a bug and should be reported. See the **BUGS** section.
parse error, it is probably because a word this bc(1) reserves as a keyword is
used as the name of a function, variable, or array. To fix that, use the
command-line option **-r** *keyword*, where *keyword* is the keyword that is
used as a name in the script. For more information, see the **OPTIONS** section.
If parsing scripts meant for other bc(1) implementations still does not work,
that is a bug and should be reported. See the **BUGS** section.
# OPTIONS
@ -142,6 +146,36 @@ The following are the options that bc(1) accepts.
This is a **non-portable extension**.
**-r** *keyword*, **-\-redefine**=*keyword*
: Redefines *keyword* in order to allow it to be used as a function, variable,
or array name. This is useful when this bc(1) gives parse errors when
parsing scripts meant for other bc(1) implementations.
The keywords this bc(1) allows to be redefined are:
* **abs**
* **continue**
* **divmod**
* **else**
* **halt**
* **last**
* **limits**
* **maxibase**
* **maxobase**
* **maxscale**
* **modexp**
* **print**
* **read**
If any of those keywords are used as a function, variable, or array name in
a script, use this option with the keyword as the argument. If multiple are
used, use this option for all of them; it can be used multiple times.
It is a fatal error to redefine keywords mandated by the POSIX standard. It
is a fatal error to attempt to redefine words that this bc(1) does not
reserve as keywords.
**-R**, **-\-no-read-prompt**
: Disables the read prompt in TTY mode. (The read prompt is only enabled in
@ -990,27 +1024,6 @@ bc(1) recognizes the following environment variables:
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_REDEFINE_KEYWORDS**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) allow the user to redefine keywords that do not exist in
the bc standard, while zero causes bc(1) to give parse errors if keywords
are not used as expected.
This has several consequences.
First, if a keyword is used before it is redefined, then the keyword acts
normally.
Second, redefining a keyword precludes any future use of that keyword during
the execution of bc(1), except as the function that redefined it.
Third, if an error occurs during the parsing of a function whose name is a
redefined keyword, the keyword remains redefined, so it cannot be recovered.
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
: If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),

@ -58,11 +58,16 @@ It also has many extensions and extra features beyond other
implementations.
.PP
\f[B]Note\f[R]: If running this bc(1) on \f[I]any\f[R] script meant for
another bc(1) gives a parse error, set the environment variable
\f[B]BC_REDEFINE_KEYWORDS\f[R] to \f[B]1\f[R] (see the \f[B]ENVIRONMENT
VARIABLES\f[R] section) and try again.
It should parse correctly.
If not, that is a bug and should be reported.
another bc(1) gives a parse error, it is probably because a word this
bc(1) reserves as a keyword is used as the name of a function, variable,
or array.
To fix that, use the command-line option \f[B]-r\f[R] \f[I]keyword\f[R],
where \f[I]keyword\f[R] is the keyword that is used as a name in the
script.
For more information, see the \f[B]OPTIONS\f[R] section.
.PP
If parsing scripts meant for other bc(1) implementations still does not
work, that is a bug and should be reported.
See the \f[B]BUGS\f[R] section.
.SH OPTIONS
.PP
@ -196,6 +201,59 @@ environment variables (see the \f[B]ENVIRONMENT VARIABLES\f[R] section).
This is a \f[B]non-portable extension\f[R].
.RE
.TP
\f[B]-r\f[R] \f[I]keyword\f[R], \f[B]--redefine\f[R]=\f[I]keyword\f[R]
Redefines \f[I]keyword\f[R] in order to allow it to be used as a
function, variable, or array name.
This is useful when this bc(1) gives parse errors when parsing scripts
meant for other bc(1) implementations.
.RS
.PP
The keywords this bc(1) allows to be redefined are:
.IP \[bu] 2
\f[B]abs\f[R]
.IP \[bu] 2
\f[B]continue\f[R]
.IP \[bu] 2
\f[B]divmod\f[R]
.IP \[bu] 2
\f[B]else\f[R]
.IP \[bu] 2
\f[B]halt\f[R]
.IP \[bu] 2
\f[B]irand\f[R]
.IP \[bu] 2
\f[B]last\f[R]
.IP \[bu] 2
\f[B]limits\f[R]
.IP \[bu] 2
\f[B]maxibase\f[R]
.IP \[bu] 2
\f[B]maxobase\f[R]
.IP \[bu] 2
\f[B]maxrand\f[R]
.IP \[bu] 2
\f[B]maxscale\f[R]
.IP \[bu] 2
\f[B]modexp\f[R]
.IP \[bu] 2
\f[B]print\f[R]
.IP \[bu] 2
\f[B]rand\f[R]
.IP \[bu] 2
\f[B]read\f[R]
.IP \[bu] 2
\f[B]seed\f[R]
.PP
If any of those keywords are used as a function, variable, or array name
in a script, use this option with the keyword as the argument.
If multiple are used, use this option for all of them; it can be used
multiple times.
.PP
It is a fatal error to redefine keywords mandated by the POSIX standard.
It is a fatal error to attempt to redefine words that this bc(1) does
not reserve as keywords.
.RE
.TP
\f[B]-R\f[R], \f[B]--no-read-prompt\f[R]
Disables the read prompt in TTY mode.
(The read prompt is only enabled in TTY mode.
@ -1925,29 +1983,6 @@ 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_REDEFINE_KEYWORDS\f[R]
If this environment variable exists and contains an integer, then a
non-zero value makes bc(1) allow the user to redefine keywords that do
not exist in the bc standard, while zero causes bc(1) to give parse
errors if keywords are not used as expected.
.RS
.PP
This has several consequences.
.PP
First, if a keyword is used before it is redefined, then the keyword
acts normally.
.PP
Second, redefining a keyword precludes any future use of that keyword
during the execution of bc(1), except as the function that redefined it.
.PP
Third, if an error occurs during the parsing of a function whose name is
a redefined keyword, the keyword remains redefined, so it cannot be
recovered.
.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 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)

@ -51,9 +51,13 @@ especially) the GNU bc(1). It also has many extensions and extra features beyond
other implementations.
**Note**: If running this bc(1) on *any* script meant for another bc(1) gives a
parse error, set the environment variable **BC_REDEFINE_KEYWORDS** to **1** (see
the **ENVIRONMENT VARIABLES** section) and try again. It should parse correctly.
If not, that is a bug and should be reported. See the **BUGS** section.
parse error, it is probably because a word this bc(1) reserves as a keyword is
used as the name of a function, variable, or array. To fix that, use the
command-line option **-r** *keyword*, where *keyword* is the keyword that is
used as a name in the script. For more information, see the **OPTIONS** section.
If parsing scripts meant for other bc(1) implementations still does not work,
that is a bug and should be reported. See the **BUGS** section.
# OPTIONS
@ -158,6 +162,40 @@ The following are the options that bc(1) accepts.
This is a **non-portable extension**.
**-r** *keyword*, **-\-redefine**=*keyword*
: Redefines *keyword* in order to allow it to be used as a function, variable,
or array name. This is useful when this bc(1) gives parse errors when
parsing scripts meant for other bc(1) implementations.
The keywords this bc(1) allows to be redefined are:
* **abs**
* **continue**
* **divmod**
* **else**
* **halt**
* **irand**
* **last**
* **limits**
* **maxibase**
* **maxobase**
* **maxrand**
* **maxscale**
* **modexp**
* **print**
* **rand**
* **read**
* **seed**
If any of those keywords are used as a function, variable, or array name in
a script, use this option with the keyword as the argument. If multiple are
used, use this option for all of them; it can be used multiple times.
It is a fatal error to redefine keywords mandated by the POSIX standard. It
is a fatal error to attempt to redefine words that this bc(1) does not
reserve as keywords.
**-R**, **-\-no-read-prompt**
: Disables the read prompt in TTY mode. (The read prompt is only enabled in
@ -1609,27 +1647,6 @@ bc(1) recognizes the following environment variables:
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_REDEFINE_KEYWORDS**
: If this environment variable exists and contains an integer, then a non-zero
value makes bc(1) allow the user to redefine keywords that do not exist in
the bc standard, while zero causes bc(1) to give parse errors if keywords
are not used as expected.
This has several consequences.
First, if a keyword is used before it is redefined, then the keyword acts
normally.
Second, redefining a keyword precludes any future use of that keyword during
the execution of bc(1), except as the function that redefined it.
Third, if an error occurs during the parsing of a function whose name is a
redefined keyword, the keyword remains redefined, so it cannot be recovered.
This environment variable overrides the default, which can be queried with
the **-h** or **-\-help** options.
**BC_SIGINT_RESET**
: If bc(1) is not in interactive mode (see the **INTERACTIVE MODE** section),

<
@ -58,11 +58,16 @@ It also has many extensions and extra features beyond other
implementations.
.PP
\f[B]Note\f[R]: If running this bc(1) on \f[I]any\f[R] script meant for
another bc(1) gives a parse error, set the environment variable
\f[B]BC_REDEFINE_KEYWORDS\f[R] to \f[B]1\f[R] (see the \f[B]ENVIRONMENT
VARIABLES\f[R] section) and try again.
It should parse correctly.
If not, that is a bug and should be reported.
another bc(1) gives a parse error, it is probably because a word this
bc(1) reserves as a keyword is used as the name of a function, variable,
or array.
To fix that, use the command-line option \f[B]-r\f[R] \f[I]keyword\f[R],
where \f[I]keyword\f[R] is the keyword that is used as a name in the
script.
For more information, see the \f[B]OPTIONS\f[R] section.
.PP
If parsing scripts meant for other bc(1) implementations still does not
work, that is a bug and should be reported.
See the \f[B]BUGS\f[R] section.