set a 111222333
regsub {2+} $a {\1kk}
111kk333
LANG=C sed -i -E 's/'\''\$\(\w+_CPPFLAGS\)'\''/'\''@\1@'\''/g' theConfig/ccmsgque/Makefile.am
sed: -e expression #1, char 31: invalid reference \1 on `s' command's RHS
Hi,
small example…
set a 111222333
regsub {2+} $a {\1kk}
111kk333
the *regsub* does not complain about *non* defined '\1', the *sed* raise
an error
LANG=C sed -i -E 's/'\''\$\(\w+_CPPFLAGS\)'\''/'\''@\1@'\''/g'theConfig/ccmsgque/Makefile.am
sed: -e expression #1, char 31: invalid reference \1 on `s' command'sRHS
background → if you explicit define an '\1' you assume that an '(...)'
is available.
if NOT this is mostly an error.
On 3/30/24 02:29, aotto1968 wrote:
Hi,
small example…
set a 111222333
regsub {2+} $a {\1kk}
111kk333
the *regsub* does not complain about *non* defined '\1', the *sed* raise an error
LANG=C sed -i -E 's/'\''\$\(\w+_CPPFLAGS\)'\''/'\''@\1@'\''/g' theConfig/ccmsgque/Makefile.am
sed: -e expression #1, char 31: invalid reference \1 on `s' command's RHS
background → if you explicit define an '\1' you assume that an '(...)' is available.
if NOT this is mostly an error.
Ah, the man page does not say that. regsub is not sed.
The \1 ... \9 are the empty string if not matched.
On 30.03.24 15:32, Gerald Lester wrote:
On 3/30/24 02:29, aotto1968 wrote:
Hi,
small example…
set a 111222333
regsub {2+} $a {\1kk}
111kk333
the *regsub* does not complain about *non* defined '\1', the *sed*
raise an error
LANG=C sed -i -E 's/'\''\$\(\w+_CPPFLAGS\)'\''/'\''@\1@'\''/g'theConfig/ccmsgque/Makefile.am
sed: -e expression #1, char 31: invalid reference \1 on `s'command's RHS
background → if you explicit define an '\1' you assume that an
'(...)' is available.
if NOT this is mostly an error.
Ah, the man page does not say that. regsub is not sed.
The \1 ... \9 are the empty string if not matched.
→ yes, make a BUG to a FEATURE and you are fine.
I already had some "problems" because of this BUG because it is
*IMPOSSIBLE* to check the
regular expression of the *regsub* to be *valid* again a target
replacement.
I understand that you already have code that depends on this BUG but
with a "-strict" switch
you have a chance to fix this BUG.
On 30.03.24 15:32, Gerald Lester wrote:
< --------
Ah, the man page does not say that. regsub is not sed.
The \1 ... \9 are the empty string if not matched.
→ yes, make a BUG to a FEATURE and you are fine.
I already had some "problems" because of this BUG because it is
*IMPOSSIBLE* to check the regular expression of the *regsub* to be *valid* again a target replacement.
I understand that you already have code that depends on this BUG but
with a "-strict" switch you have a chance to fix this BUG.
mfg
On 2024-03-31, aotto1968 <aotto1968@t-online.de> wrote:
On 30.03.24 15:32, Gerald Lester wrote:
It behaves as documented, so it's not a bug. It's always (as far as I
know) behaved like that, so you are requesting a change - write a TIP !
But I for one would be interested in seeing an example of your
*IMPOSSIBLE* validation.
Eric
As I already show in the initial post that *sed* is doing such kind of**************************
test. With *IMPOSSIPLE* I mean to check a regular expression in *tcl* is >close to *IMPOSSIPLE*. the *-strict* switch is just an example how to fix >this BUG without break *old* code.
With *IMPOSSIPLE* I mean to check a regular expression in *tcl* is
close to *IMPOSSIPLE*.
On Sun, 31 Mar 2024 20:21:58 +0200, aotto1968 wrote:
As I already show in the initial post that *sed* is doing such kind of**************************
test. With *IMPOSSIPLE* I mean to check a regular expression in *tcl* is
close to *IMPOSSIPLE*. the *-strict* switch is just an example how to fix
this BUG without break *old* code.
I see your point, you do have a point, but it's not impossible.
% set a 111222333
111222333
% regexp {2+} $a -> found1
1
% info exists found1
1
% set found1
<-- empty string
% regexp {(2+)} $a -> found1
1
% set found1
222
So you can always check if something was stored in found1, found2,
found3... etc. There is your safety check. It's only going to cost you
two additional lines.
I use *regsub* and in *regsub* you have no place to add some testing code.
On 31.03.24 20:47, Luc wrote:
On Sun, 31 Mar 2024 20:21:58 +0200, aotto1968 wrote:
As I already show in the initial post that *sed* is doing such kind of**************************
test. With *IMPOSSIPLE* I mean to check a regular expression in *tcl* is >>> close to *IMPOSSIPLE*. the *-strict* switch is just an example how to
fix
this BUG without break *old* code.
I see your point, you do have a point, but it's not impossible.
% set a 111222333
111222333
% regexp {2+} $a -> found1
1
% info exists found1
1
% set found1
<-- empty string
% regexp {(2+)} $a -> found1
1
% set found1
222
So you can always check if something was stored in found1, found2,
found3... etc. There is your safety check. It's only going to cost you
two additional lines.
I use *regsub* and in *regsub* you have no place to add some testing code.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 920 |
Nodes: | 10 (1 / 9) |
Uptime: | 96:15:51 |
Calls: | 12,189 |
Calls today: | 1 |
Files: | 186,527 |
Messages: | 2,237,344 |