bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash silently exits where attempting to assign an array to certain b


From: Chet Ramey
Subject: Re: Bash silently exits where attempting to assign an array to certain built-in variables using declare
Date: Thu, 29 Jun 2023 11:44:17 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0

On 6/29/23 9:38 AM, Kerin Millar wrote:
On Thu, 29 Jun 2023 08:51:58 -0400
Chet Ramey <chet.ramey@case.edu> wrote:

On 6/28/23 1:14 PM, Kerin Millar wrote:
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

These are all `noassign' variables; assignments to them are ignored.
The bash debugger variables cannot be unset either. Other noassign
variables can be unset; that's why they're not readonly.

(Before you ask, noassign variables have been in bash since 1996.)

Thanks for this information. While I had no expectation of them being 
assignable, some of this might have a valid place in the manual.

Agreed.


It does not happen if trying to assign a string.

It should be consistent, at least. I think the string assignment behavior
is the most reasonable: assignments return 1 but there's no assignment
error. I'll look at how compound assignments are different.

Thanks. I would just add that 'noassign' variables are not consistently indicated in the 
manual. For example, it is said for GROUPS that "Assignments to GROUPS have no 
effect" but there is no such wording for the others that I mentioned. That might be 
worth addressing, even if only by inserting similarly worded sentences where appropriate.

Agreed; the latest devel branch push added that wording for the debugger
variables.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]