bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Fwd: PROCINFO["sorted_in"] in END zone issue


From: Davide Brini
Subject: Re: [bug-gawk] Fwd: PROCINFO["sorted_in"] in END zone issue
Date: Tue, 21 Aug 2012 12:12:34 +0200

On Tue, 21 Aug 2012 12:59:52 +0300, Denis Shirokov <address@hidden>
wrote:

> Hi GAWK!
> 
> Here is the another one issue (GAWK 4.0.1 Win32):
> 
> END{
>       A[1]="A1"; A[2]="A2"; A[3]="A3";
>       PROCINFO["sorted_in"]="_sort"
>       for ( ptr in A ) {
>               print "`" ptr "':`" A[ptr] "'" } }
> 
> func  _sort(i1, v1, i2, v2) {
>       return i1 < i2 ? -1 : 1 }
> 
> 
> Expected output:
> 
> `1':`A1'
> `2':`A2'
> `3':`A3'
> 
> Actual:
> 
> gawk stop executing script and hangs up

I guess that it's because awk expects input. Either put the code in a BEGIN
block, or provide some input (empty is ok) to the script.

This is from the gawk manual:

"If an awk program has only BEGIN rules and no other rules, then the
program exits after the BEGIN rule is run. However, if an END rule
exists, then the input is read, even if there are no other rules in the
program. This is necessary in case the END rule checks the FNR and NR
variables."

-- 
D.



reply via email to

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