re: GNU bash, version 5.2.37(1)-release (aarch64-apple-darwin23.4.0)

---

1) `shopt compat50` does not exist. The manpage does specify that
'compat50' is a valid option for `shopt` under BUILTINS/shopt. Yet bash
provides an error when trying to read or change it:

> shopt compat50
bash: shopt: compat50: invalid shell option name

"Bash-5.0 is the final version for which there will be an individual shopt
option for the previous version. Users should use BASH_COMPAT on bash-5.0
and later versions."

...Not sure if this means `shopt compat50` should work or not. But either
way, `shopt compat50` should be consistent with BUILTINS/shopt.

---

2) Bash errors on valid BASH_COMPAT values? Am I missing something here?

"BASH_COMPAT...For example, 4.2 and 42 are valid values that correspond to
the compat42 shopt option and set the compatibility level to 42.  The
current version is also a valid value."

> BASH_COMPAT=4.4 bash --noprofile -l
bash: BASH_COMPAT: compat44: compatibility value out of range
bash-5.2$ shopt compat44
compat44        on

> BASH_COMPAT=44 bash --noprofile -l
bash: BASH_COMPAT: compat44: compatibility value out of range
bash-5.2$ shopt compat44
compat44        on

> BASH_COMPAT=compat44 bash --noprofile -l
bash: BASH_COMPAT: compat44: compatibility value out of range
bash: BASH_COMPAT: compat44: compatibility value out of range
bash-5.2$ shopt compat44
compat44        off
# ^-- as expected, just showing for completeness

> bash --noprofile -l
bash-5.2$ shopt compat44
compat44        off
bash-5.2$ BASH_COMPAT=44
bash-5.2$ shopt compat44
compat44        on
bash-5.2$ BASH_COMPAT=
bash-5.2$ shopt compat44
compat44        off
bash-5.2$ BASH_COMPAT=4.4
bash-5.2$ shopt compat44
compat44        on
bash-5.2$ BASH_COMPAT=
bash-5.2$ shopt compat44
compat44        off
bash-5.2$ BASH_COMPAT=compat44
bash: BASH_COMPAT: compat44: compatibility value out of range
# ^-- again, as expected, just showing for completeness

---

For convenience, here is an abridged excerpt of the manpage. Line numbers
correspond with this set of commands:

LESS="-JN -x4 --line-num-width=4 --status-col-width=1 --use-color"
MANPAGER="less -sR"
MANWIDTH=75
man bash

  714 PARAMETERS

  848    Shell Variables
  849        The following variables are set by the shell:

 1167        BASH_COMPAT
 1168               The value is used to set the shell's compatibility
level.
 1169               See SHELL COMPATIBILITY MODE below for a description of
the
 1170               various compatibility levels and their effects.  The
value
 1171               may be a decimal number (e.g., 4.2) or an integer
(e.g., 42)
 1172               corresponding to the desired compatibility level.  If
 1173               BASH_COMPAT is unset or set to the empty string, the
 1174               compatibility level is set to the default for the
current
 1175               version.  If BASH_COMPAT is set to a value that is not
one of
 1176               the valid compatibility levels, the shell prints an
error
 1177               message and sets the compatibility level to the default
for
 1178               the current version.  The valid values correspond to the
 1179               compatibility levels described below under SHELL
 1180               COMPATIBILITY MODE.  For example, 4.2 and 42 are valid
values
 1181               that correspond to the compat42 shopt option and set the
 1182               compatibility level to 42.  The current version is also
a
 1183               valid value.

 4656 SHELL BUILTIN COMMANDS

 6035        shopt [-pqsu] [-o] [optname ...]

 6065               The list of shopt options is:

 6112               compat31
 6113               compat32
 6114               compat40
 6115               compat41
 6116               compat42
 6117               compat43
 6118               compat44
 6119               compat50
 6120                       These control aspects of the shell's
compatibility
 6121                       mode (see SHELL COMPATIBILITY MODE below).

 6679 SHELL COMPATIBILITY MODE

 6708        Bash-4.3 introduced a new shell variable: BASH_COMPAT.  The
value
 6709        assigned to this variable (a decimal version number like 4.2,
or an
 6710        integer corresponding to the compatNN option, like 42)
determines
 6711        the compatibility level.
 6712
 6713        Starting with bash-4.4, Bash has begun deprecating older
 6714        compatibility levels.  Eventually, the options will be removed
in
 6715        favor of BASH_COMPAT.
 6716
 6717        Bash-5.0 is the final version for which there will be an
individual
 6718        shopt option for the previous version. Users should use
BASH_COMPAT
 6719        on bash-5.0 and later versions.
 6720
 6721        The following table describes the behavior changes controlled
by
 6722        each compatibility level setting.  The compatNN tag is used as
 6723        shorthand for setting the compatibility level to NN using one
of the
 6724        following mechanisms.  For versions prior to bash-5.0, the
 6725        compatibility level may be set using the corresponding compatNN
 6726        shopt option.  For bash-4.3 and later versions, the BASH_COMPAT
 6727        variable is preferred, and it is required for bash-5.1 and
later
 6728        versions.

 6730        compat31
 6734        compat32
 6741        compat40
 6749        compat41
 6760        compat42
 6772        compat43
 6787        compat44
 6801        compat50
 6815        compat51

Reply via email to