bug-gawk
[Top][All Lists]
Advanced

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

Re: Possible bug in array handling after end of input (END handler)


From: Andrew J. Schorr
Subject: Re: Possible bug in array handling after end of input (END handler)
Date: Fri, 4 Dec 2020 14:10:34 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Fri, Dec 04, 2020 at 03:28:54PM +0100, Christian Schmidt wrote:
> function dump() {
>     for (i in vars) printf ("%s:%s ", i, vars[i]);
>     print;
>     delete vars;
> }

Why are you calling "print" after dumping the contents of the vars
array? It prints out $0. You are getting confused by that.
If you modify the function like so, the problem should become obvious
to you:

function dump() {
    for (i in vars) printf ("%s:%s ", i, vars[i])
    printf "\n"
    print "And I'm also printing $0 here for some unknown reason"
    print
    delete vars
}

Also, FYI, you don't need those semicolons at the end of each line.
A semicolon is needed only to separate two statements that are on
the same line (and not separated by a linefeed).

Regards,
Andy



reply via email to

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