[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible bug in gawk: local FS not used
From: |
Jean-Philippe Guérard |
Subject: |
Possible bug in gawk: local FS not used |
Date: |
Mon, 11 May 2009 20:22:35 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Hello,
I might have stumbled upon a gawk bug. Its seems that a local FS
variable is not taken into account. The following script demonstrates
this behaviour:
----------------------------------------------------------------------
#!/usr/bin/gawk -f
function test_global(){
# FS is a global variable
FS="1"
getline < FILE
print $2
close( FILE )
}
function test_local( FS ){
# FS is a local variable
FS="1"
getline < FILE
print $2
close( FILE )
}
BEGIN {
FILE="/tmp/test.txt"
system( "echo 121212 > " FILE )
FS="2"
print "global FS"
test_global()
FS="2"
print "local FS"
test_local()
}
----------------------------------------------------------------------
With GNU Awk 3.1.6, I get the following result:
----------------------------------------------------------------------
$ ./test.awk
global FS
2
local FS
1
----------------------------------------------------------------------
If I understand well, when parsing the input line, the global FS
variable is always used, even if a local FS exists.
Could you confirm if this is a bug or intended?
Thanks in advance,
Regards,
--
Jean-Philippe Guérard
http://tigreraye.org