[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gensub() matched component always empty, even for the exact text of
From: |
arnold |
Subject: |
Re: gensub() matched component always empty, even for the exact text of the example in the manual |
Date: |
Sun, 03 Apr 2022 08:06:03 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hi.
Thanks for the report. On my Ubuntu 20.04 system, with the same
gawk -V output as you provide, the example program works as
expected. So I don't know how to explain it failing for you. I see:
$ sha1sum /usr/bin/gawk
dd8fa40126fb184f7c7f79744ee95c3c079825cc /usr/bin/gawk
Assuming you're on an x86_64 system, you should get the same
results.
Otherwise, is your architecture different?
Are you willing to build from source and see if such a version works?
Thanks,
Arnold
Zoli Márk via "Bug reports only for gawk." <bug-gawk@gnu.org> wrote:
> Hello -
> I have run into a problem for which I needed the (g)awk function gensub(),
> namely the "identify matched components and reuse them in the replacement
> text" kind of problem. However, it seems that the component thus matched is
> always empty, and investigating the issue has shown that in this particular
> gawk not even the manual example works.
> This happens on Ubuntu 20.04.
> gawk -V replies "GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0)" plus
> boilerplate. I can't tell anymore if I installed it from some repository or
> it came with Ubuntu - I am, however, sure that I did not install it from
> sources.
> The manual I'm referring to is the one linked from the
> https://www.gnu.org/software/gawk/ page, namely
> https://www.gnu.org/software/gawk/manual/gawk.html
> The example is the following:
> $ gawk '
> > BEGIN {
> > a = "abc def"
> > b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a)
> > print b
> > }'
> -| def abc
> Instead of printing the promised "def abc", on my computer this code prints
> an empty line only, as both \\1 and \\2 are empty. (Actually it's not an
> empty line - it contains the space from between \\2 and \\1 in the
> replacement text, as it did with other characters in my code; only the
> matched components themselves are empty.) Is this a bug?
> Best regards
> M- S- Z-
>
>