summaryrefslogtreecommitdiff
path: root/test/getline5.awk
blob: 4757bcfefa34c003780d65d12f6e4ef6cf477192 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Message-ID: <4F7832BD.9030709@gmx.com>
# Date: Sun, 01 Apr 2012 11:49:33 +0100
# From: Duncan Moore <duncan.moore@gmx.com>
# To: "bug-gawk@gnu.org" <bug-gawk@gnu.org>
# Subject: [bug-gawk] getline difference from gawk versions >=4.0.0
# 
# Hi
# 
# b.awk:
# 
# BEGIN {
#    system("echo 1 > f")
#    while ((getline a[++c] < "f") > 0) {}
#    print c
# }
# 
# gawk -f b.awk
# 
# Prior to gawk 4.0.0 this outputs:
# 
# 1
# 
# For 4.0.0 and 4.0.1 it outputs:
# 
# 2
# 
# Regards
# Duncan Moore

BEGIN {
    system("echo 1 > f")
    while ((getline a[++c] < "f") > 0) {}
    print c
    system("rm -f f")
}