Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15517

Re: Feature request: save/restore BASH_REMATCH across debug hook calls

Newsgroups gnu.bash.bug
Date 2019-10-17 00:08 -0700
References <CANCp2gZjUeDUbRDVZzjqMVn1eWoRXRK+kTf_y-UHWTs5R6a79Q@mail.gmail.com> <29baca4d-b3fe-c50a-0b59-47214cd8d418@case.edu> <mailman.903.1571253292.9715.bug-bash@gnu.org>
Message-ID <07975c33-730e-4d71-a3d0-db83cc6cafd9@googlegroups.com> (permalink)
Subject Re: Feature request: save/restore BASH_REMATCH across debug hook calls
From rocky.bernstein@gmail.com

Show all headers | View raw


On Wednesday, October 16, 2019 at 3:14:54 PM UTC-4, Chet Ramey wrote:
> On 10/16/19 1:34 PM, Rocky Bernstein wrote:
> > Current in bash 5.0 and earlier, the value of BASH_REMATCH might chanted
> > inside a debug hook.
> > 
> > Since BASH_REMATCH is read-only, resetting the value on hook return to the
> > debugged program is a bit tricky and fragile...
> 
> How about we just make it not read-only? The shell will still set it when
> it does regexp matching.


One the one hand, that helps folks writing debug hooks to restore BASH_REMATCH on hook exit. So from my side that is better than the current situations. 

But now let's also consider the downsides this approach.

First, there was a reason it was read-only, and that reason I think still applies. 

Second, every hook writer will have to know to save and restore BASH_REMATCH. (It took me a while to realize this needed to be done, and in the meantime things were just flaky). And all hook writers basically would add the same bit of code. So why not do it once inside bash? 

That said, since I'm not doing the work, either is fine.

Back to gnu.bash.bug | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Feature request: save/restore BASH_REMATCH across debug hook calls Chet Ramey <chet.ramey@case.edu> - 2019-10-16 15:14 -0400
  Re: Feature request: save/restore BASH_REMATCH across debug hook calls rocky.bernstein@gmail.com - 2019-10-17 00:08 -0700

csiph-web