This report is based on an observation made within the depths of this thread: 
https://lists.gnu.org/archive/html/bug-bash/2023-06/msg00094.html.

Attempting to assign an array to any of the following variables with the 
declare builtin causes bash to immediately exit with no diagnostic message 
being issued.

  BASH_ARGC
  BASH_ARGV
  BASH_LINENO
  BASH_SOURCE
  GROUPS

Here is an example.

  $ bash -c 'declare -p BASH_VERSION; declare BASH_ARGC=(); echo FIN'; echo $?
  declare -- BASH_VERSION="5.2.15(1)-release"

It does not happen if trying to assign a string.

  $ bash -c 'declare BASH_ARGC=1; echo FIN'
  FIN

There are various other variables bearing the readonly attribute for which this 
also happens. In the following case, bash does, at least, complain that the 
variable is readonly.

  $ bash -c 'declare BASHOPTS=(); echo FIN'
  bash: line 1: BASHOPTS: readonly variable

However:

  $ bash -c 'declare BASHOPTS=1; echo FIN'
  bash: line 1: BASHOPTS: readonly variable
  FIN

This seems rather inconsistent. Also, it is confusing for bash to quit without 
indicating why it did so.

-- 
Kerin Millar

Reply via email to