This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Awk print statement alters the argument variable's content
- From: Lundberg Christer <christer dot lundberg at scania dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Thu, 12 Jan 2017 12:26:36 +0000
- Subject: Awk print statement alters the argument variable's content
- Authentication-results: sourceware.org; auth=none
This program run with GNU awk 4.1.4 (currently installed with Cygwin):
awk '
BEGIN { OFMT="%.8g"
buf = 1+0.1
buf = buf "a"
print "Length before print:", length(buf)
print buf " "
print buf
print buf " "
print "Length after print:", length(buf)
}
'
produces the following output on our system:
Length before print: 4
1.1a
1.1
1.1
Length after print: 3
so it appears that the "print buf" statement unexpectedly alters the content of buf.
With awk 4.1.3, we got the expected output
Length before print: 4
1.1a
1.1a
1.1a
Length after print: 4
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple