help-bash
[Top][All Lists]
Advanced

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

BASH_REMATCH declared function-local (Was: Suggestion for the documentat


From: Stan Marsh
Subject: BASH_REMATCH declared function-local (Was: Suggestion for the documentation of BASH_REMATCH)
Date: Mon, 16 Mar 2026 16:03:06 -0600

From:   Greg Wooledge
Subject: Re: Suggestion for the documentation of BASH_REMATCH
Date:   Mon, 16 Mar 2026 15:25:54 -0400

>On Mon, Mar 16, 2026 at 13:18:55 -0600, Stan Marsh wrote:
>> Another thing about BASH_REMATCH that is interesting is that if you
>> declare it local (in a function), it stops working (in that
>> function).

>hobbit:~$ bash-5.2 -c 'x() { local BASH_REMATCH; [[ x =~ x ]]; declare -p 
>BASH_REMATCH; }; x'
>declare -- BASH_REMATCH
>hobbit:~$ bash-5.3 -c 'x() { local BASH_REMATCH; [[ x =~ x ]]; declare -p 
>BASH_REMATCH; }; x'
>declare -a BASH_REMATCH=([0]="x")

>It sounds like you're not on the newest stable release.

I am happy to hear that it has been fixed.  I only tested this once -
it would have been on some version of bash 5.X.something - when I hit
the problem, I assumed it was likely a feature of some sort and I just
worked around it.

I have to say that yours was not the kind of response I was expecting
to get (and that is a Good Thing).  I was expecting some kind of
explanation of how it was actually a feature (and thus would not be
fixed).

So, all is well.

=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.

When responding to my posts, please try to refrain from giving bureaucratic 
answers.
If you have nothing useful to say, then just click Next and go on.



reply via email to

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