help-gawk
[Top][All Lists]
Advanced

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

Re: warning: regexp constant for parameter #1 yields boolean value


From: Andrew J. Schorr
Subject: Re: warning: regexp constant for parameter #1 yields boolean value
Date: Thu, 4 Aug 2022 14:23:25 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Aug 04, 2022 at 12:52:25PM -0400, Andrew J. Schorr wrote:
> Hi,
> 
> On Thu, Aug 04, 2022 at 11:39:23AM -0400, J Naman wrote:
> > I am sorry, I do not understand what this warning means in this case.
> > code:
> > r0=gensub(/([0-9])[,]([0-9])/,"\\1\\2","g",r0);
> > warning: regexp constant for parameter #1 yields boolean value
> > # want "1,234,567" => "1234567"
> 
> Can you please share a full example of the problem you're trying to
> solve, as well as the platform and gawk version?
> 
> On my system, I do not see any such issue:
> 
> bash-4.2$ ./gawk -v r0=1,234,567 'BEGIN 
> {r0=gensub(/([0-9])[,]([0-9])/,"\\1\\2","g",r0); print r0}'
> 1234567
> bash-4.2$ ./gawk --lint -v r0=1,234,567 'BEGIN 
> {r0=gensub(/([0-9])[,]([0-9])/,"\\1\\2","g",r0); print r0}'
> gawk: cmd. line:1: warning: `gensub' is a gawk extension
> 1234567
> 
> This is using gawk from the master branch.

Ah, I can duplicate the problem like this:

bash-4.2$ /bin/gawk --traditional -v r0=1,234,567 'BEGIN 
{r0=gensub(/([0-9])[,]([0-9])/,"\\1\\2","g",r0); print r0}'
gawk: cmd. line:1: warning: regexp constant for parameter #1 yields boolean 
value
gawk: cmd. line:1: fatal: function `gensub' not defined

Are you invoking gawk with --traditional or using a version of awk that
does not have a gensub function?

Regards,
Andy



reply via email to

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