bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] Issues in readfile example in docs


From: Jaromir Obr
Subject: [bug-gawk] Issues in readfile example in docs
Date: Sat, 03 Sep 2016 07:09:11 +0000

Hi,
see https://www.gnu.org/software/gawk/manual/gawk.html#Readfile-Function

1) There is missing the left parenthesis in while (getline tmp < file) > 0), thus you get a syntax error
2) The function doesn't process well new lines. If you have a file with EOLN at the end of file, the EOLN is missing in contents. And if the file doesn't have the ending EOLN, there is missing the last but one EOLN in contents.

This works for me:

    contents = tmp RT
    while ((getline tmp < file) > 0)
        contents = contents tmp RT

instead of the existing code:

    contents = tmp
    while ((getline tmp < file) > 0)
        contents = contents RT tmp

Regards

Mira

reply via email to

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