bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Documentation or POSIX / compatibility mode bug


From: david kerns
Subject: Re: [bug-gawk] Documentation or POSIX / compatibility mode bug
Date: Tue, 26 Apr 2016 08:25:19 -0700

On Tue, Apr 26, 2016 at 5:23 AM, Glauco Ciullini <address@hidden> wrote:
I'm writing in regard to a bug afflicting the latest version of Gawk (4.1.3).

The bug is either in Gawk's documentation (namely in the `man` page) or in Gawk's behavior in POSIX / compatibiliy mode.

Quoting the relevant part under the section "Records" in the `man` page:

"in compatibility mode, only the first character of its string value is used for separating records."

However that doesn't seem to be the case: neither `-P` (which per the `man` page turns on compatibility mode) nor `-c` seem to affect how the value of `RS` is intepreted in order to split records; basically, the value of `RS` is apparently always interpreted as a regular _expression_.

% ./gawk -- '1' RS="b.*" <<<'foobarfoo' 
foo # ok
% ./gawk -P -- '1' RS="b.*" <<<'foobarfoo'
foo # broken
% ./gawk -c -- '1' RS="b.*" <<<'foobarfoo'
foo # broken

This on the latest version (4.1.3).

So either that's the expected behavior (and the bug is in the `man` page)
 or the compatibility mode (and consequently also the POSIX mode) are currently broken.

Best regards,

Glauco Ciullini

I agree you found a bug, but I think your reproducer script is a bit obscure.

# as expected
$ printf "0foobar0faz\n1foobar1faz\n" | awk -v RS="bar" '{print$1,$2}'
0foo
0faz 1foo
1faz
# RS now extends to the EOF
$ printf "0foobar0faz\n1foobar1faz\n" | awk -v RS="b.*" '{print$1,$2}'
0foo
# with -c, broken, should only use first letter, but still uses full specification
$ printf "0foobar0faz\n1foobar1faz\n" | awk -c -v RS="bar" '{print$1,$2}'
0foo
0faz 1foo
1faz
$ printf "0foobar0faz\n1foobar1faz\n" | awk -c -v RS="b.*" '{print$1,$2}'
0foo



reply via email to

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